for (i = 0; i < 16; i++)
if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i])
break;
+ s->samplerate_index = i;
- s->channels = avctx->channels;
-
- ERROR_IF(i == 16,
+ ERROR_IF(s->samplerate_index == 16 ||
+ s->samplerate_index >= ff_aac_swb_size_1024_len ||
+ s->samplerate_index >= ff_aac_swb_size_128_len,
"Unsupported sample rate %d\n", avctx->sample_rate);
- ERROR_IF(s->channels > AAC_MAX_CHANNELS,
+ ERROR_IF(s->channels > AAC_MAX_CHANNELS || s->channels == 7,
"Unsupported number of channels: %d\n", s->channels);
- ERROR_IF(avctx->profile != FF_PROFILE_UNKNOWN && avctx->profile != FF_PROFILE_AAC_LOW,
- "Unsupported profile %d\n", avctx->profile);
- ERROR_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels,
- "Too many bits %f > %d per frame requested\n",
+ WARN_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels,
- "Too many bits per frame requested, clamping to max\n");
++ "Too many bits %f > %d per frame requested, clamping to max\n",
+ 1024.0 * avctx->bit_rate / avctx->sample_rate,
+ 6144 * s->channels);
- s->samplerate_index = i;
-
- s->chan_map = aac_chan_configs[s->channels-1];
+ for (i = 0; i < FF_ARRAY_ELEMS(aacenc_profiles); i++)
+ if (avctx->profile == aacenc_profiles[i])
+ break;
+ ERROR_IF(i == FF_ARRAY_ELEMS(aacenc_profiles),
+ "Unsupported encoding profile: %d\n", avctx->profile);
+ if (avctx->profile == FF_PROFILE_MPEG2_AAC_LOW) {
+ avctx->profile = FF_PROFILE_AAC_LOW;
+ ERROR_IF(s->options.pred,
+ "Main prediction unavailable in the \"mpeg2_aac_low\" profile\n");
+ ERROR_IF(s->options.ltp,
+ "LTP prediction unavailable in the \"mpeg2_aac_low\" profile\n");
+ WARN_IF(s->options.pns,
+ "PNS unavailable in the \"mpeg2_aac_low\" profile, turning off\n");
+ s->options.pns = 0;
+ } else if (avctx->profile == FF_PROFILE_AAC_LTP) {
+ s->options.ltp = 1;
+ ERROR_IF(s->options.pred,
+ "Main prediction unavailable in the \"aac_ltp\" profile\n");
+ } else if (avctx->profile == FF_PROFILE_AAC_MAIN) {
+ s->options.pred = 1;
+ ERROR_IF(s->options.ltp,
+ "LTP prediction unavailable in the \"aac_main\" profile\n");
+ } else if (s->options.ltp) {
+ avctx->profile = FF_PROFILE_AAC_LTP;
+ WARN_IF(1,
+ "Chainging profile to \"aac_ltp\"\n");
+ ERROR_IF(s->options.pred,
+ "Main prediction unavailable in the \"aac_ltp\" profile\n");
+ } else if (s->options.pred) {
+ avctx->profile = FF_PROFILE_AAC_MAIN;
+ WARN_IF(1,
+ "Chainging profile to \"aac_main\"\n");
+ ERROR_IF(s->options.ltp,
+ "LTP prediction unavailable in the \"aac_main\" profile\n");
+ }
+ s->profile = avctx->profile;
+ s->coder = &ff_aac_coders[s->options.coder];
+
+ if (s->options.coder != AAC_CODER_TWOLOOP) {
+ ERROR_IF(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL,
+ "Coders other than twoloop require -strict -2 and some may be removed in the future\n");
+ WARN_IF(s->options.coder == AAC_CODER_FAAC,
+ "The FAAC-like coder will be removed in the near future, please use twoloop!\n");
+ s->options.intensity_stereo = 0;
+ s->options.pns = 0;
+ }
if ((ret = dsp_init(avctx, s)) < 0)
goto fail;