X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Faacenc.c;h=ec09063e84b9d1707b220fa17bc44a6ba2237d4f;hb=49507f1d1731585ce10c4a797c6c55e72c694ecb;hp=0bd8891ff295b30f381dc985a53105386ff0536f;hpb=93fb4a46298c5dc456154b0eb594b8a704e366cd;p=ffmpeg diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 0bd8891ff29..ec09063e84b 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -574,6 +574,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ics->num_windows = wi[ch].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; ics->num_swb = tag == TYPE_LFE ? ics->num_swb : s->psy.num_bands[ics->num_windows == 8]; + ics->max_sfb = FFMIN(ics->max_sfb, ics->num_swb); ics->swb_offset = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ? ff_swb_offset_128 [s->samplerate_index]: ff_swb_offset_1024[s->samplerate_index]; @@ -678,14 +679,14 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, for (ch = 0; ch < chans; ch++) { /* TNS and PNS */ sce = &cpe->ch[ch]; s->cur_channel = start_ch + ch; - if (s->options.pns && s->coder->search_for_pns) - s->coder->search_for_pns(s, avctx, sce); if (s->options.tns && s->coder->search_for_tns) s->coder->search_for_tns(s, sce); if (s->options.tns && s->coder->apply_tns_filt) s->coder->apply_tns_filt(s, sce); if (sce->tns.present) tns_mode = 1; + if (s->options.pns && s->coder->search_for_pns) + s->coder->search_for_pns(s, avctx, sce); } s->cur_channel = start_ch; if (s->options.intensity_stereo) { /* Intensity Stereo */ @@ -793,7 +794,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, s->lambda = FFMIN(s->lambda * ratio, 65536.f); /* Keep iterating if we must reduce and lambda is in the sky */ - if ((s->lambda < 300.f || ratio > 0.9f) && (s->lambda > 10.f || ratio < 1.1f)) { + if (ratio > 0.9f && ratio < 1.1f) { break; } else { if (is_mode || ms_mode || tns_mode || pred_mode) { @@ -903,7 +904,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) s->channels = avctx->channels; s->chan_map = aac_chan_configs[s->channels-1]; - s->random_state = 0x1f2e3d4c; s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120; avctx->extradata_size = 5; avctx->frame_size = 1024; @@ -926,7 +926,9 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) ERROR_IF(s->channels > AAC_MAX_CHANNELS || s->channels == 7, "Unsupported number of channels: %d\n", s->channels); 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); for (i = 0; i < FF_ARRAY_ELEMS(aacenc_profiles); i++) if (avctx->profile == aacenc_profiles[i]) @@ -960,13 +962,17 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) avctx->profile = FF_PROFILE_AAC_MAIN; WARN_IF(1, "Chainging profile to \"aac_main\"\n"); - ERROR_IF(s->options.pred, + 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; } @@ -990,8 +996,9 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) goto fail; s->psypp = ff_psy_preprocess_init(avctx); ff_lpc_init(&s->lpc, 2*avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON); + av_lfg_init(&s->lfg, 0x72adca55); - if (HAVE_MIPSDSPR1) + if (HAVE_MIPSDSP) ff_aac_coder_init_mips(s); if ((ret = ff_thread_once(&aac_table_init, &aac_encode_init_tables)) != 0) @@ -1039,8 +1046,7 @@ AVCodec ff_aac_encoder = { .close = aac_encode_end, .supported_samplerates = mpeg4audio_sample_rates, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY | - AV_CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .priv_class = &aacenc_class,