[FFmpeg-cvslog] aacdec_usac: remove custom rate_idx and use standard variable for it
Lynne
git at videolan.org
Fri Jun 21 11:50:40 EEST 2024
ffmpeg | branch: master | Lynne <dev at lynne.ee> | Sun Jun 16 10:28:05 2024 +0200| [d45e20c37b1144d9c4ff08732a94fee0786dc0b5] | committer: Lynne
aacdec_usac: remove custom rate_idx and use standard variable for it
m4ac.sampling_index is what aacdec.c uses.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d45e20c37b1144d9c4ff08732a94fee0786dc0b5
---
libavcodec/aac/aacdec.h | 1 -
libavcodec/aac/aacdec_usac.c | 35 ++++++++++++++---------------------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index d1a80e9ac1..e5a79a7139 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -350,7 +350,6 @@ typedef struct AACUsacElemConfig {
typedef struct AACUSACConfig {
uint8_t core_sbr_frame_len_idx; /* coreSbrFrameLengthIndex */
- uint8_t rate_idx;
uint16_t core_frame_len;
uint16_t stream_identifier;
diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index eb0e7d3659..e5504117d0 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -316,7 +316,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
GetBitContext *gb, OutputConfiguration *oc,
int channel_config)
{
- int ret, idx;
+ int ret;
uint8_t freq_idx;
uint8_t channel_config_idx;
int nb_channels = 0;
@@ -334,20 +334,10 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */
if (freq_idx == 0x1f) {
samplerate = get_bits(gb, 24); /* usacSamplingFrequency */
-
- /* Try to match up an index for the custom sample rate.
- * TODO: not sure if correct */
- for (idx = 0; idx < /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32; idx++) {
- if (ff_aac_usac_samplerate[idx] >= samplerate)
- break;
- }
- idx = FFMIN(idx, /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32 - 1);
- usac->rate_idx = idx;
} else {
samplerate = ff_aac_usac_samplerate[freq_idx];
if (samplerate < 0)
return AVERROR(EINVAL);
- usac->rate_idx = freq_idx;
}
m4ac->sample_rate = avctx->sample_rate = samplerate;
@@ -364,6 +354,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx,
usac->core_sbr_frame_len_idx == 4 ? 1 :
0;
+ m4ac->sampling_index = ff_aac_sample_rate_idx(m4ac->sample_rate);
+
channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */
if (!channel_config_idx) {
/* UsacChannelConfig() */
@@ -751,18 +743,19 @@ static int setup_sce(AACDecContext *ac, SingleChannelElement *sce,
{
AACUsacElemData *ue = &sce->ue;
IndividualChannelStream *ics = &sce->ics;
+ const int sampling_index = ac->oc[1].m4ac.sampling_index;
/* Setup window parameters */
ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
if (usac->core_frame_len == 768) {
- ics->swb_offset = ff_swb_offset_96[usac->rate_idx];
- ics->num_swb = ff_aac_num_swb_96[usac->rate_idx];
+ ics->swb_offset = ff_swb_offset_96[sampling_index];
+ ics->num_swb = ff_aac_num_swb_96[sampling_index];
} else {
- ics->swb_offset = ff_swb_offset_128[usac->rate_idx];
- ics->num_swb = ff_aac_num_swb_128[usac->rate_idx];
+ ics->swb_offset = ff_swb_offset_128[sampling_index];
+ ics->num_swb = ff_aac_num_swb_128[sampling_index];
}
- ics->tns_max_bands = ff_tns_max_bands_usac_128[usac->rate_idx];
+ ics->tns_max_bands = ff_tns_max_bands_usac_128[sampling_index];
/* Setup scalefactor grouping. 7 bit mask. */
ics->num_window_groups = 0;
@@ -779,13 +772,13 @@ static int setup_sce(AACDecContext *ac, SingleChannelElement *sce,
ics->num_windows = 8;
} else {
if (usac->core_frame_len == 768) {
- ics->swb_offset = ff_swb_offset_768[usac->rate_idx];
- ics->num_swb = ff_aac_num_swb_768[usac->rate_idx];
+ ics->swb_offset = ff_swb_offset_768[sampling_index];
+ ics->num_swb = ff_aac_num_swb_768[sampling_index];
} else {
- ics->swb_offset = ff_swb_offset_1024[usac->rate_idx];
- ics->num_swb = ff_aac_num_swb_1024[usac->rate_idx];
+ ics->swb_offset = ff_swb_offset_1024[sampling_index];
+ ics->num_swb = ff_aac_num_swb_1024[sampling_index];
}
- ics->tns_max_bands = ff_tns_max_bands_usac_1024[usac->rate_idx];
+ ics->tns_max_bands = ff_tns_max_bands_usac_1024[sampling_index];
ics->group_len[0] = 1;
ics->num_window_groups = 1;
More information about the ffmpeg-cvslog
mailing list