History

dca: remove embedded downmix coefficient extraction.

It was based on an old, seemingly incorrect specification, so default coefficients were always used anyway.

Tim Walker committed 12 years ago

Commit 27245b41 parent b6d5e6a2 files · +17 −44Browse files

Unified · Split

2 files
  1. libavcodec/dcadata.h +0 −17
  2. libavcodec/dcadec.c +17 −27
libavcodec/dcadata.h+0−17
@@ -7505,23 +7505,6 @@ DECLARE_ALIGNED(16, static const float, lfe_fir_128)[] = · 7504 unmodified lines
75057505 0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412,
75067506 };
75077507
7508−/* 10^-(dB/20), with dB being a list of dB values ranging from 0 to -72 */
7509−/* do a 20*log10(dca_downmix_coeffs) to reconvert the values */
7510−
7511−static const float dca_downmix_coeffs[65] = {
7512− 1.000000000000000, 0.988553094656939, 0.971627951577106, 0.944060876285923, 0.917275935389780, 0.891250938133746,
7513− 0.865964323360065, 0.841395141645195, 0.817523037943650, 0.794328234724281, 0.771791515585012, 0.749894209332456,
7514− 0.728618174513228, 0.707945784384138, 0.687859912308808, 0.668343917568615, 0.649381631576211, 0.630957344480193,
7515− 0.613055792149821, 0.595662143529010, 0.578761988349121, 0.562341325190349, 0.546386549881854, 0.530884444230988,
7516− 0.515822165072306, 0.501187233627272, 0.446683592150963, 0.398107170553497, 0.354813389233575, 0.316227766016838,
7517− 0.281838293126445, 0.251188643150958, 0.223872113856834, 0.199526231496888, 0.177827941003892, 0.158489319246111,
7518− 0.141253754462275, 0.125892541179417, 0.112201845430196, 0.100000000000000, 0.089125093813374, 0.079432823472428,
7519− 0.070794578438414, 0.063095734448019, 0.053088444423099, 0.044668359215096, 0.037583740428844, 0.031622776601684,
7520− 0.026607250597988, 0.022387211385683, 0.018836490894898, 0.015848931924611, 0.013335214321633, 0.011220184543020,
7521− 0.009440608762859, 0.007943282347243, 0.005623413251903, 0.003981071705535, 0.002818382931264, 0.001995262314969,
7522− 0.001412537544623, 0.001000000000000, 0.000501187233627, 0.000251188643151, 0.000000000000000,
7523−};
7524−
75257508 static const float dca_default_coeffs[10][5][2] = {
75267509 { { 0.707946, 0.707946 }, }, // A
75277510 { { 1.000000, 0.000000 }, { 0.000000, 1.000000 }, }, // A + B (dual mono)
libavcodec/dcadec.c+17−27
@@ -295,7 +295,6 @@ typedef struct { · 294 unmodified lines
295295 int bit_rate; ///< transmission bit rate
296296 int bit_rate_index; ///< transmission bit rate index
297297
298− int downmix; ///< embedded downmix enabled
299298 int dynrange; ///< embedded dynamic range flag
300299 int timestamp; ///< embedded time stamp flag
301300 int aux_data; ///< auxiliary data flag
@@ -569,7 +568,7 @@ static int dca_parse_frame_header(DCAContext *s) · 267 unmodified lines
569568 if (!s->bit_rate)
570569 return AVERROR_INVALIDDATA;
571570
572− s->downmix = get_bits(&s->gb, 1);
571+ skip_bits1(&s->gb); // always 0 (reserved, cf. ETSI TS 102 114 V1.4.1)
573572 s->dynrange = get_bits(&s->gb, 1);
574573 s->timestamp = get_bits(&s->gb, 1);
575574 s->aux_data = get_bits(&s->gb, 1);
@@ -615,7 +614,6 @@ static int dca_parse_frame_header(DCAContext *s) · 39 unmodified lines
615614 s->sample_rate);
616615 av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n",
617616 s->bit_rate);
618− av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix);
619617 av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);
620618 av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);
621619 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) · 178 unmodified lines
800798
801799 /* Stereo downmix coefficients */
802800 if (!base_channel && s->prim_channels > 2) {
803− if (s->downmix) {
804− for (j = base_channel; j < s->prim_channels; j++) {
805− s->downmix_coef[j][0] = dca_downmix_coeffs[get_bits(&s->gb, 7)];
806− s->downmix_coef[j][1] = dca_downmix_coeffs[get_bits(&s->gb, 7)];
807− }
808− } else {
809− int am = s->amode & DCA_CHANNEL_MASK;
810− if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {
811− av_log(s->avctx, AV_LOG_ERROR,
812− "Invalid channel mode %d\n", am);
813− return AVERROR_INVALIDDATA;
814− }
815− if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
816− avpriv_request_sample(s->avctx, "Downmixing %d channels",
817− s->prim_channels);
818− return AVERROR_PATCHWELCOME;
819− }
820−
821− for (j = base_channel; j < s->prim_channels; j++) {
822− s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
823− s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
824− }
801+ int am = s->amode & DCA_CHANNEL_MASK;
802+ if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {
803+ av_log(s->avctx, AV_LOG_ERROR,
804+ "Invalid channel mode %d\n", am);
805+ return AVERROR_INVALIDDATA;
806+ }
807+ if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
808+ avpriv_request_sample(s->avctx, "Downmixing %d channels",
809+ s->prim_channels);
810+ return AVERROR_PATCHWELCOME;
811+ }
812+ for (j = base_channel; j < s->prim_channels; j++) {
813+ s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
814+ s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
825815 }
826816 }
827817
@@ -919,7 +909,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) · 91 unmodified lines
919909 av_log(s->avctx, AV_LOG_DEBUG, "\n");
920910 }
921911 }
922− if (!base_channel && s->prim_channels > 2 && s->downmix) {
912+ if (!base_channel && s->prim_channels > 2) {
923913 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
924914 for (j = 0; j < s->prim_channels; j++) {
925915 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) · 393 unmodified lines
13191309 for (i = 0; i < aux_data_count; i++)
13201310 get_bits(&s->gb, 8);
13211311
1322− if (s->crc_present && (s->downmix || s->dynrange))
1312+ if (s->crc_present && s->dynrange)
13231313 get_bits(&s->gb, 16);
13241314 }
13251315

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t