[FFmpeg-devel] [PATCH 269/281] wavpack: convert to new channel layout API

Anton Khirnov anton at khirnov.net
Mon Mar 7 12:42:37 EET 2022


Quoting James Almer (2022-01-13 03:07:13)
> From: Anton Khirnov <anton at khirnov.net>
> 
> Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavcodec/wavpack.c    | 51 ++++++++++++++++++-----------------------
>  libavcodec/wavpackenc.c | 29 ++++++++++++-----------
>  2 files changed, 37 insertions(+), 43 deletions(-)
> 
> diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
> index 6b2ec19bf1..e0350ce732 100644
> --- a/libavcodec/wavpack.c
> +++ b/libavcodec/wavpack.c
> @@ -1512,36 +1509,32 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
>          new_samplerate *= rate_x;
>  
>          if (multiblock) {
> -            if (chan)
> -                new_channels = chan;
> -            if (chmask)
> -                new_chmask = chmask;
> +            if (chmask) {
> +                av_channel_layout_from_mask(&new_ch_layout, chmask);
> +                if (chan && new_ch_layout.nb_channels != chan) {
> +                    av_log(avctx, AV_LOG_ERROR, "Channel mask does not match the channel count\n");
> +                    return AVERROR_INVALIDDATA;
> +                }
> +            } else
> +                av_channel_layout_copy(&new_ch_layout, &avctx->ch_layout);

user-supplied layout can be custom, so you should probably check this
and the second copy below


-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list