diff --git a/CMakeLists.txt b/CMakeLists.txt index f9879b2af..09476b6d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -469,18 +469,9 @@ else() set(optlibsnotfound "${optlibsnotfound} AVDevice") endif() -find_package(FFMPEG COMPONENTS avutil) -if(FFMPEG_avutil_FOUND) - set(HAVE_LIBAVUTIL 1) - set(HAVE_LIBAVUTIL_AVUTIL_H 1) - set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS}) - check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) - check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) - list(APPEND ZM_BIN_LIBS "${FFMPEG_avutil_LIBRARIES}") - set(optlibsfound "${optlibsfound} AVUtil") -else() - set(optlibsnotfound "${optlibsnotfound} AVUtil") -endif() +find_package(FFMPEG REQUIRED COMPONENTS avutil) +set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_avutil_INCLUDE_DIRS}) +check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) find_package(FFMPEG COMPONENTS swscale) if(FFMPEG_swscale_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6d3ce1fb..1c89ad930 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,6 +77,7 @@ target_include_directories(zm target_link_libraries(zm PUBLIC + FFMPEG::avutil libbcrypt::bcrypt RtspServer::RtspServer martinmoene::span-lite diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 53cc907f8..ee3649618 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -27,8 +27,6 @@ extern "C" { #include "libavutil/pixdesc.h" } -#if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE - void log_libav_callback(void *ptr, int level, const char *fmt, va_list vargs) { Logger *log = Logger::fetch(); int log_level = 0; @@ -100,7 +98,6 @@ void FFMPEGDeInit() { bInit = false; } -#if HAVE_LIBAVUTIL enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder) { enum _AVPIXELFORMAT pf; @@ -190,11 +187,8 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, return 0; } #endif -#endif // HAVE_LIBAVUTIL -#endif // HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE -#if HAVE_LIBAVUTIL #if LIBAVUTIL_VERSION_CHECK(56, 0, 0, 17, 100) int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb){ int64_t a, b, this_thing; @@ -219,7 +213,6 @@ simple_round: return av_rescale_q(this_thing, fs_tb, out_tb); } #endif -#endif static void zm_log_fps(double d, const char *postfix) { uint64_t v = lrintf(d * 100); diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index 704c46d25..178e1613c 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -30,7 +30,6 @@ extern "C" { #endif // AVUTIL -#if HAVE_LIBAVUTIL_AVUTIL_H #include "libavutil/avassert.h" #include #include @@ -109,7 +108,6 @@ extern "C" { //#define AV_PIX_FMT_VDPAU_MPEG1 PIX_FMT_VDPAU_MPEG1 //#define AV_PIX_FMT_VDPAU_MPEG2 PIX_FMT_VDPAU_MPEG2 #endif -#endif /* HAVE_LIBAVUTIL_AVUTIL_H */ // AVCODEC #if HAVE_LIBAVCODEC_AVCODEC_H @@ -179,8 +177,6 @@ extern "C" { } #endif -#if ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) - #if !LIBAVFORMAT_VERSION_CHECK(52, 107, 0, 107, 0) #if defined(AVIO_WRONLY) #define AVIO_FLAG_WRITE AVIO_WRONLY @@ -193,9 +189,7 @@ extern "C" { void FFMPEGInit(); void FFMPEGDeInit(); -#if HAVE_LIBAVUTIL enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder); -#endif // HAVE_LIBAVUTIL #if !LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100) #define AV_CODEC_ID_NONE CODEC_ID_NONE @@ -253,9 +247,6 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp #endif // __cplusplus - -#endif // ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) - #ifndef av_rescale_delta /** * Rescale a timestamp while preserving known durations. diff --git a/src/zm_swscale.cpp b/src/zm_swscale.cpp index c4aa6b738..ff0aec109 100644 --- a/src/zm_swscale.cpp +++ b/src/zm_swscale.cpp @@ -22,7 +22,7 @@ #include "zm_image.h" #include "zm_logger.h" -#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL +#if HAVE_LIBSWSCALE SWScale::SWScale() : gotdefaults(false), swscale_ctx(nullptr), input_avframe(nullptr), output_avframe(nullptr) { Debug(4, "SWScale object created"); } @@ -291,4 +291,4 @@ size_t SWScale::GetBufferSize(enum _AVPIXELFORMAT pf, unsigned int width, unsign return outsize = avpicture_get_size(pf, width,height); #endif } -#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL +#endif // HAVE_LIBSWSCALE diff --git a/src/zm_swscale.h b/src/zm_swscale.h index 8e7e1fa19..026ecc59e 100644 --- a/src/zm_swscale.h +++ b/src/zm_swscale.h @@ -7,7 +7,7 @@ class Image; /* SWScale wrapper class to make our life easier and reduce code reuse */ -#if HAVE_LIBSWSCALE && HAVE_LIBAVUTIL +#if HAVE_LIBSWSCALE class SWScale { public: SWScale(); @@ -32,6 +32,6 @@ class SWScale { unsigned int default_width; unsigned int default_height; }; -#endif // HAVE_LIBSWSCALE && HAVE_LIBAVUTIL +#endif // HAVE_LIBSWSCALE #endif diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 7d5fd2323..db5d0be40 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -40,9 +40,6 @@ #cmakedefine HAVE_LIBAVCODEC_AVCODEC_H 1 #cmakedefine HAVE_LIBAVDEVICE 1 #cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H 1 -#cmakedefine HAVE_LIBAVUTIL 1 -#cmakedefine HAVE_LIBAVUTIL_AVUTIL_H 1 -#cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1 #cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 1 #cmakedefine HAVE_LIBSWSCALE 1 #cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1