summaryrefslogtreecommitdiff
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.c79
1 files changed, 3 insertions, 76 deletions
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c
index 9bed4ec..ef7a05f 100644
--- a/src/plugins/thumbnailffmpeg_extractor.c
+++ b/src/plugins/thumbnailffmpeg_extractor.c
@@ -195,14 +195,10 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
pkt.size = 0;
int gotPacket;
#if USE_JPEG
- #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
if (NULL == (encoder_codec = avcodec_find_encoder (AV_CODEC_ID_MJPEG)))
- #else
- if (NULL == (encoder_codec = avcodec_find_encoder (CODEC_ID_MJPEG)))
- #endif
- #else
+#else
if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png")))
- #endif
+#endif
{
#if DEBUG
fprintf (stderr,
@@ -227,11 +223,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
return 0;
}
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
dst_frame = av_frame_alloc ();
-#else
- dst_frame = avcodec_alloc_frame ();
-#endif
if (NULL == dst_frame)
{
#if DEBUG
@@ -251,11 +243,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
fprintf (stderr,
"Failed to allocate the destination image buffer\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
-#else
- avcodec_free_frame (&dst_frame);
-#endif
sws_freeContext (scaler_ctx);
return 0;
}
@@ -281,11 +269,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
"Failed to allocate the encoder output buffer\n");
#endif
av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
-#else
- avcodec_free_frame (&dst_frame);
-#endif
sws_freeContext (scaler_ctx);
return 0;
}
@@ -298,11 +282,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
#endif
av_free (encoder_output_buffer);
av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
-#else
- avcodec_free_frame (&dst_frame);
-#endif
sws_freeContext (scaler_ctx);
return 0;
}
@@ -310,16 +290,8 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
encoder_codec_ctx->height = dst_height;
#if USE_JPEG
encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate;
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG;
-#else
- encoder_codec_ctx->codec_id = CODEC_ID_MJPEG;
-#endif
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT (53,35,0)
encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
-#else
- encoder_codec_ctx->codec_type = CODEC_TYPE_VIDEO;
-#endif
encoder_codec_ctx->time_base.num = pCodecCtx->time_base.num;
encoder_codec_ctx->time_base.den = pCodecCtx->time_base.den;
encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT;
@@ -337,11 +309,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
avcodec_free_context (&encoder_codec_ctx);
av_free (encoder_output_buffer);
av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
-#else
- avcodec_free_frame (&dst_frame);
-#endif
sws_freeContext (scaler_ctx);
return 0;
}
@@ -364,7 +332,6 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
dst_frame->quality = encoder_codec_ctx->global_quality;
#endif
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
err = avcodec_encode_video2 (encoder_codec_ctx,
&pkt,
dst_frame, &gotPacket);
@@ -375,24 +342,12 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
memcpy (encoder_output_buffer,pkt.data, pkt.size);
av_packet_unref (&pkt);
-
-
-#else
- err = avcodec_encode_video (encoder_codec_ctx,
- encoder_output_buffer,
- encoder_output_buffer_size, dst_frame);
-
-#endif
cleanup:
av_dict_free (&opts);
avcodec_close (encoder_codec_ctx);
avcodec_free_context (&encoder_codec_ctx);
av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
-#else
- avcodec_free_frame (&dst_frame);
-#endif
sws_freeContext (scaler_ctx);
*output_data = encoder_output_buffer;
@@ -448,11 +403,7 @@ calculate_thumbnail_dimensions (int src_width,
}
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
- #define ENUM_CODEC_ID enum AVCodecID
-#else
- #define ENUM_CODEC_ID enum CodecID
-#endif
+#define ENUM_CODEC_ID enum AVCodecID
/**
* Perform thumbnailing when the input is an image.
@@ -505,11 +456,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
return;
}
av_dict_free (&opts);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
frame = av_frame_alloc ();
-#else
- frame = avcodec_alloc_frame ();
-#endif
if (NULL == frame)
{
#if DEBUG
@@ -541,11 +488,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
fprintf (stderr,
"Failed to decode a complete frame\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
-#else
- avcodec_free_frame (&frame);
-#endif
avcodec_close (codec_ctx);
avcodec_free_context (&codec_ctx);
return;
@@ -591,11 +534,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
av_free (encoded_thumbnail);
}
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
-#else
- avcodec_free_frame (&frame);
-#endif
avcodec_close (codec_ctx);
avcodec_free_context (&codec_ctx);
}
@@ -698,11 +637,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
return;
}
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
frame = av_frame_alloc ();
-#else
- frame = avcodec_alloc_frame ();
-#endif
if (NULL == frame)
{
#if DEBUG
@@ -766,11 +701,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
fprintf (stderr,
"Failed to decode a complete frame\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
-#else
- avcodec_free_frame (&frame);
-#endif
avcodec_close (codec_ctx);
avformat_close_input (&format_ctx);
av_free (io_ctx);
@@ -813,11 +744,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
#endif
av_free (encoded_thumbnail);
}
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
-#else
- avcodec_free_frame (&frame);
-#endif
avcodec_close (codec_ctx);
avformat_close_input (&format_ctx);
av_free (io_ctx);