Lines Matching defs:avctx

31  *     Speex only supports mono or stereo, so avctx->ch_layout.nb_channels must
39 * avctx->sample_rate must be set to one of these 3 values. This will be
43 * VBR mode is turned on by setting AV_CODEC_FLAG_QSCALE in avctx->flags.
44 * avctx->global_quality is used to set the encoding quality.
45 * For CBR mode, avctx->bit_rate can be used to set the constant bitrate.
48 * For ABR mode, set avctx->bit_rate and set the 'abr' option to 1.
55 * Encoding complexity is controlled by setting avctx->compression_level.
112 static av_cold void print_enc_params(AVCodecContext *avctx,
117 av_log(avctx, AV_LOG_DEBUG, "channels: %d\n", avctx->ch_layout.nb_channels);
123 av_log(avctx, AV_LOG_DEBUG, "mode: %s\n", mode_str);
125 av_log(avctx, AV_LOG_DEBUG, "rate control: VBR\n");
126 av_log(avctx, AV_LOG_DEBUG, " quality: %f\n", s->vbr_quality);
128 av_log(avctx, AV_LOG_DEBUG, "rate control: ABR\n");
129 av_log(avctx, AV_LOG_DEBUG, " bitrate: %"PRId64" bps\n", avctx->bit_rate);
131 av_log(avctx, AV_LOG_DEBUG, "rate control: CBR\n");
132 av_log(avctx, AV_LOG_DEBUG, " bitrate: %"PRId64" bps\n", avctx->bit_rate);
134 av_log(avctx, AV_LOG_DEBUG, "complexity: %d\n",
135 avctx->compression_level);
136 av_log(avctx, AV_LOG_DEBUG, "frame size: %d samples\n",
137 avctx->frame_size);
138 av_log(avctx, AV_LOG_DEBUG, "frames per packet: %d\n",
140 av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n",
141 avctx->frame_size * s->frames_per_packet);
142 av_log(avctx, AV_LOG_DEBUG, "voice activity detection: %d\n", s->vad);
143 av_log(avctx, AV_LOG_DEBUG, "discontinuous transmission: %d\n", s->dtx);
146 static av_cold int encode_init(AVCodecContext *avctx)
148 LibSpeexEncContext *s = avctx->priv_data;
149 int channels = avctx->ch_layout.nb_channels;
157 av_log(avctx, AV_LOG_ERROR, "Invalid channels (%d). Only stereo and "
163 switch (avctx->sample_rate) {
168 av_log(avctx, AV_LOG_ERROR, "Sample rate of %d Hz is not supported. "
169 "Resample to 8, 16, or 32 kHz.\n", avctx->sample_rate);
176 av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex\n");
179 speex_init_header(&s->header, avctx->sample_rate, channels, mode);
182 if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
187 s->vbr_quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA,
191 s->header.bitrate = avctx->bit_rate;
192 if (avctx->bit_rate > 0) {
214 avctx->bit_rate = s->header.bitrate + (channels == 2 ? 800 : 0);
225 av_log(avctx, AV_LOG_WARNING, "DTX is not much of use without ABR, VAD or VBR\n");
229 if (avctx->compression_level > FF_COMPRESSION_DEFAULT) {
230 complexity = av_clip(avctx->compression_level, 0, 10);
234 avctx->compression_level = complexity;
237 avctx->frame_size = s->header.frame_size;
241 speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &avctx->initial_padding);
242 ff_af_queue_init(avctx, &s->afq);
250 avctx->extradata = av_malloc(header_size + AV_INPUT_BUFFER_PADDING_SIZE);
251 if (!avctx->extradata) {
254 av_log(avctx, AV_LOG_ERROR, "memory allocation error\n");
259 memcpy(avctx->extradata, header_data, header_size);
260 avctx->extradata_size = header_size;
266 print_enc_params(avctx, s);
270 static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
273 LibSpeexEncContext *s = avctx->priv_data;
279 if (avctx->ch_layout.nb_channels == 2)
299 if ((ret = ff_alloc_packet(avctx, avpkt, speex_bits_nbytes(&s->bits))) < 0)
305 ff_af_queue_remove(&s->afq, s->frames_per_packet * avctx->frame_size,
315 static av_cold int encode_close(AVCodecContext *avctx)
317 LibSpeexEncContext *s = avctx->priv_data;