Lines Matching refs:avctx

37 static int amr_decode_fix_avctx(AVCodecContext *avctx)
39 const int is_amr_wb = 1 + (avctx->codec_id == AV_CODEC_ID_AMR_WB);
41 if (!avctx->sample_rate)
42 avctx->sample_rate = 8000 * is_amr_wb;
44 if (avctx->ch_layout.nb_channels > 1) {
45 avpriv_report_missing_feature(avctx, "multi-channel AMR");
49 av_channel_layout_uninit(&avctx->ch_layout);
50 avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
51 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
73 static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
75 AMRContext *s = avctx->priv_data;
78 if ((ret = amr_decode_fix_avctx(avctx)) < 0)
83 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\n");
90 static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
92 AMRContext *s = avctx->priv_data;
99 static int amr_nb_decode_frame(AVCodecContext *avctx, AVFrame *frame,
104 AMRContext *s = avctx->priv_data;
109 ff_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n",
110 buf, buf_size, avctx->frame_number);
114 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
121 av_log(avctx, AV_LOG_ERROR, "AMR frame too short (%d, should be %d)\n",
126 ff_dlog(avctx, "packet_size=%d buf= 0x%"PRIx8" %"PRIx8" %"PRIx8" %"PRIx8"\n",
197 static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
199 AMRContext *s = avctx->priv_data;
201 if (avctx->sample_rate != 8000 && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
202 av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
206 if (avctx->ch_layout.nb_channels != 1) {
207 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
211 avctx->frame_size = 160;
212 avctx->initial_padding = 50;
213 ff_af_queue_init(avctx, &s->afq);
217 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
221 s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
222 s->enc_bitrate = avctx->bit_rate;
227 static av_cold int amr_nb_encode_close(AVCodecContext *avctx)
229 AMRContext *s = avctx->priv_data;
236 static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
239 AMRContext *s = avctx->priv_data;
244 if (s->enc_bitrate != avctx->bit_rate) {
245 s->enc_mode = get_bitrate_mode(avctx->bit_rate, avctx);
246 s->enc_bitrate = avctx->bit_rate;
249 if ((ret = ff_alloc_packet(avctx, avpkt, 32)) < 0)
253 if (frame->nb_samples < avctx->frame_size) {
254 flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
259 if (frame->nb_samples < avctx->frame_size - avctx->initial_padding)
269 flush_buf = av_calloc(avctx->frame_size, sizeof(*flush_buf));
278 ff_dlog(avctx, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
282 ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
319 static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
321 AMRWBContext *s = avctx->priv_data;
324 if ((ret = amr_decode_fix_avctx(avctx)) < 0)
332 static int amr_wb_decode_frame(AVCodecContext *avctx, AVFrame *frame,
337 AMRWBContext *s = avctx->priv_data;
344 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
351 av_log(avctx, AV_LOG_ERROR, "AMR frame too short (%d, should be %d)\n",
356 av_log(avctx, AV_LOG_ERROR, "amr packet_size invalid\n");
367 static int amr_wb_decode_close(AVCodecContext *avctx)
369 AMRWBContext *s = avctx->priv_data;