build(cmake): reorganize CMakeLists.txt and make it compatible with Ninja
Some checks are pending
Build / ubuntu (push) Waiting to run
Build / windows (push) Waiting to run
Build / container (push) Waiting to run

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
k4yt3x 2025-01-08 00:00:00 +00:00
parent 953147ede7
commit 8687d7d175
No known key found for this signature in database
6 changed files with 598 additions and 573 deletions

235
.justfile Normal file
View File

@ -0,0 +1,235 @@
BINDIR := "build"
CXX := "clang++"
TEST_VIDEO := "data/standard-test.mp4"
TEST_OUTPUT := "data/output.mp4"
build:
cmake -G Ninja -S . -B {{BINDIR}} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER={{CXX}} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX={{BINDIR}}/video2x-install \
-DVIDEO2X_ENABLE_NATIVE=ON
cmake --build {{BINDIR}} --config Release --parallel --target install
cp {{BINDIR}}/compile_commands.json .
static:
cmake -G Ninja -S . -B {{BINDIR}} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER={{CXX}} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX={{BINDIR}}/video2x-install \
-DBUILD_SHARED_LIBS=OFF \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF
cmake --build {{BINDIR}} --config Release --parallel --target install
cp {{BINDIR}}/compile_commands.json .
debug:
cmake -G Ninja -S . -B {{BINDIR}} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER={{CXX}} \
-DCMAKE_BUILD_TYPE=Debug
cmake --build {{BINDIR}} --config Debug --parallel
cp {{BINDIR}}/compile_commands.json .
windows:
cmake -S . -B {{BINDIR}} \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX={{BINDIR}}/video2x-install
cmake --build {{BINDIR}} --config Release --parallel --target install
windows-debug:
cmake -S . -B {{BINDIR}} \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX={{BINDIR}}/video2x-install
cmake --build {{BINDIR}} --config Debug --parallel
debian:
apt-get update
apt-get install -y --no-install-recommends \
build-essential cmake clang pkg-config ninja-build \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libspdlog-dev \
libboost-program-options-dev
cmake -G Ninja -B /tmp/build -S . \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DCMAKE_CXX_COMPILER={{CXX}} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/tmp/install \
-DINSTALL_BIN_DESTINATION=. \
-DINSTALL_INCLUDE_DESTINATION=include \
-DINSTALL_LIB_DESTINATION=. \
-DINSTALL_MODEL_DESTINATION=.
cmake --build /tmp/build --config Release --target install --parallel
ubuntu2404:
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential cmake pkg-config ninja-build \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libboost-program-options-dev
cmake -G Ninja -B build -S . \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
cmake --build build --config Release --target install --parallel
mkdir -p video2x-linux-ubuntu-amd64/DEBIAN
cp packaging/debian/control.ubuntu2404 video2x-linux-ubuntu-amd64/DEBIAN/control
dpkg-deb --build video2x-linux-ubuntu-amd64
ubuntu2204:
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common
add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential cmake ninja-build \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libboost-program-options-dev
cmake -G Ninja -B build -S . \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
cmake --build build --config Release --target install --parallel
mkdir -p video2x-linux-ubuntu-amd64/DEBIAN
cp packaging/debian/control.ubuntu2204 video2x-linux-ubuntu-amd64/DEBIAN/control
dpkg-deb --build video2x-linux-ubuntu-amd64
clean:
rm -vrf {{BINDIR}} data/output*.* heaptrack*.zst valgrind.log
test-realesrgan:
LD_LIBRARY_PATH={{BINDIR}} {{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realesrgan -s 4 --realesrgan-model realesr-animevideov3
test-realcugan:
LD_LIBRARY_PATH={{BINDIR}} {{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realcugan -s 4 -n 0 --realcugan-model models-se
test-libplacebo:
LD_LIBRARY_PATH={{BINDIR}} {{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a
test-rife:
LD_LIBRARY_PATH={{BINDIR}} {{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p rife -m 4 --rife-model rife-v4.6
memcheck-realesrgan:
LD_LIBRARY_PATH={{BINDIR}} valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realesrgan -s 2 --realesrgan-model realesr-animevideov3 \
-e preset=veryfast -e crf=30
memcheck-realcugan:
LD_LIBRARY_PATH={{BINDIR}} valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realcugan -s 2 -n 0 --realcugan-model models-se \
-e preset=veryfast -e crf=30
memcheck-libplacebo:
LD_LIBRARY_PATH={{BINDIR}} valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a \
-e preset=veryfast -e crf=30
memcheck-rife:
LD_LIBRARY_PATH={{BINDIR}} valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p rife -m 4 --rife-model rife-v4.6 \
-e preset=veryfast -e crf=30
heaptrack-realesrgan:
LD_LIBRARY_PATH={{BINDIR}} HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realesrgan -s 4 --realesrgan-model realesr-animevideov3 \
-e preset=veryfast -e crf=30
heaptrack-realcugan:
LD_LIBRARY_PATH={{BINDIR}} HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p realcugan -s 4 -n 0 --realcugan-model models-se \
-e preset=veryfast -e crf=30
heaptrack-libplacebo:
LD_LIBRARY_PATH={{BINDIR}} HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a \
-e preset=veryfast -e crf=30
heaptrack-rife:
LD_LIBRARY_PATH={{BINDIR}} HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
{{BINDIR}}/video2x \
-i {{TEST_VIDEO}} -o {{TEST_OUTPUT}} \
-p rife -m 4 --rife-model rife-v4.6 \
-e preset=veryfast -e crf=30

View File

@ -10,11 +10,6 @@ if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW) cmake_policy(SET CMP0167 NEW)
endif() endif()
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the default build type to Release if not specified # Set the default build type to Release if not specified
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
@ -24,15 +19,15 @@ endif()
option(BUILD_SHARED_LIBS "Build libvideo2x as a shared library" ON) option(BUILD_SHARED_LIBS "Build libvideo2x as a shared library" ON)
option(VIDEO2X_BUILD_CLI "Build the video2x command line interface executable" ON) option(VIDEO2X_BUILD_CLI "Build the video2x command line interface executable" ON)
option(VIDEO2X_ENABLE_NATIVE "Enable optimizations for the native architecture" OFF)
option(VIDEO2X_ENABLE_X86_64_V4 "Enable x86-64-v4 (AVX-512) optimizations" OFF)
option(VIDEO2X_ENABLE_X86_64_V3 "Enable x86-64-v3 (AVX2) optimizations" OFF)
option(VIDEO2X_USE_EXTERNAL_NCNN "Use the system-provided ncnn library" ON) option(VIDEO2X_USE_EXTERNAL_NCNN "Use the system-provided ncnn library" ON)
option(VIDEO2X_USE_EXTERNAL_SPDLOG "Use the system-provided spdlog library" ON) option(VIDEO2X_USE_EXTERNAL_SPDLOG "Use the system-provided spdlog library" ON)
option(VIDEO2X_USE_EXTERNAL_BOOST "Use the system-provided Boost library" ON) option(VIDEO2X_USE_EXTERNAL_BOOST "Use the system-provided Boost library" ON)
# Set global compile options for all targets option(VIDEO2X_ENABLE_NATIVE "Enable optimizations for the native architecture" OFF)
option(VIDEO2X_ENABLE_X86_64_V4 "Enable x86-64-v4 (AVX-512) optimizations" OFF)
option(VIDEO2X_ENABLE_X86_64_V3 "Enable x86-64-v3 (AVX2) optimizations" OFF)
# Enable extra compiler warnings
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/W4 /permissive-) add_compile_options(/W4 /permissive-)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
@ -41,7 +36,6 @@ endif()
# Set the default optimization flags for Release builds # Set the default optimization flags for Release builds
if(CMAKE_BUILD_TYPE STREQUAL "Release") if(CMAKE_BUILD_TYPE STREQUAL "Release")
# Set the optimization flags for each compiler
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/Ox /Ot /GL /DNDEBUG) add_compile_options(/Ox /Ot /GL /DNDEBUG)
add_link_options(/LTCG /OPT:REF /OPT:ICF) add_link_options(/LTCG /OPT:REF /OPT:ICF)
@ -72,71 +66,126 @@ elseif(VIDEO2X_ENABLE_X86_64_V3)
endif() endif()
endif() endif()
# Define lists to store include directories and libraries # Generate the version header file
set(LIBVIDEO2X_INCLUDE_DIRS) configure_file(
set(LIBVIDEO2X_LIBS) "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in"
set(VIDEO2X_INCLUDE_DIRS) "${CMAKE_CURRENT_BINARY_DIR}/libvideo2x/version.h"
set(VIDEO2X_LIBS) @ONLY
)
# Platform-specific dependencies # Add the libvideo2x shared library
add_library(libvideo2x
src/avutils.cpp
src/conversions.cpp
src/decoder.cpp
src/encoder.cpp
src/filter_libplacebo.cpp
src/filter_realcugan.cpp
src/filter_realesrgan.cpp
src/fsutils.cpp
src/interpolator_rife.cpp
src/libplacebo.cpp
src/libvideo2x.cpp
src/logger_manager.cpp
src/processor_factory.cpp
)
# Set the C++ standard to C++17
target_compile_features(libvideo2x PRIVATE cxx_std_17)
# Set the shared library output name and disable C++ extensions
set_target_properties(libvideo2x PROPERTIES
PREFIX lib
OUTPUT_NAME video2x
CXX_EXTENSIONS OFF
)
# Include directories for the shared library
target_include_directories(libvideo2x PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/include/libvideo2x"
"${PROJECT_SOURCE_DIR}/third_party/librealesrgan_ncnn_vulkan/src"
"${PROJECT_SOURCE_DIR}/third_party/librealcugan_ncnn_vulkan/src"
"${PROJECT_SOURCE_DIR}/third_party/librife_ncnn_vulkan/src"
)
# Add the export definition for the exported symbols
target_compile_definitions(libvideo2x PRIVATE LIBVIDEO2X_EXPORTS)
# Set debug compile options
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(libvideo2x PRIVATE $<$<CONFIG:Debug>:/Zi /Od /MDd>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(libvideo2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -O0>)
endif()
# FFmpeg
if(WIN32) if(WIN32)
# Define base paths for FFmpeg and ncnn target_include_directories(libvideo2x SYSTEM PRIVATE
set(FFMPEG_BASE_PATH ${PROJECT_SOURCE_DIR}/third_party/ffmpeg-shared) "${PROJECT_SOURCE_DIR}/third_party/ffmpeg-shared/include"
set(NCNN_BASE_PATH ${PROJECT_SOURCE_DIR}/third_party/ncnn-shared/x64)
# FFmpeg
set(FFMPEG_LIB
${FFMPEG_BASE_PATH}/lib/avcodec.lib
${FFMPEG_BASE_PATH}/lib/avdevice.lib
${FFMPEG_BASE_PATH}/lib/avfilter.lib
${FFMPEG_BASE_PATH}/lib/avformat.lib
${FFMPEG_BASE_PATH}/lib/avutil.lib
${FFMPEG_BASE_PATH}/lib/swscale.lib
) )
list(APPEND LIBVIDEO2X_LIBS ${FFMPEG_LIB}) target_link_libraries(libvideo2x PRIVATE
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${FFMPEG_BASE_PATH}/include) "${ffmpeg_base_path}/lib/avcodec.lib"
list(APPEND VIDEO2X_LIBS ${FFMPEG_LIB}) "${ffmpeg_base_path}/lib/avfilter.lib"
list(APPEND VIDEO2X_INCLUDE_DIRS ${FFMPEG_BASE_PATH}/include) "${ffmpeg_base_path}/lib/avformat.lib"
"${ffmpeg_base_path}/lib/avutil.lib"
# ncnn "${ffmpeg_base_path}/lib/swscale.lib"
set(SPIRV_BUILD_PATH
${CMAKE_BINARY_DIR}/realesrgan-prefix/src/realesrgan-build/ncnn/glslang/SPIRV
) )
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SPIRV_LIB ${SPIRV_BUILD_PATH}/Release/SPIRV.lib)
else()
set(SPIRV_LIB ${SPIRV_BUILD_PATH}/Debug/SPIRVd.lib)
endif()
list(APPEND LIBVIDEO2X_LIBS ${NCNN_BASE_PATH}/lib/ncnn.lib ${SPIRV_LIB})
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${NCNN_BASE_PATH}/include/ncnn)
else() else()
# FFmpeg # Use pkg-config to find FFmpeg libraries
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
set(FFMPEG_REQUIRED_PKGS
libavcodec # Find and configure FFmpeg libraries
libavdevice pkg_check_modules(libavcodec REQUIRED libavcodec)
libavfilter pkg_check_modules(libavfilter REQUIRED libavfilter)
libavformat pkg_check_modules(libavformat REQUIRED libavformat)
libavutil pkg_check_modules(libavutil REQUIRED libavutil)
libswscale pkg_check_modules(libswscale REQUIRED libswscale)
# Apply include directories and libraries directly to the target
target_include_directories(libvideo2x SYSTEM PRIVATE
${libavcodec_INCLUDE_DIRS}
${libavfilter_LIBRARIES}
${libavformat_INCLUDE_DIRS}
${libavutil_INCLUDE_DIRS}
${libswscale_INCLUDE_DIRS}
) )
target_link_libraries(libvideo2x PRIVATE
${libavcodec_LIBRARIES}
${libavfilter_LIBRARIES}
${libavformat_LIBRARIES}
${libavutil_LIBRARIES}
${libswscale_LIBRARIES}
)
endif()
# Loop through each package to find and collect include dirs and libraries # ncnn
foreach(PKG ${FFMPEG_REQUIRED_PKGS})
pkg_check_modules(${PKG} REQUIRED ${PKG})
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${${PKG}_INCLUDE_DIRS})
list(APPEND LIBVIDEO2X_LIBS ${${PKG}_LIBRARIES})
list(APPEND VIDEO2X_INCLUDE_DIRS ${${PKG}_INCLUDE_DIRS})
list(APPEND VIDEO2X_LIBS ${${PKG}_LIBRARIES})
endforeach()
endif() # WIN32
# Find ncnn package
if(VIDEO2X_USE_EXTERNAL_NCNN) if(VIDEO2X_USE_EXTERNAL_NCNN)
find_package(ncnn REQUIRED) find_package(ncnn REQUIRED)
target_link_libraries(libvideo2x PRIVATE ncnn)
else() else()
option(NCNN_INSTALL_SDK "" OFF) if(WIN32)
# On Windows, use the pre-built shared ncnn library
set(ncnn_base_path "${PROJECT_SOURCE_DIR}/third_party/ncnn-shared/x64")
set(spirv_build_path
"${CMAKE_BINARY_DIR}/realesrgan-prefix/src/realesrgan-build/ncnn/glslang/SPIRV"
)
# Link ncnn and SPIRV libraries
target_include_directories(libvideo2x SYSTEM PRIVATE "${ncnn_base_path}/include/ncnn")
target_link_libraries(libvideo2x PRIVATE "${ncnn_base_path}/lib/ncnn.lib")
# SPIRV needs to be linked explicitly
if(CMAKE_BUILD_TYPE STREQUAL Release)
target_link_libraries(libvideo2x PRIVATE "${spirv_build_path}/Release/SPIRV.lib")
else()
target_link_libraries(libvideo2x PRIVATE "${spirv_build_path}/Debug/SPIRVd.lib")
endif()
else()
option(NCNN_INSTALL_SDK "" ON)
option(SKIP_GLSLANG_INSTALL "" OFF)
option(NCNN_PIXEL_ROTATE "" OFF) option(NCNN_PIXEL_ROTATE "" OFF)
option(NCNN_VULKAN "" ON) option(NCNN_VULKAN "" ON)
option(NCNN_VULKAN_ONLINE_SPIRV "" ON) option(NCNN_VULKAN_ONLINE_SPIRV "" ON)
@ -147,7 +196,6 @@ else()
option(NCNN_DISABLE_RTTI "" ON) option(NCNN_DISABLE_RTTI "" ON)
option(NCNN_DISABLE_EXCEPTION "" ON) option(NCNN_DISABLE_EXCEPTION "" ON)
option(NCNN_BUILD_SHARED_LIBS "" OFF) option(NCNN_BUILD_SHARED_LIBS "" OFF)
option(SKIP_GLSLANG_INSTALL "" ON)
option(WITH_LAYER_absval "" OFF) option(WITH_LAYER_absval "" OFF)
option(WITH_LAYER_argmax "" OFF) option(WITH_LAYER_argmax "" OFF)
@ -229,260 +277,227 @@ else()
option(WITH_LAYER_softplus "" OFF) option(WITH_LAYER_softplus "" OFF)
add_subdirectory(third_party/ncnn) add_subdirectory(third_party/ncnn)
target_link_libraries(libvideo2x PRIVATE ncnn)
endif()
endif() endif()
# spdlog # spdlog
if(VIDEO2X_USE_EXTERNAL_SPDLOG) if(VIDEO2X_USE_EXTERNAL_SPDLOG)
find_package(spdlog REQUIRED) find_package(spdlog REQUIRED)
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${spdlog_INCLUDE_DIRS}) target_include_directories(libvideo2x SYSTEM PRIVATE ${spdlog_INCLUDE_DIRS})
list(APPEND VIDEO2X_INCLUDE_DIRS ${spdlog_INCLUDE_DIRS}) target_link_libraries(libvideo2x PRIVATE spdlog::spdlog)
set(SPDLOG_LIB spdlog::spdlog)
else() else()
# spdlog exceptions are incompatible with ncnn # spdlog exceptions are incompatible with ncnn
option(SPDLOG_NO_EXCEPTIONS "" ON) option(SPDLOG_NO_EXCEPTIONS "" ON)
option(SPDLOG_INSTALL "" ON)
add_subdirectory(third_party/spdlog) add_subdirectory(third_party/spdlog)
set(SPDLOG_LIB spdlog::spdlog_header_only) target_link_libraries(libvideo2x PRIVATE spdlog::spdlog_header_only)
endif()
list(APPEND LIBVIDEO2X_LIBS ${SPDLOG_LIB})
list(APPEND VIDEO2X_LIBS ${SPDLOG_LIB})
# Find dependencies required for the CLI
if(VIDEO2X_BUILD_CLI)
# Vulkan
find_package(Vulkan REQUIRED)
list(APPEND VIDEO2X_LIBS Vulkan::Vulkan)
# Boost
if(VIDEO2X_USE_EXTERNAL_BOOST)
find_package(Boost REQUIRED COMPONENTS program_options)
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
else()
option(Boost_USE_STATIC_LIBS "" ON)
option(Boost_USE_STATIC_RUNTIME "" ON)
option(Boost_COMPONENTS "program_options")
add_subdirectory(third_party/boost)
include_directories(${PROJECT_SOURCE_DIR}/third_party/boost/libs/program_options/include)
set(BOOST_BASE_PATH
${CMAKE_BINARY_DIR}/third_party/boost/libs/program_options/${CMAKE_BUILD_TYPE}
)
endif()
list(APPEND VIDEO2X_LIBS Boost::program_options)
endif() endif()
# Add librealesrgan-ncnn-vulkan as an external project # Real-ESRGAN, Real-CUGAN, and RIFE
ExternalProject_Add( option(USE_SYSTEM_NCNN "" ${VIDEO2X_USE_EXTERNAL_NCNN})
realesrgan add_subdirectory(third_party/librealesrgan_ncnn_vulkan/src)
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/librealesrgan_ncnn_vulkan/src add_subdirectory(third_party/librealcugan_ncnn_vulkan/src)
CMAKE_ARGS add_subdirectory(third_party/librife_ncnn_vulkan/src)
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/realesrgan-install
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DUSE_SYSTEM_NCNN=${VIDEO2X_USE_EXTERNAL_NCNN}
BUILD_ALWAYS ON
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Add librealcugan-ncnn-vulkan as an external project # Determine the library suffix based on the platform
ExternalProject_Add(
realcugan
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/librealcugan_ncnn_vulkan/src
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/realcugan-install
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DUSE_SYSTEM_NCNN=${VIDEO2X_USE_EXTERNAL_NCNN}
BUILD_ALWAYS ON
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Add librife-ncnn-vulkan as an external project
ExternalProject_Add(
rife
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/librife_ncnn_vulkan/src
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/rife-install
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DUSE_SYSTEM_NCNN=${VIDEO2X_USE_EXTERNAL_NCNN}
BUILD_ALWAYS ON
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Remove duplicate entries
list(REMOVE_DUPLICATES LIBVIDEO2X_INCLUDE_DIRS)
list(REMOVE_DUPLICATES LIBVIDEO2X_LIBS)
list(REMOVE_DUPLICATES VIDEO2X_INCLUDE_DIRS)
list(REMOVE_DUPLICATES VIDEO2X_LIBS)
# Create the shared library 'libvideo2x'
file(GLOB LIBVIDEO2X_SOURCES src/*.cpp)
add_library(libvideo2x ${LIBVIDEO2X_SOURCES})
target_compile_definitions(libvideo2x PRIVATE LIBVIDEO2X_EXPORTS)
if(WIN32) if(WIN32)
set_target_properties(libvideo2x PROPERTIES OUTPUT_NAME libvideo2x) set(suffix ${CMAKE_STATIC_LIBRARY_SUFFIX})
else() else()
set_target_properties(libvideo2x PROPERTIES OUTPUT_NAME video2x) set(suffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif() endif()
# Ensure that the shared library is built after the external projects # Link the shared library with the ncnn-Vulkan-based libraries
add_dependencies(libvideo2x realesrgan realcugan rife) set(ncnn_vulkan_libs)
foreach(lib IN ITEMS realesrgan realcugan rife)
# Generate the version header file list(APPEND ncnn_vulkan_libs
configure_file( "${CMAKE_BINARY_DIR}/third_party/lib${lib}_ncnn_vulkan/src/lib${lib}-ncnn-vulkan${suffix}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/libvideo2x/version.h"
@ONLY
)
# Include directories for the shared library
target_include_directories(libvideo2x PRIVATE
${LIBVIDEO2X_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/include/libvideo2x
${PROJECT_SOURCE_DIR}/third_party/librealesrgan_ncnn_vulkan/src
${PROJECT_SOURCE_DIR}/third_party/librealcugan_ncnn_vulkan/src
${PROJECT_SOURCE_DIR}/third_party/librife_ncnn_vulkan/src
)
# Set the compile options for the shared library
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(libvideo2x PRIVATE $<$<CONFIG:Debug>:/Zi /Od /MDd>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(libvideo2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -O0>)
endif()
# Define the paths to the shared libraries
if(WIN32)
set(REALESRGAN_LIB ${CMAKE_BINARY_DIR}/realesrgan-install/lib/librealesrgan-ncnn-vulkan.lib)
set(REALCUGAN_LIB ${CMAKE_BINARY_DIR}/realcugan-install/lib/librealcugan-ncnn-vulkan.lib)
set(RIFE_LIB ${CMAKE_BINARY_DIR}/rife-install/lib/librife-ncnn-vulkan.lib)
else()
set(REALESRGAN_LIB ${CMAKE_BINARY_DIR}/realesrgan-install/lib/librealesrgan-ncnn-vulkan.so)
set(REALCUGAN_LIB ${CMAKE_BINARY_DIR}/realcugan-install/lib/librealcugan-ncnn-vulkan.so)
set(RIFE_LIB ${CMAKE_BINARY_DIR}/rife-install/lib/librife-ncnn-vulkan.so)
endif()
list(APPEND LIBVIDEO2X_LIBS ${REALESRGAN_LIB} ${REALCUGAN_LIB} ${RIFE_LIB})
# Link the shared library with the dependencies
target_link_libraries(libvideo2x PRIVATE ${LIBVIDEO2X_LIBS})
if(NOT WIN32)
if(VIDEO2X_USE_EXTERNAL_NCNN)
target_link_libraries(libvideo2x PUBLIC ncnn)
else()
target_link_libraries(libvideo2x PRIVATE ncnn)
endif()
endif()
# Build the Video2X CLI executable
if(VIDEO2X_BUILD_CLI)
file(GLOB VIDEO2X_SOURCES tools/video2x/src/*.cpp)
add_executable(video2x ${VIDEO2X_SOURCES})
set_target_properties(video2x PROPERTIES OUTPUT_NAME video2x)
# Include directories for the executable
target_include_directories(video2x PRIVATE
${VIDEO2X_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/tools/video2x/include
) )
endforeach()
# Compile options for the executable target_link_libraries(libvideo2x PRIVATE ${ncnn_vulkan_libs})
target_compile_options(video2x PRIVATE $<$<CONFIG:Debug>:-g -DDEBUG>)
# Link the executable with the shared library
target_link_libraries(video2x PRIVATE libvideo2x ${VIDEO2X_LIBS})
endif()
# Determine the installation directories # Determine the installation directories
if(WIN32) if(WIN32)
set(INSTALL_BIN_DESTINATION ".") set(install_bin_destination .)
set(INSTALL_INCLUDE_DESTINATION "include/libvideo2x") set(install_include_destination include/libvideo2x)
set(INSTALL_LIB_DESTINATION ".") set(install_lib_destination .)
set(INSTALL_MODEL_DESTINATION ".") set(install_model_destination .)
set(INSTALL_CMAKE_DESTINATION "cmake/Video2X") set(install_cmake_destination cmake/Video2X)
else() else()
set(INSTALL_BIN_DESTINATION "${CMAKE_INSTALL_BINDIR}") set(install_bin_destination "${CMAKE_INSTALL_BINDIR}")
set(INSTALL_INCLUDE_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libvideo2x") set(install_include_destination "${CMAKE_INSTALL_INCLUDEDIR}/libvideo2x")
set(INSTALL_LIB_DESTINATION "${CMAKE_INSTALL_LIBDIR}") set(install_lib_destination "${CMAKE_INSTALL_LIBDIR}")
set(INSTALL_MODEL_DESTINATION "${CMAKE_INSTALL_DATADIR}/video2x") set(install_model_destination "${CMAKE_INSTALL_DATADIR}/video2x")
set(INSTALL_CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Video2X") set(install_cmake_destination "${CMAKE_INSTALL_LIBDIR}/cmake/Video2X")
endif() endif()
# Common installation rules for libvideo2x and models # Common installation rules for libvideo2x and models
install(TARGETS libvideo2x install(TARGETS libvideo2x
EXPORT Video2XTargets EXPORT Video2XTargets
LIBRARY DESTINATION ${INSTALL_LIB_DESTINATION} RUNTIME DESTINATION "${install_bin_destination}"
ARCHIVE DESTINATION ${INSTALL_LIB_DESTINATION} LIBRARY DESTINATION "${install_lib_destination}"
RUNTIME DESTINATION ${INSTALL_BIN_DESTINATION} ARCHIVE DESTINATION "${install_lib_destination}"
INCLUDES DESTINATION "${install_include_destination}"
) )
# Install the header files from the include directory # Install the header files from the include directory
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/libvideo2x/ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/libvideo2x/"
DESTINATION ${INSTALL_INCLUDE_DESTINATION} DESTINATION "${install_include_destination}"
FILES_MATCHING PATTERN "*.h" FILES_MATCHING PATTERN "*.h"
) )
# Install the generated version.h file # Install the generated version.h file
install(FILES install(FILES
${CMAKE_CURRENT_BINARY_DIR}/libvideo2x/version.h "${CMAKE_CURRENT_BINARY_DIR}/libvideo2x/version.h"
DESTINATION ${INSTALL_INCLUDE_DESTINATION} DESTINATION "${install_include_destination}"
) )
# Export targets and create CMake package config # Export targets and create CMake package config
install(EXPORT Video2XTargets install(EXPORT Video2XTargets
FILE Video2XTargets.cmake FILE Video2XTargets.cmake
NAMESPACE Video2X:: NAMESPACE Video2X::
DESTINATION ${INSTALL_CMAKE_DESTINATION} DESTINATION "${install_cmake_destination}"
) )
# Generate the CMake package config file # Generate the CMake package config file
configure_package_config_file( configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Video2XConfig.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Video2XConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/Video2XConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/Video2XConfig.cmake"
INSTALL_DESTINATION ${INSTALL_CMAKE_DESTINATION} INSTALL_DESTINATION "${install_cmake_destination}"
) )
# Install the CMake package config file # Install the CMake package config file
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/Video2XConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/Video2XConfig.cmake"
DESTINATION ${INSTALL_CMAKE_DESTINATION} DESTINATION "${install_cmake_destination}"
) )
# Install model files # Install model files
install(DIRECTORY ${CMAKE_SOURCE_DIR}/models DESTINATION ${INSTALL_MODEL_DESTINATION}) install(DIRECTORY "${CMAKE_SOURCE_DIR}/models" DESTINATION "${install_model_destination}")
# Platform-specific installation rules # Platform-specific installation rules
if(WIN32) if(WIN32)
file(GLOB FFMPEG_DLLS "${FFMPEG_BASE_PATH}/bin/*.dll") file(GLOB ffmpeg_dlls "${ffmpeg_base_path}/bin/*.dll")
install(FILES install(FILES
${CMAKE_BINARY_DIR}/realesrgan-install/bin/librealesrgan-ncnn-vulkan.dll ${ffmpeg_dlls}
${CMAKE_BINARY_DIR}/realcugan-install/bin/librealcugan-ncnn-vulkan.dll "${ncnn_base_path}/bin/ncnn.dll"
${CMAKE_BINARY_DIR}/rife-install/bin/librife-ncnn-vulkan.dll ${ncnn_vulkan_libs}
${FFMPEG_DLLS} DESTINATION "${install_bin_destination}"
${NCNN_BASE_PATH}/bin/ncnn.dll
DESTINATION ${INSTALL_BIN_DESTINATION}
) )
else() else()
install(FILES ${REALESRGAN_LIB} ${REALCUGAN_LIB} ${RIFE_LIB} install(FILES
DESTINATION ${INSTALL_LIB_DESTINATION} ${ncnn_vulkan_libs}
DESTINATION "${install_lib_destination}"
) )
endif() endif()
# Install the Video2X CLI executable # Build the video2x CLI executable
if(VIDEO2X_BUILD_CLI) if(VIDEO2X_BUILD_CLI)
install(TARGETS video2x RUNTIME DESTINATION ${INSTALL_BIN_DESTINATION}) add_executable(video2x
tools/video2x/src/argparse.cpp
tools/video2x/src/newline_safe_sink.cpp
tools/video2x/src/timer.cpp
tools/video2x/src/validators.cpp
tools/video2x/src/video2x.cpp
tools/video2x/src/vulkan_utils.cpp
)
# Set the C++ standard to C++17
target_compile_features(video2x PRIVATE cxx_std_17)
# Set the shared library output name and disable C++ extensions
set_target_properties(video2x PROPERTIES
OUTPUT_NAME video2x
CXX_EXTENSIONS OFF
)
# Include directories for the executable
target_include_directories(video2x PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/tools/video2x/include"
)
# Link the executable with the shared library
target_link_libraries(video2x PRIVATE libvideo2x)
# Set debug compile options
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(video2x PRIVATE $<$<CONFIG:Debug>:/Zi /Od /MDd>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(video2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -O0>)
endif()
# FFmpeg
if(WIN32)
target_include_directories(video2x SYSTEM PRIVATE
"${PROJECT_SOURCE_DIR}/third_party/ffmpeg-shared/include"
)
target_link_libraries(video2x PRIVATE
"${ffmpeg_base_path}/lib/avcodec.lib"
"${ffmpeg_base_path}/lib/avutil.lib"
)
else()
# FFmpeg libraries have already been found
# Apply include directories and libraries directly to the target
target_include_directories(video2x SYSTEM PRIVATE
${libavcodec_INCLUDE_DIRS}
${libavutil_INCLUDE_DIRS}
)
target_link_libraries(video2x PRIVATE ${libavcodec_LIBRARIES} ${libavutil_LIBRARIES})
endif()
# spdlog
# spdlog targets has already been added
if(VIDEO2X_USE_EXTERNAL_SPDLOG)
target_include_directories(video2x SYSTEM PRIVATE ${spdlog_INCLUDE_DIRS})
target_link_libraries(video2x PRIVATE spdlog::spdlog)
else()
target_link_libraries(video2x PRIVATE spdlog::spdlog_header_only)
endif()
# Vulkan
find_package(Vulkan REQUIRED)
target_link_libraries(video2x PRIVATE Vulkan::Vulkan)
# Boost
if(VIDEO2X_USE_EXTERNAL_BOOST)
find_package(Boost REQUIRED COMPONENTS program_options)
else()
option(Boost_USE_STATIC_LIBS "" ON)
option(Boost_USE_STATIC_RUNTIME "" ON)
option(Boost_COMPONENTS program_options)
add_subdirectory(third_party/boost)
target_include_directories(video2x SYSTEM PRIVATE
${PROJECT_SOURCE_DIR}/third_party/boost/libs/program_options/include
)
# Suppress the -Wsign-conversion warnings for Boost.Nowide
if (TARGET boost_nowide)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(boost_nowide PRIVATE -Wno-error=sign-conversion)
endif()
endif()
endif()
target_link_libraries(video2x PRIVATE Boost::program_options)
# Install the video2x executable
install(TARGETS video2x RUNTIME DESTINATION "${install_bin_destination}")
# Install the Boost DLL # Install the Boost DLL
if(WIN32 AND NOT VIDEO2X_USE_EXTERNAL_BOOST) if(WIN32 AND NOT VIDEO2X_USE_EXTERNAL_BOOST)
if(CMAKE_BUILD_TYPE STREQUAL "Release") set(boost_base_path
set(BOOST_DLL_PATH ${BOOST_BASE_PATH}/boost_program_options-vc143-mt-x64-1_86.dll) "${CMAKE_BINARY_DIR}/third_party/boost/libs/program_options/${CMAKE_BUILD_TYPE}"
)
# Different build types have different DLL names
if(CMAKE_BUILD_TYPE STREQUAL Release)
set(boost_dll_path "${boost_base_path}/boost_program_options-vc143-mt-x64-1_86.dll")
else() else()
set(BOOST_DLL_PATH ${BOOST_BASE_PATH}/boost_program_options-vc143-mt-gd-x64-1_86.dll) set(boost_dll_path "${boost_base_path}/boost_program_options-vc143-mt-gd-x64-1_86.dll")
endif() endif()
install(FILES ${BOOST_DLL_PATH} DESTINATION ${INSTALL_BIN_DESTINATION})
install(FILES "${boost_dll_path}" DESTINATION "${install_bin_destination}")
endif() endif()
endif() endif()

225
Makefile
View File

@ -1,225 +0,0 @@
.PHONY: build static debug windows windows-debug debian ubuntu clean \
test-realesrgan test-realcugan test-libplacebo test-rife \
memcheck-realesrgan memcheck-realcugan memcheck-libplacebo memcheck-rife \
heaptrack-realesrgan heaptrack-realcugan heaptrack-libplacebo heaptrack-rife
BINDIR=build
CXX=clang++
TEST_VIDEO=data/standard-test.mp4
TEST_OUTPUT=data/output.mp4
build:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_INSTALL_PREFIX=$(BINDIR)/video2x-install \
-DCMAKE_BUILD_TYPE=Release \
-DVIDEO2X_ENABLE_NATIVE=ON
cmake --build $(BINDIR) --config Release --parallel --target install
cp $(BINDIR)/compile_commands.json .
static:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF
cmake --build $(BINDIR) --config Release --parallel --target install
cp $(BINDIR)/compile_commands.json .
debug:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Debug
cmake --build $(BINDIR) --config Debug --parallel
cp $(BINDIR)/compile_commands.json .
windows:
cmake -S . -B $(BINDIR) \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=build/libvideo2x-shared
cmake --build $(BINDIR) --config Release --parallel --target install
windows-debug:
cmake -S . -B $(BINDIR) \
-DVIDEO2X_USE_EXTERNAL_NCNN=OFF \
-DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DVIDEO2X_USE_EXTERNAL_BOOST=OFF \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=build/libvideo2x-shared
cmake --build $(BINDIR) --config Debug --parallel --target install
debian:
apt-get update
apt-get install -y --no-install-recommends \
build-essential cmake clang pkg-config \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libspdlog-dev \
libboost-program-options-dev
cmake -B /tmp/build -S . -DVIDEO2X_USE_EXTERNAL_NCNN=OFF -DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install \
-DINSTALL_BIN_DESTINATION=. -DINSTALL_INCLUDE_DESTINATION=include \
-DINSTALL_LIB_DESTINATION=. -DINSTALL_MODEL_DESTINATION=.
cmake --build /tmp/build --config Release --target install --parallel
ubuntu2404:
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential cmake pkg-config \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libboost-program-options-dev
cmake -B build -S . -DVIDEO2X_USE_EXTERNAL_NCNN=OFF -DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
cmake --build build --config Release --target install --parallel
mkdir -p video2x-linux-ubuntu-amd64/DEBIAN
cp packaging/debian/control.ubuntu2404 video2x-linux-ubuntu-amd64/DEBIAN/control
dpkg-deb --build video2x-linux-ubuntu-amd64
ubuntu2204:
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common
add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential cmake \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libvulkan-dev \
glslang-tools \
libomp-dev \
libboost-program-options-dev
cmake -B build -S . -DVIDEO2X_USE_EXTERNAL_NCNN=OFF -DVIDEO2X_USE_EXTERNAL_SPDLOG=OFF \
-DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
cmake --build build --config Release --target install --parallel
mkdir -p video2x-linux-ubuntu-amd64/DEBIAN
cp packaging/debian/control.ubuntu2204 video2x-linux-ubuntu-amd64/DEBIAN/control
dpkg-deb --build video2x-linux-ubuntu-amd64
clean:
rm -vrf $(BINDIR) data/output*.* heaptrack*.zst valgrind.log
test-realesrgan:
LD_LIBRARY_PATH=$(BINDIR) $(BINDIR)/video2x -i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realesrgan -s 4 --realesrgan-model realesr-animevideov3
test-realcugan:
LD_LIBRARY_PATH=$(BINDIR) $(BINDIR)/video2x -i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realcugan -s 4 -n 0 --realcugan-model models-se
test-libplacebo:
LD_LIBRARY_PATH=$(BINDIR) $(BINDIR)/video2x -i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a
test-rife:
LD_LIBRARY_PATH=$(BINDIR) $(BINDIR)/video2x -i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p rife -m 4 --rife-model rife-v4.6
memcheck-realesrgan:
LD_LIBRARY_PATH=$(BINDIR) valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realesrgan -s 2 --realesrgan-model realesr-animevideov3 \
-e preset=veryfast -e crf=30
memcheck-realcugan:
LD_LIBRARY_PATH=$(BINDIR) valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realcugan -s 2 -n 0 --realcugan-model models-se \
-e preset=veryfast -e crf=30
memcheck-libplacebo:
LD_LIBRARY_PATH=$(BINDIR) valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a \
-e preset=veryfast -e crf=30
memcheck-rife:
LD_LIBRARY_PATH=$(BINDIR) valgrind \
--tool=memcheck \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--show-reachable=yes \
--verbose --log-file="valgrind.log" \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p rife -m 4 --rife-model rife-v4.6 \
-e preset=veryfast -e crf=30
heaptrack-realesrgan:
LD_LIBRARY_PATH=$(BINDIR) HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realesrgan -s 4 --realesrgan-model realesr-animevideov3 \
-e preset=veryfast -e crf=30
heaptrack-realcugan:
LD_LIBRARY_PATH=$(BINDIR) HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p realcugan -s 4 -n 0 --realcugan-model models-se \
-e preset=veryfast -e crf=30
heaptrack-libplacebo:
LD_LIBRARY_PATH=$(BINDIR) HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p libplacebo -w 1920 -h 1080 --libplacebo-shader anime4k-v4-a \
-e preset=veryfast -e crf=30
heaptrack-rife:
LD_LIBRARY_PATH=$(BINDIR) HEAPTRACK_ENABLE_DEBUGINFOD=1 heaptrack \
$(BINDIR)/video2x \
-i $(TEST_VIDEO) -o $(TEST_OUTPUT) \
-p rife -m 4 --rife-model rife-v4.6 \
-e preset=veryfast -e crf=30

@ -1 +1 @@
Subproject commit 52f598265a973fc8b17eb5e13cddc0e71c0a79dc Subproject commit 97faecb22d2c32d9bbd9478e726b1add6eabcf9c

@ -1 +1 @@
Subproject commit 7966e68979ab9c002d10f9bfa507bd25e551b377 Subproject commit 95ce7b81685a5a324c347df60f16ce96a1dd6e50

@ -1 +1 @@
Subproject commit b3b2ce899011fa7940178163f0b4a3ebc251a934 Subproject commit 8bdf0a596d8562f909cea96d5816460d8bf7e024