[FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index

James Almer jamrial at gmail.com
Fri Mar 24 23:27:29 EET 2023


On 3/24/2023 6:09 PM, Martin Storsjö wrote:
> When scanning through the index, account for the fact that the
> compared samples may be located in an unexpected order in the file;
> this function is mainly interested in the absolute difference between
> file locations.
> 
> Signed-off-by: Martin Storsjö <martin at martin.st>
> ---
>   libavformat/seek.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/seek.c b/libavformat/seek.c
> index 818549dfef..62a26d6b5f 100644
> --- a/libavformat/seek.c
> +++ b/libavformat/seek.c
> @@ -210,7 +210,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
>                       int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
>                       if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
>                           continue;
> -                    pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);
> +                    pos_delta = FFMAX(pos_delta, llabs(e1->pos - e2->pos));

There's FFABS(), which gives a lot more hits with git grep than llabs.

>                       break;
>                   }
>               }


More information about the ffmpeg-devel mailing list