[FFmpeg-devel] zlib decoder

Reimar Döffinger Reimar.Doeffinger
Sat Jul 7 21:50:28 CEST 2007


Hello,
On Thu, Jul 05, 2007 at 07:48:59PM +0100, M?ns Rullg?rd wrote:
> M?ns Rullg?rd <mans at mansr.com> writes:
> > Mike Melanson <mike at multimedia.cx> writes:
> >> M?ns Rullg?rd wrote:
> >>> M?ns Rullg?rd <mans at mansr.com> writes:
> >>> 
> >>>> 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.
> >>> 
> >>> Oh, one thing I just remembered I hadn't implemented yet: parsing the
> >>> standard zlib header ;-)
> >>
> >> So, is it good for anything yet? Can it decode compressed QT moov atoms?
> >
> > Haven't tried.
> >
> >> ZMBV data?
> >
> > Yes, after I implemented zlib header parsing.  Will post code later.
> 
> Here's the promised code.  It has zlib header handling and some code
> moved from macros to functions.

As an API example, for testing, and to be applied after this:
here is a patch that makes cscd.c use this.
Mans seems to already have done the same thing, but who doesn't enjoy a bit
of duplicated effort ;-).
cscd samples here: http://samples.mplayerhq.hu/V-codecs/CSCD/, at least first one uses zlib.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/cscd.c
===================================================================
--- libavcodec/cscd.c	(revision 9522)
+++ libavcodec/cscd.c	(working copy)
@@ -23,9 +23,7 @@
 
 #include "avcodec.h"
 
-#ifdef CONFIG_ZLIB
-#include <zlib.h>
-#endif
+#include "inflate.h"
 #include "lzo.h"
 
 typedef struct {
@@ -163,15 +161,12 @@
             break;
         }
         case 1: { // zlib compression
-#ifdef CONFIG_ZLIB
-            unsigned long dlen = c->decomp_size;
-            if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK)
+            unsigned int dlen = c->decomp_size;
+            AVInflateContext *ictx = av_inflate_open();
+            if (av_inflate(ictx, c->decomp_buf, &dlen, &buf[2], buf_size - 2) < 0)
                 av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
+            av_inflate_close(ictx);
             break;
-#else
-            av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
-            return -1;
-#endif
         }
         default:
             av_log(avctx, AV_LOG_ERROR, "unknown compression\n");



More information about the ffmpeg-devel mailing list