FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
alac.c File Reference

ALAC (Apple Lossless Audio Codec) decoder. More...

#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"

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, int32_t *buffer_out, int nb_samples, int bps, int16_t *lpc_coefs, int lpc_order, int lpc_quant)
 
static void decorrelate_stereo (int32_t *buffer[2], int nb_samples, int decorr_shift, int decorr_left_weight)
 
static void append_extra_bits (int32_t *buffer[2], int32_t *extra_bits_buffer[2], int extra_bits, int channels, int nb_samples)
 
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)
 
static int init_thread_copy (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:

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

Definition in file alac.c.

Macro Definition Documentation

#define ALAC_EXTRADATA_SIZE   36

Definition at line 61 of file alac.c.

Referenced by alac_decode_init().

Function Documentation

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

Definition at line 86 of file alac.c.

Referenced by 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 108 of file alac.c.

Referenced by decode_element().

static int sign_only ( int  v)
inlinestatic

Definition at line 165 of file alac.c.

Referenced by lpc_prediction().

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

Definition at line 170 of file alac.c.

Referenced by decode_element().

static void decorrelate_stereo ( int32_t buffer[2],
int  nb_samples,
int  decorr_shift,
int  decorr_left_weight 
)
static

Definition at line 233 of file alac.c.

Referenced by decode_element().

static void append_extra_bits ( int32_t buffer[2],
int32_t extra_bits_buffer[2],
int  extra_bits,
int  channels,
int  nb_samples 
)
static

Definition at line 252 of file alac.c.

Referenced by decode_element().

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

Definition at line 262 of file alac.c.

Referenced by alac_decode_frame().

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

Definition at line 458 of file alac.c.

static av_cold int alac_decode_close ( AVCodecContext avctx)
static

Definition at line 517 of file alac.c.

Referenced by allocate_buffers().

static int allocate_buffers ( ALACContext alac)
static

Definition at line 532 of file alac.c.

Referenced by alac_decode_init(), and init_thread_copy().

static int alac_set_info ( ALACContext alac)
static

Definition at line 562 of file alac.c.

Referenced by alac_decode_init().

static av_cold int alac_decode_init ( AVCodecContext avctx)
static

Definition at line 593 of file alac.c.

static int init_thread_copy ( AVCodecContext avctx)
static

Definition at line 646 of file alac.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "extra_bits_bug", "Force non-standard decoding process",
0x42, AV_OPT_TYPE_INT, { .i64 = 0 },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:290
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:286

Definition at line 653 of file alac.c.

const AVClass alac_class
static
Initial value:
= {
.class_name = "alac",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
static const AVOption options[]
Definition: alac.c:653
av_default_item_name

Definition at line 660 of file alac.c.

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
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int alac_decode_close(AVCodecContext *avctx)
Definition: alac.c:517
static const AVClass alac_class
Definition: alac.c:660
static int alac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: alac.c:458
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:920
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:214
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:523
static av_cold int alac_decode_init(AVCodecContext *avctx)
Definition: alac.c:593
static int init_thread_copy(AVCodecContext *avctx)
Definition: alac.c:646
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:857

Definition at line 667 of file alac.c.