Lines Matching refs:avctx

91 static void ffat_update_ctx(AVCodecContext *avctx)
93 ATDecodeContext *at = avctx->priv_data;
110 avctx->initial_padding = prime_info.leadingFrames;
118 avctx->frame_size = out_format.mFramesPerPacket;
119 if (out_format.mBytesPerPacket && avctx->codec_id == AV_CODEC_ID_ILBC)
120 avctx->block_align = out_format.mBytesPerPacket;
123 at->frame_size = avctx->frame_size;
124 if (avctx->codec_id == AV_CODEC_ID_PCM_MULAW ||
125 avctx->codec_id == AV_CODEC_ID_PCM_ALAW) {
127 avctx->frame_size *= 1024;
145 static int get_ilbc_mode(AVCodecContext *avctx)
147 if (avctx->block_align == 38)
149 else if (avctx->block_align == 50)
151 else if (avctx->bit_rate > 0)
152 return avctx->bit_rate <= 14000 ? 30 : 20;
231 static av_cold int ffat_init_encoder(AVCodecContext *avctx)
233 ATDecodeContext *at = avctx->priv_data;
237 .mSampleRate = avctx->sample_rate,
239 .mFormatFlags = ((avctx->sample_fmt == AV_SAMPLE_FMT_FLT ||
240 avctx->sample_fmt == AV_SAMPLE_FMT_DBL) ? kAudioFormatFlagIsFloat
241 : avctx->sample_fmt == AV_SAMPLE_FMT_U8 ? 0
244 .mBytesPerPacket = av_get_bytes_per_sample(avctx->sample_fmt) * avctx->ch_layout.nb_channels,
246 .mBytesPerFrame = av_get_bytes_per_sample(avctx->sample_fmt) * avctx->ch_layout.nb_channels,
247 .mChannelsPerFrame = avctx->ch_layout.nb_channels,
248 .mBitsPerChannel = av_get_bytes_per_sample(avctx->sample_fmt) * 8,
251 .mSampleRate = avctx->sample_rate,
252 .mFormatID = ffat_get_format_id(avctx->codec_id, avctx->profile),
256 sizeof(AudioChannelDescription) * avctx->ch_layout.nb_channels;
262 if (avctx->codec_id == AV_CODEC_ID_ILBC) {
263 int mode = get_ilbc_mode(avctx);
271 av_log(avctx, AV_LOG_ERROR, "AudioToolbox init error: %i\n", (int)status);
276 if (avctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
277 av_channel_layout_default(&avctx->ch_layout, avctx->ch_layout.nb_channels);
279 if ((status = remap_layout(channel_layout, &avctx->ch_layout)) < 0) {
280 av_log(avctx, AV_LOG_ERROR, "Invalid channel layout\n");
287 av_log(avctx, AV_LOG_ERROR, "Unsupported input channel layout\n");
291 if (avctx->codec_id == AV_CODEC_ID_AAC) {
292 int tag = get_aac_tag(&avctx->ch_layout);
300 av_log(avctx, AV_LOG_ERROR, "Unsupported output channel layout\n");
306 if (avctx->bits_per_raw_sample)
309 sizeof(avctx->bits_per_raw_sample),
310 &avctx->bits_per_raw_sample);
314 at->mode = (avctx->flags & AV_CODEC_FLAG_QSCALE) ?
322 int q = avctx->global_quality / FF_QP2LAMBDA;
324 av_log(avctx, AV_LOG_WARNING,
333 if (avctx->bit_rate > 0) {
334 UInt32 rate = avctx->bit_rate;
363 av_log(avctx, AV_LOG_WARNING,
378 &avctx->extradata_size, NULL) &&
379 avctx->extradata_size) {
380 int extradata_size = avctx->extradata_size;
382 if (!(avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE)))
384 if (avctx->codec_id == AV_CODEC_ID_ALAC) {
385 avctx->extradata_size = 0x24;
386 AV_WB32(avctx->extradata, 0x24);
387 AV_WB32(avctx->extradata + 4, MKBETAG('a','l','a','c'));
388 extradata = avctx->extradata + 12;
389 avctx->extradata_size = 0x24;
391 extradata = avctx->extradata;
397 av_log(avctx, AV_LOG_ERROR, "AudioToolbox cookie error: %i\n", (int)status);
399 } else if (avctx->codec_id == AV_CODEC_ID_AAC) {
411 avctx->extradata_size = len;
426 } else if (avctx->codec_id != AV_CODEC_ID_ALAC) {
427 avctx->extradata_size = extradata_size;
431 ffat_update_ctx(avctx);
434 if (at->mode == kAudioCodecBitRateControlMode_Variable && avctx->rc_max_rate) {
435 UInt32 max_size = avctx->rc_max_rate * avctx->frame_size / avctx->sample_rate;
442 ff_af_queue_init(avctx, &at->afq);
456 AVCodecContext *avctx = inctx;
457 ATDecodeContext *at = avctx->priv_data;
474 data->mBuffers[0].mNumberChannels = avctx->ch_layout.nb_channels;
476 av_get_bytes_per_sample(avctx->sample_fmt) *
477 avctx->ch_layout.nb_channels;
489 ff_bufqueue_add(avctx, &at->used_frame_queue, frame);
494 static int ffat_encode(AVCodecContext *avctx, AVPacket *avpkt,
497 ATDecodeContext *at = avctx->priv_data;
504 .mNumberChannels = avctx->ch_layout.nb_channels,
520 av_log(avctx, AV_LOG_ERROR, "Bug: frame queue is too small.\n");
531 ff_bufqueue_add(avctx, &at->frame_queue, in_frame);
536 if ((ret = ff_alloc_packet(avctx, avpkt, at->pkt_size)) < 0)
542 *got_packet_ptr = avctx->frame_size / at->frame_size;
544 ret = AudioConverterFillComplexBuffer(at->converter, ffat_encode_callback, avctx,
546 (avctx->frame_size > at->frame_size) ? NULL : &out_pkt_desc);
554 avctx->frame_size,
558 av_log(avctx, AV_LOG_ERROR, "Encode error: %i\n", ret);
565 static av_cold void ffat_encode_flush(AVCodecContext *avctx)
567 ATDecodeContext *at = avctx->priv_data;
573 static av_cold int ffat_close_encoder(AVCodecContext *avctx)
575 ATDecodeContext *at = avctx->priv_data;