[FFmpeg-devel] [PATCH] Avoid a few shifts on each frame while decoding mpeg audio.

Clément Bœsch ubitux
Sun Jan 16 23:28:40 CET 2011


On Sun, Jan 16, 2011 at 11:12:51PM +0100, Michael Niedermayer wrote:
> On Sun, Jan 16, 2011 at 09:53:38PM +0100, Cl?ment B?sch wrote:
> > Hi,
> > 
> > The MPEG audio parser seems to do a few useless shifts each time a new
> > frame is sent for feeding; this patch avoids this (one read instead of 4
> > shifts). I ran the fate tests locally and it seems it didn't break
> > anything.
> > 
> > Also, I don't understand the header_count field (in use a few lines below)
> > so it may be wise to check if it is not related to what I tried to
> > achieve.
> > 
> > Regards,
> > 
> > -- 
> > Cl?ment B.
> 
> >  mpegaudio_parser.c |    6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 813002a20dc97930cd819d7d7fca2a5a73d702ba  0001-Avoid-a-few-shifts-on-each-frame-while-decoding-mpeg.patch
> > From beb7d21224596d98dd3eebca5fef43c74da5c1ad Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
> > Date: Sun, 16 Jan 2011 21:43:16 +0100
> > Subject: [PATCH] Avoid a few shifts on each frame while decoding mpeg audio.
> 
> this looks buggy
> it skips the first 3 checks and i dont see why they cant be true

The state variable contains the previous one. What's happening is 4 shifts
at each frame until the header is completely read. You can see it very
clearly by printing the state evolution in the while(i<buf_size) loop.

Another solution may be to directly feed mpegaudio_parse with the buffer
shifted to the next header and not the previous state, but not sure it's
the correct thing to do.

-- 
Cl?ment B.



More information about the ffmpeg-devel mailing list