aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/previewopus_extractor.c34
-rw-r--r--src/plugins/thumbnailffmpeg_extractor.c79
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)
280static int 280static int
281init_input_frame (AVFrame **frame) 281init_input_frame (AVFrame **frame)
282{ 282{
283#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
284 *frame = av_frame_alloc (); 283 *frame = av_frame_alloc ();
285#else
286 *frame = avcodec_alloc_frame ();
287#endif
288 if (NULL == *frame) 284 if (NULL == *frame)
289 { 285 {
290#if DEBUG 286#if DEBUG
@@ -694,12 +690,7 @@ cleanup:
694 av_freep (&converted_input_samples[0]); 690 av_freep (&converted_input_samples[0]);
695 free (converted_input_samples); 691 free (converted_input_samples);
696 } 692 }
697#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
698 av_frame_free (&input_frame); 693 av_frame_free (&input_frame);
699#else
700 avcodec_free_frame (&input_frame);
701#endif
702
703 return ret; 694 return ret;
704} 695}
705 696
@@ -716,11 +707,7 @@ init_output_frame (AVFrame **frame,
716 int error; 707 int error;
717 708
718 /** Create a new frame to store the audio samples. */ 709 /** Create a new frame to store the audio samples. */
719#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
720 *frame = av_frame_alloc (); 710 *frame = av_frame_alloc ();
721#else
722 *frame = avcodec_alloc_frame ();
723#endif
724 if (NULL == *frame) 711 if (NULL == *frame)
725 { 712 {
726#if DEBUG 713#if DEBUG
@@ -753,11 +740,7 @@ init_output_frame (AVFrame **frame,
753 fprintf (stderr, "Could allocate output frame samples (error '%s')\n", 740 fprintf (stderr, "Could allocate output frame samples (error '%s')\n",
754 get_error_text (error)); 741 get_error_text (error));
755#endif 742#endif
756#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
757 av_frame_free (frame); 743 av_frame_free (frame);
758#else
759 avcodec_free_frame (frame);
760#endif
761 return error; 744 return error;
762 } 745 }
763 746
@@ -846,11 +829,7 @@ load_encode_and_write (AVAudioFifo *fifo,
846#if DEBUG 829#if DEBUG
847 fprintf (stderr, "Could not read data from FIFO\n"); 830 fprintf (stderr, "Could not read data from FIFO\n");
848#endif 831#endif
849#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
850 av_frame_free (&output_frame); 832 av_frame_free (&output_frame);
851#else
852 avcodec_free_frame (&output_frame);
853#endif
854 return AVERROR_EXIT; 833 return AVERROR_EXIT;
855 } 834 }
856 835
@@ -858,18 +837,10 @@ load_encode_and_write (AVAudioFifo *fifo,
858 if (encode_audio_frame (output_frame, output_format_context, 837 if (encode_audio_frame (output_frame, output_format_context,
859 output_codec_context, &data_written)) 838 output_codec_context, &data_written))
860 { 839 {
861#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
862 av_frame_free (&output_frame); 840 av_frame_free (&output_frame);
863#else
864 avcodec_free_frame (&output_frame);
865#endif
866 return AVERROR_EXIT; 841 return AVERROR_EXIT;
867 } 842 }
868#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
869 av_frame_free (&output_frame); 843 av_frame_free (&output_frame);
870#else
871 avcodec_free_frame (&output_frame);
872#endif
873 return 0; 844 return 0;
874} 845}
875 846
@@ -990,11 +961,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
990 return; 961 return;
991 } 962 }
992 963
993#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
994 frame = av_frame_alloc (); 964 frame = av_frame_alloc ();
995#else
996 frame = avcodec_alloc_frame ();
997#endif
998 if (NULL == frame) 965 if (NULL == frame)
999 { 966 {
1000#if DEBUG 967#if DEBUG
@@ -1199,7 +1166,6 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec)
1199 ssize_t iret; 1166 ssize_t iret;
1200 void *data; 1167 void *data;
1201 1168
1202
1203 if (-1 == (iret = ec->read (ec->cls, 1169 if (-1 == (iret = ec->read (ec->cls,
1204 &data, 1170 &data,
1205 16 * 1024))) 1171 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,
195 pkt.size = 0; 195 pkt.size = 0;
196 int gotPacket; 196 int gotPacket;
197#if USE_JPEG 197#if USE_JPEG
198 #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
199 if (NULL == (encoder_codec = avcodec_find_encoder (AV_CODEC_ID_MJPEG))) 198 if (NULL == (encoder_codec = avcodec_find_encoder (AV_CODEC_ID_MJPEG)))
200 #else 199#else
201 if (NULL == (encoder_codec = avcodec_find_encoder (CODEC_ID_MJPEG)))
202 #endif
203 #else
204 if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png"))) 200 if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png")))
205 #endif 201#endif
206 { 202 {
207#if DEBUG 203#if DEBUG
208 fprintf (stderr, 204 fprintf (stderr,
@@ -227,11 +223,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
227 return 0; 223 return 0;
228 } 224 }
229 225
230#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
231 dst_frame = av_frame_alloc (); 226 dst_frame = av_frame_alloc ();
232#else
233 dst_frame = avcodec_alloc_frame ();
234#endif
235 if (NULL == dst_frame) 227 if (NULL == dst_frame)
236 { 228 {
237#if DEBUG 229#if DEBUG
@@ -251,11 +243,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
251 fprintf (stderr, 243 fprintf (stderr,
252 "Failed to allocate the destination image buffer\n"); 244 "Failed to allocate the destination image buffer\n");
253#endif 245#endif
254#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
255 av_frame_free (&dst_frame); 246 av_frame_free (&dst_frame);
256#else
257 avcodec_free_frame (&dst_frame);
258#endif
259 sws_freeContext (scaler_ctx); 247 sws_freeContext (scaler_ctx);
260 return 0; 248 return 0;
261 } 249 }
@@ -281,11 +269,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
281 "Failed to allocate the encoder output buffer\n"); 269 "Failed to allocate the encoder output buffer\n");
282#endif 270#endif
283 av_free (dst_buffer); 271 av_free (dst_buffer);
284#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
285 av_frame_free (&dst_frame); 272 av_frame_free (&dst_frame);
286#else
287 avcodec_free_frame (&dst_frame);
288#endif
289 sws_freeContext (scaler_ctx); 273 sws_freeContext (scaler_ctx);
290 return 0; 274 return 0;
291 } 275 }
@@ -298,11 +282,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
298#endif 282#endif
299 av_free (encoder_output_buffer); 283 av_free (encoder_output_buffer);
300 av_free (dst_buffer); 284 av_free (dst_buffer);
301#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
302 av_frame_free (&dst_frame); 285 av_frame_free (&dst_frame);
303#else
304 avcodec_free_frame (&dst_frame);
305#endif
306 sws_freeContext (scaler_ctx); 286 sws_freeContext (scaler_ctx);
307 return 0; 287 return 0;
308 } 288 }
@@ -310,16 +290,8 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
310 encoder_codec_ctx->height = dst_height; 290 encoder_codec_ctx->height = dst_height;
311#if USE_JPEG 291#if USE_JPEG
312 encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate; 292 encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate;
313#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
314 encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG; 293 encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG;
315#else
316 encoder_codec_ctx->codec_id = CODEC_ID_MJPEG;
317#endif
318#if LIBAVCODEC_BUILD >= AV_VERSION_INT (53,35,0)
319 encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO; 294 encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
320#else
321 encoder_codec_ctx->codec_type = CODEC_TYPE_VIDEO;
322#endif
323 encoder_codec_ctx->time_base.num = pCodecCtx->time_base.num; 295 encoder_codec_ctx->time_base.num = pCodecCtx->time_base.num;
324 encoder_codec_ctx->time_base.den = pCodecCtx->time_base.den; 296 encoder_codec_ctx->time_base.den = pCodecCtx->time_base.den;
325 encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT; 297 encoder_codec_ctx->pix_fmt = PIX_OUTPUT_FORMAT;
@@ -337,11 +309,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
337 avcodec_free_context (&encoder_codec_ctx); 309 avcodec_free_context (&encoder_codec_ctx);
338 av_free (encoder_output_buffer); 310 av_free (encoder_output_buffer);
339 av_free (dst_buffer); 311 av_free (dst_buffer);
340#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
341 av_frame_free (&dst_frame); 312 av_frame_free (&dst_frame);
342#else
343 avcodec_free_frame (&dst_frame);
344#endif
345 sws_freeContext (scaler_ctx); 313 sws_freeContext (scaler_ctx);
346 return 0; 314 return 0;
347 } 315 }
@@ -364,7 +332,6 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
364 dst_frame->quality = encoder_codec_ctx->global_quality; 332 dst_frame->quality = encoder_codec_ctx->global_quality;
365#endif 333#endif
366 334
367#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
368 err = avcodec_encode_video2 (encoder_codec_ctx, 335 err = avcodec_encode_video2 (encoder_codec_ctx,
369 &pkt, 336 &pkt,
370 dst_frame, &gotPacket); 337 dst_frame, &gotPacket);
@@ -375,24 +342,12 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
375 memcpy (encoder_output_buffer,pkt.data, pkt.size); 342 memcpy (encoder_output_buffer,pkt.data, pkt.size);
376 343
377 av_packet_unref (&pkt); 344 av_packet_unref (&pkt);
378
379
380#else
381 err = avcodec_encode_video (encoder_codec_ctx,
382 encoder_output_buffer,
383 encoder_output_buffer_size, dst_frame);
384
385#endif
386cleanup: 345cleanup:
387 av_dict_free (&opts); 346 av_dict_free (&opts);
388 avcodec_close (encoder_codec_ctx); 347 avcodec_close (encoder_codec_ctx);
389 avcodec_free_context (&encoder_codec_ctx); 348 avcodec_free_context (&encoder_codec_ctx);
390 av_free (dst_buffer); 349 av_free (dst_buffer);
391#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
392 av_frame_free (&dst_frame); 350 av_frame_free (&dst_frame);
393#else
394 avcodec_free_frame (&dst_frame);
395#endif
396 sws_freeContext (scaler_ctx); 351 sws_freeContext (scaler_ctx);
397 *output_data = encoder_output_buffer; 352 *output_data = encoder_output_buffer;
398 353
@@ -448,11 +403,7 @@ calculate_thumbnail_dimensions (int src_width,
448} 403}
449 404
450 405
451#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0) 406#define ENUM_CODEC_ID enum AVCodecID
452 #define ENUM_CODEC_ID enum AVCodecID
453#else
454 #define ENUM_CODEC_ID enum CodecID
455#endif
456 407
457/** 408/**
458 * Perform thumbnailing when the input is an image. 409 * Perform thumbnailing when the input is an image.
@@ -505,11 +456,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
505 return; 456 return;
506 } 457 }
507 av_dict_free (&opts); 458 av_dict_free (&opts);
508#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
509 frame = av_frame_alloc (); 459 frame = av_frame_alloc ();
510#else
511 frame = avcodec_alloc_frame ();
512#endif
513 if (NULL == frame) 460 if (NULL == frame)
514 { 461 {
515#if DEBUG 462#if DEBUG
@@ -541,11 +488,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
541 fprintf (stderr, 488 fprintf (stderr,
542 "Failed to decode a complete frame\n"); 489 "Failed to decode a complete frame\n");
543#endif 490#endif
544#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
545 av_frame_free (&frame); 491 av_frame_free (&frame);
546#else
547 avcodec_free_frame (&frame);
548#endif
549 avcodec_close (codec_ctx); 492 avcodec_close (codec_ctx);
550 avcodec_free_context (&codec_ctx); 493 avcodec_free_context (&codec_ctx);
551 return; 494 return;
@@ -591,11 +534,7 @@ extract_image (ENUM_CODEC_ID image_codec_id,
591 534
592 av_free (encoded_thumbnail); 535 av_free (encoded_thumbnail);
593 } 536 }
594#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
595 av_frame_free (&frame); 537 av_frame_free (&frame);
596#else
597 avcodec_free_frame (&frame);
598#endif
599 avcodec_close (codec_ctx); 538 avcodec_close (codec_ctx);
600 avcodec_free_context (&codec_ctx); 539 avcodec_free_context (&codec_ctx);
601} 540}
@@ -698,11 +637,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
698 return; 637 return;
699 } 638 }
700 639
701#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
702 frame = av_frame_alloc (); 640 frame = av_frame_alloc ();
703#else
704 frame = avcodec_alloc_frame ();
705#endif
706 if (NULL == frame) 641 if (NULL == frame)
707 { 642 {
708#if DEBUG 643#if DEBUG
@@ -766,11 +701,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
766 fprintf (stderr, 701 fprintf (stderr,
767 "Failed to decode a complete frame\n"); 702 "Failed to decode a complete frame\n");
768#endif 703#endif
769#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
770 av_frame_free (&frame); 704 av_frame_free (&frame);
771#else
772 avcodec_free_frame (&frame);
773#endif
774 avcodec_close (codec_ctx); 705 avcodec_close (codec_ctx);
775 avformat_close_input (&format_ctx); 706 avformat_close_input (&format_ctx);
776 av_free (io_ctx); 707 av_free (io_ctx);
@@ -813,11 +744,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
813#endif 744#endif
814 av_free (encoded_thumbnail); 745 av_free (encoded_thumbnail);
815 } 746 }
816#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
817 av_frame_free (&frame); 747 av_frame_free (&frame);
818#else
819 avcodec_free_frame (&frame);
820#endif
821 avcodec_close (codec_ctx); 748 avcodec_close (codec_ctx);
822 avformat_close_input (&format_ctx); 749 avformat_close_input (&format_ctx);
823 av_free (io_ctx); 750 av_free (io_ctx);