libavcodec/ac3enc.c File Reference

The simplest AC-3 encoder. More...

#include "libavutil/crc.h"
#include "avcodec.h"
#include "bitstream.h"
#include "ac3.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 MUL16(a, b)   ((a) * (b))
#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 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 106 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 121 of file ac3enc.c.

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

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

Definition at line 1050 of file ac3enc.c.

Referenced by output_frame_end().

#define EXP_DIFF_THRESHOLD   1000

Definition at line 74 of file ac3enc.c.

Referenced by compute_exp_strategy().

#define MDCT_NBITS   9

Definition at line 70 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

#define MUL16 ( a,
 )     ((a) * (b))

#define N   (1 << MDCT_NBITS)

#define SNR_INC1   4

Definition at line 480 of file ac3enc.c.

Referenced by compute_bit_allocation().


Function Documentation

static av_cold int AC3_encode_close ( AVCodecContext avctx  )  [static]

Definition at line 1259 of file ac3enc.c.

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

Definition at line 1145 of file ac3enc.c.

static av_cold int AC3_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 612 of file ac3enc.c.

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

Definition at line 757 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 447 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 418 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 230 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 482 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 240 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 368 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 299 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 287 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 129 of file ac3enc.c.

Referenced by mdct512().

static av_cold void fft_init ( int  ln  )  [static]

Definition at line 91 of file ac3enc.c.

Referenced by AC3_encode_init().

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

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

Referenced by AC3_encode_frame().

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

Definition at line 1094 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

Definition at line 198 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 1052 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 777 of file ac3enc.c.

Referenced by AC3_encode_frame().

static int output_frame_end ( AC3EncodeContext s  )  [static]

Definition at line 1111 of file ac3enc.c.

Referenced by AC3_encode_frame().

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

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

Referenced by output_frame_end().

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

Definition at line 739 of file ac3enc.c.

Referenced by output_audio_block().


Variable Documentation

Initial value:

 {
    "ac3",
    CODEC_TYPE_AUDIO,
    CODEC_ID_AC3,
    sizeof(AC3EncodeContext),
    AC3_encode_init,
    AC3_encode_frame,
    AC3_encode_close,
    NULL,
    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
    .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
}

Definition at line 1358 of file ac3enc.c.

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 xcos1[128] [static]

Definition at line 67 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().

int16_t xsin1[128] [static]

Definition at line 68 of file ac3enc.c.

Referenced by AC3_encode_init(), and mdct512().


Generated on Fri Oct 26 02:35:42 2012 for FFmpeg by  doxygen 1.5.8