diff options
author | LRN <lrn1986@gmail.com> | 2015-04-21 15:52:22 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2015-04-21 15:52:22 +0000 |
commit | 9942b74efc813b4a309c0f570d07b222b98f3795 (patch) | |
tree | 50579d90c516846fccb49c29b3570f3e1791d3c7 | |
parent | 35ba8cb93b1c2521c749246ecedb3356870de572 (diff) | |
download | libextractor-9942b74efc813b4a309c0f570d07b222b98f3795.tar.gz libextractor-9942b74efc813b4a309c0f570d07b222b98f3795.zip |
Make thumbnailffmpeg compatible with newer libav versions
-rw-r--r-- | src/plugins/thumbnailffmpeg_extractor.c | 87 |
1 files changed, 69 insertions, 18 deletions
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c index 8bfd7d1..1185945 100644 --- a/src/plugins/thumbnailffmpeg_extractor.c +++ b/src/plugins/thumbnailffmpeg_extractor.c | |||
@@ -222,7 +222,12 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | ||
225 | if (NULL == (dst_frame = avcodec_alloc_frame ())) | 225 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
226 | dst_frame = av_frame_alloc (); | ||
227 | #else | ||
228 | dst_frame = avcodec_alloc_frame(); | ||
229 | #endif | ||
230 | if (NULL == dst_frame) | ||
226 | { | 231 | { |
227 | #if DEBUG | 232 | #if DEBUG |
228 | fprintf (stderr, | 233 | fprintf (stderr, |
@@ -244,7 +249,11 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
244 | fprintf (stderr, | 249 | fprintf (stderr, |
245 | "Failed to allocate the destination image buffer\n"); | 250 | "Failed to allocate the destination image buffer\n"); |
246 | #endif | 251 | #endif |
247 | av_free (dst_frame); | 252 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
253 | av_frame_free (&dst_frame); | ||
254 | #else | ||
255 | avcodec_free_frame (&dst_frame); | ||
256 | #endif | ||
248 | sws_freeContext (scaler_ctx); | 257 | sws_freeContext (scaler_ctx); |
249 | return 0; | 258 | return 0; |
250 | } | 259 | } |
@@ -270,7 +279,11 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
270 | "Failed to allocate the encoder output buffer\n"); | 279 | "Failed to allocate the encoder output buffer\n"); |
271 | #endif | 280 | #endif |
272 | av_free (dst_buffer); | 281 | av_free (dst_buffer); |
273 | av_free (dst_frame); | 282 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
283 | av_frame_free (&dst_frame); | ||
284 | #else | ||
285 | avcodec_free_frame (&dst_frame); | ||
286 | #endif | ||
274 | sws_freeContext (scaler_ctx); | 287 | sws_freeContext (scaler_ctx); |
275 | return 0; | 288 | return 0; |
276 | } | 289 | } |
@@ -283,7 +296,11 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
283 | #endif | 296 | #endif |
284 | av_free (encoder_output_buffer); | 297 | av_free (encoder_output_buffer); |
285 | av_free (dst_buffer); | 298 | av_free (dst_buffer); |
286 | av_free (dst_frame); | 299 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
300 | av_frame_free (&dst_frame); | ||
301 | #else | ||
302 | avcodec_free_frame (&dst_frame); | ||
303 | #endif | ||
287 | sws_freeContext (scaler_ctx); | 304 | sws_freeContext (scaler_ctx); |
288 | return 0; | 305 | return 0; |
289 | } | 306 | } |
@@ -315,10 +332,14 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
315 | fprintf (stderr, | 332 | fprintf (stderr, |
316 | "Failed to open the encoder\n"); | 333 | "Failed to open the encoder\n"); |
317 | #endif | 334 | #endif |
318 | av_free (encoder_codec_ctx); | 335 | avcodec_free_context (&encoder_codec_ctx); |
319 | av_free (encoder_output_buffer); | 336 | av_free (encoder_output_buffer); |
320 | av_free (dst_buffer); | 337 | av_free (dst_buffer); |
321 | av_free (dst_frame); | 338 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
339 | av_frame_free (&dst_frame); | ||
340 | #else | ||
341 | avcodec_free_frame (&dst_frame); | ||
342 | #endif | ||
322 | sws_freeContext (scaler_ctx); | 343 | sws_freeContext (scaler_ctx); |
323 | return 0; | 344 | return 0; |
324 | } | 345 | } |
@@ -357,9 +378,13 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height, | |||
357 | cleanup: | 378 | cleanup: |
358 | av_dict_free (&opts); | 379 | av_dict_free (&opts); |
359 | avcodec_close (encoder_codec_ctx); | 380 | avcodec_close (encoder_codec_ctx); |
360 | av_free (encoder_codec_ctx); | 381 | avcodec_free_context (&encoder_codec_ctx); |
361 | av_free (dst_buffer); | 382 | av_free (dst_buffer); |
362 | av_free (dst_frame); | 383 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
384 | av_frame_free (&dst_frame); | ||
385 | #else | ||
386 | avcodec_free_frame (&dst_frame); | ||
387 | #endif | ||
363 | sws_freeContext (scaler_ctx); | 388 | sws_freeContext (scaler_ctx); |
364 | *output_data = encoder_output_buffer; | 389 | *output_data = encoder_output_buffer; |
365 | 390 | ||
@@ -468,18 +493,23 @@ extract_image (ENUM_CODEC_ID image_codec_id, | |||
468 | fprintf (stderr, | 493 | fprintf (stderr, |
469 | "Failed to open image codec\n"); | 494 | "Failed to open image codec\n"); |
470 | #endif | 495 | #endif |
471 | av_free (codec_ctx); | 496 | avcodec_free_context (&codec_ctx); |
472 | return; | 497 | return; |
473 | } | 498 | } |
474 | av_dict_free (&opts); | 499 | av_dict_free (&opts); |
475 | if (NULL == (frame = avcodec_alloc_frame ())) | 500 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
501 | frame = av_frame_alloc (); | ||
502 | #else | ||
503 | frame = avcodec_alloc_frame(); | ||
504 | #endif | ||
505 | if (NULL == frame) | ||
476 | { | 506 | { |
477 | #if DEBUG | 507 | #if DEBUG |
478 | fprintf (stderr, | 508 | fprintf (stderr, |
479 | "Failed to allocate frame\n"); | 509 | "Failed to allocate frame\n"); |
480 | #endif | 510 | #endif |
481 | avcodec_close (codec_ctx); | 511 | avcodec_close (codec_ctx); |
482 | av_free (codec_ctx); | 512 | avcodec_free_context (&codec_ctx); |
483 | return; | 513 | return; |
484 | } | 514 | } |
485 | 515 | ||
@@ -503,9 +533,13 @@ extract_image (ENUM_CODEC_ID image_codec_id, | |||
503 | fprintf (stderr, | 533 | fprintf (stderr, |
504 | "Failed to decode a complete frame\n"); | 534 | "Failed to decode a complete frame\n"); |
505 | #endif | 535 | #endif |
506 | av_free (frame); | 536 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
537 | av_frame_free (&frame); | ||
538 | #else | ||
539 | avcodec_free_frame (&frame); | ||
540 | #endif | ||
507 | avcodec_close (codec_ctx); | 541 | avcodec_close (codec_ctx); |
508 | av_free (codec_ctx); | 542 | avcodec_free_context (&codec_ctx); |
509 | return; | 543 | return; |
510 | } | 544 | } |
511 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, | 545 | calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height, |
@@ -548,9 +582,13 @@ extract_image (ENUM_CODEC_ID image_codec_id, | |||
548 | 582 | ||
549 | av_free (encoded_thumbnail); | 583 | av_free (encoded_thumbnail); |
550 | } | 584 | } |
551 | av_free (frame); | 585 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
586 | av_frame_free (&frame); | ||
587 | #else | ||
588 | avcodec_free_frame (&frame); | ||
589 | #endif | ||
552 | avcodec_close (codec_ctx); | 590 | avcodec_close (codec_ctx); |
553 | av_free (codec_ctx); | 591 | avcodec_free_context (&codec_ctx); |
554 | } | 592 | } |
555 | 593 | ||
556 | 594 | ||
@@ -644,7 +682,12 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
644 | return; | 682 | return; |
645 | } | 683 | } |
646 | 684 | ||
647 | if (NULL == (frame = avcodec_alloc_frame ())) | 685 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
686 | frame = av_frame_alloc (); | ||
687 | #else | ||
688 | frame = avcodec_alloc_frame(); | ||
689 | #endif | ||
690 | if (NULL == frame) | ||
648 | { | 691 | { |
649 | #if DEBUG | 692 | #if DEBUG |
650 | fprintf (stderr, | 693 | fprintf (stderr, |
@@ -712,7 +755,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
712 | fprintf (stderr, | 755 | fprintf (stderr, |
713 | "Failed to decode a complete frame\n"); | 756 | "Failed to decode a complete frame\n"); |
714 | #endif | 757 | #endif |
715 | av_free (frame); | 758 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
759 | av_frame_free (&frame); | ||
760 | #else | ||
761 | avcodec_free_frame (&frame); | ||
762 | #endif | ||
716 | avcodec_close (codec_ctx); | 763 | avcodec_close (codec_ctx); |
717 | avformat_close_input (&format_ctx); | 764 | avformat_close_input (&format_ctx); |
718 | av_free (io_ctx); | 765 | av_free (io_ctx); |
@@ -756,7 +803,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
756 | #endif | 803 | #endif |
757 | av_free (encoded_thumbnail); | 804 | av_free (encoded_thumbnail); |
758 | } | 805 | } |
759 | av_free (frame); | 806 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) |
807 | av_frame_free (&frame); | ||
808 | #else | ||
809 | avcodec_free_frame (&frame); | ||
810 | #endif | ||
760 | avcodec_close (codec_ctx); | 811 | avcodec_close (codec_ctx); |
761 | avformat_close_input (&format_ctx); | 812 | avformat_close_input (&format_ctx); |
762 | av_free (io_ctx); | 813 | av_free (io_ctx); |