[FFmpeg-devel] [PATCH] swresample fixes

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jan 4 19:18:32 EET 2023


Paul B Mahol:
> diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
> index 971c861d0e..7923377c8c 100644
> --- a/libavfilter/af_aresample.c
> +++ b/libavfilter/af_aresample.c
> @@ -209,18 +209,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      } else {
>          outsamplesref->pts  = AV_NOPTS_VALUE;
>      }
> -    n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
> -                                 (void *)insamplesref->extended_data, n_in);
> -    if (n_out <= 0) {
> +    ret = swr_convert_frame(aresample->swr, outsamplesref,
> +                            (void *)insamplesref);

Don't know whether the actual change has advantages, but you should not
cast here. The cast above exists because there is no automatic cast
T**->const T** (it is actually unsafe; we should change swr_convert() to
accept const uint8_t *const * for in and uint8_t *const * for out at the
next major version bump, but even then C requires the cast). There is no
reason for a cast with the new code.

> +    if (ret < 0) {
>          av_frame_free(&outsamplesref);
>          av_frame_free(&insamplesref);
> -        return 0;
> +        return ret;
>      }
>  
>      aresample->more_data = outsamplesref->nb_samples == n_out; // Indicate that there is probably more data in our buffers
>  
> -    outsamplesref->nb_samples  = n_out;
> -
>      ret = ff_filter_frame(outlink, outsamplesref);
>      av_frame_free(&insamplesref);
>      return ret;



More information about the ffmpeg-devel mailing list