From a15cc3aa4f7baf88e44682f36268fecf16d8363b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 18 Dec 2022 17:05:04 +0200 Subject: [PATCH] thumbnailers: use video_thumbnailer_set_size() if available side note: ffmpegthumbnailer::VideoThumbnailer::setThumbnailSize(int) is not marked as deprecated Signed-off-by: Ivailo Monev --- thumbnailers/ffmpegthumbs/CMakeLists.txt | 19 +++++++++++++++++++ .../config-ffmpegthumbnailer.h.cmake | 2 ++ .../ffmpegthumbs/ffmpegthumbnailer.cpp | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 thumbnailers/ffmpegthumbs/config-ffmpegthumbnailer.h.cmake diff --git a/thumbnailers/ffmpegthumbs/CMakeLists.txt b/thumbnailers/ffmpegthumbs/CMakeLists.txt index 357fdc77..e98ee186 100644 --- a/thumbnailers/ffmpegthumbs/CMakeLists.txt +++ b/thumbnailers/ffmpegthumbs/CMakeLists.txt @@ -1,9 +1,28 @@ project(ffmpegthumbs) +include(CheckSymbolExists) +include(CMakePushCheckState) + include_directories( + ${CMAKE_CURRENT_BINARY_DIR} ${FFMPEGTHUMBNAILER_INCLUDES} ) +cmake_reset_check_state() +set(CMAKE_REQUIRED_INCLUDES ${FFMPEGTHUMBNAILER_INCLUDES}) +set(CMAKE_REQUIRED_LIBRARIES ${FFMPEGTHUMBNAILER_LIBRARIES}) +check_symbol_exists( + video_thumbnailer_set_size + "libffmpegthumbnailer/videothumbnailerc.h" + HAVE_VIDEO_THUMBNAILER_SET_SIZE +) +cmake_reset_check_state() + +configure_file ( + config-ffmpegthumbnailer.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config-ffmpegthumbnailer.h +) + set(ffmpegthumbs_PART_SRCS ffmpegthumbnailer.cpp ) diff --git a/thumbnailers/ffmpegthumbs/config-ffmpegthumbnailer.h.cmake b/thumbnailers/ffmpegthumbs/config-ffmpegthumbnailer.h.cmake new file mode 100644 index 00000000..910b56ec --- /dev/null +++ b/thumbnailers/ffmpegthumbs/config-ffmpegthumbnailer.h.cmake @@ -0,0 +1,2 @@ +/* Defines if you have video_thumbnailer_set_size() */ +#cmakedefine HAVE_VIDEO_THUMBNAILER_SET_SIZE 1 diff --git a/thumbnailers/ffmpegthumbs/ffmpegthumbnailer.cpp b/thumbnailers/ffmpegthumbs/ffmpegthumbnailer.cpp index e5fbad7f..f67f0780 100644 --- a/thumbnailers/ffmpegthumbs/ffmpegthumbnailer.cpp +++ b/thumbnailers/ffmpegthumbs/ffmpegthumbnailer.cpp @@ -16,6 +16,7 @@ Boston, MA 02110-1301, USA. */ +#include "config-ffmpegthumbnailer.h" #include "ffmpegthumbnailer.h" #include @@ -67,7 +68,11 @@ bool FFMpegThumbnailer::create(const QString &path, int width, int heigth, QImag } const QByteArray pathbytes = QFile::encodeName(path); +#if defined(HAVE_VIDEO_THUMBNAILER_SET_SIZE) + video_thumbnailer_set_size(ffmpegthumb, width, heigth); +#else ffmpegthumb->thumbnail_size = qMax(width, heigth); +#endif ffmpegthumb->seek_percentage = 20; ffmpegthumb->overlay_film_strip = 1; ffmpegthumb->thumbnail_image_type = ThumbnailerImageType::Png;