[FFmpeg-devel] [PATCH v2] swr/swresample: avoid reapplication of firstpts

Michael Niedermayer michael at niedermayer.cc
Fri Dec 15 20:16:42 EET 2023


On Fri, Dec 15, 2023 at 12:30:46PM +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 firstpts initialized to AV_NOPTS_VALUE in swr_alloc and then
> checked in swr_init to avoid resetting outpts, thus avoiding reapplication
> of firstpts.
> 
> Fixes #4131.
> ---
>  libswresample/options.c    | 1 +
>  libswresample/swresample.c | 5 +++--
>  2 files changed, 4 insertions(+), 2 deletions(-)

LGTM

also can a fate test be added for this ?

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- 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/20231215/944a39f0/attachment.sig>


More information about the ffmpeg-devel mailing list