[FFmpeg-devel] [PATCH] Speed up wtv index creation

Michael Niedermayer michael at niedermayer.cc
Mon Feb 1 00:40:10 CET 2016


On Sun, Jan 31, 2016 at 10:36:11PM +1100, Peter Ross wrote:
> On Fri, Jan 29, 2016 at 09:36:30PM +0000, popcorn mix wrote:
> > The index creation is O(N^2) with number of entries (typically thousands).
> > On a Raspberry Pi this can take more than 60 seconds to execute for a recording of a few hours.
> >     
> > By replacing with an O(N) loop, this takes virtually zero time
> > 
> > This patch has been in all Pi builds of Kodi for the last couple of years,
> > so it is quite widely tested. No change in FATE output.
> >
> > From 4bad5dbd752e96a6dfcb7e46aff1d64996d08ed1 Mon Sep 17 00:00:00 2001
> > From: popcornmix <popcornmix at gmail.com>
> > Date: Fri, 29 Jan 2016 20:27:00 +0000
> > Subject: [PATCH] wtv: Speed up wtv index creation
> > 
> > The index creation is O(N^2) with number of entries (typically thousands).
> > On a Pi this can take more than 60 seconds to execute for a recording of a few hours.
> > 
> > By replacing with an O(N) loop, this takes virtually zero time
> > ---
> >  libavformat/wtvdec.c | 18 ++++++++++--------
> >  1 file changed, 10 insertions(+), 8 deletions(-)
> > 
> > diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> > index e8f6196..b329b7c 100644
> > --- a/libavformat/wtvdec.c
> > +++ b/libavformat/wtvdec.c
> > @@ -1028,21 +1028,23 @@ static int read_header(AVFormatContext *s)
> >                  pb = wtvfile_open(s, root, root_size, ff_timeline_table_0_entries_Events_le16);
> >                  if (pb) {
> >                      int i;
> > +                    AVIndexEntry *e = wtv->index_entries;
> > +                    AVIndexEntry *e_end = wtv->index_entries + wtv->nb_index_entries - 1;
> > +                    uint64_t last_position = 0;
> >                      while (1) {
> >                          uint64_t frame_nb = avio_rl64(pb);
> >                          uint64_t position = avio_rl64(pb);
> > +                        while (frame_nb > e->size && e <= e_end) {
> > +                           e->pos = last_position;
> > +                           e++;
> 
> ^^^ this indent isn't aligned.

fixed


> 
> otherwise, great stuff. your implementation is solid.

applied

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160201/4b7492a4/attachment.sig>


More information about the ffmpeg-devel mailing list