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
7505 0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412,7505 0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412,
7506};7506};
7507 7507
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
7511static 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
7525static const float dca_default_coeffs[10][5][2] = {7508static const float dca_default_coeffs[10][5][2] = {
7526 { { 0.707946, 0.707946 }, }, // A7509 { { 0.707946, 0.707946 }, }, // A
7527 { { 1.000000, 0.000000 }, { 0.000000, 1.000000 }, }, // A + B (dual mono)7510 { { 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
295 int bit_rate; ///< transmission bit rate295 int bit_rate; ///< transmission bit rate
296 int bit_rate_index; ///< transmission bit rate index296 int bit_rate_index; ///< transmission bit rate index
297 297
298 int downmix; ///< embedded downmix enabled
299 int dynrange; ///< embedded dynamic range flag298 int dynrange; ///< embedded dynamic range flag
300 int timestamp; ///< embedded time stamp flag299 int timestamp; ///< embedded time stamp flag
301 int aux_data; ///< auxiliary data flag300 int aux_data; ///< auxiliary data flag
@@ -569,7 +568,7 @@ static int dca_parse_frame_header(DCAContext *s) · 267 unmodified lines
569 if (!s->bit_rate)568 if (!s->bit_rate)
570 return AVERROR_INVALIDDATA;569 return AVERROR_INVALIDDATA;
571 570
572 s->downmix = get_bits(&s->gb, 1);571 skip_bits1(&s->gb); // always 0 (reserved, cf. ETSI TS 102 114 V1.4.1)
573 s->dynrange = get_bits(&s->gb, 1);572 s->dynrange = get_bits(&s->gb, 1);
574 s->timestamp = get_bits(&s->gb, 1);573 s->timestamp = get_bits(&s->gb, 1);
575 s->aux_data = get_bits(&s->gb, 1);574 s->aux_data = get_bits(&s->gb, 1);
@@ -615,7 +614,6 @@ static int dca_parse_frame_header(DCAContext *s) · 39 unmodified lines
615 s->sample_rate);614 s->sample_rate);
616 av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n",615 av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n",
617 s->bit_rate);616 s->bit_rate);
618 av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix);
619 av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);617 av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);
620 av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);618 av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);
621 av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data);619 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
800 798
801 /* Stereo downmix coefficients */799 /* Stereo downmix coefficients */
802 if (!base_channel && s->prim_channels > 2) {800 if (!base_channel && s->prim_channels > 2) {
803 if (s->downmix) {801 int am = s->amode & DCA_CHANNEL_MASK;
804 for (j = base_channel; j < s->prim_channels; j++) {802 if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {
805 s->downmix_coef[j][0] = dca_downmix_coeffs[get_bits(&s->gb, 7)];803 av_log(s->avctx, AV_LOG_ERROR,
806 s->downmix_coef[j][1] = dca_downmix_coeffs[get_bits(&s->gb, 7)];804 "Invalid channel mode %d\n", am);
807 }805 return AVERROR_INVALIDDATA;
808 } else {806 }
809 int am = s->amode & DCA_CHANNEL_MASK;807 if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {
810 if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {808 avpriv_request_sample(s->avctx, "Downmixing %d channels",
811 av_log(s->avctx, AV_LOG_ERROR,809 s->prim_channels);
812 "Invalid channel mode %d\n", am);810 return AVERROR_PATCHWELCOME;
813 return AVERROR_INVALIDDATA;811 }
814 }812 for (j = base_channel; j < s->prim_channels; j++) {
815 if (s->prim_channels > FF_ARRAY_ELEMS(dca_default_coeffs[0])) {813 s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
816 avpriv_request_sample(s->avctx, "Downmixing %d channels",814 s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
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 }
825 }815 }
826 }816 }
827 817
@@ -919,7 +909,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) · 91 unmodified lines
919 av_log(s->avctx, AV_LOG_DEBUG, "\n");909 av_log(s->avctx, AV_LOG_DEBUG, "\n");
920 }910 }
921 }911 }
922 if (!base_channel && s->prim_channels > 2 && s->downmix) {912 if (!base_channel && s->prim_channels > 2) {
923 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");913 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
924 for (j = 0; j < s->prim_channels; j++) {914 for (j = 0; j < s->prim_channels; j++) {
925 av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,915 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
1319 for (i = 0; i < aux_data_count; i++)1309 for (i = 0; i < aux_data_count; i++)
1320 get_bits(&s->gb, 8);1310 get_bits(&s->gb, 8);
1321 1311
1322 if (s->crc_present && (s->downmix || s->dynrange))1312 if (s->crc_present && s->dynrange)
1323 get_bits(&s->gb, 16);1313 get_bits(&s->gb, 16);
1324 }1314 }
1325 1315

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