[FFmpeg-devel] [PATCH] swresample fixes

James Almer jamrial at gmail.com
Wed Jan 4 19:02:06 EET 2023


On 1/4/2023 1:59 PM, Paul B Mahol wrote:
> From 0415ed37bee0c2b640920edad87ec927dda95fb5 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda at gmail.com>
> Date: Wed, 4 Jan 2023 17:53:01 +0100
> Subject: [PATCH 2/3] swresample/swresample_frame: fix regression in detecting
>  changes
> 
> Do not overwrite return variable values, instead use different
> one for checking results.
> 
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libswresample/swresample_frame.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libswresample/swresample_frame.c b/libswresample/swresample_frame.c
> index 53ac487136..319ce045a1 100644
> --- a/libswresample/swresample_frame.c
> +++ b/libswresample/swresample_frame.c
> @@ -84,7 +84,7 @@ static int config_changed(SwrContext *s,
>                            const AVFrame *out, const AVFrame *in)
>  {
>      AVChannelLayout ch_layout = { 0 };
> -    int ret = 0;
> +    int ret = 0, iret;
>  
>      if (in) {
>  #if FF_API_OLD_CHANNEL_LAYOUT
> @@ -96,8 +96,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  FF_ENABLE_DEPRECATION_WARNINGS
>          } else
>  #endif
> -        if ((ret = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
> -            return ret;
> +        if ((iret = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
> +            return iret;
>          if (av_channel_layout_compare(&s->in_ch_layout, &ch_layout) ||
>              s->in_sample_rate != in->sample_rate ||
>              s->in_sample_fmt  != in->format) {
> @@ -116,8 +116,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  FF_ENABLE_DEPRECATION_WARNINGS
>          } else
>  #endif
> -        if ((ret = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
> -            return ret;
> +        if ((iret = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
> +            return iret;
>          if (av_channel_layout_compare(&s->out_ch_layout, &ch_layout) ||
>              s->out_sample_rate != out->sample_rate ||
>              s->out_sample_fmt  != out->format) {

Patch 2/3 LGTM, and it should be backported to 5.1.

Also, FWIW, these copies will be unnecessary after the old channel 
layout API is dropped, so this can be undone later.


More information about the ffmpeg-devel mailing list