[MPlayer-dev-eng] [BUG][PATCH] gif library incompatibility fixes

Joey Parrish joey at nicewarrior.org
Sat Feb 15 18:53:23 CET 2003


Hello,

Attached below are two patches to help fix incompatibilities between gif
library versions.  The first adds an extra check to configure that looks
for advanced functionality preferred by demux_gif.  If no such function
is found, then a workaround is enabled.  The second patch will make
configure check for libungif before libgif.  Since I am now aware of the
need for libungif's special functions, I believe configure should prefer
libungif over libgif in all cases.  These patches are intended for both
0_90 and main.

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;
-------------- 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	Sat Feb 15 11:50:32 2003
@@ -2911,18 +2911,18 @@
   return 0;
 }
 EOF
-  if cc_check -lgif && "$TMPO" >> "$TMPLOG" ; then
-    _gif=yes
-    _ld_gif="-lgif"
-  elif cc_check -lungif && "$TMPO" >> "$TMPLOG" ; then
+  if cc_check -lungif && "$TMPO" >> "$TMPLOG" ; then
     _gif=yes
     _ld_gif="-lungif"
-  elif cc_check -lgif $_ld_x11 && "$TMPO" >> "$TMPLOG" ; then
-    _gif=yes
-    _ld_gif="-lgif $_ld_x11"
   elif cc_check -lungif $_ld_x11 && "$TMPO" >> "$TMPLOG" ; then
     _gif=yes
     _ld_gif="-lungif $_ld_x11"
+  elif cc_check -lgif && "$TMPO" >> "$TMPLOG" ; then
+    _gif=yes
+    _ld_gif="-lgif"
+  elif cc_check -lgif $_ld_x11 && "$TMPO" >> "$TMPLOG" ; then
+    _gif=yes
+    _ld_gif="-lgif $_ld_x11"
   fi
 fi
 


More information about the MPlayer-dev-eng mailing list