From 27245b4e1bbb7a863341db321b5bdc5792e427d9 Mon Sep 17 00:00:00 2001 From: Tim Walker Date: Fri, 22 Nov 2013 20:25:57 +0100 Subject: [PATCH] dca: remove embedded downmix coefficient extraction. It was based on an old, seemingly incorrect specification, so default coefficients were always used anyway. Signed-off-by: Anton Khirnov --- libavcodec/dcadata.h | 17 ----------------- libavcodec/dcadec.c | 44 +++++++++++++++++--------------------------- 2 files changed, 17 insertions(+), 44 deletions(-) diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h index e8f07e8beb..c4841fbac8 100644 --- a/libavcodec/dcadata.h +++ b/libavcodec/dcadata.h @@ -7505,23 +7505,6 @@ DECLARE_ALIGNED(16, static const float, lfe_fir_128)[] = 0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412, }; -/* 10^-(dB/20), with dB being a list of dB values ranging from 0 to -72 */ -/* do a 20*log10(dca_downmix_coeffs) to reconvert the values */ - -static const float dca_downmix_coeffs[65] = { - 1.000000000000000, 0.988553094656939, 0.971627951577106, 0.944060876285923, 0.917275935389780, 0.891250938133746, - 0.865964323360065, 0.841395141645195, 0.817523037943650, 0.794328234724281, 0.771791515585012, 0.749894209332456, - 0.728618174513228, 0.707945784384138, 0.687859912308808, 0.668343917568615, 0.649381631576211, 0.630957344480193, - 0.613055792149821, 0.595662143529010, 0.578761988349121, 0.562341325190349, 0.546386549881854, 0.530884444230988, - 0.515822165072306, 0.501187233627272, 0.446683592150963, 0.398107170553497, 0.354813389233575, 0.316227766016838, - 0.281838293126445, 0.251188643150958, 0.223872113856834, 0.199526231496888, 0.177827941003892, 0.158489319246111, - 0.141253754462275, 0.125892541179417, 0.112201845430196, 0.100000000000000, 0.089125093813374, 0.079432823472428, - 0.070794578438414, 0.063095734448019, 0.053088444423099, 0.044668359215096, 0.037583740428844, 0.031622776601684, - 0.026607250597988, 0.022387211385683, 0.018836490894898, 0.015848931924611, 0.013335214321633, 0.011220184543020, - 0.009440608762859, 0.007943282347243, 0.005623413251903, 0.003981071705535, 0.002818382931264, 0.001995262314969, - 0.001412537544623, 0.001000000000000, 0.000501187233627, 0.000251188643151, 0.000000000000000, -}; - static const float dca_default_coeffs[10][5][2] = { { { 0.707946, 0.707946 }, }, // A { { 1.000000, 0.000000 }, { 0.000000, 1.000000 }, }, // A + B (dual mono) diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 33a2ac6e9a..eb229ce98e 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -295,7 +295,6 @@ typedef struct { int bit_rate; ///< transmission bit rate int bit_rate_index; ///< transmission bit rate index - int downmix; ///< embedded downmix enabled int dynrange; ///< embedded dynamic range flag int timestamp; ///< embedded time stamp flag int aux_data; ///< auxiliary data flag @@ -569,7 +568,7 @@ static int dca_parse_frame_header(DCAContext *s) if (!s->bit_rate) return AVERROR_INVALIDDATA; - s->downmix = get_bits(&s->gb, 1); + skip_bits1(&s->gb); // always 0 (reserved, cf. ETSI TS 102 114 V1.4.1) s->dynrange = get_bits(&s->gb, 1); s->timestamp = get_bits(&s->gb, 1); s->aux_data = get_bits(&s->gb, 1); @@ -615,7 +614,6 @@ static int dca_parse_frame_header(DCAContext *s) s->sample_rate); av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n", s->bit_rate); - av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix); av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange); av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp); av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data); @@ -800,28 +798,20 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) /* Stereo downmix coefficients */ if (!base_channel && s->prim_channels > 2) { - if (s->downmix) { - for (j = base_channel; j < s->prim_channels; j++) { - s->downmix_coef[j][0] = dca_downmix_coeffs[get_bits(&s->gb, 7)]; - s->downmix_coef[j][1] = dca_downmix_coeffs[get_bits(&s->gb, 7)]; - } - } else { - int am = s->amode & DCA_CHANNEL_MASK; - if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) { - av_log(s->avctx, AV_LOG_ERROR, - "Invalid channel mode %d\n", am); - return AVERROR_INVALIDDATA; - } - if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) { - avpriv_request_sample(s->avctx, "Downmixing %d channels", - s->prim_channels); - return AVERROR_PATCHWELCOME; - } - - for (j = base_channel; j < s->prim_channels; j++) { - s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; - s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; - } + int am = s->amode & DCA_CHANNEL_MASK; + if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) { + av_log(s->avctx, AV_LOG_ERROR, + "Invalid channel mode %d\n", am); + return AVERROR_INVALIDDATA; + } + if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) { + avpriv_request_sample(s->avctx, "Downmixing %d channels", + s->prim_channels); + return AVERROR_PATCHWELCOME; + } + for (j = base_channel; j < s->prim_channels; j++) { + s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; + s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; } } @@ -919,7 +909,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } - if (!base_channel && s->prim_channels > 2 && s->downmix) { + if (!base_channel && s->prim_channels > 2) { av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); for (j = 0; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j, @@ -1319,7 +1309,7 @@ static int dca_subframe_footer(DCAContext *s, int base_channel) for (i = 0; i < aux_data_count; i++) get_bits(&s->gb, 8); - if (s->crc_present && (s->downmix || s->dynrange)) + if (s->crc_present && s->dynrange) get_bits(&s->gb, 16); }