alacenc.c File Reference
#include "avcodec.h"
#include "put_bits.h"
#include "internal.h"
#include "lpc.h"
#include "mathops.h"
#include "alac_data.h"
Include dependency graph for alacenc.c:

Go to the source code of this file.

Data Structures

struct  RiceContext
 
struct  AlacLPCContext
 
struct  AlacEncodeContext
 

Macros

#define DEFAULT_FRAME_SIZE   4096
 
#define ALAC_EXTRADATA_SIZE   36
 
#define ALAC_FRAME_HEADER_SIZE   55
 
#define ALAC_FRAME_FOOTER_SIZE   3
 
#define ALAC_ESCAPE_CODE   0x1FF
 
#define ALAC_MAX_LPC_ORDER   30
 
#define DEFAULT_MAX_PRED_ORDER   6
 
#define DEFAULT_MIN_PRED_ORDER   4
 
#define ALAC_MAX_LPC_PRECISION   9
 
#define ALAC_MAX_LPC_SHIFT   9
 
#define ALAC_CHMODE_LEFT_RIGHT   0
 
#define ALAC_CHMODE_LEFT_SIDE   1
 
#define ALAC_CHMODE_RIGHT_SIDE   2
 
#define ALAC_CHMODE_MID_SIDE   3
 
#define COPY_SAMPLES(type)
 

Typedefs

typedef struct RiceContext RiceContext
 
typedef struct AlacLPCContext AlacLPCContext
 
typedef struct AlacEncodeContext AlacEncodeContext
 

Functions

static void init_sample_buffers (AlacEncodeContext *s, int channels, uint8_t const *samples[2])
 
static void encode_scalar (AlacEncodeContext *s, int x, int k, int write_sample_size)
 
static void write_element_header (AlacEncodeContext *s, enum AlacRawDataBlockType element, int instance)
 
static void calc_predictor_params (AlacEncodeContext *s, int ch)
 
static int estimate_stereo_mode (int32_t *left_ch, int32_t *right_ch, int n)
 
static void alac_stereo_decorrelation (AlacEncodeContext *s)
 
static void alac_linear_predictor (AlacEncodeContext *s, int ch)
 
static void alac_entropy_coder (AlacEncodeContext *s)
 
static void write_element (AlacEncodeContext *s, enum AlacRawDataBlockType element, int instance, const uint8_t *samples0, const uint8_t *samples1)
 
static int write_frame (AlacEncodeContext *s, AVPacket *avpkt, uint8_t *const *samples)
 
static av_always_inline int get_max_frame_size (int frame_size, int ch, int bps)
 
static av_cold int alac_encode_close (AVCodecContext *avctx)
 
static av_cold int alac_encode_init (AVCodecContext *avctx)
 
static int alac_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 

Variables

AVCodec ff_alac_encoder
 

Macro Definition Documentation

#define ALAC_CHMODE_LEFT_RIGHT   0

Definition at line 41 of file alacenc.c.

Referenced by alac_stereo_decorrelation().

#define ALAC_CHMODE_LEFT_SIDE   1

Definition at line 42 of file alacenc.c.

Referenced by alac_stereo_decorrelation().

#define ALAC_CHMODE_MID_SIDE   3

Definition at line 44 of file alacenc.c.

#define ALAC_CHMODE_RIGHT_SIDE   2

Definition at line 43 of file alacenc.c.

Referenced by alac_stereo_decorrelation().

#define ALAC_ESCAPE_CODE   0x1FF

Definition at line 34 of file alacenc.c.

Referenced by encode_scalar().

#define ALAC_EXTRADATA_SIZE   36

Definition at line 30 of file alacenc.c.

Referenced by alac_encode_init().

#define ALAC_FRAME_FOOTER_SIZE   3

Definition at line 32 of file alacenc.c.

#define ALAC_FRAME_HEADER_SIZE   55

Definition at line 31 of file alacenc.c.

#define ALAC_MAX_LPC_ORDER   30

Definition at line 35 of file alacenc.c.

Referenced by alac_encode_init().

#define ALAC_MAX_LPC_PRECISION   9

Definition at line 38 of file alacenc.c.

Referenced by calc_predictor_params().

#define ALAC_MAX_LPC_SHIFT   9

Definition at line 39 of file alacenc.c.

Referenced by calc_predictor_params().

