View | Details | Raw Unified | Return to bug 209121
Collapse All | Expand All

(-)textproc/libextractor/files/patch-ffmpeg29 (+350 lines)
Line 0 Link Here
1
Description: update to new API in FFmpeg 2.9, fix FTBS
2
Origin: upstream
3
Applied-Upstream: commit: r35548:r35549 and r36975
4
--- src/plugins/thumbnailffmpeg_extractor.c.orig
5
+++ src/plugins/thumbnailffmpeg_extractor.c
6
@@ -59,6 +59,20 @@
7
 #include <ffmpeg/swscale.h>
8
 #endif
9
 
10
+#if USE_JPEG
11
+#ifdef PIX_FMT_YUVJ420P
12
+#define PIX_OUTPUT_FORMAT PIX_FMT_YUVJ420P
13
+#else
14
+#define PIX_OUTPUT_FORMAT AV_PIX_FMT_YUVJ420P
15
+#endif
16
+#else
17
+#ifdef PIX_FMT_RGB24
18
+#define PIX_OUTPUT_FORMAT PIX_FMT_RGB24
19
+#else
20
+#define PIX_OUTPUT_FORMAT AV_PIX_FMT_RGB24
21
+#endif
22
+#endif
23
+
24
 /**
25
  * Set to 1 to enable debug output.
26
  */ 
27
@@ -153,7 +167,7 @@
28
 static size_t 
29
 create_thumbnail (int src_width, int src_height, 
30
 		  int src_stride[],
31
-		  enum PixelFormat src_pixfmt, 
32
+		  enum AVPixelFormat src_pixfmt, 
33
 		  const uint8_t * const src_data[],
34
 		  int dst_width, int dst_height,
35
 		  uint8_t **output_data, 
36
@@ -189,7 +203,8 @@
37
   if (NULL == 
38
       (scaler_ctx =
39
        sws_getContext (src_width, src_height, src_pixfmt,
40
-		       dst_width, dst_height, PIX_FMT_RGB24, 
41
+		       dst_width, dst_height,
42
+		       PIX_OUTPUT_FORMAT, 
43
 		       SWS_BILINEAR, NULL, NULL, NULL)))
44
     {
45
 #if DEBUG
46
@@ -199,7 +214,12 @@
47
       return 0;
48
     }
49
 
50
-  if (NULL == (dst_frame = avcodec_alloc_frame ()))
51
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
52
+  dst_frame = av_frame_alloc ();
53
+#else
54
+  dst_frame = avcodec_alloc_frame();
55
+#endif
56
+  if (NULL == dst_frame)
57
     {
58
 #if DEBUG
59
       fprintf (stderr,
60
@@ -209,18 +229,24 @@
61
       return 0;
62
     }
63
   if (NULL == (dst_buffer =
64
-	       av_malloc (avpicture_get_size (PIX_FMT_RGB24, dst_width, dst_height))))
65
+	       av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT,
66
+                                              dst_width, dst_height))))
67
     {
68
 #if DEBUG
69
       fprintf (stderr,
70
                "Failed to allocate the destination image buffer\n");
71
 #endif
72
-      av_free (dst_frame);
73
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
74
+      av_frame_free (&dst_frame);
75
+#else
76
+      avcodec_free_frame (&dst_frame);
77
+#endif
78
       sws_freeContext (scaler_ctx);
79
       return 0;
80
     }
81
   avpicture_fill ((AVPicture *) dst_frame, dst_buffer,
82
-                  PIX_FMT_RGB24, dst_width, dst_height);
83
+                  PIX_OUTPUT_FORMAT,
84
+                  dst_width, dst_height);
85
   sws_scale (scaler_ctx,
86
              src_data, 
87
              src_stride,
88
@@ -236,7 +262,11 @@
89
                "Failed to allocate the encoder output buffer\n");
90
 #endif
91
       av_free (dst_buffer);
92
-      av_free (dst_frame);
93
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
94
+      av_frame_free (&dst_frame);
95
+#else
96
+      avcodec_free_frame (&dst_frame);
97
+#endif
98
       sws_freeContext (scaler_ctx);
