#include "avcodec.h"#include "bitstream.h"#include "ac3.h"#include "ac3tab.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 void | fft_init (int ln) |
| static void | ac3_crc_init (void) |
| static int16_t | fix15 (float a) |
| static int | calc_lowcomp1 (int a, int b0, int b1) |
| static int | calc_lowcomp (int a, int b0, int b1, int bin) |
| void | ac3_parametric_bit_allocation (AC3BitAllocParameters *s, uint8_t *bap, int8_t *exp, int start, int end, int snroffset, int fgain, int is_lfe, int deltbae, int deltnseg, uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba) |
| 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 int | bit_alloc (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, 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) |
| void | ac3_common_init (void) |
| 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 | ac3_crc (uint8_t *data, int n, unsigned int crc) |
| 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) |
Variables | |
| AVCodec | ac3_encoder |
Definition in file ac3enc.c.
| #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 315 of file ac3enc.c.
Referenced by dct32(), ff_fft_calc_altivec(), ff_fft_calc_c(), fft(), and simple_idct248_put().
| #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 330 of file ac3enc.c.
Referenced by ff_fft_calc_altivec(), ff_fft_calc_c(), ff_imdct_calc(), ff_mdct_calc(), fft(), and mdct512().
| #define CRC16_POLY ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16)) |
| #define EXP_DIFF_THRESHOLD 1000 |
| #define MDCT_NBITS 9 |
Definition at line 328 of file ac3enc.c.
Referenced by AC3_encode_frame(), idctRowCondDC(), idctSparseCol(), idctSparseColAdd(), and idctSparseColPut().
| #define N (1 << MDCT_NBITS) |
Definition at line 63 of file ac3enc.c.
Referenced by AC3_encode_frame(), AC3_encode_init(), compute_bit_allocation(), compute_exp_strategy(), encode_exp(), mdct512(), output_audio_block(), putseq(), ratectl_update_pict(), and readcmdline().
| #define SNR_INC1 4 |
| void ac3_common_init | ( | void | ) |
| static unsigned int ac3_crc | ( | uint8_t * | data, | |
| int | n, | |||
| unsigned int | crc | |||
| ) | [static] |
| static void ac3_crc_init | ( | void | ) | [static] |
Definition at line 1243 of file ac3enc.c.
References c, CRC16_POLY, and crc_table.
Referenced by AC3_encode_init().
| static int AC3_encode_close | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1465 of file ac3enc.c.
References av_freep(), and AVCodecContext::coded_frame.

| static int AC3_encode_frame | ( | AVCodecContext * | avctx, | |
| unsigned char * | frame, | |||
| int | buf_size, | |||
| void * | data | |||
| ) | [static] |
Definition at line 1360 of file ac3enc.c.
References AC3_MAX_CHANNELS, ac3_window, compute_bit_allocation(), compute_exp_strategy(), e, encode_exp(), EXP_REUSE, exponent_min(), AC3EncodeContext::last_samples, AC3EncodeContext::lfe_channel, log2_tab(), lshift_tab(), mdct512(), memcpy, MUL16, N, AC3EncodeContext::nb_all_channels, NB_BLOCKS, AC3EncodeContext::nb_coefs, output_audio_block(), output_frame_end(), output_frame_header(), AVCodecContext::priv_data, s, and samples.

| static int AC3_encode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 809 of file ac3enc.c.
References ac3_bitratetab, ac3_common_init(), ac3_crc_init(), AC3_FRAME_SIZE, ac3_freqs, AC3EncodeContext::acmod, avcodec_alloc_frame(), AC3EncodeContext::bit_rate, AVCodecContext::bit_rate, bitrate, AC3EncodeContext::bsid, AC3EncodeContext::bsmod, AVCodecContext::channels, AC3EncodeContext::chbwcod, AVCodecContext::coded_frame, AC3EncodeContext::csnroffst, fft_init(), fix15(), AC3EncodeContext::frame_size, AVCodecContext::frame_size, AC3EncodeContext::frame_size_min, AC3EncodeContext::frmsizecod, AC3EncodeContext::fscod, AC3EncodeContext::halfratecod, AC3EncodeContext::lfe, AC3EncodeContext::lfe_channel, M_PI, MDCT_NBITS, N, AC3EncodeContext::nb_all_channels, AC3EncodeContext::nb_channels, AC3EncodeContext::nb_coefs, AVCodecContext::priv_data, s, AC3EncodeContext::sample_rate, AVCodecContext::sample_rate, xcos1, and xsin1.

