[FFmpeg-devel] [PATCH] ff_add_av_index_entry_internal

Baptiste Coudurier baptiste.coudurier
Sat Nov 21 03:16:48 CET 2009


On 11/20/2009 06:15 PM, Baptiste Coudurier wrote:
> On 11/20/2009 05:52 PM, Michael Niedermayer wrote:
>> On Fri, Nov 20, 2009 at 05:41:09PM -0800, Baptiste Coudurier wrote:
>>> Guys,
>>>
>>> This introduce ff_add_av_index_entry_internal which do _not_ search for
>>> duplicates.
>>> Searching for duplicates really slow down index populating for demuxers
>>> having an index in the file, and it's useless since there are no
>>> duplicates. Basically mov demuxer calls it for each sample :(
>>
>> i think i know a better solution:
>> add a check in av_index_search_timestamp() before the slow loop
>> that checks if the searched pos is after the last and if so skip
>> the loop.
>>
>
> Something like this ?
>
>
> av_index_search_timestamps_fast.patch
>
>
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revision 20554)
> +++ libavformat/utils.c	(working copy)
> @@ -1283,6 +1283,8 @@
>       a = - 1;
>       b = nb_entries;
>
> +    if (nb_entries>  0&&
> +        wanted_timestamp<= entries[nb_entries-1].timestamp) {
>       while (b - a>  1) {
>           m = (a + b)>>  1;
>           timestamp = entries[m].timestamp;
> @@ -1291,6 +1293,7 @@
>           if(timestamp<= wanted_timestamp)
>               a = m;
>       }
> +    }
>       m= (flags&  AVSEEK_FLAG_BACKWARD) ? a : b;
>
>       if(!(flags&  AVSEEK_FLAG_ANY)){

This one, forget the other hunks.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list