The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / mplayer / 0005-Support-newer-GIFLIB-versions.patch
1 Support newer GIFLIB versions
2
3 This is an adapted upstream patch. This patch is incomplete so a new
4 patch needs to be added after this one.
5
6 Upstream commit:
7
8    https://github.com/pigoz/mplayer-svn/commit/a0ddaef5457e222dade386901bf448c5e3ac7b89
9
10 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
11
12 From a0ddaef5457e222dade386901bf448c5e3ac7b89 Mon Sep 17 00:00:00 2001
13 From: al <al@b3059339-0415-0410-9bf9-f77b7e298cf2>
14 Date: Sat, 27 Jul 2013 21:16:06 +0000
15 Subject: [PATCH] Support newer GIFLIB versions
16
17 Work with GIFLIB version >= 4.2
18
19 Several functions have been renamed or changed in signature.
20
21 GIFLIB is used by vo gif89a and demuxer gif.
22
23 Note about GIFLIB Version 4.2:
24 It does not work with vanilla GIFLIB 4.2 but it works with
25 versions that have re-added quantize support like e.g. the
26 package from arch linux.
27
28 Note about GIFLIB Version 5:
29 The newly added GCB functions use size_t but the necessary
30 standard headers are not included in gif_lib.h . To workaround
31 this:
32
33 * configure: use statement_check_broken to include stdlib.h
34 * vo gif89: include gif_lib.h after stdlib.h
35 * demuxer gif: no workaround needed,
36                gif_lib.h is already included after stdlib.h
37
38
39
40 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36367 b3059339-0415-0410-9bf9-f77b7e298cf2
41 ---
42  configure              |    1 +
43  libmpdemux/demux_gif.c |   44 +++++++++++++++++++++++++++++++++++---------
44  libvo/vo_gif89a.c      |   35 ++++++++++++++++++++++++-----------
45  3 files changed, 61 insertions(+), 21 deletions(-)
46
47 diff --git a/configure b/configure
48 index e9152a8..4cd378d 100755
49 --- a/configure
50 +++ b/configure
51 @@ -4938,6 +4938,7 @@ if test "$_gif" = auto ; then
52    _gif=no
53    for ld_gif in "-lungif" "-lgif" ; do
54      statement_check gif_lib.h 'QuantizeBuffer(0, 0, 0, 0, 0, 0, 0, 0)' $ld_gif && _gif=yes && break
55 +    statement_check_broken stdlib.h gif_lib.h 'GifQuantizeBuffer(0, 0, 0, 0, 0, 0, 0, 0)' $ld_gif && _gif=yes && break
56    done
57  fi
58  
59  
60 diff --git a/libmpdemux/demux_gif.c b/libmpdemux/demux_gif.c
61 index 804ce8c..0a11322 100644
62 --- a/libmpdemux/demux_gif.c
63 +++ b/libmpdemux/demux_gif.c
64 @@ -45,6 +45,32 @@ typedef struct {
65  
66  #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
67  
68 +#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
69 +#define DGifOpen(a, b) DGifOpen(a, b, NULL)
70 +#define DGifOpenFileHandle(a) DGifOpenFileHandle(a, NULL)
71 +#define GifError() (gif ? gif->Error : 0)
72 +#define GifErrorString() GifErrorString(gif->Error)
73 +#endif
74 +
75 +/* >= 4.2 prior GIFLIB did not have MAJOR/MINOR defines */
76 +#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 4
77 +static void print_gif_error(GifFileType *gif)
78 +{
79 +  int err = GifError();
80 +  char *err_str = GifErrorString();
81 +
82 +  if (err_str)
83 +    mp_msg(MSGT_DEMUX, MSGL_ERR, "\n[gif] GIF-LIB error: %s.\n", err_str);
84 +  else
85 +    mp_msg(MSGT_DEMUX, MSGL_ERR, "\n[gif] GIF-LIB undefined error %d.\n", err);
86 +}
87 +#else
88 +static void print_gif_error(GifFileType *gif)
89 +{
90 +  PrintGifError();
91 +}
92 +#endif
93 +
94  #ifndef CONFIG_GIF_TVT_HACK
95  // not supported by certain versions of the library
96  static int my_read_gif(GifFileType *gif, uint8_t *buf, int len)
97 @@ -94,14 +120,14 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
98  
99    while (type != IMAGE_DESC_RECORD_TYPE) {
100      if (DGifGetRecordType(gif, &type) == GIF_ERROR) {
101 -      PrintGifError();
102 +      print_gif_error(priv->gif);
103        return 0; // oops
104      }
105      if (type == TERMINATE_RECORD_TYPE)
106        return 0; // eof
107      if (type == SCREEN_DESC_RECORD_TYPE) {
108        if (DGifGetScreenDesc(gif) == GIF_ERROR) {
109 -        PrintGifError();
110 +        print_gif_error(priv->gif);
111          return 0; // oops
112        }
113      }
114 @@ -109,7 +135,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
115        int code;
116        unsigned char *p = NULL;
117        if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) {
118 -        PrintGifError();
119 +        print_gif_error(priv->gif);
120          return 0; // oops
121        }
122        if (code == 0xF9) {
123 @@ -138,7 +164,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
124           comments[length] = 0;
125           printf("%s", comments);
126            if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
127 -            PrintGifError();
128 +            print_gif_error(priv->gif);
129              return 0; // oops
130            }
131         }
132 @@ -146,7 +172,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
133        }
134        while (p != NULL) {
135          if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
136 -          PrintGifError();
137 +          print_gif_error(priv->gif);
138            return 0; // oops
139          }
140        }
141 @@ -154,7 +180,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
142    }
143  
144    if (DGifGetImageDesc(gif) == GIF_ERROR) {
145 -    PrintGifError();
146 +    print_gif_error(priv->gif);
147      return 0; // oops
148    }
149  
150 @@ -167,7 +193,7 @@ static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
151      memset(dp->buffer, gif->SBackGroundColor, priv->w * priv->h);
152  
153    if (DGifGetLine(gif, buf, len) == GIF_ERROR) {
154 -    PrintGifError();
155 +    print_gif_error(priv->gif);
156      free(buf);
157      free_demux_packet(dp);
158      return 0; // oops
159 @@ -261,7 +287,7 @@ static demuxer_t* demux_open_gif(demuxer_t* demuxer)
160    gif = DGifOpen(demuxer->stream, my_read_gif);
161  #endif
162    if (!gif) {
163 -    PrintGifError();
164 +    print_gif_error(NULL);
165      free(priv);
166      return NULL;
167    }
168 @@ -303,7 +329,7 @@ static void demux_close_gif(demuxer_t* demuxer)
169    gif_priv_t *priv = demuxer->priv;
170    if (!priv) return;
171    if (priv->gif && DGifCloseFile(priv->gif) == GIF_ERROR)
172 -    PrintGifError();
173 +    print_gif_error(priv->gif);
174    free(priv->refimg);
175    free(priv);
176  }
177 diff --git a/libvo/vo_gif89a.c b/libvo/vo_gif89a.c
178 index b808f81..160291a 100644
179 --- a/libvo/vo_gif89a.c
180 +++ b/libvo/vo_gif89a.c
181 @@ -44,13 +44,13 @@
182   * entire argument being interpretted as the filename.
183   */
184  
185 -#include <gif_lib.h>
186 -
187  #include <stdio.h>
188  #include <stdlib.h>
189  #include <string.h>
190  #include <unistd.h>
191  
192 +#include <gif_lib.h>
193 +
194  #include "config.h"
195  #include "subopt-helper.h"
196  #include "video_out.h"
197 @@ -69,6 +69,12 @@ static const vo_info_t info = {
198  
199  const LIBVO_EXTERN(gif89a)
200  
201 +#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
202 +#define EGifOpenFileName(a, b) EGifOpenFileName(a, b, NULL)
203 +#define MakeMapObject GifMakeMapObject
204 +#define FreeMapObject GifFreeMapObject
205 +#define QuantizeBuffer GifQuantizeBuffer
206 +#endif
207  
208  // how many frames per second we are aiming for during output.
209  static float target_fps;
210 @@ -156,7 +162,7 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
211                 uint32_t d_height, uint32_t flags, char *title,
212                 uint32_t format)
213  {
214 -#ifdef CONFIG_GIF_4
215 +#if defined CONFIG_GIF_4 || GIFLIB_MAJOR >= 5
216         // these are control blocks for the gif looping extension.
217         char LB1[] = "NETSCAPE2.0";
218         char LB2[] = { 1, 0, 0 };
219 @@ -185,23 +191,25 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
220                 return 1;
221         }
222  
223 +       new_gif = EGifOpenFileName(gif_filename, 0);
224 +       if (new_gif == NULL) {
225 +               mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: error opening file \"%s\" for output.\n", gif_filename);
226 +               return 1;
227 +       }
228 +
229 +#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
230 +       EGifSetGifVersion(new_gif, 1);
231 +#elif defined CONFIG_GIF_4
232         // the EGifSetGifVersion line causes segfaults in certain
233         // earlier versions of libungif.  i don't know exactly which,
234         // but certainly in all those before v4.  if you have problems,
235         // you need to upgrade your gif library.
236 -#ifdef CONFIG_GIF_4
237         EGifSetGifVersion("89a");
238  #else
239         mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Your version of libungif needs to be upgraded.\n");
240         mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Some functionality has been disabled.\n");
241  #endif
242  
243 -       new_gif = EGifOpenFileName(gif_filename, 0);
244 -       if (new_gif == NULL) {
245 -               mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: error opening file \"%s\" for output.\n", gif_filename);
246 -               return 1;
247 -       }
248 -
249         slice_data = malloc(img_width * img_height * 3);
250         if (slice_data == NULL) {
251                 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: malloc failed.\n");
252 @@ -231,7 +239,12 @@ static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
253  
254         // set the initial width and height info.
255         EGifPutScreenDesc(new_gif, s_width, s_height, 256, 0, reduce_cmap);
256 -#ifdef CONFIG_GIF_4
257 +#if defined GIFLIB_MAJOR && GIFLIB_MAJOR >= 5
258 +       EGifPutExtensionLeader(new_gif, 0xFF);
259 +       EGifPutExtensionBlock(new_gif, 11, LB1);
260 +       EGifPutExtensionBlock(new_gif, 3, LB2);
261 +       EGifPutExtensionTrailer(new_gif);
262 +#elif defined CONFIG_GIF_4
263         // version 3 of libungif does not support multiple control blocks.
264         // looping requires multiple control blocks.
265         // therefore, looping is only enabled for v4 and up.
266 -- 
267 1.7.1
268