summaryrefslogtreecommitdiff
path: root/libavcodec/imc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-07 07:20:32 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:42 -0300
commit2c15e1975a75cf9556fd66d23f01ca3faf94772a (patch)
tree46a6b1b637aadd9168c8638b7ba0aa962805e1a5 /libavcodec/imc.c
parentc67dd4eff95b986b45937f1589e68a10d3b8fee8 (diff)
imc: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/imc.c')
-rw-r--r--libavcodec/imc.c22
1 files 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)