[FFmpeg-devel] [PATCH 05/10] avcodec/dca: use LUT for LBR frequency ranges
foo86
foobaz86 at gmail.com
Fri May 13 11:48:27 CEST 2016
Values for unsupported frequencies > 48000 Hz are still included (parser
will make use of them).
Also convert sampling frequencies array to unsigned.
---
libavcodec/dca_lbr.c | 15 +++++----------
libavcodec/dcadata.c | 6 +++++-
libavcodec/dcadata.h | 3 ++-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 9a7f4cd..f116ab9 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -1000,15 +1000,15 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb)
int old_band_limit = s->band_limit;
int old_nchannels = s->nchannels;
int version, bit_rate_hi;
- unsigned int code;
+ unsigned int sr_code;
// Sample rate of LBR audio
- code = bytestream2_get_byte(gb);
- if (code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {
+ sr_code = bytestream2_get_byte(gb);
+ if (sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n");
return AVERROR_INVALIDDATA;
}
- s->sample_rate = ff_dca_sampling_freqs[code];
+ s->sample_rate = ff_dca_sampling_freqs[sr_code];
if (s->sample_rate > 48000) {
avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate);
return AVERROR_PATCHWELCOME;
@@ -1076,12 +1076,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb)
}
// Setup frequency range
- if (s->sample_rate < 14000)
- s->freq_range = 0;
- else if (s->sample_rate < 28000)
- s->freq_range = 1;
- else
- s->freq_range = 2;
+ s->freq_range = ff_dca_freq_ranges[sr_code];
// Setup resolution profile
if (s->bit_rate_orig >= 44000 * (s->nchannels_total + 2))
diff --git a/libavcodec/dcadata.c b/libavcodec/dcadata.c
index 53be01d..2d533d0 100644
--- a/libavcodec/dcadata.c
+++ b/libavcodec/dcadata.c
@@ -8725,11 +8725,15 @@ const int32_t ff_dca_xll_band_coeff[20] = {
3259333, -5074941, 6928550, -8204883
};
-const int32_t ff_dca_sampling_freqs[16] = {
+const uint32_t ff_dca_sampling_freqs[16] = {
8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
};
+const uint8_t ff_dca_freq_ranges[16] = {
+ 0, 1, 2, 3, 4, 1, 2, 3, 4, 4, 0, 1, 2, 3, 4, 4
+};
+
const uint16_t ff_dca_avg_g3_freqs[3] = { 16000, 18000, 24000 };
const uint16_t ff_dca_fst_amp[44] = {
diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h
index 0c54225..1ef1342 100644
--- a/libavcodec/dcadata.h
+++ b/libavcodec/dcadata.h
@@ -71,7 +71,8 @@ extern const uint16_t ff_dca_xll_refl_coeff[128];
extern const int32_t ff_dca_xll_band_coeff[20];
-extern const int32_t ff_dca_sampling_freqs[16];
+extern const uint32_t ff_dca_sampling_freqs[16];
+extern const uint8_t ff_dca_freq_ranges[16];
extern const uint16_t ff_dca_avg_g3_freqs[3];
--
2.8.1
More information about the ffmpeg-devel
mailing list