[FFmpeg-devel] [PATCH] FLAC parser

Michael Niedermayer michaelni
Thu Oct 21 01:05:19 CEST 2010


On Wed, Oct 20, 2010 at 03:38:14PM +0200, Michael Chinen wrote:
> Hi,
> 
> On Tue, Oct 19, 2010 at 2:48 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >[...]
> >> I did profiling again and it turns out I missed one exit point for the
> >> function the last time.  The non-flat wrap buffer version is about
> >> 2-4% faster overall.  I've squashed it into the 0003.
> >
> >what is the speed difference between current svn and after this patch ?
> 
> I used the -benchmark flag for 'ffmpeg -i fourminsong.flac a.wav' and
> five runs and got
> without patch: utime = 2.044-2.042s
> with patch:    utime = 2.363-2.379s
> 
> So flac demuxing with the parser is slower.

its not a problem when the parser is needed, like for -acodec copy but when
it is not needed then a 15% slowdown is a problem. That said it of course
would be nicer if it was faster than that even when needed



[...]
> >
> >
> > [...]
> >> +static int find_headers_search(FLACParseContext *fpc, uint8_t *buf, int buf_size,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int search_start)
> >> +
> >> +{
> >> + ? ?FLACFrameInfo fi;
> >> + ? ?int size = 0, i;
> >> + ? ?uint8_t *header_buf;
> >> +
> >> + ? ?for (i = 0; i < buf_size - 1; i++) {
> >> + ? ? ? ?if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8) {
> >
> > something based on testing several positions at once is likely faster
> > like
> > x= AV_RB32()
> > (x & ~(x+0x01010101))&0x80808080
> > that will detect 0xFF bytes and only after that testing the 4 positions for
> > FFF8
> 
> Hmm.  Since in both cases (header there/header not there) this will
> require more masks on a 2 byte int how will it be faster?
> Also since it is 15 bits that we are looking for is the 32 bit
> handling a mistake?

the code is executed 4 times less often than your 2 byte masking
see ff_avc_find_startcode_internal() for something quite similar

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101021/e556e179/attachment.pgp>



More information about the ffmpeg-devel mailing list