Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index
@ 2023-03-24 21:09 Martin Storsjö
  2023-03-24 21:27 ` James Almer
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2023-03-24 21:09 UTC (permalink / raw)
  To: ffmpeg-devel

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@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));
                     break;
                 }
             }
-- 
2.37.1 (Apple Git-137.1)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index
  2023-03-24 21:09 [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index Martin Storsjö
@ 2023-03-24 21:27 ` James Almer
  2023-03-24 21:45   ` Martin Storsjö
  0 siblings, 1 reply; 4+ messages in thread
From: James Almer @ 2023-03-24 21:27 UTC (permalink / raw)
  To: ffmpeg-devel

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@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;
>                   }
>               }
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index
  2023-03-24 21:27 ` James Almer
@ 2023-03-24 21:45   ` Martin Storsjö
  2023-03-24 21:48     ` James Almer
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2023-03-24 21:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, 24 Mar 2023, James Almer wrote:

> 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@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.

Fair enough, I can change it to that too.

Since FFMAX is a macro, it ends up expanding the arguments twice, so with 
a call to llabs, we'd have two function calls. I guess it'd be better with 
an intermediate variable,

     int64_t delta = FFABS(e1->pos - e2->pos);
     pos_delta = FFMAX(pos_delta, delta);

WDYT?

// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index
  2023-03-24 21:45   ` Martin Storsjö
@ 2023-03-24 21:48     ` James Almer
  0 siblings, 0 replies; 4+ messages in thread
From: James Almer @ 2023-03-24 21:48 UTC (permalink / raw)
  To: ffmpeg-devel

On 3/24/2023 6:45 PM, Martin Storsjö wrote:
> On Fri, 24 Mar 2023, James Almer wrote:
> 
>> 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@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.
> 
> Fair enough, I can change it to that too.
> 
> Since FFMAX is a macro, it ends up expanding the arguments twice, so 
> with a call to llabs, we'd have two function calls. I guess it'd be 
> better with an intermediate variable,
> 
>      int64_t delta = FFABS(e1->pos - e2->pos);
>      pos_delta = FFMAX(pos_delta, delta);
> 
> WDYT?

Yeah, that good.

> 
> // Martin
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-24 21:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 21:09 [FFmpeg-devel] [PATCH] libavformat: Account for negative position differences in ff_configure_buffers_for_index Martin Storsjö
2023-03-24 21:27 ` James Almer
2023-03-24 21:45   ` Martin Storsjö
2023-03-24 21:48     ` James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git