[MPlayer-dev-eng] [PATCH] fix version incompatibilities with gif lib

Joey Parrish joey at nicewarrior.org
Thu Feb 13 23:48:45 CET 2003


On Thu, Feb 13, 2003 at 03:55:17PM -0600, Joey Parrish wrote:
> On Thu, Feb 13, 2003 at 02:56:30PM +0100, Gabucino wrote:
> > Why on this goddamn Earth is the gif demuxer enabled by default? Isn't MPlayer
> > a Movie player?
> 
> It's enabled by autodetect of the gif library.  What you see here is an
> incompatibility between gif library versions that (until today) I was
> completely unaware of.  Help me fix this by telling me what distriubtion
> and library version manifests this problem.

Nevermind, I found it.  All the way back to v3 of libungif, everything
is fine.  It's the version just before that which causes this problem.
I can't imagine why it would still be around.  I recommend upgrading to
whoever reported this.  In any case, here's a patch to fix this.  It
adds a section to configure that detects these old versions.  It adds a
workaround to demux_gif to use the old way of doing things if this old
version is around.  With these old versions of giflib, streaming for
GIFs will be disabled.  This is because the older versions are unable to
interface to MPlayer's cache.  What happens in these cases is that once
MPlayer detects the file type, the library then starts to read directly
from the stream.  Since the stream cannot seek back to byte 0, the
library does not believe that it is a valid GIF.  (No signature.)

Thanks,
--Joey
-------------- next part --------------
diff -ur 0_90.cvs/configure 0_90.dev/configure
--- 0_90.cvs/configure	Thu Feb 13 15:57:26 2003
+++ 0_90.dev/configure	Thu Feb 13 16:37:06 2003
@@ -2960,6 +2960,27 @@
 echores "$_gif"
 
 
+if test "$_gif" = yes ; then
+  echocheck "broken giflib workaround"
+  _def_gif_tvt_hack='#define HAVE_GIF_TVT_HACK 1'
+
+  cat > $TMPC << EOF
+#include <gif_lib.h>
+int main(void) {
+  GifFileType gif;
+  printf("UserData is at address %p\n", gif.UserData);
+  return 0;
+}
+EOF
+  if cc_check "$_ld_gif" && ( "$TMPO" ) >>"$TMPLOG" 2>&1 ; then
+    _def_gif_tvt_hack='#undef HAVE_GIF_TVT_HACK'
+    echores "disabled"
+  else
+    echores "enabled"
+  fi
+fi
+
+
 if test "$_vesa" != no ; then
 echocheck "VESA support"
 if x86 && linux ; then
@@ -5275,6 +5296,7 @@
 /* enable GIF support */
 $_def_gif
 $_def_gif_4
+$_def_gif_tvt_hack
 
 /* enable FreeType support */
 $_def_freetype
diff -ur 0_90.cvs/libmpdemux/demux_gif.c 0_90.dev/libmpdemux/demux_gif.c
--- 0_90.cvs/libmpdemux/demux_gif.c	Sat Feb  8 11:29:43 2003
+++ 0_90.dev/libmpdemux/demux_gif.c	Thu Feb 13 16:37:36 2003
@@ -24,9 +24,12 @@
 
 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
 
+#ifndef HAVE_GIF_TVT_HACK
+// not supported by certain versions of the library
 int my_read_gif(GifFileType *gif, uint8_t *buf, int len) {
   return stream_read(gif->UserData, buf, len);
 }
+#endif
   
 int gif_check_file(demuxer_t *demuxer)
 {
@@ -156,7 +159,17 @@
   // go back to the beginning
   stream_seek(demuxer->stream,demuxer->stream->start_pos);
 
+#ifdef HAVE_GIF_TVT_HACK
+  // without the TVT functionality of libungif, a hard seek must be
+  // done to the beginning of the file.  this is because libgif is
+  // unable to use mplayer's cache, and without this lseek libgif will
+  // not read from the beginning of the file and the command will fail.
+  // with this hack enabled, you will lose the ability to stream a GIF.
+  lseek(demuxer->stream->fd, 0, SEEK_SET);
+  gif = DGifOpenFileHandle(demuxer->stream->fd);
+#else
   gif = DGifOpen(demuxer->stream, my_read_gif);
+#endif
   if (!gif) {
     PrintGifError();
     return NULL;


More information about the MPlayer-dev-eng mailing list