| void ac3_parametric_bit_allocation | ( | AC3BitAllocParameters * | s, | |
| uint8_t * | bap, | |||
| int8_t * | exp, | |||
| int | start, | |||
| int | end, | |||
| int | snroffset, | |||
| int | fgain, | |||
| int | is_lfe, | |||
| int | deltbae, | |||
| int | deltnseg, | |||
| uint8_t * | deltoffst, | |||
| uint8_t * | deltlen, | |||
| uint8_t * | deltba | |||
| ) |
Definition at line 118 of file ac3enc.c.
References baptab, bndsz, bndtab, c, calc_lowcomp(), calc_lowcomp1(), AC3BitAllocParameters::cplfleak, AC3BitAllocParameters::cplsleak, AC3BitAllocParameters::dbknee, AC3BitAllocParameters::fdecay, AC3BitAllocParameters::floor, AC3BitAllocParameters::fscod, AC3BitAllocParameters::halfratecod, hth, latab, masktab, AC3BitAllocParameters::sdecay, and AC3BitAllocParameters::sgain.
Referenced by bit_alloc().

| static int asym_quant | ( | int | c, | |
| int | e, | |||
| int | qbits | |||
| ) | [inline, static] |
| static int bit_alloc | ( | 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, | |||
| int | csnroffst, | |||
| int | fsnroffst | |||
| ) | [static] |
Definition at line 632 of file ac3enc.c.
References ac3_parametric_bit_allocation(), AC3EncodeContext::bit_alloc, compute_mantissa_size(), AC3EncodeContext::fgaincod, fgaintab, AC3EncodeContext::frame_size, AC3EncodeContext::lfe_channel, AC3EncodeContext::mant1_cnt, AC3EncodeContext::mant2_cnt, AC3EncodeContext::mant4_cnt, AC3EncodeContext::nb_all_channels, NB_BLOCKS, AC3EncodeContext::nb_coefs, and NULL.
Referenced by a_bit_allocation(), a_bit_allocation_new(), bits_for_nonoise_new(), compute_bit_allocation(), CRC_calc(), CRC_calcDAB(), encode_bit_alloc(), encode_frame(), encode_scale(), main_bit_allocation(), main_bit_allocation_new(), mp_decode_layer2(), MPA_encode_frame(), mpeg3audio_dolayer2(), sample_encoding(), subband_quantization(), subband_quantization_new(), toolame(), VBR_bit_allocation(), VBR_bit_allocation_new(), write_bit_alloc(), write_samples_new(), and write_scalefactors().

| static int calc_exp_diff | ( | uint8_t * | exp1, | |
| uint8_t * | exp2, | |||
| int | n | |||
| ) | [static] |
| static int calc_lowcomp | ( | int | a, | |
| int | b0, | |||
| int | b1, | |||
| int | bin | |||
| ) | [inline, static] |
| static int calc_lowcomp1 | ( | int | a, | |
| int | b0, | |||
| int | b1 | |||
| ) | [inline, static] |
| 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 668 of file ac3enc.c.
References AC3EncodeContext::acmod, av_log(), AV_LOG_ERROR, bit_alloc(), AC3EncodeContext::bit_alloc, AC3EncodeContext::csnroffst, AC3BitAllocParameters::dbknee, AC3EncodeContext::dbkneecod, dbkneetab, EXP_REUSE, AC3BitAllocParameters::fdecay, AC3EncodeContext::fdecaycod, fdecaytab, AC3EncodeContext::fgaincod, AC3BitAllocParameters::floor, AC3EncodeContext::floorcod, floortab, AC3EncodeContext::fscod, AC3BitAllocParameters::fscod, AC3EncodeContext::fsnroffst, AC3EncodeContext::halfratecod, AC3BitAllocParameters::halfratecod, AC3EncodeContext::lfe, memcpy, N, AC3EncodeContext::nb_all_channels, NB_BLOCKS, AC3EncodeContext::nb_channels, AC3EncodeContext::nb_coefs, NULL, AC3BitAllocParameters::sdecay, AC3EncodeContext::sdecaycod, sdecaytab, AC3BitAllocParameters::sgain, AC3EncodeContext::sgaincod, sgaintab, and SNR_INC1.
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 454 of file ac3enc.c.
References av_log(), AV_LOG_DEBUG, calc_exp_diff(), EXP_D15, EXP_D25, EXP_D45, EXP_DIFF_THRESHOLD, EXP_NEW, EXP_REUSE, N, NB_BLOCKS, and NULL.
Referenced by AC3_encode_frame().

