Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

# Apple
if(APPLE)
set(CMAKE_PREFIX_PATH "/usr/local/opt/")
find_library(OpenMP_omp_LIBRARY omp HINTS "/usr/local/opt/libomp/lib")

set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/include")
set(OpenMP_C_LIB_NAMES "omp")

set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/include")
set(OpenMP_CXX_LIB_NAMES "omp")
endif()

# Build options
option(BUILD_SHARED_LIBS "Build libvideo2x as a shared library" ON)
option(VIDEO2X_BUILD_CLI "Build the video2x command line interface executable" ON)
Expand All @@ -41,7 +53,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_link_options(/LTCG /OPT:REF /OPT:ICF)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-O3 -ffunction-sections -fdata-sections)
add_link_options(-Wl,-s -flto -Wl,--gc-sections)
if(APPLE)
add_link_options(-dead_strip)
else()
add_link_options(-Wl,-s -flto -Wl,--gc-sections)
endif()
endif()
endif()

Expand Down
4 changes: 4 additions & 0 deletions src/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ int Encoder::init(
return 0;
}

#ifndef __clang__
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
#endif
int Encoder::write_frame(AVFrame* frame, int64_t frame_idx) {
AVFrame* converted_frame = nullptr;
int ret;
Expand Down Expand Up @@ -338,7 +340,9 @@ int Encoder::write_frame(AVFrame* frame, int64_t frame_idx) {
return 0;
}

#ifndef __clang__
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
#endif
int Encoder::flush() {
int ret;
AVPacket* enc_pkt = av_packet_alloc();
Expand Down
2 changes: 2 additions & 0 deletions src/libvideo2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ VideoProcessor::VideoProcessor(
hw_device_type_(hw_device_type),
benchmark_(benchmark) {}

#ifndef __clang__
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
#endif
int VideoProcessor::process(
const std::filesystem::path in_fname,
const std::filesystem::path out_fname
Expand Down