History

avcodec/dca: use LUT for LBR frequency ranges

Values for unsupported frequencies > 48000 Hz are still included (parser will make use of them). Also convert sampling frequencies array to unsigned.

foo86 committed 10 years ago

Commit 64fe1ee1 parent 801dbf03 files · +12 −12Browse files

Unified · Split

3 files
  1. libavcodec/dca_lbr.c +5 −10
  2. libavcodec/dcadata.c +5 −1
  3. libavcodec/dcadata.h +2 −1
libavcodec/dca_lbr.c+5−10
@@ -1000,15 +1000,15 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) · 999 unmodified lines
10001000 int old_band_limit = s->band_limit;
10011001 int old_nchannels = s->nchannels;
10021002 int version, bit_rate_hi;
1003− unsigned int code;
1003+ unsigned int sr_code;
10041004
10051005 // Sample rate of LBR audio
1006− code = bytestream2_get_byte(gb);
1007− if (code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {
1006+ sr_code = bytestream2_get_byte(gb);
1007+ if (sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {
10081008 av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n");
10091009 return AVERROR_INVALIDDATA;
10101010 }
1011− s->sample_rate = ff_dca_sampling_freqs[code];
1011+ s->sample_rate = ff_dca_sampling_freqs[sr_code];
10121012 if (s->sample_rate > 48000) {
10131013 avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate);
10141014 return AVERROR_PATCHWELCOME;
@@ -1076,12 +1076,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) · 61 unmodified lines
10761076 }
10771077
10781078 // Setup frequency range
1079− if (s->sample_rate < 14000)
1080− s->freq_range = 0;
1081− else if (s->sample_rate < 28000)
1082− s->freq_range = 1;
1083− else
1084− s->freq_range = 2;
1079+ s->freq_range = ff_dca_freq_ranges[sr_code];
10851080
10861081 // Setup resolution profile
10871082 if (s->bit_rate_orig >= 44000 * (s->nchannels_total + 2))
libavcodec/dcadata.c+5−1
@@ -8725,11 +8725,15 @@ const int32_t ff_dca_xll_band_coeff[20] = { · 8724 unmodified lines
87258725 3259333, -5074941, 6928550, -8204883
87268726 };
87278727
8728−const int32_t ff_dca_sampling_freqs[16] = {
8728+const uint32_t ff_dca_sampling_freqs[16] = {
87298729 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
87308730 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
87318731 };
87328732
8733+const uint8_t ff_dca_freq_ranges[16] = {
8734+ 0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4
8735+};
8736+
87338737 const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 };
87348738
87358739 const uint16_t ff_dca_fst_amp[44] = {
libavcodec/dcadata.h+2−1
@@ -71,7 +71,8 @@ extern const uint16_t ff_dca_xll_refl_coeff[128]; · 70 unmodified lines
7171
7272 extern const int32_t ff_dca_xll_band_coeff[20];
7373
74−extern const int32_t ff_dca_sampling_freqs[16];
74+extern const uint32_t ff_dca_sampling_freqs[16];
75+extern const uint8_t ff_dca_freq_ranges[16];
7576
7677 extern const uint16_t ff_dca_avg_g3_freqs[3];
7778

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