diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-06-26 01:14:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-06-26 01:14:00 +0200 |
commit | 2a90e967727015c9cd20de68f3b2cc5b1a715475 (patch) | |
tree | 94e044e96d4b1e7a77eb99216592477ed549abb0 | |
parent | 8b04a0f003a5a8afe19f071e3017a4bb76c07931 (diff) |
remove support for ancient libav versions
-rw-r--r-- | src/plugins/previewopus_extractor.c | 34 | ||||
-rw-r--r-- | src/plugins/thumbnailffmpeg_extractor.c | 79 |
2 files changed, 3 insertions, 110 deletions
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c index a47cdbc..45ea420 100644 --- a/src/plugins/previewopus_extractor.c +++ b/src/plugins/previewopus_extractor.c @@ -280,11 +280,7 @@ init_packet (AVPacket *packet) static int init_input_frame (AVFrame **frame) { -#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 @@ -694,12 +690,7 @@ cleanup: av_freep (&converted_input_samples[0]); free (converted_input_samples); } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) av_frame_free (&input_frame); -#else - avcodec_free_frame (&input_frame); -#endif - return ret; } @@ -716,11 +707,7 @@ init_output_frame (AVFrame **frame, int error; /** Create a new frame to store the audio samples. */ -#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 @@ -753,11 +740,7 @@ init_output_frame (AVFrame **frame, fprintf (stderr, "Could allocate output frame samples (error '%s')\n", get_error_text (error)); #endif -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) av_frame_free (frame); -#else - avcodec_free_frame (frame); -#endif return error; } @@ -846,11 +829,7 @@ load_encode_and_write (AVAudioFifo *fifo, #if DEBUG fprintf (stderr, "Could not read data from FIFO\n"); #endif -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) av_frame_free (&output_frame); -#else - avcodec_free_frame (&output_frame); -#endif return AVERROR_EXIT; } @@ -858,18 +837,10 @@ load_encode_and_write (AVAudioFifo *fifo, if (encode_audio_frame (output_frame, output_format_context, output_codec_context, &data_written)) { -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) av_frame_free (&output_frame); -#else - avcodec_free_frame (&output_frame); -#endif return AVERROR_EXIT; } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1) av_frame_free (&output_frame); -#else - avcodec_free_frame (&output_frame); -#endif return 0; } @@ -990,11 +961,7 @@ extract_audio (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 @@ -1199,7 +1166,6 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec) ssize_t iret; void *data; - if (-1 == (iret = ec->read (ec->cls, &data, 16 * 1024))) 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); |