99
       return 0;
100
     }
101
@@ -249,13 +279,17 @@
102
 #endif
103
       av_free (encoder_output_buffer);
104
       av_free (dst_buffer);
105
-      av_free (dst_frame);
106
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
107
+      av_frame_free (&dst_frame);
108
+#else
109
+      avcodec_free_frame (&dst_frame);
110
+#endif
111
       sws_freeContext (scaler_ctx);
112
       return 0;
113
     }
114
   encoder_codec_ctx->width = dst_width;
115
   encoder_codec_ctx->height = dst_height;
116
-  encoder_codec_ctx->pix_fmt = PIX_FMT_RGB24;
117
+  encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT;
118
   opts = NULL;
119
   if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0)
120
     {
121
@@ -263,10 +297,14 @@
122
       fprintf (stderr,
123
                "Failed to open the encoder\n");
124
 #endif
125
-      av_free (encoder_codec_ctx);
126
+      avcodec_free_context (&encoder_codec_ctx);
127
       av_free (encoder_output_buffer);
128
       av_free (dst_buffer);
129
-      av_free (dst_frame);
130
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
131
+      av_frame_free (&dst_frame);
132
+#else
133
+      avcodec_free_frame (&dst_frame);
134
+#endif
135
       sws_freeContext  (scaler_ctx);
136
       return 0;
137
     }
138
@@ -295,9 +333,13 @@
139
 cleanup:
140
   av_dict_free (&opts);
141
   avcodec_close (encoder_codec_ctx);
142
-  av_free (encoder_codec_ctx);
143
+  avcodec_free_context (&encoder_codec_ctx);
144
   av_free (dst_buffer);
145
-  av_free (dst_frame);
146
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
147
+  av_frame_free (&dst_frame);
148
+#else
149
+  avcodec_free_frame (&dst_frame);
150
+#endif
151
   sws_freeContext (scaler_ctx);
152
   *output_data = encoder_output_buffer;
153
 
154
@@ -406,18 +448,23 @@
155
       fprintf (stderr,
156
 	       "Failed to open image codec\n");
157
 #endif
158
-      av_free (codec_ctx);
159
+      avcodec_free_context (&codec_ctx);
160
       return;
161
     }
162
   av_dict_free (&opts);
163
-  if (NULL == (frame = avcodec_alloc_frame ()))
164
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
165
+  frame = av_frame_alloc ();
166
+#else
167
+  frame = avcodec_alloc_frame();
168
+#endif
169
+  if (NULL == frame)
170
     {
171
 #if DEBUG
172
       fprintf (stderr,
173
                "Failed to allocate frame\n");
174
 #endif
175
       avcodec_close (codec_ctx);
176
-      av_free (codec_ctx);
177
+      avcodec_free_context (&codec_ctx);
178
       return;
179
     }
180
 
181
@@ -441,9 +488,13 @@
182
       fprintf (stderr,
183
 	       "Failed to decode a complete frame\n");
184
 #endif
185
-      av_free (frame);
186
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
187
+      av_frame_free (&frame);
188
+#else
189
+      avcodec_free_frame (&frame);
190
+#endif
191
       avcodec_close (codec_ctx);
192
-      av_free (codec_ctx);
193
+      avcodec_free_context (&codec_ctx);
194
       return;
195
     }
196
   calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height,
197
@@ -467,9 +518,13 @@
198
 		err);
199
       av_free (encoded_thumbnail);
200
     }
201
-  av_free (frame);
202
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
203
+  av_frame_free (&frame);
204
+#else
205
+  avcodec_free_frame (&frame);
206
+#endif
207
   avcodec_close (codec_ctx);
208
-  av_free (codec_ctx);
209
+  avcodec_free_context (&codec_ctx);
210
 }
211
 
212
 
213
@@ -563,7 +618,12 @@
214
       return;
215
     }
216
 
