[FFmpeg-devel] [PATCH] swr/swresample: avoid reapplication of firstpts
Michael Niedermayer
michael at niedermayer.cc
Thu Dec 14 21:13:40 EET 2023
On Tue, Dec 12, 2023 at 04:50:08PM +0530, Gyan Doshi wrote:
> During a resampling operation where
>
> 1) user has specified first_pts
> 2) SWR_FLAG_RESAMPLE is not set initially (directly or otherwise)
> 3) first_pts has been fulfilled (always using hard compensation)
>
> then upon first encountering a delay where a soft compensation is
> required, swr_set_compensation will lead to another init of swr which
> will reset outpts to the specified firstpts thus leading to an output
> frame having its pts = firstpts. When the next input frame is received,
> swr will see a large delay and inject silence from firstpts to the
> current frame's pts. This can lead to severe desync and in worst case,
> loss of audio playback.
>
> Parameter initcount added to keep track of swr_init calls of the swrcontext
> and to ultimately avoid enforcing firstpts again.
>
> Fixes #4131.
> ---
> libswresample/swresample.c | 7 +++++--
> libswresample/swresample_internal.h | 1 +
> libswresample/version.h | 2 +-
> 3 files changed, 7 insertions(+), 3 deletions(-)
Would it work to instead set firstpts = AV_NOPTS_VALUE on allocation
and then use firstpts == AV_NOPTS_VALUE to detect if it has been set
already ?
If that workes, that seems simpler than counting init
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20231214/5a222c69/attachment.sig>
More information about the ffmpeg-devel
mailing list