Lines Matching refs:avctx
161 static int ffat_update_ctx(AVCodecContext *avctx)
163 ATDecodeContext *at = avctx->priv_data;
170 avctx->sample_rate = format.mSampleRate;
171 av_channel_layout_uninit(&avctx->ch_layout);
172 av_channel_layout_default(&avctx->ch_layout, format.mChannelsPerFrame);
173 avctx->frame_size = format.mFramesPerPacket;
179 format.mSampleRate = avctx->sample_rate;
180 format.mChannelsPerFrame = avctx->ch_layout.nb_channels;
206 av_channel_layout_uninit(&avctx->ch_layout);
207 av_channel_layout_from_mask(&avctx->ch_layout, layout_mask);
216 if (!avctx->frame_size)
217 avctx->frame_size = 2048;
231 static uint8_t* ffat_get_magic_cookie(AVCodecContext *avctx, UInt32 *cookie_size)
233 ATDecodeContext *at = avctx->priv_data;
234 if (avctx->codec_id == AV_CODEC_ID_AAC) {
271 static av_cold int ffat_usable_extradata(AVCodecContext *avctx)
273 ATDecodeContext *at = avctx->priv_data;
275 (avctx->codec_id == AV_CODEC_ID_ALAC ||
276 avctx->codec_id == AV_CODEC_ID_QDM2 ||
277 avctx->codec_id == AV_CODEC_ID_QDMC ||
278 avctx->codec_id == AV_CODEC_ID_AAC);
281 static int ffat_set_extradata(AVCodecContext *avctx)
283 ATDecodeContext *at = avctx->priv_data;
284 if (ffat_usable_extradata(avctx)) {
287 uint8_t *cookie = ffat_get_magic_cookie(avctx, &cookie_size);
295 av_log(avctx, AV_LOG_WARNING, "AudioToolbox cookie error: %i\n", (int)status);
303 static av_cold int ffat_create_decoder(AVCodecContext *avctx,
306 ATDecodeContext *at = avctx->priv_data;
310 enum AVSampleFormat sample_fmt = (avctx->bits_per_raw_sample == 32) ?
314 .mFormatID = ffat_get_format_id(avctx->codec_id, avctx->profile),
315 .mBytesPerPacket = (avctx->codec_id == AV_CODEC_ID_ILBC) ? avctx->block_align : 0,
324 avctx->sample_fmt = sample_fmt;
326 if (ffat_usable_extradata(avctx)) {
329 uint8_t *cookie = ffat_get_magic_cookie(avctx, &cookie_size);
337 av_log(avctx, AV_LOG_ERROR, "AudioToolbox header-parse error: %i\n", (int)status);
342 (avctx->codec_id == AV_CODEC_ID_MP1 ||
343 avctx->codec_id == AV_CODEC_ID_MP2 ||
344 avctx->codec_id == AV_CODEC_ID_MP3)) {
347 if (ff_mpa_decode_header(AV_RB32(pkt->data), &avctx->sample_rate,
348 &in_format.mChannelsPerFrame, &avctx->frame_size,
351 avctx->bit_rate = bit_rate;
352 in_format.mSampleRate = avctx->sample_rate;
356 (avctx->codec_id == AV_CODEC_ID_AC3 ||
357 avctx->codec_id == AV_CODEC_ID_EAC3)) {
365 avctx->frame_size = hdr.num_blocks * 256;
366 avctx->bit_rate = hdr.bit_rate;
369 in_format.mSampleRate = avctx->sample_rate ? avctx->sample_rate : 44100;
370 in_format.mChannelsPerFrame = avctx->ch_layout.nb_channels ? avctx->ch_layout.nb_channels : 1;
373 avctx->sample_rate = out_format.mSampleRate = in_format.mSampleRate;
374 av_channel_layout_uninit(&avctx->ch_layout);
375 avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
376 avctx->ch_layout.nb_channels = out_format.mChannelsPerFrame = in_format.mChannelsPerFrame;
383 if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_QT)
389 av_log(avctx, AV_LOG_ERROR, "AudioToolbox init error: %i\n", (int)status);
393 if ((status = ffat_set_extradata(avctx)) < 0)
399 ffat_update_ctx(avctx);
401 if(!(at->decoded_data = av_malloc(av_get_bytes_per_sample(avctx->sample_fmt)
402 * avctx->frame_size * avctx->ch_layout.nb_channels)))
410 static av_cold int ffat_init_decoder(AVCodecContext *avctx)
412 ATDecodeContext *at = avctx->priv_data;
413 if (avctx->extradata_size) {
414 at->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
417 at->extradata_size = avctx->extradata_size;
418 memcpy(at->extradata, avctx->extradata, avctx->extradata_size);
421 if ((avctx->ch_layout.nb_channels && avctx->sample_rate) || ffat_usable_extradata(avctx))
422 return ffat_create_decoder(avctx, NULL);
432 AVCodecContext *avctx = inctx;
433 ATDecodeContext *at = avctx->priv_data;
468 type *end_ptr = in_ptr + frame->nb_samples * avctx->ch_layout.nb_channels; \
470 for (; in_ptr < end_ptr; in_ptr += avctx->ch_layout.nb_channels, out_ptr += avctx->ch_layout.nb_channels) { \
472 for (c = 0; c < avctx->ch_layout.nb_channels; c++) \
476 static void ffat_copy_samples(AVCodecContext *avctx, AVFrame *frame)
478 ATDecodeContext *at = avctx->priv_data;
479 if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) {
486 static int ffat_decode(AVCodecContext *avctx, AVFrame *frame,
489 ATDecodeContext *at = avctx->priv_data;
494 if (avctx->codec_id == AV_CODEC_ID_AAC) {
512 if ((ret = ffat_create_decoder(avctx, avpkt)) < 0) {
521 .mNumberChannels = avctx->ch_layout.nb_channels,
522 .mDataByteSize = av_get_bytes_per_sample(avctx->sample_fmt) * avctx->frame_size
523 * avctx->ch_layout.nb_channels,
538 frame->sample_rate = avctx->sample_rate;
540 frame->nb_samples = avctx->frame_size;
544 ret = AudioConverterFillComplexBuffer(at->converter, ffat_decode_callback, avctx,
547 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
549 ffat_copy_samples(avctx, frame);
556 av_log(avctx, AV_LOG_WARNING, "Decode error: %i\n", ret);
564 static av_cold void ffat_decode_flush(AVCodecContext *avctx)
566 ATDecodeContext *at = avctx->priv_data;
572 static av_cold int ffat_close_decoder(AVCodecContext *avctx)
574 ATDecodeContext *at = avctx->priv_data;