[FFmpeg-devel] zlib decoder

Michael Niedermayer michaelni
Wed Jul 4 02:51:25 CEST 2007


Hi

On Tue, Jul 03, 2007 at 10:40:34PM +0100, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
> 
> > Hi
> >
> > On Mon, Jul 02, 2007 at 10:30:16PM +0100, M?ns Rullg?rd wrote:
> >> Here, at long last, is my highly anticipated zlib decoder.
> >> 
> >> It decompresses a random choice of gzip files I've tried it on
> >> correctly.  I'm sure there still are corner cases I haven't covered,
> >> though.  Any help finding, and better yet fixing, these is
> >> appreciated.
> >> 
> >> Speedwise it's on par with gunzip, with large buffer sizes even a bit
> >> faster.
> > [...]
> >> static const unsigned int len_tab[29][2] = {
> 
> [...]
> 
> >> static const unsigned int dist_tab[32][2] = {
> 
> [...]
> 
> > this fit in short
> 
> Yes, it does.
> 
> > are all thouse macros really needed?
> > cant this be implemented in a more readable way?
> 
> Some could probably be made into functions.  Every place that reads
> bits needs to be reachable from the switch statement though.  I moved
> the huffman code parsing out of the main loop to make that part easier
> to read.
> 
> Do you see any real bugs?  Optimisations?  API comments?

bugs no, optimiztaions, yes, get rid of the macros and switch :)
that is instead of 

case foobar:
ctx->state= foobar;
if(!do we have enough bits){
    "safe state" and return, we will continue from the case above
}

i would rather not even start decompressing if iam low on input data
but rather accumulate a minimum amount of kbytes unless its the last call
this should simplify the code alot, things like headers and huffman
tables should be guranteed to be fully available
i would just check in the 2 block loops if iam close to out of data
and if so return and then continue from there
IMHO that way there would be only 3 entry points

of course thats all just an idea and there could be issues iam missing

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

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070704/54a0e25a/attachment.pgp>



More information about the ffmpeg-devel mailing list