ac3enc.c File Reference


Detailed Description

The simplest AC3 encoder.

Definition in file ac3enc.c.

Go to the source code of this file.

Classes

struct  AC3EncodeContext
struct  IComplex

Functions

static void fft_init (int ln)
static int16_t fix15 (float a)
static void fft (IComplex *z, int ln)
static void mdct512 (int32_t *out, int16_t *in)
static int calc_exp_diff (uint8_t *exp1, uint8_t *exp2, int n)
static void compute_exp_strategy (uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], int ch, int is_lfe)
static void exponent_min (uint8_t exp[N/2], uint8_t exp1[N/2], int n)
static int encode_exp (uint8_t encoded_exp[N/2], uint8_t exp[N/2], int nb_exps, int exp_strategy)
static int compute_mantissa_size (AC3EncodeContext *s, uint8_t *m, int nb_coefs)
static void bit_alloc_masking (AC3EncodeContext *s, uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50])
static int bit_alloc (AC3EncodeContext *s, int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50], int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], int frame_bits, int csnroffst, int fsnroffst)
static int compute_bit_allocation (AC3EncodeContext *s, uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], int frame_bits)
static int AC3_encode_init (AVCodecContext *avctx)
static void output_frame_header (AC3EncodeContext *s, unsigned char *frame)
static int sym_quant (int c, int e, int levels)
static int asym_quant (int c, int e, int qbits)
static void output_audio_block (AC3EncodeContext *s, uint8_t exp_strategy[AC3_MAX_CHANNELS], uint8_t encoded_exp[AC3_MAX_CHANNELS][N/2], uint8_t bap[AC3_MAX_CHANNELS][N/2], int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2], int8_t global_exp[AC3_MAX_CHANNELS], int block_num)
static unsigned int mul_poly (unsigned int a, unsigned int b, unsigned int poly)
static unsigned int pow_poly (unsigned int a, unsigned int n, unsigned int poly)
static int log2_tab (int16_t *tab, int n)
static void lshift_tab (int16_t *tab, int n, int lshift)
static int output_frame_end (AC3EncodeContext *s)
static int AC3_encode_frame (AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data)
static int AC3_encode_close (AVCodecContext *avctx)
void fft_test (void)
void mdct_test (void)
void test_ac3 (void)

Variables

static int16_t costab [64]
static int16_t sintab [64]
static int16_t fft_rev [512]
static int16_t xcos1 [128]
static int16_t xsin1 [128]
AVCodec ac3_encoder


Function Documentation

static void fft_init ( int  ln  )  [static]

Definition at line 94 of file ac3enc.c.

Referenced by AC3_encode_init().

static int16_t fix15 ( float  a  )  [inline, static]

Definition at line 79 of file ac3enc.c.

Referenced by AC3_encode_init(), and fft_init().

static void fft ( IComplex z,
int  ln 
) [static]

Definition at line 140 of file ac3enc.c.

Referenced by fft_test(), and mdct512().

static void mdct512 ( int32_t out,
int16_t in 
) [static]

Definition at line 214 of file ac3enc.c.

Referenced by AC3_encode_frame(), and mdct_test().

static int calc_exp_diff ( uint8_t *  exp1,
uint8_t *  exp2,
int  n 
) [static]

Definition at line 246 of file ac3enc.c.

Referenced by compute_exp_strategy().

static void compute_exp_strategy ( uint8_t  exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
uint8_t  exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
int  ch,
int  is_lfe 
) [static]

Definition at line 256 of file ac3enc.c.

Referenced by AC3_encode_frame().

static void exponent_min ( uint8_t  exp[N/2],
uint8_t  exp1[N/2],
int  n 
) [static]

Definition at line 303 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int encode_exp ( uint8_t  encoded_exp[N/2],
uint8_t  exp[N/2],
int  nb_exps,
int  exp_strategy 
) [static]

Definition at line 315 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int compute_mantissa_size ( AC3EncodeContext s,
uint8_t *  m,
int  nb_coefs 
) [static]

Definition at line 384 of file ac3enc.c.

Referenced by bit_alloc().

static void bit_alloc_masking ( AC3EncodeContext s,
uint8_t  encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
uint8_t  exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
int16_t  psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
int16_t  mask[NB_BLOCKS][AC3_MAX_CHANNELS][50] 
) [static]

