[FFmpeg-devel] [PATCH] ff_add_av_index_entry_internal

Michael Niedermayer michaelni
Sat Nov 21 11:13:45 CET 2009


On Fri, Nov 20, 2009 at 06:15:47PM -0800, 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 ?
>
> -- 
> Baptiste COUDURIER
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> FFmpeg maintainer                                  http://www.ffmpeg.org

>  utils.c |   11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> fdfb7ddf4346318e7e00ccaa15833c4842a8eb17  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 appears to be wrong to me when AVSEEK_FLAG_BACKWARD is set

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091121/01080eaf/attachment.pgp>



More information about the ffmpeg-devel mailing list