libavcodec/ac3enc.c File Reference

The simplest AC-3 encoder. More...

#include "libavutil/crc.h"
#include "avcodec.h"
#include "libavutil/common.h"
#include "put_bits.h"
#include "ac3.h"
#include "audioconvert.h"

Go to the source code of this file.

Data Structures

struct  AC3EncodeContext
struct  IComplex

Defines

#define MDCT_NBITS   9
#define N   (1 << MDCT_NBITS)
#define EXP_DIFF_THRESHOLD   1000
#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1)
#define CMUL(pre, pim, are, aim, bre, bim)
#define SNR_INC1   4
#define CRC16_POLY   ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))

Functions

static int16_t fix15 (float a)
static av_cold void fft_init (int ln)
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 coarse_snr_offset, int fine_snr_offset)
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 av_cold int set_channel_info (AC3EncodeContext *s, int channels, int64_t *channel_layout)
static av_cold 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 av_cold int AC3_encode_close (AVCodecContext *avctx)

Variables

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


Detailed Description

The simplest AC-3 encoder.

Definition in file ac3enc.c.


Define Documentation

#define BF ( pre,
pim,
qre,
qim,
pre1,
pim1,
qre1,
qim1   ) 

Value:

{\
  int ax, ay, bx, by;\
  bx=pre1;\
  by=pim1;\
  ax=qre1;\
  ay=qim1;\
  pre = (bx + ax) >> 1;\
  pim = (by + ay) >> 1;\
  qre = (bx - ax) >> 1;\
  qim = (by - ay) >> 1;\
}

Definition at line 109 of file ac3enc.c.

Referenced by dct32(), ff_simple_idct248_put(), fft(), fft4(), and fft8().

#define CMUL ( pre,
pim,
are,
aim,
bre,
bim   ) 

Value:

{\
   pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15;\
   pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15;\
}

Definition at line 122 of file ac3enc.c.

Referenced by ff_imdct_half_3dn2(), ff_imdct_half_c(), ff_imdct_half_sse(), ff_mdct_calc_c(), fft(), and mdct512().

#define CRC16_POLY   ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))

Definition at line 1085 of file ac3enc.c.

Referenced by output_frame_end().

#define EXP_DIFF_THRESHOLD   1000

Definition at line 77 of file ac3enc.c.

Referenced by compute_exp_strategy().

#define MDCT_NBITS   9

Definition at line 73 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

#define N   (1 << MDCT_NBITS)

#define SNR_INC1   4

Definition at line 479 of file ac3enc.c.

Referenced by compute_bit_allocation().


Function Documentation

static av_cold int AC3_encode_close ( AVCodecContext avctx  )  [static]

Definition at line 1295 of file ac3enc.c.

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

Definition at line 1180 of file ac3enc.c.

static av_cold int AC3_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 655 of file ac3enc.c.

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

Definition at line 792 of file ac3enc.c.

Referenced by output_audio_block().

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  coarse_snr_offset,
int  fine_snr_offset 
) [static]

Definition at line 446 of file ac3enc.c.

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

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 417 of file ac3enc.c.

Referenced by compute_bit_allocation().

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

Definition at line 231 of file ac3enc.c.

Referenced by compute_exp_strategy().

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 481 of file ac3enc.c.

Referenced by AC3_encode_frame(), and MPA_encode_frame().

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 241 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 367 of file ac3enc.c.

Referenced by bit_alloc().

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 298 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 286 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 130 of file ac3enc.c.

Referenced by mdct512().

static av_cold 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 int log2_tab ( int16_t *  tab,
int  n 
) [static]

Definition at line 1118 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 1129 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 199 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 1087 of file ac3enc.c.

Referenced by output_frame_end(), and pow_poly().

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 812 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int output_frame_end ( AC3EncodeContext s  )  [static]

Definition at line 1146 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 744 of file ac3enc.c.

Referenced by AC3_encode_frame(), and flac_encode_frame().

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

Definition at line 1103 of file ac3enc.c.

Referenced by output_frame_end().

static av_cold int set_channel_info ( AC3EncodeContext s,
int  channels,
int64_t *  channel_layout 
) [static]

Definition at line 611 of file ac3enc.c.

Referenced by AC3_encode_init().

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

Definition at line 774 of file ac3enc.c.

Referenced by output_audio_block().


Variable Documentation

Definition at line 1394 of file ac3enc.c.

int16_t costab[64] [static]

Definition at line 68 of file ac3enc.c.

Referenced by fft(), and fft_init().

int16_t sintab[64] [static]

Definition at line 69 of file ac3enc.c.

Referenced by fft(), and fft_init().

int16_t xcos1[128] [static]

Definition at line 70 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

int16_t xsin1[128] [static]

Definition at line 71 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().


Generated on Fri Oct 26 02:36:50 2012 for FFmpeg by  doxygen 1.5.8