Lines Matching defs:avctx
53 static av_cold int twolame_encode_close(AVCodecContext *avctx)
55 TWOLAMEContext *s = avctx->priv_data;
60 static av_cold int twolame_encode_init(AVCodecContext *avctx)
62 TWOLAMEContext *s = avctx->priv_data;
65 avctx->frame_size = TWOLAME_SAMPLES_PER_FRAME;
66 avctx->initial_padding = 512 - 32 + 1;
80 twolame_set_num_channels(s->glopts, avctx->ch_layout.nb_channels);
81 twolame_set_in_samplerate(s->glopts, avctx->sample_rate);
82 twolame_set_out_samplerate(s->glopts, avctx->sample_rate);
84 if (!avctx->bit_rate) {
85 if ((s->mode == TWOLAME_AUTO_MODE && avctx->ch_layout.nb_channels == 1) || s->mode == TWOLAME_MONO)
86 avctx->bit_rate = avctx->sample_rate < 28000 ? 80000 : 192000;
88 avctx->bit_rate = avctx->sample_rate < 28000 ? 160000 : 384000;
91 if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) {
94 avctx->global_quality / (float) FF_QP2LAMBDA);
95 av_log(avctx, AV_LOG_WARNING,
98 twolame_set_bitrate(s->glopts, avctx->bit_rate / 1000);
103 twolame_encode_close(avctx);
110 static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
113 TWOLAMEContext *s = avctx->priv_data;
116 if ((ret = ff_alloc_packet(avctx, avpkt, MPA_MAX_CODED_FRAME_SIZE)) < 0)
120 switch (avctx->sample_fmt) {
149 av_log(avctx, AV_LOG_ERROR,
150 "Unsupported sample format %d.\n", avctx->sample_fmt);
163 avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
165 avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);