| static int compute_mantissa_size | ( | AC3EncodeContext * | s, | |
| uint8_t * | m, | |||
| int | nb_coefs | |||
| ) | [static] |
Definition at line 582 of file ac3enc.c.
References bits, AC3EncodeContext::mant1_cnt, AC3EncodeContext::mant2_cnt, and AC3EncodeContext::mant4_cnt.
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 513 of file ac3enc.c.
References av_log(), AV_LOG_DEBUG, EXP_D15, EXP_D25, EXP_D45, N, and NULL.
Referenced by AC3_encode_frame().

| static void exponent_min | ( | uint8_t | exp[N/2], | |
| uint8_t | exp1[N/2], | |||
| int | n | |||
| ) | [static] |
| static void fft | ( | IComplex * | z, | |
| int | ln | |||
| ) | [static] |
Definition at line 338 of file ac3enc.c.
References BF, CMUL, costab, fft_rev, IComplex::im, IComplex::re, and sintab.
Referenced by mdct512().
| static void fft_init | ( | int | ln | ) | [static] |
| static int16_t fix15 | ( | float | a | ) | [inline, static] |
| static int log2_tab | ( | int16_t * | tab, | |
| int | n | |||
| ) | [static] |
| static void lshift_tab | ( | int16_t * | tab, | |
| int | n, | |||
| int | lshift | |||
| ) | [static] |
| static void mdct512 | ( | int32_t * | out, | |
| int16_t * | in | |||
| ) | [static] |
Definition at line 412 of file ac3enc.c.
References CMUL, fft(), IComplex::im, MDCT_NBITS, N, IComplex::re, xcos1, and xsin1.
Referenced by AC3_encode_frame().

| static unsigned int mul_poly | ( | unsigned int | a, | |
| unsigned int | b, | |||
| unsigned int | poly | |||
| ) | [static] |
Definition at line 1268 of file ac3enc.c.
References 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 966 of file ac3enc.c.
References AC3EncodeContext::acmod, asym_quant(), av_log(), AV_LOG_DEBUG, b, c, AC3EncodeContext::chbwcod, AC3EncodeContext::csnroffst, AC3EncodeContext::dbkneecod, e, EXP_D15, EXP_D25, EXP_D45, EXP_REUSE, AC3EncodeContext::fdecaycod, AC3EncodeContext::fgaincod, AC3EncodeContext::floorcod, AC3EncodeContext::fsnroffst, AC3EncodeContext::lfe, AC3EncodeContext::lfe_channel, N, AC3EncodeContext::nb_all_channels, AC3EncodeContext::nb_channels, AC3EncodeContext::nb_coefs, NULL, AC3EncodeContext::pb, put_bits(), AC3EncodeContext::sdecaycod, AC3EncodeContext::sgaincod, and sym_quant().
Referenced by AC3_encode_frame().

| static int output_frame_end | ( | AC3EncodeContext * | s | ) | [static] |
Definition at line 1327 of file ac3enc.c.
References ac3_crc(), PutBitContext::buf, CRC16_POLY, flush_put_bits(), AC3EncodeContext::frame_size, mul_poly(), AC3EncodeContext::pb, pbBufPtr(), and pow_poly().
Referenced by AC3_encode_frame().

| static void output_frame_header | ( | AC3EncodeContext * | s, | |
| unsigned char * | frame | |||
| ) | [static] |
Definition at line 898 of file ac3enc.c.
References AC3_MAX_CODED_FRAME_SIZE, AC3EncodeContext::acmod, AC3EncodeContext::bsid, AC3EncodeContext::bsmod, AC3EncodeContext::frame_size, AC3EncodeContext::frame_size_min, AC3EncodeContext::frmsizecod, AC3EncodeContext::fscod, init_put_bits(), AC3EncodeContext::lfe, AC3EncodeContext::pb, and put_bits().
Referenced by AC3_encode_frame().

| static unsigned int pow_poly | ( | unsigned int | a, | |
| unsigned int | n, | |||
| unsigned int | poly | |||
| ) | [static] |
Definition at line 1284 of file ac3enc.c.
References mul_poly(), and r.
Referenced by output_frame_end().

| static int sym_quant | ( | int | c, | |
| int | e, | |||
| int | levels | |||
| ) | [inline, static] |
Initial value:
{
"ac3",
CODEC_TYPE_AUDIO,
CODEC_ID_AC3,
sizeof(AC3EncodeContext),
AC3_encode_init,
AC3_encode_frame,
AC3_encode_close,
NULL,
}
Definition at line 1563 of file ac3enc.c.
Referenced by avcodec_register_all().
1.5.5