[FFmpeg-devel] [PATCH] swresample fixes
Paul B Mahol
onemda at gmail.com
Wed Jan 4 19:25:58 EET 2023
On Wed, Jan 4, 2023 at 6:18 PM Andreas Rheinhardt <
andreas.rheinhardt at outlook.com> wrote:
> 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
>
It adds better support for runtime change of input/output sample rates.
Instead of re-initializing whole filter graph.
> 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;
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list