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