Definition at line 434 of file ac3enc.c.

Referenced by compute_bit_allocation().

static int bit_alloc ( AC3EncodeContext s,
int16_t  mask[NB_BLOCKS][AC3_MAX_CHANNELS][50],
int16_t  psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
uint8_t  bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
int  frame_bits,
int  csnroffst,
int  fsnroffst 
) [static]

Definition at line 463 of file ac3enc.c.

Referenced by compute_bit_allocation(), encode_frame(), mp_decode_layer2(), and MPA_encode_frame().

static int compute_bit_allocation ( AC3EncodeContext s,
uint8_t  bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
uint8_t  encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
uint8_t  exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
int  frame_bits 
) [static]

Definition at line 497 of file ac3enc.c.

Referenced by AC3_encode_frame(), and MPA_encode_frame().

static int AC3_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 627 of file ac3enc.c.

Referenced by test_ac3().

static void output_frame_header ( AC3EncodeContext s,
unsigned char *  frame 
) [static]

Definition at line 715 of file ac3enc.c.

Referenced by AC3_encode_frame(), and flac_encode_frame().

static int sym_quant ( int  c,
int  e,
int  levels 
) [inline, static]

Definition at line 745 of file ac3enc.c.

Referenced by output_audio_block().

static int asym_quant ( int  c,
int  e,
int  qbits 
) [inline, static]

Definition at line 763 of file ac3enc.c.

Referenced by output_audio_block().

static void output_audio_block ( AC3EncodeContext s,
uint8_t  exp_strategy[AC3_MAX_CHANNELS],
uint8_t  encoded_exp[AC3_MAX_CHANNELS][N/2],
uint8_t  bap[AC3_MAX_CHANNELS][N/2],
int32_t  mdct_coefs[AC3_MAX_CHANNELS][N/2],
int8_t  global_exp[AC3_MAX_CHANNELS],
int  block_num 
) [static]

Definition at line 783 of file ac3enc.c.

Referenced by AC3_encode_frame().

static unsigned int mul_poly ( unsigned int  a,
unsigned int  b,
unsigned int  poly 
) [static]

Definition at line 1058 of file ac3enc.c.

Referenced by output_frame_end(), and pow_poly().

static unsigned int pow_poly ( unsigned int  a,
unsigned int  n,
unsigned int  poly 
) [static]

Definition at line 1074 of file ac3enc.c.

Referenced by output_frame_end().

static int log2_tab ( int16_t tab,
int  n 
) [static]

Definition at line 1089 of file ac3enc.c.

Referenced by AC3_encode_frame().

static void lshift_tab ( int16_t tab,
int  n,
int  lshift 
) [static]

Definition at line 1100 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int output_frame_end ( AC3EncodeContext s  )  [static]

Definition at line 1117 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int AC3_encode_frame ( AVCodecContext avctx,
unsigned char *  frame,
int  buf_size,
void *  data 
) [static]

Definition at line 1148 of file ac3enc.c.

Referenced by test_ac3().

static int AC3_encode_close ( AVCodecContext avctx  )  [static]

Definition at line 1262 of file ac3enc.c.

void fft_test ( void   ) 

Definition at line 1275 of file ac3enc.c.

Referenced by test_ac3().

void mdct_test ( void   ) 

Definition at line 1304 of file ac3enc.c.

Referenced by test_ac3().

void test_ac3 ( void   ) 

Definition at line 1342 of file ac3enc.c.


Variable Documentation

int16_t costab[64] [static]

Definition at line 65 of file ac3enc.c.

Referenced by fft(), and fft_init().

int16_t sintab[64] [static]

Definition at line 66 of file ac3enc.c.

Referenced by fft(), and fft_init().

int16_t fft_rev[512] [static]

Definition at line 67 of file ac3enc.c.

Referenced by fft(), and fft_init().

int16_t xcos1[128] [static]

Definition at line 68 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

int16_t xsin1[128] [static]

Definition at line 69 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

Initial value:

Definition at line 1361 of file ac3enc.c.


Generated on Sat Dec 18 05:15:50 2010 for MythTV by  doxygen 1.5.5