64 #define EAC3_SR_CODE_REDUCED 3
75 num_copy_sections = 0;
84 for (i = 0; i < bandsize; i += copysize) {
101 for (i = 0; i < num_copy_sections; i++) {
105 bin += copy_sizes[i];
113 for (i = 0; i < bandsize; i++) {
115 accum += coeff *
coeff;
117 rms_energy[bnd] = sqrtf(accum / bandsize);
128 coeffs[0] *= atten_tab[0];
129 coeffs[1] *= atten_tab[1];
130 coeffs[2] *= atten_tab[2];
131 coeffs[3] *= atten_tab[1];
132 coeffs[4] *= atten_tab[0];
143 float nscale = s->
spx_noise_blend[ch][bnd] * rms_energy[bnd] * (1.0f / INT32_MIN);
147 nscale *= 1.0 / (1<<23);
148 sscale *= 1.0 / (1<<23);
161 #define COEFF_0 10273905LL
164 #define COEFF_1 11863283LL
167 #define COEFF_2 3070444LL
176 int even0, even1, even2, odd0, odd1, odd2;
178 odd1 = pre_mant[1] - pre_mant[3] - pre_mant[5];
180 even2 = ( pre_mant[2] *
COEFF_0) >> 23;
181 tmp = ( pre_mant[4] *
COEFF_1) >> 23;
182 odd0 = ((pre_mant[1] + pre_mant[5]) *
COEFF_2) >> 23;
184 even0 = pre_mant[0] + (tmp >> 1);
185 even1 = pre_mant[0] - tmp;
192 odd0 = tmp + pre_mant[1] + pre_mant[3];
193 odd2 = tmp + pre_mant[5] - pre_mant[3];
195 pre_mant[0] = even0 + odd0;
196 pre_mant[1] = even1 + odd1;
197 pre_mant[2] = even2 + odd2;
198 pre_mant[3] = even2 - odd2;
199 pre_mant[4] = even1 - odd1;
200 pre_mant[5] = even0 - odd0;
206 int end_bap, gaq_mode;
211 end_bap = (gaq_mode < 2) ? 12 : 17;
218 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
219 if (s->
bap[ch][bin] > 7 && s->
bap[ch][bin] < end_bap)
220 gaq_gain[gs++] =
get_bits1(gbc) << (gaq_mode-1);
225 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
226 if (s->
bap[ch][bin] > 7 && s->
bap[ch][bin] < 17) {
229 if (group_code > 26) {
243 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
244 int hebap = s->
bap[ch][bin];
248 for (blk = 0; blk < 6; blk++) {
251 }
else if (hebap < 8) {
254 for (blk = 0; blk < 6; blk++) {
261 log_gain = gaq_gain[gs++];
265 gbits = bits - log_gain;
267 for (blk = 0; blk < 6; blk++) {
269 if (log_gain && mant == -(1 << (gbits-1))) {
272 int mbits = bits - (2 - log_gain);
274 mant <<= (23 - (mbits - 1));
277 b = 1 << (23 - log_gain);
299 int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
300 int parse_transient_proc_info;
387 int mix_data_size = (
get_bits(gbc, 5) + 2) << 3;
453 for (i = 0; i < addbsil + 1; i++) {
466 ac3_exponent_strategy = 1;
471 parse_transient_proc_info =
get_bits1(gbc);
516 if (ac3_exponent_strategy) {
519 for (ch = !s->
cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
525 for (ch = !((s->
channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
527 for (blk = 0; blk < 6; blk++) {
545 if (parse_aht_info) {
551 for (ch = (num_cpl_blocks != 6); ch <= s->
channels; ch++) {
553 for (blk = 1; blk < 6; blk++) {
568 int csnroffst = (
get_bits(gbc, 6) - 15) << 4;
569 int snroffst = (csnroffst +
get_bits(gbc, 4)) << 2;
570 for (ch = 0; ch <= s->
channels; ch++)
575 if (parse_transient_proc_info) {
586 if (parse_spx_atten_data &&
get_bits1(gbc)) {
EAC3GaqMode
gain adaptive quantization mode
const uint8_t ff_ac3_slow_decay_tab[4]
int dither_flag[AC3_MAX_CHANNELS]
dither flags (dithflg)
const float ff_eac3_spx_atten_tab[32][3]
Table E.25: Spectral Extension Attenuation Table ff_eac3_spx_atten_tab[code][bin]=pow(2.0,(bin+1)*(code+1)/-15.0);.
int preferred_downmix
Preferred 2-channel downmix mode (dmixmod)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3]
Table used to ungroup 3 values stored in 5 bits.
static int ff_eac3_parse_header(AC3DecodeContext *s)
static void skip_bits_long(GetBitContext *s, int n)
int channels
number of total channels
int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]
exponent strategies (expstr)
int lfe_on
lfe channel in use
const uint16_t ff_ac3_slow_gain_tab[4]
int block_switch[AC3_MAX_CHANNELS]
block switch flags (blksw)
int dba_syntax
delta bit allocation syntax enabled (dbaflde)
int spx_src_start_freq
spx start frequency bin
static int get_sbits(GetBitContext *s, int n)
int lfe_mix_level_exists
indicates if lfemixlevcod is specified (lfemixlevcode)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define COEFF_0
lrint(M_SQRT2*cos(2*M_PI/12)*(1<<23))
int first_cpl_coords[AC3_MAX_CHANNELS]
first coupling coordinates states (firstcplcos)
INTFLOAT spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]
spx noise blending factor (nblendfact)
int bit_allocation_syntax
bit allocation model syntax enabled (bamode)
Common code between the AC-3 and E-AC-3 decoders.
static void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch)
int substreamid
substream identification
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const uint8_t ff_ac3_fast_decay_tab[4]
int lfe_ch
index of LFE channel
uint8_t first_spx_coords[AC3_MAX_CHANNELS]
first spx coordinates states (firstspxcos)
AC3BitAllocParameters bit_alloc_params
bit allocation parameters
int dolby_surround_mode
dolby surround mode (dsurmod)
GetBitContext gbc
bitstream reader
int dolby_headphone_mode
dolby headphone mode (dheadphonmod)
#define COEFF_2
lrint(M_SQRT2*cos(5*M_PI/12)*(1<<23))
Libavcodec external API header.
#define EAC3_SR_CODE_REDUCED
int block_switch_syntax
block switch syntax enabled (blkswe)
int fast_gain_syntax
fast gain codes enabled (frmfgaincode)
uint8_t channel_uses_spx[AC3_MAX_CHANNELS]
channel uses spectral extension (chinspx)
static void idct6(int pre_mant[6])
Calculate 6-point IDCT of the pre-mantissas.
int surround_mix_level_ltrt
Surround mix level index for Lt/Rt (ltrtsurmixlev)
int dither_flag_syntax
dither flag syntax enabled (dithflage)
const int16_t ff_eac3_gaq_remap_1[12]
Table E3.6, Gk=1 No gain (Gk=1) inverse quantization, remapping scale factors ff_eac3_gaq_remap[hebap...
const int16_t ff_eac3_gaq_remap_2_4_a[9][2]
Table E3.6, Gk=2 & Gk=4, A Large mantissa inverse quantization, remapping scale factors ff_eac3_gaq_r...
#define COEFF_1
lrint(M_SQRT2*cos(0*M_PI/12)*(1<<23)) = lrint(M_SQRT2*(1<<23))
AVCodecContext * avctx
parent context
const uint8_t ff_eac3_bits_vs_hebap[20]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int fbw_channels
number of full-bandwidth channels
int8_t spx_atten_code[AC3_MAX_CHANNELS]
spx attenuation code (spxattencod)
static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]
bit allocation pointers
#define CPL_CH
coupling channel index
const int16_t ff_eac3_gaq_remap_2_4_b[9][2]
Table E3.6, Gk=2 & Gk=4, B Large mantissa inverse quantization, negative mantissa remapping offsets f...
static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
int num_spx_bands
number of spx bands (nspxbnds)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
INTFLOAT spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]
spx signal blending factor (sblendfact)
static void skip_bits(GetBitContext *s, int n)
int bitstream_mode
bitstream mode (bsmod)
int center_mix_level_ltrt
Center mix level index for Lt/Rt (ltrtcmixlev)
int frame_type
frame type (strmtyp)
int channel_uses_aht[AC3_MAX_CHANNELS]
channel AHT in use (chahtinu)
const int16_t ff_ac3_floor_tab[8]
int cpl_in_use[AC3_MAX_BLOCKS]
coupling in use (cplinu)
int first_cpl_leak
first coupling leak state (firstcplleak)
int surround_mix_level
Surround mix level index.
int snr_offset[AC3_MAX_CHANNELS]
signal-to-noise ratio offsets (snroffst)
common internal api header.
const uint8_t ff_eac3_frm_expstr[32][6]
Table E2.14 Frame Exponent Strategy Combinations.
int num_blocks
number of audio blocks
float transform_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]
transform coefficients
int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]
pre-IDCT mantissas
uint8_t spx_band_sizes[SPX_MAX_BANDS]
number of bins in each spx band
int lfe_mix_level
LFE mix level index (lfemixlevcod)
int snr_offset_strategy
SNR offset strategy (snroffststr)
static const int16_t coeffs[]
int start_freq[AC3_MAX_CHANNELS]
start frequency bin (strtmant)
int center_mix_level
Center mix level index.
static const double coeff[2][5]
int frame_size
current frame size, in bytes
const int16_t(*const [8] ff_eac3_mantissa_vq)[6]
int dolby_surround_ex_mode
dolby surround ex mode (dsurexmod)
AVLFG dith_state
for dither generation
int cpl_strategy_exists[AC3_MAX_BLOCKS]
coupling strategy exists (cplstre)
const uint16_t ff_ac3_db_per_bit_tab[4]
Common code between the AC-3 encoder and decoder.
int channel_mode
channel mode (acmod)
int spx_dst_start_freq
spx starting frequency bin for copying (copystartmant) the copy region ends at the start of the spx r...
int skip_syntax
skip field syntax enabled (skipflde)