[MPlayer-dev-eng] [PATCH] Support newer GIFLIB versions

Alexander Strasser eclipse7 at gmx.net
Mon Jul 22 00:20:57 CEST 2013


Work with GIFLIB version >= 4.2

Several functions have been renamed or changed in signature.

GIFLIB is used by vo gif89a and demuxer gif.

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 configure              |  1 +
 libmpdemux/demux_gif.c | 44 +++++++++++++++++++++++++++++++++++---------
 libvo/vo_gif89a.c      |  6 ++++++
 3 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 6f62eaa..47debc1 100755
--- a/configure
+++ b/configure
@@ -5091,6 +5091,7 @@ if test "$_gif" = auto ; then
   _gif=no
   for ld_gif in "-lungif" "-lgif" ; do
     statement_check gif_lib.h 'QuantizeBuffer(0, 0, 0, 0, 0, 0, 0, 0)' $ld_gif && _gif=yes && break
+    statement_check gif_lib.h 'GifQuantizeBuffer(0, 0, 0, 0, 0, 0, 0, 0)' $ld_gif && _gif=yes && break
   done
 fi
 
diff --git a/libmpdemux/demux_gif.c b/libmpdemux/demux_gif.c
index 804ce8c..d08ce4c 100644
--- a/libmpdemux/demux_gif.c
+++ b/libmpdemux/demux_gif.c
@@ -45,6 +45,32 @@ typedef struct {
 
 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
 
+#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
+#define DGifOpen(a, b) DGifOpen(a, b, NULL)
+#define DGifOpenFileHandle(a) DGifOpenFileHandle(a, NULL)
+#define GifError() gif->Error
+#define GifErrorString() GifErrorString(gif->Error)
+#endif
+
+/* >= 4.2 prior GIFLIB did not have MAJOR/MINOR defines */
+#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 4
+static void print_gif_error(GifFileType * gif)
+{
+  int err = GifError();
+  char *err_str = GifErrorString();
+
+  if (err_str)
+    fprintf(stderr, "\nGIF-LIB error: %s.\n", err_str);
+  else
+    fprintf(stderr, "\nGIF-LIB undefined error %d.\n", err);
+}
+#else
+static void print_gif_error(GifFileType * gif)
+{
+  PrintGifError();
+}
+#endif
+
 #ifndef CONFIG_GIF_TVT_HACK
 // not supported by certain versions of the library
 static int my_read_gif(GifFileType *gif, uint8_t *buf, int len)
@@ -94,14 +120,14 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
 
   while (type != IMAGE_DESC_RECORD_TYPE) {
     if (DGifGetRecordType(gif, &type) == GIF_ERROR) {
-      PrintGifError();
+      print_gif_error(priv->gif);
       return 0; // oops
     }
     if (type == TERMINATE_RECORD_TYPE)
       return 0; // eof
     if (type == SCREEN_DESC_RECORD_TYPE) {
       if (DGifGetScreenDesc(gif) == GIF_ERROR) {
-        PrintGifError();
+        print_gif_error(priv->gif);
         return 0; // oops
       }
     }
@@ -109,7 +135,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
       int code;
       unsigned char *p = NULL;
       if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) {
-        PrintGifError();
+        print_gif_error(priv->gif);
         return 0; // oops
       }
       if (code == 0xF9) {
@@ -138,7 +164,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
 	  comments[length] = 0;
 	  printf("%s", comments);
           if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
-            PrintGifError();
+            print_gif_error(priv->gif);
             return 0; // oops
           }
 	}
@@ -146,7 +172,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
       }
       while (p != NULL) {
         if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
-          PrintGifError();
+          print_gif_error(priv->gif);
           return 0; // oops
         }
       }
@@ -154,7 +180,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
   }
 
   if (DGifGetImageDesc(gif) == GIF_ERROR) {
-    PrintGifError();
+    print_gif_error(priv->gif);
     return 0; // oops
   }
 
@@ -167,7 +193,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
     memset(dp->buffer, gif->SBackGroundColor, priv->w * priv->h);
 
   if (DGifGetLine(gif, buf, len) == GIF_ERROR) {
-    PrintGifError();
+    print_gif_error(priv->gif);
     free(buf);
     free_demux_packet(dp);
     return 0; // oops
@@ -261,7 +287,7 @@ static demuxer_t* demux_open_gif(demuxer_t* demuxer)
   gif = DGifOpen(demuxer->stream, my_read_gif);
 #endif
   if (!gif) {
-    PrintGifError();
+    print_gif_error(priv->gif);
     free(priv);
     return NULL;
   }
@@ -303,7 +329,7 @@ static void demux_close_gif(demuxer_t* demuxer)
   gif_priv_t *priv = demuxer->priv;
   if (!priv) return;
   if (priv->gif && DGifCloseFile(priv->gif) == GIF_ERROR)
-    PrintGifError();
+    print_gif_error(priv->gif);
   free(priv->refimg);
   free(priv);
 }
diff --git a/libvo/vo_gif89a.c b/libvo/vo_gif89a.c
index b808f81..3732225 100644
--- a/libvo/vo_gif89a.c
+++ b/libvo/vo_gif89a.c
@@ -69,6 +69,12 @@ static const vo_info_t info = {
 
 const LIBVO_EXTERN(gif89a)
 
+#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
+#define EGifOpenFileName(a, b) EGifOpenFileName(a, b, NULL)
+#define MakeMapObject GifMakeMapObject
+#define FreeMapObject GifFreeMapObject
+#define QuantizeBuffer GifQuantizeBuffer
+#endif
 
 // how many frames per second we are aiming for during output.
 static float target_fps;
-- 


More information about the MPlayer-dev-eng mailing list