From 00fd056bb4e6862ac97994390a8f5b082175f29f Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Tue, 4 Apr 2017 16:36:51 +0200 Subject: [PATCH] atrac3plus: convert to new channel layout API Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavcodec/atrac3plusdec.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index e342f09fdb..3f0f08ee00 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -64,7 +64,6 @@ typedef struct ATRAC3PContext { int num_channel_blocks; ///< number of channel blocks uint8_t channel_blocks[5]; ///< channel configuration descriptor - uint64_t my_channel_layout; ///< current channel layout } ATRAC3PContext; static av_cold int atrac3p_decode_close(AVCodecContext *avctx) @@ -83,36 +82,36 @@ static av_cold int atrac3p_decode_close(AVCodecContext *avctx) static av_cold int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) { + int channels = avctx->ch_layout.nb_channels; memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks)); - switch (avctx->channels) { + av_channel_layout_uninit(&avctx->ch_layout); + switch (channels) { case 1: - if (avctx->channel_layout != AV_CH_FRONT_LEFT) - avctx->channel_layout = AV_CH_LAYOUT_MONO; - + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; ctx->num_channel_blocks = 1; ctx->channel_blocks[0] = CH_UNIT_MONO; break; case 2: - avctx->channel_layout = AV_CH_LAYOUT_STEREO; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; ctx->num_channel_blocks = 1; ctx->channel_blocks[0] = CH_UNIT_STEREO; break; case 3: - avctx->channel_layout = AV_CH_LAYOUT_SURROUND; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND; ctx->num_channel_blocks = 2; ctx->channel_blocks[0] = CH_UNIT_STEREO; ctx->channel_blocks[1] = CH_UNIT_MONO; break; case 4: - avctx->channel_layout = AV_CH_LAYOUT_4POINT0; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0; ctx->num_channel_blocks = 3; ctx->channel_blocks[0] = CH_UNIT_STEREO; ctx->channel_blocks[1] = CH_UNIT_MONO; ctx->channel_blocks[2] = CH_UNIT_MONO; break; case 6: - avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK; ctx->num_channel_blocks = 4; ctx->channel_blocks[0] = CH_UNIT_STEREO; ctx->channel_blocks[1] = CH_UNIT_MONO; @@ -120,7 +119,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, ctx->channel_blocks[3] = CH_UNIT_MONO; break; case 7: - avctx->channel_layout = AV_CH_LAYOUT_6POINT1_BACK; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK; ctx->num_channel_blocks = 5; ctx->channel_blocks[0] = CH_UNIT_STEREO; ctx->channel_blocks[1] = CH_UNIT_MONO; @@ -129,7 +128,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, ctx->channel_blocks[4] = CH_UNIT_MONO; break; case 8: - avctx->channel_layout = AV_CH_LAYOUT_7POINT1; + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1; ctx->num_channel_blocks = 5; ctx->channel_blocks[0] = CH_UNIT_STEREO; ctx->channel_blocks[1] = CH_UNIT_MONO; @@ -139,7 +138,7 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx, break; default: av_log(avctx, AV_LOG_ERROR, - "Unsupported channel count: %d!\n", avctx->channels); + "Unsupported channel count: %d!\n", channels); return AVERROR_INVALIDDATA; } @@ -173,8 +172,6 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx) if ((ret = set_channel_params(ctx, avctx)) < 0) return ret; - ctx->my_channel_layout = avctx->channel_layout; - ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units)); ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);