[MPlayer-cvslog] r37586 - trunk/libmpdemux/demux_gif.c

rtogni subversion at mplayerhq.hu
Mon Jan 4 19:52:20 CET 2016


Author: rtogni
Date: Mon Jan  4 19:52:20 2016
New Revision: 37586

Log:
Make gif detection more robust in demuxer_gif.

Check for the full signature 'GIF[8/9]a' instead of 'GIF' only

Modified:
   trunk/libmpdemux/demux_gif.c

Modified: trunk/libmpdemux/demux_gif.c
==============================================================================
--- trunk/libmpdemux/demux_gif.c	Mon Jan  4 19:29:06 2016	(r37585)
+++ trunk/libmpdemux/demux_gif.c	Mon Jan  4 19:52:20 2016	(r37586)
@@ -43,7 +43,7 @@ typedef struct {
   uint8_t *refimg;
 } gif_priv_t;
 
-#define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
+#define GIF_SIGNATURE (('G' << 24) | ('I' << 16) | ('F' << 8) | '8')
 
 #if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
 #define DGifOpen(a, b) DGifOpen(a, b, NULL)
@@ -84,8 +84,11 @@ static int my_read_gif(GifFileType *gif,
 
 static int gif_check_file(demuxer_t *demuxer)
 {
-  if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE)
-    return DEMUXER_TYPE_GIF;
+  if (stream_read_dword(demuxer->stream) == GIF_SIGNATURE) {
+    int sig = stream_read_word(demuxer->stream);
+    if ((((sig & 0xff00) == 0x3700) || ((sig & 0xff00) == 0x3900)) && (sig & 0xff) == 'a')
+      return DEMUXER_TYPE_GIF;
+  }
   return 0;
 }
 


More information about the MPlayer-cvslog mailing list