diff options
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3.h | 2 | ||||
-rw-r--r-- | libavcodec/ac3dec.c | 9 | ||||
-rw-r--r-- | libavcodec/ac3dec.h | 4 | ||||
-rw-r--r-- | libavcodec/eac3dec.c | 14 |
4 files changed, 22 insertions, 7 deletions
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h index 747f2f561d..5c9c37727e 100644 --- a/libavcodec/ac3.h +++ b/libavcodec/ac3.h @@ -87,7 +87,7 @@ typedef int16_t SHORTFLOAT; #define AC3_NORM(norm) (1.0f/(norm)) #define AC3_MUL(a,b) ((a) * (b)) #define AC3_RANGE(x) (dynamic_range_tab[(x)]) -#define AC3_HEAVY_RANGE(x) (heavy_dynamic_range_tab[(x)]) +#define AC3_HEAVY_RANGE(x) (ff_ac3_heavy_dynamic_range_tab[(x)]) #define AC3_DYNAMIC_RANGE(x) (powf(x, s->drc_scale)) #define AC3_SPX_BLEND(x) (x)* (1.0f/32) #define AC3_DYNAMIC_RANGE1 1.0f diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index fac189b6b6..a95c2049b5 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -63,9 +63,11 @@ static const uint8_t quantization_tab[16] = { 5, 6, 7, 8, 9, 10, 11, 12, 14, 16 }; +#if (!USE_FIXED) /** dynamic range table. converts codes to scale factors. */ static float dynamic_range_tab[256]; -static float heavy_dynamic_range_tab[256]; +float ff_ac3_heavy_dynamic_range_tab[256]; +#endif /** Adjustments in dB gain */ static const float gain_levels[9] = { @@ -159,6 +161,7 @@ static av_cold void ac3_tables_init(void) b5_mantissas[i] = symmetric_dequant(i, 15); } +#if (!USE_FIXED) /* generate dynamic range table reference: Section 7.7.1 Dynamic Range Control */ for (i = 0; i < 256; i++) { @@ -170,9 +173,9 @@ static av_cold void ac3_tables_init(void) reference: Section 7.7.2 Heavy Compression */ for (i = 0; i < 256; i++) { int v = (i >> 4) - ((i >> 7) << 4) - 4; - heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10); + ff_ac3_heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10); } - +#endif } /** diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index c2b867e32c..6cd67c0f21 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -260,4 +260,8 @@ static void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch); */ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s); +#if (!USE_FIXED) +extern float ff_ac3_heavy_dynamic_range_tab[256]; +#endif + #endif /* AVCODEC_AC3DEC_H */ diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c index 47e5aa6587..83a54bcfab 100644 --- a/libavcodec/eac3dec.c +++ b/libavcodec/eac3dec.c @@ -339,9 +339,17 @@ static int ff_eac3_parse_header(AC3DecodeContext *s) /* volume control params */ for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { - skip_bits(gbc, 5); // skip dialog normalization - if (get_bits1(gbc)) { - skip_bits(gbc, 8); // skip compression gain word + s->dialog_normalization[i] = -get_bits(gbc, 5); + if (s->dialog_normalization[i] == 0) { + s->dialog_normalization[i] = -31; + } + if (s->target_level != 0) { + s->level_gain[i] = powf(2.0f, + (float)(s->target_level - s->dialog_normalization[i])/6.0f); + } + s->compression_exists[i] = get_bits1(gbc); + if (s->compression_exists[i]) { + s->heavy_dynamic_range[i] = AC3_HEAVY_RANGE(get_bits(gbc, 8)); } } |