MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_aac_decode_init

Function ff_aac_decode_init

libavcodec/aac/aacdec.c:1210–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1208}
1209
1210av_cold int ff_aac_decode_init(AVCodecContext *avctx)
1211{
1212 AACDecContext *ac = avctx->priv_data;
1213 int ret;
1214
1215 if (avctx->sample_rate > 96000)
1216 return AVERROR_INVALIDDATA;
1217
1218 ff_aacdec_common_init_once();
1219
1220 ac->avctx = avctx;
1221 ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
1222
1223 if (avctx->extradata_size > 0) {
1224 if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1],
1225 avctx->extradata,
1226 avctx->extradata_size * 8LL,
1227 1)) < 0)
1228 return ret;
1229 } else {
1230 int sr, i;
1231 uint8_t layout_map[MAX_ELEM_ID*4][3];
1232 int layout_map_tags;
1233
1234 sr = ff_aac_sample_rate_idx(avctx->sample_rate);
1235 ac->oc[1].m4ac.sampling_index = sr;
1236 ac->oc[1].m4ac.channels = avctx->ch_layout.nb_channels;
1237 ac->oc[1].m4ac.sbr = -1;
1238 ac->oc[1].m4ac.ps = -1;
1239
1240 for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
1241 if (ff_mpeg4audio_channels[i] == avctx->ch_layout.nb_channels)
1242 break;
1243 if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
1244 i = 0;
1245 }
1246 ac->oc[1].m4ac.chan_config = i;
1247
1248 if (ac->oc[1].m4ac.chan_config) {
1249 int ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
1250 &layout_map_tags,
1251 ac->oc[1].m4ac.chan_config);
1252 if (!ret)
1253 ff_aac_output_configure(ac, layout_map, layout_map_tags,
1254 OC_GLOBAL_HDR, 0);
1255 else if (avctx->err_recognition & AV_EF_EXPLODE)
1256 return AVERROR_INVALIDDATA;
1257 }
1258 }
1259
1260 if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
1261 av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
1262 return AVERROR_INVALIDDATA;
1263 }
1264
1265 ac->random_state = 0x1f2e3d4c;
1266
1267 return init_dsp(avctx);

Callers 2

ff_aac_decode_init_fixedFunction · 0.85
ff_aac_decode_init_floatFunction · 0.85

Calls 7

ff_aac_sample_rate_idxFunction · 0.85
ff_aac_output_configureFunction · 0.85
av_logFunction · 0.85
init_dspFunction · 0.85

Tested by

no test coverage detected