diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cace4b..2b021c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(video2x VERSION 6.3.1 LANGUAGES CXX) # The FindBoost module is removed in CMake 3.30 @@ -346,10 +346,10 @@ target_include_directories(libvideo2x PRIVATE ) # Set the compile options for the shared library -if(MSVC) - target_compile_options(libvideo2x PRIVATE $<$:/Zi /DDEBUG>) -else() - target_compile_options(libvideo2x PRIVATE -fPIC $<$:-g -DDEBUG>) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(libvideo2x PRIVATE $<$:/Zi /Od /MDd>) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(libvideo2x PRIVATE -fPIC $<$:-g -O0>) endif() # Define the paths to the shared libraries diff --git a/src/avutils.cpp b/src/avutils.cpp index 1001f88..9014da1 100644 --- a/src/avutils.cpp +++ b/src/avutils.cpp @@ -135,7 +135,7 @@ AVPixelFormat get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat return best_pix_fmt; } -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] float get_frame_diff(AVFrame *frame1, AVFrame *frame2) { if (!frame1 || !frame2) { logger()->error("Invalid frame(s) provided for comparison"); diff --git a/src/conversions.cpp b/src/conversions.cpp index d3d2885..71dba36 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -11,7 +11,7 @@ namespace video2x { namespace conversions { // Convert AVFrame format -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) { AVFrame *dst_frame = av_frame_alloc(); if (dst_frame == nullptr) { @@ -68,7 +68,7 @@ AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) { } // Convert AVFrame to ncnn::Mat by copying the data -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame) { AVFrame *converted_frame = nullptr; @@ -108,7 +108,7 @@ ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame) { } // Convert ncnn::Mat to AVFrame with a specified pixel format (this part is unchanged) -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) { int ret; diff --git a/src/encoder.cpp b/src/encoder.cpp index efa940d..68ee387 100644 --- a/src/encoder.cpp +++ b/src/encoder.cpp @@ -254,7 +254,7 @@ int Encoder::init( return 0; } -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) { AVFrame *converted_frame = nullptr; int ret; @@ -326,7 +326,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) { return 0; } -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] int Encoder::flush() { int ret; AVPacket *enc_pkt = av_packet_alloc(); diff --git a/src/libvideo2x.cpp b/src/libvideo2x.cpp index f86f2a4..cb72c55 100644 --- a/src/libvideo2x.cpp +++ b/src/libvideo2x.cpp @@ -28,7 +28,7 @@ VideoProcessor::VideoProcessor( hw_device_type_(hw_device_type), benchmark_(benchmark) {} -[[gnu::target_clones("default", "avx2", "avx512f")]] +[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]] int VideoProcessor::process( const std::filesystem::path in_fname, const std::filesystem::path out_fname