aac: expose ff_aac_sample_rate_idx() in aac.h

The rate index is a value important to both encoders and decoders.
USAC needs it as well, so put it into the shared main header.
This commit is contained in:
Lynne 2024-06-16 10:20:56 +02:00
parent 1c3545f053
commit 50e5b78b79
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 17 additions and 17 deletions

View File

@ -103,4 +103,20 @@ typedef struct Pulse {
int amp[4];
} Pulse;
static inline int ff_aac_sample_rate_idx(int rate)
{
if (92017 <= rate) return 0;
else if (75132 <= rate) return 1;
else if (55426 <= rate) return 2;
else if (46009 <= rate) return 3;
else if (37566 <= rate) return 4;
else if (27713 <= rate) return 5;
else if (23004 <= rate) return 6;
else if (18783 <= rate) return 7;
else if (13856 <= rate) return 8;
else if (11502 <= rate) return 9;
else if (9391 <= rate) return 10;
else return 11;
}
#endif /* AVCODEC_AAC_H */

View File

@ -1095,22 +1095,6 @@ static int decode_audio_specific_config(AACDecContext *ac,
sync_extension);
}
static int sample_rate_idx (int rate)
{
if (92017 <= rate) return 0;
else if (75132 <= rate) return 1;
else if (55426 <= rate) return 2;
else if (46009 <= rate) return 3;
else if (37566 <= rate) return 4;
else if (27713 <= rate) return 5;
else if (23004 <= rate) return 6;
else if (18783 <= rate) return 7;
else if (13856 <= rate) return 8;
else if (11502 <= rate) return 9;
else if (9391 <= rate) return 10;
else return 11;
}
static av_cold int decode_close(AVCodecContext *avctx)
{
AACDecContext *ac = avctx->priv_data;
@ -1211,7 +1195,7 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx)
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags;
sr = sample_rate_idx(avctx->sample_rate);
sr = ff_aac_sample_rate_idx(avctx->sample_rate);
ac->oc[1].m4ac.sampling_index = sr;
ac->oc[1].m4ac.channels = avctx->ch_layout.nb_channels;
ac->oc[1].m4ac.sbr = -1;