#define COPY_SAMPLES (   type)
Value:
do { \
for (ch = 0; ch < channels; ch++) { \
int32_t *bptr = s->sample_buf[ch]; \
const type *sptr = (const type *)samples[ch]; \
for (i = 0; i < s->frame_size; i++) \
bptr[i] = sptr[i] >> shift; \
} \
} while (0)
const char * s
Definition: avisynth_c.h:668
static int shift(int a, int b)
Definition: sonic.c:86
int32_t
synthesis window for stochastic i
#define type
Filter the word “frame” indicates either a video frame or a group of audio samples
for(j=16;j >0;--j)

Referenced by init_sample_buffers().

#define DEFAULT_FRAME_SIZE   4096
#define DEFAULT_MAX_PRED_ORDER   6

Definition at line 36 of file alacenc.c.

Referenced by alac_encode_init().

#define DEFAULT_MIN_PRED_ORDER   4

Definition at line 37 of file alacenc.c.

Referenced by alac_encode_init().

Typedef Documentation

typedef struct RiceContext RiceContext

Function Documentation

static av_cold int alac_encode_close ( AVCodecContext avctx)
static

Definition at line 480 of file alacenc.c.

Referenced by alac_encode_init().

static int alac_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)
static

Definition at line 602 of file alacenc.c.

static av_cold int alac_encode_init ( AVCodecContext avctx)
static

Definition at line 490 of file alacenc.c.

static void alac_entropy_coder ( AlacEncodeContext s)
static

Definition at line 316 of file alacenc.c.

Referenced by write_element().

static void alac_linear_predictor ( AlacEncodeContext s,
int  ch 
)
static

Definition at line 252 of file alacenc.c.

Referenced by write_element().

static void alac_stereo_decorrelation ( AlacEncodeContext s)
static

Definition at line 212 of file alacenc.c.

Referenced by write_element().

static void calc_predictor_params ( AlacEncodeContext s,
int  ch 
)
static

Definition at line 149 of file alacenc.c.

Referenced by write_element().

static void encode_scalar ( AlacEncodeContext s,
int  x,
int  k,
int  write_sample_size 
)
static

Definition at line 102 of file alacenc.c.

Referenced by alac_entropy_coder().

static int estimate_stereo_mode ( int32_t left_ch,
int32_t right_ch,
int  n 
)
static

Definition at line 179 of file alacenc.c.

Referenced by alac_stereo_decorrelation().

static av_always_inline int get_max_frame_size ( int  frame_size,
int  ch,
int  bps 
)
static

Definition at line 474 of file alacenc.c.

Referenced by alac_encode_frame(), and alac_encode_init().

static void init_sample_buffers ( AlacEncodeContext s,
int  channels,
uint8_t const *  samples[2] 
)
static

Definition at line 80 of file alacenc.c.

Referenced by write_element().

static void write_element ( AlacEncodeContext s,
enum AlacRawDataBlockType  element,
int  instance,
const uint8_t samples0,
const uint8_t samples1 
)
static

Definition at line 360 of file alacenc.c.

Referenced by write_frame().

static void write_element_header ( AlacEncodeContext s,
enum AlacRawDataBlockType  element,
int  instance 
)
static

Definition at line 130 of file alacenc.c.

Referenced by write_element().

static int write_frame ( AlacEncodeContext s,
AVPacket avpkt,
uint8_t *const *  samples 
)
static

Definition at line 443 of file alacenc.c.

Referenced by alac_encode_frame().

Variable Documentation

AVCodec ff_alac_encoder
Initial value:
= {
.name = "alac",
.priv_data_size = sizeof(AlacEncodeContext),
.encode2 = alac_encode_frame,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME,
.channel_layouts = ff_alac_channel_layouts,
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int alac_encode_init(AVCodecContext *avctx)
Definition: alacenc.c:490
signed 32 bits, planar
Definition: samplefmt.h:59
static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: alacenc.c:602
#define CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const uint64_t ff_alac_channel_layouts[ALAC_MAX_CHANNELS+1]
Definition: alac_data.c:35
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
static av_cold int alac_encode_close(AVCodecContext *avctx)
Definition: alacenc.c:480
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
signed 16 bits, planar
Definition: samplefmt.h:58
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:700
struct AlacEncodeContext AlacEncodeContext

Definition at line 642 of file alacenc.c.