Lines Matching defs:avctx

196 static int sbc_encode_init(AVCodecContext *avctx)
198 SBCEncContext *sbc = avctx->priv_data;
201 if (avctx->profile == FF_PROFILE_SBC_MSBC)
205 if (avctx->ch_layout.nb_channels != 1) {
206 av_log(avctx, AV_LOG_ERROR, "mSBC require mono channel.\n");
210 if (avctx->sample_rate != 16000) {
211 av_log(avctx, AV_LOG_ERROR, "mSBC require 16 kHz samplerate.\n");
221 avctx->frame_size = 8 * MSBC_BLOCKS;
225 if (avctx->global_quality > 255*FF_QP2LAMBDA) {
226 av_log(avctx, AV_LOG_ERROR, "bitpool > 255 is not allowed.\n");
230 if (avctx->ch_layout.nb_channels == 1) {
232 if (sbc->max_delay <= 3000 || avctx->bit_rate > 270000)
237 if (avctx->bit_rate < 180000 || avctx->bit_rate > 420000)
241 if (sbc->max_delay <= 4000 || avctx->bit_rate > 420000)
247 frame->blocks = av_clip(((sbc->max_delay * avctx->sample_rate + 2)
253 frame->bitpool = (((avctx->bit_rate * frame->subbands * frame->blocks) / avctx->sample_rate)
254 - 4 * frame->subbands * avctx->ch_layout.nb_channels
256 if (avctx->global_quality > 0)
257 frame->bitpool = avctx->global_quality / FF_QP2LAMBDA;
259 avctx->frame_size = 4*((frame->subbands >> 3) + 1) * 4*(frame->blocks >> 2);
262 for (int i = 0; avctx->codec->supported_samplerates[i]; i++)
263 if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
266 frame->channels = avctx->ch_layout.nb_channels;
267 frame->codesize = frame->subbands * frame->blocks * avctx->ch_layout.nb_channels * 2;
278 static int sbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
281 SBCEncContext *sbc = avctx->priv_data;
295 if ((ret = ff_get_encode_buffer(avctx, avpkt, frame_length, 0)) < 0)