aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/thumbnailffmpeg_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/thumbnailffmpeg_extractor.c')
-rw-r--r--src/plugins/thumbnailffmpeg_extractor.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c
index 72f0137..9bed4ec 100644
--- a/src/plugins/thumbnailffmpeg_extractor.c
+++ b/src/plugins/thumbnailffmpeg_extractor.c
@@ -38,26 +38,11 @@
38#include "extractor.h" 38#include "extractor.h"
39#include <magic.h> 39#include <magic.h>
40 40
41#if HAVE_LIBAVUTIL_AVUTIL_H
42#include <libavutil/avutil.h> 41#include <libavutil/avutil.h>
43#elif HAVE_FFMPEG_AVUTIL_H 42#include <libavutil/imgutils.h>
44#include <ffmpeg/avutil.h>
45#endif
46#if HAVE_LIBAVFORMAT_AVFORMAT_H
47#include <libavformat/avformat.h> 43#include <libavformat/avformat.h>
48#elif HAVE_FFMPEG_AVFORMAT_H
49#include <ffmpeg/avformat.h>
50#endif
51#if HAVE_LIBAVCODEC_AVCODEC_H
52#include <libavcodec/avcodec.h> 44#include <libavcodec/avcodec.h>
53#elif HAVE_FFMPEG_AVCODEC_H
54#include <ffmpeg/avcodec.h>
55#endif
56#if HAVE_LIBSWSCALE_SWSCALE_H
57#include <libswscale/swscale.h> 45#include <libswscale/swscale.h>
58#elif HAVE_FFMPEG_SWSCALE_H
59#include <ffmpeg/swscale.h>
60#endif
61 46
62#if USE_JPEG 47#if USE_JPEG
63#ifdef PIX_FMT_YUVJ420P 48#ifdef PIX_FMT_YUVJ420P
@@ -257,8 +242,10 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
257 return 0; 242 return 0;
258 } 243 }
259 if (NULL == (dst_buffer = 244 if (NULL == (dst_buffer =
260 av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT, 245 av_malloc (av_image_get_buffer_size (PIX_OUTPUT_FORMAT,
261 dst_width, dst_height)))) 246 dst_width,
247 dst_height,
248 1))))
262 { 249 {
263#if DEBUG 250#if DEBUG
264 fprintf (stderr, 251 fprintf (stderr,
@@ -272,9 +259,13 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
272 sws_freeContext (scaler_ctx); 259 sws_freeContext (scaler_ctx);
273 return 0; 260 return 0;
274 } 261 }
275 avpicture_fill ((AVPicture *) dst_frame, dst_buffer, 262 av_image_fill_arrays (dst_frame->data,
276 PIX_OUTPUT_FORMAT, 263 dst_frame->linesize,
277 dst_width, dst_height); 264 dst_buffer,
265 PIX_OUTPUT_FORMAT,
266 dst_width,
267 dst_height,
268 1);
278 sws_scale (scaler_ctx, 269 sws_scale (scaler_ctx,
279 src_data, 270 src_data,
280 src_stride, 271 src_stride,
@@ -383,7 +374,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
383 err = pkt.size; 374 err = pkt.size;
384 memcpy (encoder_output_buffer,pkt.data, pkt.size); 375 memcpy (encoder_output_buffer,pkt.data, pkt.size);
385 376
386 av_free_packet (&pkt); 377 av_packet_unref (&pkt);
387 378
388 379
389#else 380#else
@@ -622,6 +613,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
622 AVIOContext *io_ctx; 613 AVIOContext *io_ctx;
623 struct AVFormatContext *format_ctx; 614 struct AVFormatContext *format_ctx;
624 AVCodecContext *codec_ctx; 615 AVCodecContext *codec_ctx;
616 AVCodecParameters *codecpar;
625 AVCodec *codec; 617 AVCodec *codec;
626 AVDictionary *options; 618 AVDictionary *options;
627 AVFrame *frame; 619 AVFrame *frame;
@@ -675,10 +667,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
675 video_stream_index = -1; 667 video_stream_index = -1;
676 for (i = 0; i<format_ctx->nb_streams; i++) 668 for (i = 0; i<format_ctx->nb_streams; i++)
677 { 669 {
670 codecpar = format_ctx->streams[i]->codecpar;
678 codec_ctx = format_ctx->streams[i]->codec; 671 codec_ctx = format_ctx->streams[i]->codec;
679 if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type) 672 if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type)
680 continue; 673 continue;
681 if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) 674 if (NULL == (codec = avcodec_find_decoder (codecpar->codec_id)))
682 continue; 675 continue;
683 options = NULL; 676 options = NULL;
684 if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) 677 if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
@@ -760,11 +753,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
760 &packet); 753 &packet);
761 if (frame_finished && frame->key_frame) 754 if (frame_finished && frame->key_frame)
762 { 755 {
763 av_free_packet (&packet); 756 av_packet_unref (&packet);
764 break; 757 break;
765 } 758 }
766 } 759 }
767 av_free_packet (&packet); 760 av_packet_unref (&packet);
768 } 761 }
769 762
770 if (! frame_finished) 763 if (! frame_finished)
@@ -945,7 +938,6 @@ void __attribute__ ((constructor))
945thumbnailffmpeg_lib_init (void) 938thumbnailffmpeg_lib_init (void)
946{ 939{
947 av_log_set_callback (&thumbnailffmpeg_av_log_callback); 940 av_log_set_callback (&thumbnailffmpeg_av_log_callback);
948 av_register_all ();
949 magic = magic_open (MAGIC_MIME_TYPE); 941 magic = magic_open (MAGIC_MIME_TYPE);
950 if (0 != magic_load (magic, NULL)) 942 if (0 != magic_load (magic, NULL))
951 { 943 {