217
-  if (NULL == (frame = avcodec_alloc_frame ()))
218
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
219
+  frame = av_frame_alloc ();
220
+#else
221
+  frame = avcodec_alloc_frame();
222
+#endif
223
+  if (NULL == frame)
224
     {
225
 #if DEBUG
226
       fprintf (stderr,
227
@@ -616,7 +676,11 @@
228
       fprintf (stderr,
229
 	       "Failed to decode a complete frame\n");
230
 #endif
231
-      av_free (frame);
232
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
233
+      av_frame_free (&frame);
234
+#else
235
+      avcodec_free_frame (&frame);
236
+#endif
237
       avcodec_close (codec_ctx);
238
       avformat_close_input (&format_ctx);
239
       av_free (io_ctx);
240
@@ -643,7 +707,11 @@
241
 		err);
242
       av_free (encoded_thumbnail);
243
     }
244
-  av_free (frame);
245
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
246
+  av_frame_free (&frame);
247
+#else
248
+  avcodec_free_frame (&frame);
249
+#endif
250
   avcodec_close (codec_ctx);
251
   avformat_close_input (&format_ctx);
252
   av_free (io_ctx);
253
--- src/plugins/previewopus_extractor.c.orig
254
+++ src/plugins/previewopus_extractor.c
255
@@ -296,7 +296,12 @@
256
 /** Initialize one audio frame for reading from the input file */
257
 static int init_input_frame(AVFrame **frame)
258
 {
259
-    if (!(*frame = avcodec_alloc_frame())) {
260
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
261
+    *frame = av_frame_alloc ();
262
+#else
263
+    *frame = avcodec_alloc_frame();
264
+#endif
265
+    if (NULL == *frame) {
266
  #if DEBUG
267
         fprintf(stderr, "Could not allocate input frame\n");
268
 #endif
269
@@ -655,7 +660,11 @@
270
         av_freep(&converted_input_samples[0]);
271
         free(converted_input_samples);
272
     }
273
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
274
+    av_frame_free (&input_frame);
275
+#else
276
     avcodec_free_frame(&input_frame);
277
+#endif
278
 
279
     return ret;
280
 }
281
@@ -671,7 +680,12 @@
282
     int error;
283
 
284
     /** Create a new frame to store the audio samples. */
285
-    if (!(*frame = avcodec_alloc_frame())) {
286
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
287
+    *frame = av_frame_alloc ();
288
+#else
289
+    *frame = avcodec_alloc_frame();
290
+#endif
291
+    if (NULL == *frame) {
292
         #if DEBUG
293
 		fprintf(stderr, "Could not allocate output frame\n");
294
 		#endif
295
@@ -702,7 +716,11 @@
296
         #if DEBUG
297
 		fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error));
298
 		#endif
299
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
300
+        av_frame_free (frame);
301
+#else
302
         avcodec_free_frame(frame);
303
+#endif
304
         return error;
305
     }
306
 
307
@@ -783,17 +801,29 @@
308
         #if DEBUG
309
 		fprintf(stderr, "Could not read data from FIFO\n");
310
 		#endif
311
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
312
+        av_frame_free (&output_frame);
313
+#else
314
         avcodec_free_frame(&output_frame);
315
+#endif
316
         return AVERROR_EXIT;
317
     }
318
 
319
     /** Encode one frame worth of audio samples. */
320
     if (encode_audio_frame(output_frame, output_format_context,
321
                            output_codec_context, &data_written)) {
322
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
323
+        av_frame_free (&output_frame);
324
+#else
325
         avcodec_free_frame(&output_frame);
326
+#endif
327
         return AVERROR_EXIT;
328
     }
329
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
330
+    av_frame_free (&output_frame);
331
+#else
332
     avcodec_free_frame(&output_frame);
333
+#endif
334
     return 0;
335
 }
336
 /** Write the trailer of the output file container. */
337
@@ -907,7 +937,12 @@
338
       return;
339
     }
340
 
341
-  if (NULL == (frame = avcodec_alloc_frame ()))
342
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
343
+  frame = av_frame_alloc ();
344
+#else
345
+  frame = avcodec_alloc_frame();
346
+#endif
347
+  if (NULL == frame)
348
     {
349
 #if DEBUG
350
       fprintf (stderr,

Return to bug 209121