Lines Matching defs:avctx
54 static void put_pce(PutBitContext *pb, AVCodecContext *avctx)
57 AACEncContext *s = avctx->priv_data;
59 const int bitexact = avctx->flags & AV_CODEC_FLAG_BITEXACT;
64 put_bits(pb, 2, avctx->profile);
95 static int put_audio_specific_config(AVCodecContext *avctx)
98 AACEncContext *s = avctx->priv_data;
102 avctx->extradata = av_mallocz(max_size);
103 if (!avctx->extradata)
106 init_put_bits(&pb, avctx->extradata, max_size);
115 put_pce(&pb, avctx);
122 avctx->extradata_size = put_bytes_output(&pb);
385 static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
488 static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s,
501 encode_scale_factors(avctx, s, sce);
557 static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
560 AACEncContext *s = avctx->priv_data;
584 if (!avctx->frame_number)
674 av_log(avctx, AV_LOG_ERROR, "Input contains (near) NaN/+-Inf\n");
682 if ((ret = ff_alloc_packet(avctx, avpkt, 8192 * s->channels)) < 0)
688 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT))
722 * (s->lambda / (avctx->global_quality ? avctx->global_quality : 120));
729 s->coder->mark_pns(s, avctx, &cpe->ch[ch]);
730 s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda);
754 s->coder->search_for_pns(s, avctx, sce);
759 s->coder->search_for_is(s, avctx, cpe);
815 encode_individual_channel(avctx, s, &cpe->ch[ch], cpe->common_window);
820 if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
830 rate_bits = avctx->bit_rate * 1024 / avctx->sample_rate;
893 ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
900 static av_cold int aac_encode_end(AVCodecContext *avctx)
902 AACEncContext *s = avctx->priv_data;
904 av_log(avctx, AV_LOG_INFO, "Qavg: %.3f\n", s->lambda_count ? s->lambda_sum / s->lambda_count : NAN);
919 static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
923 s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
938 static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s)
951 static av_cold int aac_encode_init(AVCodecContext *avctx)
953 AACEncContext *s = avctx->priv_data;
961 avctx->frame_size = 1024;
962 avctx->initial_padding = 1024;
963 s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
966 s->channels = avctx->ch_layout.nb_channels;
970 if (!av_channel_layout_compare(&avctx->ch_layout, &aac_normal_chan_layouts[i])) {
979 if (!av_channel_layout_compare(&avctx->ch_layout, &aac_pce_configs[i].layout))
981 av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf));
983 av_log(avctx, AV_LOG_ERROR, "Unsupported channel layout \"%s\"\n", buf);
986 av_log(avctx, AV_LOG_INFO, "Using a PCE to encode channel layout \"%s\"\n", buf);
995 if (!avctx->bit_rate) {
997 avctx->bit_rate += s->chan_map[i] == TYPE_CPE ? 128000 : /* Pair */
1005 if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
1011 "Unsupported sample rate %d\n", avctx->sample_rate);
1014 WARN_IF(1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * s->channels,
1016 1024.0 * avctx->bit_rate / avctx->sample_rate,
1018 avctx->bit_rate = (int64_t)FFMIN(6144 * s->channels / 1024.0 * avctx->sample_rate,
1019 avctx->bit_rate);
1022 avctx->profile = avctx->profile == FF_PROFILE_UNKNOWN ? FF_PROFILE_AAC_LOW :
1023 avctx->profile;
1025 if (avctx->profile == aacenc_profiles[i])
1027 if (avctx->profile == FF_PROFILE_MPEG2_AAC_LOW) {
1028 avctx->profile = FF_PROFILE_AAC_LOW;
1036 } else if (avctx->profile == FF_PROFILE_AAC_LTP) {
1040 } else if (avctx->profile == FF_PROFILE_AAC_MAIN) {
1045 avctx->profile = FF_PROFILE_AAC_LTP;
1051 avctx->profile = FF_PROFILE_AAC_MAIN;
1057 s->profile = avctx->profile;
1062 ERROR_IF(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL,
1067 ERROR_IF(s->options.ltp && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL,
1074 if ((ret = dsp_init(avctx, s)) < 0)
1077 if ((ret = alloc_buffers(avctx, s)) < 0)
1080 if ((ret = put_audio_specific_config(avctx)))
1089 if ((ret = ff_psy_init(&s->psy, avctx, 2, sizes, lengths,
1092 s->psypp = ff_psy_preprocess_init(avctx);
1093 ff_lpc_init(&s->lpc, 2*avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON);
1107 ff_af_queue_init(avctx, &s->afq);