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