1 --- a/src/plugins/thumbnailffmpeg_extractor.c
2 +++ b/src/plugins/thumbnailffmpeg_extractor.c
4 #include <ffmpeg/swscale.h>
8 +#ifdef PIX_FMT_YUVJ420P
9 +#define PIX_OUTPUT_FORMAT PIX_FMT_YUVJ420P
11 +#define PIX_OUTPUT_FORMAT AV_PIX_FMT_YUVJ420P
15 +#define PIX_OUTPUT_FORMAT PIX_FMT_RGB24
17 +#define PIX_OUTPUT_FORMAT AV_PIX_FMT_RGB24
22 * Set to 1 to enable debug output.
26 create_thumbnail (int src_width, int src_height,
28 - enum PixelFormat src_pixfmt,
29 + enum AVPixelFormat src_pixfmt,
30 const uint8_t * const src_data[],
31 int dst_width, int dst_height,
32 uint8_t **output_data,
36 sws_getContext (src_width, src_height, src_pixfmt,
37 - dst_width, dst_height, PIX_FMT_RGB24,
38 + dst_width, dst_height,
40 SWS_BILINEAR, NULL, NULL, NULL)))
47 - if (NULL == (dst_frame = avcodec_alloc_frame ()))
48 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
49 + dst_frame = av_frame_alloc ();
51 + dst_frame = avcodec_alloc_frame();
53 + if (NULL == dst_frame)
60 if (NULL == (dst_buffer =
61 - av_malloc (avpicture_get_size (PIX_FMT_RGB24, dst_width, dst_height))))
62 + av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT,
63 + dst_width, dst_height))))
67 "Failed to allocate the destination image buffer\n");
69 - av_free (dst_frame);
70 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
71 + av_frame_free (&dst_frame);
73 + avcodec_free_frame (&dst_frame);
75 sws_freeContext (scaler_ctx);
78 avpicture_fill ((AVPicture *) dst_frame, dst_buffer,
79 - PIX_FMT_RGB24, dst_width, dst_height);
81 + dst_width, dst_height);
82 sws_scale (scaler_ctx,
86 "Failed to allocate the encoder output buffer\n");
89 - av_free (dst_frame);
90 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
91 + av_frame_free (&dst_frame);
93 + avcodec_free_frame (&dst_frame);
95 sws_freeContext (scaler_ctx);
100 av_free (encoder_output_buffer);
101 av_free (dst_buffer);
102 - av_free (dst_frame);
103 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
104 + av_frame_free (&dst_frame);
106 + avcodec_free_frame (&dst_frame);
108 sws_freeContext (scaler_ctx);
111 encoder_codec_ctx->width = dst_width;
112 encoder_codec_ctx->height = dst_height;
113 - encoder_codec_ctx->pix_fmt = PIX_FMT_RGB24;
114 + encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT;
116 if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0)
118 @@ -263,10 +297,14 @@
120 "Failed to open the encoder\n");
122 - av_free (encoder_codec_ctx);
123 + avcodec_free_context (&encoder_codec_ctx);
124 av_free (encoder_output_buffer);
125 av_free (dst_buffer);
126 - av_free (dst_frame);
127 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
128 + av_frame_free (&dst_frame);
130 + avcodec_free_frame (&dst_frame);
132 sws_freeContext (scaler_ctx);
137 av_dict_free (&opts);
138 avcodec_close (encoder_codec_ctx);
139 - av_free (encoder_codec_ctx);
140 + avcodec_free_context (&encoder_codec_ctx);
141 av_free (dst_buffer);
142 - av_free (dst_frame);
143 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
144 + av_frame_free (&dst_frame);
146 + avcodec_free_frame (&dst_frame);
148 sws_freeContext (scaler_ctx);
149 *output_data = encoder_output_buffer;
151 @@ -406,18 +448,23 @@
153 "Failed to open image codec\n");
155 - av_free (codec_ctx);
156 + avcodec_free_context (&codec_ctx);
159 av_dict_free (&opts);
160 - if (NULL == (frame = avcodec_alloc_frame ()))
161 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
162 + frame = av_frame_alloc ();
164 + frame = avcodec_alloc_frame();
170 "Failed to allocate frame\n");
172 avcodec_close (codec_ctx);
173 - av_free (codec_ctx);
174 + avcodec_free_context (&codec_ctx);
180 "Failed to decode a complete frame\n");
183 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
184 + av_frame_free (&frame);
186 + avcodec_free_frame (&frame);
188 avcodec_close (codec_ctx);
189 - av_free (codec_ctx);
190 + avcodec_free_context (&codec_ctx);
193 calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height,
196 av_free (encoded_thumbnail);
199 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
200 + av_frame_free (&frame);
202 + avcodec_free_frame (&frame);
204 avcodec_close (codec_ctx);
205 - av_free (codec_ctx);
206 + avcodec_free_context (&codec_ctx);
214 - if (NULL == (frame = avcodec_alloc_frame ()))
215 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
216 + frame = av_frame_alloc ();
218 + frame = avcodec_alloc_frame();
226 "Failed to decode a complete frame\n");
229 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
230 + av_frame_free (&frame);
232 + avcodec_free_frame (&frame);
234 avcodec_close (codec_ctx);
235 avformat_close_input (&format_ctx);
239 av_free (encoded_thumbnail);
242 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
243 + av_frame_free (&frame);
245 + avcodec_free_frame (&frame);
247 avcodec_close (codec_ctx);
248 avformat_close_input (&format_ctx);
250 --- a/src/plugins/previewopus_extractor.c
251 +++ b/src/plugins/previewopus_extractor.c
253 /** Initialize one audio frame for reading from the input file */
254 static int init_input_frame(AVFrame **frame)
256 - if (!(*frame = avcodec_alloc_frame())) {
257 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
258 + *frame = av_frame_alloc ();
260 + *frame = avcodec_alloc_frame();
262 + if (NULL == *frame) {
264 fprintf(stderr, "Could not allocate input frame\n");
267 av_freep(&converted_input_samples[0]);
268 free(converted_input_samples);
270 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
271 + av_frame_free (&input_frame);
273 avcodec_free_frame(&input_frame);
281 /** Create a new frame to store the audio samples. */
282 - if (!(*frame = avcodec_alloc_frame())) {
283 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
284 + *frame = av_frame_alloc ();
286 + *frame = avcodec_alloc_frame();
288 + if (NULL == *frame) {
290 fprintf(stderr, "Could not allocate output frame\n");
294 fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error));
296 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
297 + av_frame_free (frame);
299 avcodec_free_frame(frame);
304 @@ -783,17 +801,29 @@
306 fprintf(stderr, "Could not read data from FIFO\n");
308 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
309 + av_frame_free (&output_frame);
311 avcodec_free_frame(&output_frame);
316 /** Encode one frame worth of audio samples. */
317 if (encode_audio_frame(output_frame, output_format_context,
318 output_codec_context, &data_written)) {
319 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
320 + av_frame_free (&output_frame);
322 avcodec_free_frame(&output_frame);
326 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
327 + av_frame_free (&output_frame);
329 avcodec_free_frame(&output_frame);
333 /** Write the trailer of the output file container. */
338 - if (NULL == (frame = avcodec_alloc_frame ()))
339 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
340 + frame = av_frame_alloc ();
342 + frame = avcodec_alloc_frame();