feat(rife): add support for frame interpolation and RIFE (#1244)

* feat: add RIFE files and processor/interpolator abstractions
* feat: add `rife` as processor option
* feat: add frame interpolation math except first frame
* feat: complete motion interpolation and add scene detection
* feat: improve Vulkan device validation
* fix: fix casting issues and variable names
* refactor: improve error-checking; add abstractions and factories
* refactor: improve readability of the frames processor
* docs: update changelog

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
K4YT3X
2024-12-01 09:55:56 +00:00
committed by GitHub
parent 2fc89e3883
commit 627f3d84a4
84 changed files with 4914 additions and 615 deletions

View File

@@ -253,6 +253,19 @@ ExternalProject_Add(
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Add librealesrgan-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=${USE_SYSTEM_NCNN}
BUILD_ALWAYS ON
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Remove duplicate entries
list(REMOVE_DUPLICATES ALL_INCLUDE_DIRS)
list(REMOVE_DUPLICATES ALL_LIBRARIES)
@@ -267,8 +280,8 @@ else()
set_target_properties(libvideo2x PROPERTIES OUTPUT_NAME video2x)
endif()
# Ensure libvideo2x depends on realesrgan being built and installed
add_dependencies(libvideo2x realesrgan)
# Ensure that the shared library is built after the external projects
add_dependencies(libvideo2x realesrgan rife)
# Include directories for the shared library
target_include_directories(libvideo2x PRIVATE
@@ -277,6 +290,7 @@ target_include_directories(libvideo2x PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/include/libvideo2x
${PROJECT_SOURCE_DIR}/third_party/librealesrgan_ncnn_vulkan/src
${PROJECT_SOURCE_DIR}/third_party/librife_ncnn_vulkan/src
)
# Compile options for the shared library
@@ -286,14 +300,15 @@ target_compile_options(libvideo2x PRIVATE
$<$<CONFIG:Debug>:-g -DDEBUG>
)
# Define the path to the built libresrgan-ncnn-vulkan library
# Define the paths to the shared libraries
if(WIN32)
set(REALESRGAN_LIB ${CMAKE_BINARY_DIR}/realesrgan_install/lib/librealesrgan-ncnn-vulkan.lib)
list(APPEND ALL_LIBRARIES ${REALESRGAN_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)
list(APPEND ALL_LIBRARIES ${REALESRGAN_LIB})
set(RIFE_LIB ${CMAKE_BINARY_DIR}/rife_install/lib/librife-ncnn-vulkan.so)
endif()
list(APPEND ALL_LIBRARIES ${REALESRGAN_LIB} ${RIFE_LIB})
# Link the shared library with the dependencies
target_link_libraries(libvideo2x PRIVATE ${ALL_LIBRARIES})
@@ -392,6 +407,7 @@ if(WIN32)
install(FILES
${CMAKE_BINARY_DIR}/realesrgan_install/bin/librealesrgan-ncnn-vulkan.dll
${CMAKE_BINARY_DIR}/rife_install/bin/librife-ncnn-vulkan.dll
${FFMPEG_DLLS}
${NCNN_BASE_PATH}/bin/ncnn.dll
${BOOST_DLL_PATH}
@@ -401,7 +417,7 @@ if(WIN32)
WORLD_READ WORLD_EXECUTE
)
else()
install(FILES ${REALESRGAN_LIB}
install(FILES ${REALESRGAN_LIB} ${RIFE_LIB}
DESTINATION ${INSTALL_LIB_DESTINATION}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE