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
1000 int old_band_limit = s->band_limit;1000 int old_band_limit = s->band_limit;
1001 int old_nchannels = s->nchannels;1001 int old_nchannels = s->nchannels;
1002 int version, bit_rate_hi;1002 int version, bit_rate_hi;
1003 unsigned int code;1003 unsigned int sr_code;
1004 1004
1005 // Sample rate of LBR audio1005 // Sample rate of LBR audio
1006 code = bytestream2_get_byte(gb);1006 sr_code = bytestream2_get_byte(gb);
1007 if (code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {1007 if (sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {
1008 av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n");1008 av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n");
1009 return AVERROR_INVALIDDATA;1009 return AVERROR_INVALIDDATA;
1010 }1010 }
1011 s->sample_rate = ff_dca_sampling_freqs[code];1011 s->sample_rate = ff_dca_sampling_freqs[sr_code];
1012 if (s->sample_rate > 48000) {1012 if (s->sample_rate > 48000) {
1013 avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate);1013 avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate);
1014 return AVERROR_PATCHWELCOME;1014 return AVERROR_PATCHWELCOME;
@@ -1076,12 +1076,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) · 61 unmodified lines
1076 }1076 }
1077 1077
1078 // Setup frequency range1078 // Setup frequency range
1079 if (s->sample_rate < 14000)1079 s->freq_range = ff_dca_freq_ranges[sr_code];
1080 s->freq_range = 0;
1081 else if (s->sample_rate < 28000)
1082 s->freq_range = 1;
1083 else
1084 s->freq_range = 2;
1085 1080
1086 // Setup resolution profile1081 // Setup resolution profile
1087 if (s->bit_rate_orig >= 44000 * (s->nchannels_total + 2))1082 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
8725 3259333, -5074941, 6928550, -82048838725 3259333, -5074941, 6928550, -8204883
8726};8726};
8727 8727
8728const int32_t ff_dca_sampling_freqs[16] = {8728const uint32_t ff_dca_sampling_freqs[16] = {
8729 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,8729 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
8730 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,8730 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
8731};8731};
8732 8732
8733const 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
8733const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 };8737const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 };
8734 8738
8735const uint16_t ff_dca_fst_amp[44] = {8739const 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
71 71
72extern const int32_t ff_dca_xll_band_coeff[20];72extern const int32_t ff_dca_xll_band_coeff[20];
73 73
74extern const int32_t ff_dca_sampling_freqs[16];74extern const uint32_t ff_dca_sampling_freqs[16];
75extern const uint8_t ff_dca_freq_ranges[16];
75 76
76extern const uint16_t ff_dca_avg_g3_freqs[3];77extern const uint16_t ff_dca_avg_g3_freqs[3];
77 78

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