Values for unsupported frequencies > 48000 Hz are still included (parser will make use of them). Also convert sampling frequencies array to unsigned.
Unified · Split
| @@ -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 audio | 1005 | // 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 range | 1078 | // 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 profile | 1081 | // 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)) |
| @@ -8725,11 +8725,15 @@ const int32_t ff_dca_xll_band_coeff[20] = { · 8724 unmodified lines | |||
| 8725 | 3259333, -5074941, 6928550, -8204883 | 8725 | 3259333, -5074941, 6928550, -8204883 |
| 8726 | }; | 8726 | }; |
| 8727 | 8727 | ||
| 8728 | const int32_t ff_dca_sampling_freqs[16] = { | 8728 | const 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 | ||
| 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 | |||
| 8733 | const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 }; | 8737 | const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 }; |
| 8734 | 8738 | ||
| 8735 | const uint16_t ff_dca_fst_amp[44] = { | 8739 | const uint16_t ff_dca_fst_amp[44] = { |
| @@ -71,7 +71,8 @@ extern const uint16_t ff_dca_xll_refl_coeff[128]; · 70 unmodified lines | |||
| 71 | 71 | ||
| 72 | extern const int32_t ff_dca_xll_band_coeff[20]; | 72 | extern const int32_t ff_dca_xll_band_coeff[20]; |
| 73 | 73 | ||
| 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]; | ||
| 75 | 76 | ||
| 76 | extern const uint16_t ff_dca_avg_g3_freqs[3]; | 77 | extern const uint16_t ff_dca_avg_g3_freqs[3]; |
| 77 | 78 | ||