--- configure~ 2013-02-15 04:07:31.732217305 +0000 +++ configure 2013-02-15 04:14:50.727477186 +0000 @@ -4966,9 +4966,11 @@ #include static void catch(int sig) { exit(1); } int main(void) { + GifFileType type; + signal(SIGSEGV, catch); // catch segfault - printf("EGifPutExtensionFirst is at address %p\n", EGifPutExtensionFirst); - EGifSetGifVersion("89a"); // this will segfault a buggy gif lib. + printf("EGifPutExtensionLeader is at address %p\n", EGifPutExtensionLeader); + EGifSetGifVersion(&type, true); // this will segfault a buggy gif lib. return 0; } EOF --- libvo/vo_gif89a.c.orig 2011-05-07 11:59:11.000000000 +0100 +++ libvo/vo_gif89a.c 2013-02-15 05:23:50.294026168 +0000 @@ -44,8 +44,15 @@ * entire argument being interpretted as the filename. */ +#include #include +#if GIFLIB_MAJOR >= 5 +#define MakeMapObject GifMakeMapObject +#define FreeMapObject GifFreeMapObject +#define QuantizeBuffer GifQuantizeBuffer +#endif + #include #include #include @@ -189,19 +196,29 @@ // earlier versions of libungif. i don't know exactly which, // but certainly in all those before v4. if you have problems, // you need to upgrade your gif library. +#if GIFLIB_MAJOR < 5 #ifdef CONFIG_GIF_4 EGifSetGifVersion("89a"); #else mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Your version of libungif needs to be upgraded.\n"); mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Some functionality has been disabled.\n"); #endif +#endif +#if GIFLIB_MAJOR >= 5 + new_gif = EGifOpenFileName(gif_filename, 0, NULL); +#else new_gif = EGifOpenFileName(gif_filename, 0); +#endif if (new_gif == NULL) { mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: error opening file \"%s\" for output.\n", gif_filename); return 1; } +#if GIFLIB_MAJOR >= 5 + EGifSetGifVersion(new_gif, true); +#endif + slice_data = malloc(img_width * img_height * 3); if (slice_data == NULL) { mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: malloc failed.\n"); @@ -235,9 +252,14 @@ // version 3 of libungif does not support multiple control blocks. // looping requires multiple control blocks. // therefore, looping is only enabled for v4 and up. +#if GIFLIB_MAJOR >= 5 + EGifPutExtension(new_gif, 0xFF, 11, LB1); + EGifPutExtension(new_gif, 0, 3, LB2); +#else EGifPutExtensionFirst(new_gif, 0xFF, 11, LB1); EGifPutExtensionLast(new_gif, 0, 3, LB2); #endif +#endif mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: Config finished.\n"); return 0; --- libmpdemux/demux_gif.c.orig 2013-02-15 04:34:49.479240490 +0000 +++ libmpdemux/demux_gif.c 2013-02-15 05:20:16.326563017 +0000 @@ -53,6 +53,18 @@ } #endif +#if GIFLIB_MAJOR >= 5 +static void PrintGifErrorStr(char *str) +{ + fprintf(stderr, "Error in GIF library: %s\n", str); +} + +static void PrintGifError(int errorCode) +{ + PrintGifErrorStr(GifErrorString(errorCode)); +} +#endif + static int gif_check_file(demuxer_t *demuxer) { if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE) @@ -94,14 +106,18 @@ while (type != IMAGE_DESC_RECORD_TYPE) { if (DGifGetRecordType(gif, &type) == GIF_ERROR) { +#if GIFLIB_MAJOR < 5 PrintGifError(); +#else + PrintGifError(gif->Error); +#endif return 0; // oops } if (type == TERMINATE_RECORD_TYPE) return 0; // eof if (type == SCREEN_DESC_RECORD_TYPE) { if (DGifGetScreenDesc(gif) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); return 0; // oops } } @@ -109,7 +125,7 @@ int code; unsigned char *p = NULL; if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); return 0; // oops } if (code == 0xF9) { @@ -138,7 +154,7 @@ comments[length] = 0; printf("%s", comments); if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); return 0; // oops } } @@ -146,7 +162,7 @@ } while (p != NULL) { if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); return 0; // oops } } @@ -154,7 +170,7 @@ } if (DGifGetImageDesc(gif) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); return 0; // oops } @@ -167,7 +183,7 @@ memset(dp->buffer, gif->SBackGroundColor, priv->w * priv->h); if (DGifGetLine(gif, buf, len) == GIF_ERROR) { - PrintGifError(); + PrintGifError(gif->Error); free(buf); return 0; // oops } @@ -241,6 +257,9 @@ gif_priv_t *priv = calloc(1, sizeof(gif_priv_t)); sh_video_t *sh_video = NULL; GifFileType *gif = NULL; +#if GIFLIB_MAJOR >= 5 + int error = 0; +#endif priv->current_pts = 0; demuxer->seekable = 0; // FIXME @@ -257,13 +276,25 @@ lseek(demuxer->stream->fd, 0, SEEK_SET); gif = DGifOpenFileHandle(demuxer->stream->fd); #else +#if GIFLIB_MAJOR < 5 gif = DGifOpen(demuxer->stream, my_read_gif); -#endif + if (!gif) { PrintGifError(); free(priv); return NULL; } +#else + + gif = DGifOpen(demuxer->stream, my_read_gif, &error); + + if (error) { + PrintGifError(error); + free(priv); + return NULL; + } +#endif +#endif // create a new video stream header sh_video = new_sh_video(demuxer, 0); @@ -302,7 +333,11 @@ gif_priv_t *priv = demuxer->priv; if (!priv) return; if (priv->gif && DGifCloseFile(priv->gif) == GIF_ERROR) +#if GIFLIB_MAJOR < 5 PrintGifError(); +#else + PrintGifError(priv->gif->Error); +#endif free(priv->refimg); free(priv); }