FFmpeg
Data Structures | Macros | Functions | Variables
alac.c File Reference
#include <inttypes.h>
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
#include "internal.h"
#include "thread.h"
#include "unary.h"
#include "mathops.h"
#include "alac_data.h"
#include "alacdsp.h"

Go to the source code of this file.

Data Structures

struct  ALACContext
 

Macros

#define ALAC_EXTRADATA_SIZE   36
 

Functions

static unsigned int decode_scalar (GetBitContext *gb, int k, int bps)
 
static int rice_decompress (ALACContext *alac, int32_t *output_buffer, int nb_samples, int bps, int rice_history_mult)
 
static int sign_only (int v)
 
static void lpc_prediction (int32_t *error_buffer, uint32_t *buffer_out, int nb_samples, int bps, int16_t *lpc_coefs, int lpc_order, int lpc_quant)
 
static int decode_element (AVCodecContext *avctx, AVFrame *frame, int ch_index, int channels)
 
static int alac_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int alac_decode_close (AVCodecContext *avctx)
 
static int allocate_buffers (ALACContext *alac)
 
static int alac_set_info (ALACContext *alac)
 
static av_cold int alac_decode_init (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass alac_class
 
AVCodec ff_alac_decoder
 

Detailed Description

ALAC (Apple Lossless Audio Codec) decoder

Author
2005 David Hammerton
See also
http://crazney.net/programs/itunes/alac.html

Note: This decoder expects a 36-byte QuickTime atom to be passed through the extradata[_size] fields. This atom is tacked onto the end of an 'alac' stsd atom and has the following format:

32 bits atom size 32 bits tag ("alac") 32 bits tag version (0) 32 bits samples per frame (used when not set explicitly in the frames) 8 bits compatible version (0) 8 bits sample size 8 bits history mult (40) 8 bits initial history (10) 8 bits rice param limit (14) 8 bits channels 16 bits maxRun (255) 32 bits max coded frame size (0 means unknown) 32 bits average bitrate (0 means unknown) 32 bits samplerate

Definition in file alac.c.

Macro Definition Documentation

◆ ALAC_EXTRADATA_SIZE

#define ALAC_EXTRADATA_SIZE   36

Definition at line 62 of file alac.c.

Function Documentation

◆ decode_scalar()

static unsigned int decode_scalar ( GetBitContext gb,
int  k,
int  bps 
)
inlinestatic

Definition at line 90 of file alac.c.

Referenced by rice_decompress().

◆ rice_decompress()

static int rice_decompress ( ALACContext alac,
int32_t output_buffer,
int  nb_samples,
int  bps,
int  rice_history_mult 
)
static

Definition at line 112 of file alac.c.

Referenced by decode_element().

◆ sign_only()

static int sign_only ( int  v)
inlinestatic

Definition at line 169 of file alac.c.

Referenced by lpc_prediction().

◆ lpc_prediction()

static void lpc_prediction ( int32_t error_buffer,
uint32_t *  buffer_out,
int  nb_samples,
int  bps,
int16_t *  lpc_coefs,
int  lpc_order,
int  lpc_quant 
)
static

Definition at line 174 of file alac.c.

Referenced by decode_element().

◆ decode_element()

static int decode_element ( AVCodecContext avctx,
AVFrame frame,
int  ch_index,
int  channels 
)
static

Definition at line 237 of file alac.c.

Referenced by alac_decode_frame().

◆ alac_decode_frame()

static int alac_decode_frame ( AVCodecContext avctx,
void *  data,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 417 of file alac.c.

◆ alac_decode_close()

static av_cold int alac_decode_close ( AVCodecContext avctx)
static

Definition at line 476 of file alac.c.

Referenced by allocate_buffers().

◆ allocate_buffers()

static int allocate_buffers ( ALACContext alac)
static

Definition at line 491 of file alac.c.

Referenced by alac_decode_init().

◆ alac_set_info()

static int alac_set_info ( ALACContext alac)
static

Definition at line 521 of file alac.c.

Referenced by alac_decode_init().

◆ alac_decode_init()

static av_cold int alac_decode_init ( AVCodecContext avctx)
static

Definition at line 552 of file alac.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "extra_bits_bug", "Force non-standard decoding process",
0x42, AV_OPT_TYPE_BOOL, { .i64 = 0 },
{ NULL },
}

Definition at line 616 of file alac.c.

◆ alac_class

const AVClass alac_class
static
Initial value:
= {
.class_name = "alac",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 623 of file alac.c.

◆ ff_alac_decoder

AVCodec ff_alac_decoder
Initial value:
= {
.name = "alac",
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
.priv_data_size = sizeof(ALACContext),
.priv_class = &alac_class
}

Definition at line 630 of file alac.c.

init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
alac_decode_close
static av_cold int alac_decode_close(AVCodecContext *avctx)
Definition: alac.c:476
AV_CODEC_ID_ALAC
@ AV_CODEC_ID_ALAC
Definition: avcodec.h:580
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:278
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1037
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
options
static const AVOption options[]
Definition: alac.c:616
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
ONLY_IF_THREADS_ENABLED
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:227
alac_decode_init
static av_cold int alac_decode_init(AVCodecContext *avctx)
Definition: alac.c:552
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
init_thread_copy
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have add an init_thread_copy() which re-allocates them for other threads. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies
ALACContext
Definition: alac.c:64
alac_class
static const AVClass alac_class
Definition: alac.c:623
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:277
alac_decode_frame
static int alac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: alac.c:417
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240