mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
atrac3plus: convert to new channel layout API
Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
70da5ce478
commit
00fd056bb4
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user