From 2c15e1975a75cf9556fd66d23f01ca3faf94772a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 7 May 2013 07:20:32 +0200 Subject: [PATCH] imc: convert to new channel layout API Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavcodec/imc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 116c273ba0..89b2ac33e6 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -206,15 +206,17 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } - if (avctx->codec_id == AV_CODEC_ID_IMC) - avctx->channels = 1; + if (avctx->codec_id == AV_CODEC_ID_IMC) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + } - if (avctx->channels > 2) { + if (avctx->ch_layout.nb_channels > 2) { avpriv_request_sample(avctx, "Number of channels > 2"); return AVERROR_PATCHWELCOME; } - for (j = 0; j < avctx->channels; j++) { + for (j = 0; j < avctx->ch_layout.nb_channels; j++) { q->chctx[j].decoder_reset = 1; for (i = 0; i < BANDS; i++) @@ -270,8 +272,6 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) ff_bswapdsp_init(&q->bdsp); avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO - : AV_CH_LAYOUT_STEREO; ff_thread_once(&init_static_once, imc_init_static); @@ -1013,7 +1013,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags)); - imc_imdct256(q, chctx, avctx->channels); + imc_imdct256(q, chctx, avctx->ch_layout.nb_channels); return 0; } @@ -1032,7 +1032,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, q->avctx = avctx; - if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { + if (buf_size < IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels) { av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); return AVERROR_INVALIDDATA; } @@ -1042,7 +1042,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - for (i = 0; i < avctx->channels; i++) { + for (i = 0; i < avctx->ch_layout.nb_channels; i++) { q->out_samples = (float *)frame->extended_data[i]; q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2); @@ -1055,14 +1055,14 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, return ret; } - if (avctx->channels == 2) { + if (avctx->ch_layout.nb_channels == 2) { q->butterflies_float((float *)frame->extended_data[0], (float *)frame->extended_data[1], COEFFS); } *got_frame_ptr = 1; - return IMC_BLOCK_SIZE * avctx->channels; + return IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels; } static av_cold int imc_decode_close(AVCodecContext * avctx)