18 Commits
6.2.0 ... 6.3.1

Author SHA1 Message Date
k4yt3x
996b0bfa78 docs(readme): update readme for 6.3.1
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
709cf08760 fix(encoder): decreasing PTS precision with increasing video duration (#1269)
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
bf5917b084 docs(readme): add French to the list of GUI languages
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
96ebd860e3 docs(readme): add sample clips for Real-CUGAN and Real-ESRGAN
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
2afbeab2aa fix(video2x): remove redundant newline statements
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
5c4d23bc97 docs(readme): update readme for 6.3.0
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
20e43a9724 chore: update changelogs for version 6.3.0
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
k4yt3x
486c23d9f4 fix(video2x): add missing Real-CUGAN help messages
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 00:00:00 +00:00
K4YT3X
127d9e0019 feat(realcugan): add support for Real-CUGAN ncnn Vulkan (#1268)
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-21 02:58:19 +00:00
k4yt3x
e1e8d64056 chore(deps): update spdlog to v1.15.0
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-20 00:00:00 +00:00
k4yt3x
7b8e186207 feat(logger): improve logger initialization
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-20 00:00:00 +00:00
k4yt3x
f3999a431c feat(logger): improve FFmpeg logging format
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-20 00:00:00 +00:00
K4YT3X
6676cd2439 feat(logger): add logger manager to provide unified logging (#1267)
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-20 04:46:10 +00:00
k4yt3x
b8eb6de59b docs(readme): add licensing information for RIFE ncnn Vulkan
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-19 00:00:00 +00:00
K4YT3X
ae2d5d32e4 feat(ns): improve optimization flags and add namespaces (#1261)
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-17 16:24:51 +00:00
k4yt3x
5884dd1ba4 fix(encoder): always use the calculated PTS with corrected math
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-16 00:00:00 +00:00
k4yt3x
33ee43a088 docs(citation): add citation information
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-15 00:00:00 +00:00
k4yt3x
7ee9d60fcf docs(readme): update readme for 6.2.0
Signed-off-by: k4yt3x <i@k4yt3x.com>
2024-12-12 00:00:00 +00:00
91 changed files with 2348 additions and 647 deletions

View File

@@ -54,7 +54,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/tmp/install \
-DINSTALL_BIN_DESTINATION=. -DINSTALL_INCLUDE_DESTINATION=include \
-DINSTALL_LIB_DESTINATION=. -DINSTALL_MODEL_DESTINATION=.
cmake --build /tmp/build --config Debug --target install --parallel
cmake --build /tmp/build --config Debug --target install
- name: Upload artifacts
uses: actions/upload-artifact@v4

View File

@@ -68,6 +68,8 @@ jobs:
path: build/video2x-linux-ubuntu-2404-amd64.deb
windows:
# Disabled because it takes too long to build
if: false
name: Build Windows release
needs:
- setup
@@ -143,14 +145,14 @@ jobs:
needs:
- setup
# - ubuntu-2404
- windows
# - windows
- container
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
# outputs:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
# - name: Download artifacts
# uses: actions/download-artifact@v4
- name: Create release
id: create_release
@@ -161,5 +163,3 @@ jobs:
name: ${{ needs.setup.outputs.version }}
draft: true
prerelease: false
files: |
video2x-windows-amd64.zip

9
.gitmodules vendored
View File

@@ -1,6 +1,3 @@
[submodule "third_party/librealesrgan_ncnn_vulkan"]
path = third_party/librealesrgan_ncnn_vulkan
url = https://github.com/k4yt3x/librealesrgan-ncnn-vulkan.git
[submodule "third_party/ncnn"]
path = third_party/ncnn
url = https://github.com/Tencent/ncnn.git
@@ -10,6 +7,12 @@
[submodule "third_party/boost"]
path = third_party/boost
url = https://github.com/boostorg/boost.git
[submodule "third_party/librealesrgan_ncnn_vulkan"]
path = third_party/librealesrgan_ncnn_vulkan
url = https://github.com/k4yt3x/librealesrgan-ncnn-vulkan.git
[submodule "third_party/librealcugan_ncnn_vulkan"]
path = third_party/librealcugan_ncnn_vulkan
url = https://github.com/k4yt3x/librealcugan-ncnn-vulkan.git
[submodule "third_party/librife_ncnn_vulkan"]
path = third_party/librife_ncnn_vulkan
url = https://github.com/k4yt3x/librife-ncnn-vulkan.git

View File

@@ -5,6 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [6.3.1] - 2024-12-21
### Fixed
- The issue of decreasing PTS precision with increasing video duration (#1269).
- (Video2X Qt6) Errors restoring Real-CUGAN configs in the Edit Task dialog.
- (Video2X Qt6) The incorrect comparison of version numbers.
## [6.3.0] - 2024-12-20
### Added
- A logger manager to provide unified logging across the application.
- Support for Real-CUGAN ncnn Vulkan (#1198).
- (Video2X Qt6) A check to ensure the required VC++ Redistributable version is installed.
- (Video2X Qt6) A configuration manager to save user preferences like the last selected language.
- (Video2X Qt6) A new logging widget to display logs in the UI.
- (Video2X Qt6) Custom options `crf=20` and `preset=slow` to the default encoder options.
- (Video2X Qt6) French translation.
- (Video2X Qt6) The ability to check for available updates and prompt the user to update.
- (Video2X Qt6) Tooltips for processor and encoder options.
### Changed
- Improve optimization flags and add namespaces for better code organization.
- (Video2X Qt6) Add processor names to processed videos instead of `.processed`.
- (Video2X Qt6) The output video suffix from auto-generated to `.mkv`.
### Fixed
- Make the encoder always use the calculated PTS with corrected math.
- (Video2X Qt6) The issue where task configs are being restored incorrectly in the UI.
## [6.2.0] - 2024-12-11
### Added
@@ -14,14 +47,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- More `AVCodecContext` options.
- Support for RIFE ncnn Vulkan.
- Support for specifying arbitrary `AVOptions` for the encoder (#1232).
- Visual C++ Redistributable version check to the installer. (Video2X Qt6)
- (Video2X Qt6) Visual C++ Redistributable version check to the installer.
### Changed
- Improve CLI argument validation.
- Improve error handling and error messages.
- Improve the CLI help message structure and clarity.
- Improve the UI with a complete redesign. (Video2X Qt6)
- (Video2X Qt6) Improve the UI with a complete redesign.
### Removed
@@ -48,9 +81,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A better timer that gets paused when the processing is paused.
- Detection for the validity of the provided GPU ID.
- Status bar and processing statistics. (Video2X Qt6)
- The `--listgpus` option to list available Vulkan GPU devices.
- Vulkan device selection for libplacebo.
- (Video2X Qt6) Status bar and processing statistics.
### Changed

16
CITATION.cff Normal file
View File

@@ -0,0 +1,16 @@
cff-version: 1.2.0
title: Video2X
abstract: >-
Video2X is a A machine learning-based video super resolution and frame interpolation framework.
message: Please cite this software using these metadata.
type: software
authors:
- name: K4YT3X
date-released: 2018-02-24
url: https://video2x.org
repository-code: https://github.com/k4yt3x/video2x
license: AGPL-3.0
keywords:
- machine learning
- super resolution
- frame interpolation

View File

@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.10)
project(video2x VERSION 6.2.0 LANGUAGES CXX)
project(video2x VERSION 6.3.1 LANGUAGES CXX)
# The FindBoost module is removed in CMake 3.30
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
@@ -15,24 +16,24 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Set the default optimization flags for Release builds
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox /GL /LTCG /MD /DNDEBUG")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -s")
endif()
endif()
# Set global compile options for all targets
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/W4 /permissive-)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion -Wshadow)
endif()
# Set the default optimization flags for Release builds
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/Ox /Ot /GL /DNDEBUG)
add_link_options(/LTCG /OPT:REF /OPT:ICF)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-O3 -march=native -ffunction-sections -fdata-sections)
add_link_options(-Wl,-s -flto -Wl,--gc-sections)
endif()
endif()
# Build options
option(BUILD_SHARED_LIBS "Build libvideo2x as a shared library" ON)
option(BUILD_VIDEO2X_CLI "Build the video2x executable" ON)
@@ -48,8 +49,10 @@ configure_file(
)
# Find the required packages
set(ALL_INCLUDE_DIRS)
set(ALL_LIBRARIES)
set(LIBVIDEO2X_INCLUDE_DIRS)
set(LIBVIDEO2X_LIBS)
set(VIDEO2X_INCLUDE_DIRS)
set(VIDEO2X_LIBS)
# Platform-specific dependencies
if(WIN32)
@@ -66,11 +69,12 @@ if(WIN32)
${FFMPEG_BASE_PATH}/lib/avutil.lib
${FFMPEG_BASE_PATH}/lib/swscale.lib
)
list(APPEND ALL_LIBRARIES ${FFMPEG_LIB})
list(APPEND ALL_INCLUDE_DIRS ${FFMPEG_BASE_PATH}/include)
list(APPEND LIBVIDEO2X_LIBS ${FFMPEG_LIB})
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${FFMPEG_BASE_PATH}/include)
list(APPEND VIDEO2X_LIBS ${FFMPEG_LIB})
list(APPEND VIDEO2X_INCLUDE_DIRS ${FFMPEG_BASE_PATH}/include)
# ncnn
# TODO: Figure out why this file is not being copied to the install directory
set(SPIRV_BUILD_PATH
${CMAKE_BINARY_DIR}/realesrgan-prefix/src/realesrgan-build/ncnn/glslang/SPIRV
)
@@ -80,11 +84,8 @@ if(WIN32)
set(SPIRV_LIB ${SPIRV_BUILD_PATH}/Debug/SPIRVd.lib)
endif()
list(APPEND ALL_LIBRARIES
${NCNN_BASE_PATH}/lib/ncnn.lib
${SPIRV_LIB}
)
list(APPEND ALL_INCLUDE_DIRS ${NCNN_BASE_PATH}/include/ncnn)
list(APPEND LIBVIDEO2X_LIBS ${NCNN_BASE_PATH}/lib/ncnn.lib ${SPIRV_LIB})
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${NCNN_BASE_PATH}/include/ncnn)
else()
# FFmpeg
find_package(PkgConfig REQUIRED)
@@ -98,13 +99,13 @@ else()
)
# Loop through each package to find and collect include dirs and libraries
set(FFMPEG_LIB)
foreach(PKG ${FFMPEG_REQUIRED_PKGS})
pkg_check_modules(${PKG} REQUIRED ${PKG})
list(APPEND ALL_INCLUDE_DIRS ${${PKG}_INCLUDE_DIRS})
list(APPEND FFMPEG_LIB ${${PKG}_LIBRARIES})
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()
list(APPEND ALL_LIBRARIES ${FFMPEG_LIB})
endif() # WIN32
# Find ncnn package
@@ -209,32 +210,38 @@ endif()
# spdlog
if(USE_SYSTEM_SPDLOG)
find_package(spdlog REQUIRED)
list(APPEND ALL_INCLUDE_DIRS ${spdlog_INCLUDE_DIRS})
list(APPEND LIBVIDEO2X_INCLUDE_DIRS ${spdlog_INCLUDE_DIRS})
list(APPEND VIDEO2X_INCLUDE_DIRS ${spdlog_INCLUDE_DIRS})
set(SPDLOG_LIB spdlog::spdlog)
else()
add_subdirectory(third_party/spdlog)
set(SPDLOG_LIB spdlog::spdlog_header_only)
endif()
list(APPEND ALL_LIBRARIES ${SPDLOG_LIB})
# Boost
if(USE_SYSTEM_BOOST)
find_package(Boost REQUIRED COMPONENTS program_options)
list(APPEND ALL_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()
set(BOOST_LIB Boost::program_options)
list(APPEND LIBVIDEO2X_LIBS ${SPDLOG_LIB})
list(APPEND VIDEO2X_LIBS ${SPDLOG_LIB})
# Find dependencies required for the CLI
if(BUILD_VIDEO2X_CLI)
# Vulkan
find_package(Vulkan REQUIRED)
set(VULKAN_LIB Vulkan::Vulkan)
list(APPEND VIDEO2X_LIBS Vulkan::Vulkan)
# Boost
if(USE_SYSTEM_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()
# Include ExternalProject module
@@ -253,7 +260,20 @@ ExternalProject_Add(
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
)
# Add librealesrgan-ncnn-vulkan as an external project
# Add librealcugan-ncnn-vulkan as an external project
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=${USE_SYSTEM_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
@@ -267,8 +287,10 @@ ExternalProject_Add(
)
# Remove duplicate entries
list(REMOVE_DUPLICATES ALL_INCLUDE_DIRS)
list(REMOVE_DUPLICATES ALL_LIBRARIES)
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)
@@ -281,37 +303,36 @@ else()
endif()
# Ensure that the shared library is built after the external projects
add_dependencies(libvideo2x realesrgan rife)
add_dependencies(libvideo2x realesrgan realcugan rife)
# Include directories for the shared library
target_include_directories(libvideo2x PRIVATE
${ALL_INCLUDE_DIRS}
${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
)
# Compile options for the shared library
target_compile_options(libvideo2x PRIVATE
-fPIC
$<$<CONFIG:Release>:-Ofast>
$<$<CONFIG:Debug>:-g -DDEBUG>
)
target_compile_options(libvideo2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -DDEBUG>)
# 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 ALL_LIBRARIES ${REALESRGAN_LIB} ${RIFE_LIB})
list(APPEND LIBVIDEO2X_LIBS ${REALESRGAN_LIB} ${REALCUGAN_LIB} ${RIFE_LIB})
# Link the shared library with the dependencies
target_link_libraries(libvideo2x PRIVATE ${ALL_LIBRARIES})
target_link_libraries(libvideo2x PRIVATE ${LIBVIDEO2X_LIBS})
if(NOT WIN32)
if(USE_SYSTEM_NCNN)
@@ -329,7 +350,7 @@ if(BUILD_VIDEO2X_CLI)
# Include directories for the executable
target_include_directories(video2x PRIVATE
${ALL_INCLUDE_DIRS}
${VIDEO2X_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/tools/video2x/include
@@ -339,13 +360,7 @@ if(BUILD_VIDEO2X_CLI)
target_compile_options(video2x PRIVATE $<$<CONFIG:Debug>:-g -DDEBUG>)
# Link the executable with the shared library
target_link_libraries(video2x PRIVATE
libvideo2x
${FFMPEG_LIB}
${SPDLOG_LIB}
${BOOST_LIB}
${VULKAN_LIB}
)
target_link_libraries(video2x PRIVATE libvideo2x ${VIDEO2X_LIBS})
endif()
# Define the default installation directories
@@ -404,6 +419,7 @@ if(WIN32)
file(GLOB FFMPEG_DLLS "${FFMPEG_BASE_PATH}/bin/*.dll")
install(FILES
${CMAKE_BINARY_DIR}/realesrgan_install/bin/librealesrgan-ncnn-vulkan.dll
${CMAKE_BINARY_DIR}/realcugan_install/bin/librealcugan-ncnn-vulkan.dll
${CMAKE_BINARY_DIR}/rife_install/bin/librife-ncnn-vulkan.dll
${FFMPEG_DLLS}
${NCNN_BASE_PATH}/bin/ncnn.dll
@@ -414,7 +430,7 @@ if(WIN32)
WORLD_READ WORLD_EXECUTE
)
else()
install(FILES ${REALESRGAN_LIB} ${RIFE_LIB}
install(FILES ${REALESRGAN_LIB} ${REALCUGAN_LIB} ${RIFE_LIB}
DESTINATION ${INSTALL_LIB_DESTINATION}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE

View File

@@ -1,10 +1,9 @@
.PHONY: build static debug windows windows-debug debian ubuntu clean \
test-realesrgan test-libplacebo test-rife \
memcheck-realesrgan memcheck-libplacebo memcheck-rife \
heaptrack-realesrgan heaptrack-libplacebo heaptrack-rife
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
CC=clang
CXX=clang++
TEST_VIDEO=data/standard-test.mp4
@@ -13,7 +12,6 @@ TEST_OUTPUT=data/output.mp4
build:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Release
cmake --build $(BINDIR) --config Release --parallel
@@ -22,17 +20,18 @@ build:
static:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=OFF \
-DUSE_SYSTEM_NCNN=OFF \
-DUSE_SYSTEM_SPDLOG=OFF \
-DUSE_SYSTEM_BOOST=OFF
cmake --build $(BINDIR) --config Release --parallel
cp $(BINDIR)/compile_commands.json .
debug:
cmake -S . -B $(BINDIR) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_BUILD_TYPE=Debug
cmake --build $(BINDIR) --config Debug --parallel
@@ -71,8 +70,7 @@ debian:
libomp-dev \
libspdlog-dev \
libboost-program-options-dev
cmake -B /tmp/build -S . -DUSE_SYSTEM_NCNN=OFF \
-DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) \
cmake -B /tmp/build -S . -DUSE_SYSTEM_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=.
@@ -93,8 +91,8 @@ ubuntu2404:
libomp-dev \
libboost-program-options-dev
cmake -B build -S . -DUSE_SYSTEM_NCNN=OFF -DUSE_SYSTEM_SPDLOG=OFF -DSPDLOG_NO_EXCEPTIONS=ON \
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
-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
@@ -118,8 +116,8 @@ ubuntu2204:
libomp-dev \
libboost-program-options-dev
cmake -B build -S . -DUSE_SYSTEM_NCNN=OFF -DUSE_SYSTEM_SPDLOG=OFF -DSPDLOG_NO_EXCEPTIONS=ON \
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=video2x-linux-ubuntu-amd64/usr
-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
@@ -132,6 +130,10 @@ 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
@@ -153,6 +155,19 @@ memcheck-realesrgan:
-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 \
@@ -186,6 +201,13 @@ heaptrack-realesrgan:
-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 \

9
NOTICE
View File

@@ -4,8 +4,17 @@ Copyright (C) 2018-2024 K4YT3X and contributors.
This product depends on FFmpeg, which is available under the GNU Lesser General Public License 2.1.
The source code can be found at https://github.com/FFmpeg/FFmpeg.
This product depends on Anime4K, which is available under the MIT License.
The source code can be found at https://github.com/bloc97/Anime4K.
This product depends on Real-ESRGAN ncnn Vulkan, which is available under the MIT License.
The source code can be found at https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan.
This product depends on Real-CUGAN ncnn Vulkan, which is available under the MIT License.
The source code can be found at https://github.com/nihui/realcugan-ncnn-vulkan.
This product depends on RIFE ncnn Vulkan, which is available under the MIT License.
The source code can be found at https://github.com/nihui/rife-ncnn-vulkan.
This product depends on ncnn, which is available under the BSD 3-Clause License.
The source code can be found at https://github.com/Tencent/ncnn.

View File

@@ -27,23 +27,19 @@ Version 6.0.0 is a complete rewrite of this project in C/C++. It:
- genuinely works this time, with much less hassle compared to the 5.0.0 beta;
- is blazing fast, thanks to the new optimized pipeline and the efficiency of C/C++;
- is cross-platform, available now for both Windows and Linux;
- offers significantly better output quality with Anime4K v4, RealESRGAN, and RIFE;
- offers significantly better output quality with Anime4K v4, RealESRGAN, RealCUGAN, and RIFE;
- supports two modes: filtering (upscaling) and frame interpolation;
- supports Anime4K v4 and all custom MPV-compatible GLSL shaders;
- supports RealESRGAN (all three models) via ncnn and Vulkan;
- supports RIFE via ncnn and Vulkan;
- requires zero additional disk space during processing, just space for the final output; and
- exports a standard C function for easy integration into other projects! (documentation is on the way)
Support for RealCUGAN is coming soon.
- supports RealESRGAN, RealCUGAN, and RIFE (all models) via ncnn and Vulkan;
- requires zero additional disk space during processing, just space for the final output.
</details>
![6.1.0-screenshot](https://github.com/user-attachments/assets/57aa11d0-dd01-49e9-b6b0-2d2f21a363ac)
![6.3.0-screenshot](https://github.com/user-attachments/assets/c5442f84-5ffc-4476-915f-a0fc188a2cb3)
## [🪟 Install on Windows](https://docs.video2x.org/installing/windows-qt6.html)
**[Download the Latest Windows Installer Executable (6.1.1)](https://github.com/k4yt3x/video2x/releases/download/6.1.1/video2x-qt6-windows-amd64-installer.exe)**
**[Download the Latest Windows Installer Executable (6.3.1)](https://github.com/k4yt3x/video2x/releases/download/6.3.1/video2x-qt6-windows-amd64-installer.exe)**
You can download the latest Windows release on the [releases page](https://github.com/k4yt3x/video2x/releases/latest). For basic GUI usage, refer to the [documentation](https://docs.video2x.org/running/desktop.html). If you're unable to download directly from GitHub, try the [mirror site](https://files.k4yt3x.com/Projects/Video2X). The GUI currently supports the following languages:
@@ -51,6 +47,7 @@ You can download the latest Windows release on the [releases page](https://githu
- 简体中文(中国)
- 日本語(日本)
- Português (Portugal)
- Français (France)
## [🐧 Install on Linux](https://docs.video2x.org/installing/linux.html)
@@ -92,6 +89,8 @@ _Upscale demo: Spirited Away's movie trailer_
The following clip can be used to test if your setup works properly. This is also the standard clip used for running performance benchmarks.
- [Standard Test Clip (240P)](https://files.k4yt3x.com/Resources/Videos/standard-test.mp4) 4.54 MiB
- [Real-CUGAN Upscaled Sample (1704P)](https://files.k4yt3x.com/Resources/Videos/standard-realcugan.mp4) 3.5 MiB
- [Real-ESRGAN Upscaled Sample (1704P)](https://files.k4yt3x.com/Resources/Videos/standard-realesrgan.mp4) 3.1 MiB
- [waifu2x Upscaled Sample (1080P)](https://files.k4yt3x.com/Resources/Videos/standard-waifu2x.mp4) 4.54 MiB
- [Ground Truth (1080P)](https://files.k4yt3x.com/Resources/Videos/standard-original.mp4) 22.2 MiB
@@ -109,10 +108,12 @@ This project includes or depends on these following projects:
| Project | License |
| ------------------------------------------------------------------------------------- | --------------- |
| [bloc97/Anime4K](https://github.com/bloc97/Anime4K) | MIT License |
| [FFmpeg/FFmpeg](https://www.ffmpeg.org/) | LGPLv2.1, GPLv2 |
| [xinntao/Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan) | MIT License |
| [Tencent/ncnn](https://github.com/Tencent/ncnn) | BSD 3-Clause |
| [bloc97/Anime4K](https://github.com/bloc97/Anime4K) | MIT License |
| [nihui/realcugan-ncnn-vulkan](https://github.com/nihui/realcugan-ncnn-vulkan) | MIT License |
| [nihui/rife-ncnn-vulkan](https://github.com/nihui/rife-ncnn-vulkan) | MIT License |
| [xinntao/Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan) | MIT License |
More licensing information can be found in the [NOTICE](NOTICE) file.

View File

@@ -4,6 +4,9 @@ extern "C" {
#include <libavformat/avformat.h>
}
namespace video2x {
namespace avutils {
AVRational get_video_frame_rate(AVFormatContext *ifmt_ctx, int in_vstream_idx);
int64_t get_video_frame_count(AVFormatContext *ifmt_ctx, int in_vstream_idx);
@@ -17,3 +20,6 @@ void av_bufferref_deleter(AVBufferRef *bufferref);
void av_frame_deleter(AVFrame *frame);
void av_packet_deleter(AVPacket *packet);
} // namespace avutils
} // namespace video2x

View File

@@ -7,6 +7,9 @@ extern "C" {
#include <mat.h>
namespace video2x {
namespace conversions {
// Convert AVFrame to another pixel format
AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt);
@@ -15,3 +18,6 @@ ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame);
// Convert ncnn::Mat to AVFrame
AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt);
} // namespace conversions
} // namespace video2x

View File

@@ -7,6 +7,9 @@ extern "C" {
#include <libavformat/avformat.h>
}
namespace video2x {
namespace decoder {
class Decoder {
public:
Decoder();
@@ -26,3 +29,6 @@ class Decoder {
AVCodecContext *dec_ctx_;
int in_vstream_idx_;
};
} // namespace decoder
} // namespace video2x

View File

@@ -12,6 +12,9 @@ extern "C" {
#include "fsutils.h"
namespace video2x {
namespace encoder {
// Encoder configurations
struct EncoderConfig {
// Non-AVCodecContext options
@@ -42,7 +45,7 @@ struct EncoderConfig {
int delay = -1;
// Extra AVOptions
std::vector<std::pair<StringType, StringType>> extra_opts;
std::vector<std::pair<fsutils::StringType, fsutils::StringType>> extra_opts;
};
class Encoder {
@@ -76,3 +79,6 @@ class Encoder {
int out_vstream_idx_;
int *stream_map_;
};
} // namespace encoder
} // namespace video2x

View File

@@ -10,6 +10,9 @@ extern "C" {
#include "processor.h"
namespace video2x {
namespace processors {
// FilterLibplacebo class definition
class FilterLibplacebo : public Filter {
public:
@@ -56,3 +59,6 @@ class FilterLibplacebo : public Filter {
AVRational in_time_base_;
AVRational out_time_base_;
};
} // namespace processors
} // namespace video2x

View File

@@ -0,0 +1,63 @@
#pragma once
extern "C" {
#include <libavcodec/avcodec.h>
}
#include "processor.h"
#include "realcugan.h"
namespace video2x {
namespace processors {
// FilterRealcugan class definition
class FilterRealcugan : public Filter {
public:
// Constructor
FilterRealcugan(
int gpuid = 0,
bool tta_mode = false,
int scaling_factor = 4,
int noise_level = -1,
int num_threads = 1,
int syncgap = 3,
const fsutils::StringType model_name = STR("models-pro")
);
// Destructor
virtual ~FilterRealcugan() override;
// Initializes the filter with decoder and encoder contexts
int init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *hw_ctx) override;
// Processes an input frame and returns the processed frame
int filter(AVFrame *in_frame, AVFrame **out_frame) override;
// Returns the filter's type
ProcessorType get_processor_type() const override { return ProcessorType::RealCUGAN; }
// Returns the filter's output dimensions
void get_output_dimensions(
const ProcessorConfig &proc_cfg,
int in_width,
int in_height,
int &out_width,
int &out_height
) const override;
private:
RealCUGAN *realcugan_;
int gpuid_;
bool tta_mode_;
int scaling_factor_;
int noise_level_;
int num_threads_;
int syncgap_;
const fsutils::StringType model_name_;
AVRational in_time_base_;
AVRational out_time_base_;
AVPixelFormat out_pix_fmt_;
};
} // namespace processors
} // namespace video2x

View File

@@ -7,6 +7,9 @@ extern "C" {
#include "processor.h"
#include "realesrgan.h"
namespace video2x {
namespace processors {
// FilterRealesrgan class definition
class FilterRealesrgan : public Filter {
public:
@@ -15,7 +18,7 @@ class FilterRealesrgan : public Filter {
int gpuid = 0,
bool tta_mode = false,
int scaling_factor = 4,
const StringType model_name = STR("realesr-animevideov3")
const fsutils::StringType model_name = STR("realesr-animevideov3")
);
// Destructor
@@ -44,8 +47,11 @@ class FilterRealesrgan : public Filter {
int gpuid_;
bool tta_mode_;
int scaling_factor_;
const StringType model_name_;
const fsutils::StringType model_name_;
AVRational in_time_base_;
AVRational out_time_base_;
AVPixelFormat out_pix_fmt_;
};
} // namespace processors
} // namespace video2x

View File

@@ -3,6 +3,9 @@
#include <filesystem>
#include <string>
namespace video2x {
namespace fsutils {
#ifdef _WIN32
typedef wchar_t CharType;
#define STR(x) L##x
@@ -23,8 +26,11 @@ std::filesystem::path find_resource_file(const std::filesystem::path &path);
std::string path_to_u8string(const std::filesystem::path &path);
std::string wstring_to_u8string(const StringType &wstr);
std::string wstring_to_u8string(const fsutils::StringType &wstr);
StringType path_to_string_type(const std::filesystem::path &path);
fsutils::StringType path_to_string_type(const std::filesystem::path &path);
StringType to_string_type(int value);
fsutils::StringType to_string_type(int value);
} // namespace fsutils
} // namespace video2x

View File

@@ -7,6 +7,9 @@ extern "C" {
#include "processor.h"
#include "rife.h"
namespace video2x {
namespace processors {
// InterpolatorRIFE class definition
class InterpolatorRIFE : public Interpolator {
public:
@@ -17,7 +20,7 @@ class InterpolatorRIFE : public Interpolator {
bool tta_temporal_mode = false,
bool uhd_mode = false,
int num_threads = 1,
const StringType model_name = STR("rife-v4.6")
const fsutils::StringType model_name = STR("rife-v4.6")
);
// Destructor
@@ -49,8 +52,11 @@ class InterpolatorRIFE : public Interpolator {
bool tta_temporal_mode_;
bool uhd_mode_;
int num_threads_;
const StringType model_name_;
const fsutils::StringType model_name_;
AVRational in_time_base_;
AVRational out_time_base_;
AVPixelFormat out_pix_fmt_;
};
} // namespace processors
} // namespace video2x

View File

@@ -7,6 +7,9 @@ extern "C" {
#include <libavfilter/avfilter.h>
}
namespace video2x {
namespace processors {
int init_libplacebo(
AVFilterGraph **filter_graph,
AVFilterContext **buffersrc_ctx,
@@ -17,3 +20,6 @@ int init_libplacebo(
uint32_t vk_device_index,
const std::filesystem::path &shader_path
);
} // namespace processors
} // namespace video2x

View File

@@ -12,18 +12,10 @@ extern "C" {
#include "avutils.h"
#include "decoder.h"
#include "encoder.h"
#include "logging.h"
#include "libvideo2x_export.h"
#include "processor.h"
#ifdef _WIN32
#ifdef LIBVIDEO2X_EXPORTS
#define LIBVIDEO2X_API __declspec(dllexport)
#else
#define LIBVIDEO2X_API __declspec(dllimport)
#endif
#else
#define LIBVIDEO2X_API
#endif
namespace video2x {
enum class VideoProcessorState {
Idle,
@@ -37,11 +29,10 @@ enum class VideoProcessorState {
class LIBVIDEO2X_API VideoProcessor {
public:
VideoProcessor(
const ProcessorConfig proc_cfg,
const EncoderConfig enc_cfg,
const uint32_t vk_device_index = 0,
const processors::ProcessorConfig proc_cfg,
const encoder::EncoderConfig enc_cfg,
const uint32_t vk_device_idx = 0,
const AVHWDeviceType hw_device_type = AV_HWDEVICE_TYPE_NONE,
const Video2xLogLevel = Video2xLogLevel::Info,
const bool benchmark = false
);
@@ -55,14 +46,17 @@ class LIBVIDEO2X_API VideoProcessor {
void abort() { state_.store(VideoProcessorState::Aborted); }
VideoProcessorState get_state() const { return state_.load(); }
int64_t get_processed_frames() const { return frame_index_.load(); }
int64_t get_processed_frames() const { return frame_idx_.load(); }
int64_t get_total_frames() const { return total_frames_.load(); }
private:
[[nodiscard]] int
process_frames(Decoder &decoder, Encoder &encoder, std::unique_ptr<Processor> &processor);
[[nodiscard]] int process_frames(
decoder::Decoder &decoder,
encoder::Encoder &encoder,
std::unique_ptr<processors::Processor> &processor
);
[[nodiscard]] int write_frame(AVFrame *frame, Encoder &encoder);
[[nodiscard]] int write_frame(AVFrame *frame, encoder::Encoder &encoder);
[[nodiscard]] inline int write_raw_packet(
AVPacket *packet,
@@ -72,27 +66,29 @@ class LIBVIDEO2X_API VideoProcessor {
);
[[nodiscard]] inline int process_filtering(
std::unique_ptr<Processor> &processor,
Encoder &encoder,
std::unique_ptr<processors::Processor> &processor,
encoder::Encoder &encoder,
AVFrame *frame,
AVFrame *proc_frame
);
[[nodiscard]] inline int process_interpolation(
std::unique_ptr<Processor> &processor,
Encoder &encoder,
std::unique_ptr<AVFrame, decltype(&av_frame_deleter)> &prev_frame,
std::unique_ptr<processors::Processor> &processor,
encoder::Encoder &encoder,
std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)> &prev_frame,
AVFrame *frame,
AVFrame *proc_frame
);
ProcessorConfig proc_cfg_;
EncoderConfig enc_cfg_;
uint32_t vk_device_index_ = 0;
processors::ProcessorConfig proc_cfg_;
encoder::EncoderConfig enc_cfg_;
uint32_t vk_device_idx_ = 0;
AVHWDeviceType hw_device_type_ = AV_HWDEVICE_TYPE_NONE;
bool benchmark_ = false;
std::atomic<VideoProcessorState> state_ = VideoProcessorState::Idle;
std::atomic<int64_t> frame_index_ = 0;
std::atomic<int64_t> frame_idx_ = 0;
std::atomic<int64_t> total_frames_ = 0;
};
} // namespace video2x

View File

@@ -0,0 +1,11 @@
#pragma once
#ifdef _WIN32
#ifdef LIBVIDEO2X_EXPORTS
#define LIBVIDEO2X_API __declspec(dllexport)
#else
#define LIBVIDEO2X_API __declspec(dllimport)
#endif
#else
#define LIBVIDEO2X_API
#endif

View File

@@ -0,0 +1,48 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <spdlog/logger.h>
#include <spdlog/sinks/sink.h>
#include "libvideo2x_export.h"
namespace video2x {
namespace logger_manager {
class LIBVIDEO2X_API LoggerManager {
public:
LoggerManager(const LoggerManager &) = delete;
LoggerManager &operator=(const LoggerManager &) = delete;
static LoggerManager &instance();
std::shared_ptr<spdlog::logger> logger();
bool reconfigure_logger(
const std::string &logger_name,
const std::vector<spdlog::sink_ptr> &sinks,
const std::string &pattern = "%+"
);
bool set_log_level(const std::string &level_str);
void hook_ffmpeg_logging();
void unhook_ffmpeg_logging();
private:
LoggerManager();
std::shared_ptr<spdlog::logger> logger_ = nullptr;
};
} // namespace logger_manager
// Convenience function to get the logger instance
inline std::shared_ptr<spdlog::logger> logger() {
return logger_manager::LoggerManager::instance().logger();
}
} // namespace video2x

View File

@@ -1,20 +0,0 @@
#pragma once
#include <optional>
#include "fsutils.h"
enum class Video2xLogLevel {
Unknown,
Trace,
Debug,
Info,
Warning,
Error,
Critical,
Off
};
void set_log_level(Video2xLogLevel log_level);
std::optional<Video2xLogLevel> find_log_level_by_name(const StringType &log_level_name);

View File

@@ -11,6 +11,9 @@ extern "C" {
#include "fsutils.h"
namespace video2x {
namespace processors {
enum class ProcessingMode {
Filter,
Interpolate,
@@ -20,16 +23,24 @@ enum class ProcessorType {
None,
Libplacebo,
RealESRGAN,
RealCUGAN,
RIFE,
};
struct LibplaceboConfig {
StringType shader_path;
fsutils::StringType shader_path;
};
struct RealESRGANConfig {
bool tta_mode = false;
StringType model_name;
fsutils::StringType model_name;
};
struct RealCUGANConfig {
bool tta_mode = false;
int num_threads = 1;
int syncgap = 3;
fsutils::StringType model_name;
};
struct RIFEConfig {
@@ -37,7 +48,7 @@ struct RIFEConfig {
bool tta_temporal_mode = false;
bool uhd_mode = false;
int num_threads = 0;
StringType model_name;
fsutils::StringType model_name;
};
// Unified filter configuration
@@ -46,16 +57,17 @@ struct ProcessorConfig {
int width = 0;
int height = 0;
int scaling_factor = 0;
int noise_level = -1;
int frm_rate_mul = 0;
float scn_det_thresh = 0.0f;
std::variant<LibplaceboConfig, RealESRGANConfig, RIFEConfig> config;
std::variant<LibplaceboConfig, RealESRGANConfig, RealCUGANConfig, RIFEConfig> config;
};
class Processor {
public:
virtual ~Processor() = default;
virtual int init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *hw_ctx) = 0;
virtual int flush(std::vector<AVFrame *> &_) { return 0; }
virtual int flush(std::vector<AVFrame *> &) { return 0; }
virtual ProcessingMode get_processing_mode() const = 0;
virtual ProcessorType get_processor_type() const = 0;
virtual void get_output_dimensions(
@@ -81,3 +93,6 @@ class Interpolator : public Processor {
virtual int
interpolate(AVFrame *prev_frame, AVFrame *in_frame, AVFrame **out_frame, float time_step) = 0;
};
} // namespace processors
} // namespace video2x

View File

@@ -6,6 +6,9 @@
#include "processor.h"
namespace video2x {
namespace processors {
// Processor Factory Class
class ProcessorFactory {
public:
@@ -31,3 +34,6 @@ class ProcessorFactory {
// Static initializer for default processors
static void init_default_processors(ProcessorFactory &factory);
};
} // namespace processors
} // namespace video2x

View File

@@ -1,3 +1,7 @@
#pragma once
namespace video2x {
#define LIBVIDEO2X_VERSION_STRING "@PROJECT_VERSION@"
} // namespace video2x

Binary file not shown.

View File

@@ -0,0 +1,37 @@
7767517
35 39
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 4 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Crop slice_43 1 1 5 9 -23309=2,4,4 -23310=2,-4,-4 -23311=2,1,2
Deconvolution deconvrelu_0 1 1 8 10 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_0 2 1 10 9 11
Convolution convrelu_5 1 1 11 12 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_20 1 1 12 13 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_1 1 2 13 14 15
Convolution convrelu_6 1 1 14 16 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_7 1 1 16 17 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_2 1 2 17 18 19
Convolution convrelu_8 1 1 18 20 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_9 1 1 20 21 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 21 22 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 22 23 24
Convolution convrelu_11 1 1 23 25 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_12 1 1 25 26 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_13 1 1 26 27 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Crop slice_44 1 1 24 28 -23309=2,4,4 -23310=2,-4,-4 -23311=2,1,2
Deconvolution deconvrelu_1 1 1 27 29 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 29 28 30
Convolution convrelu_14 1 1 30 31 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 31 32 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Crop slice_45 1 1 19 33 -23309=2,16,16 -23310=2,-16,-16 -23311=2,1,2
Deconvolution deconvrelu_2 1 1 32 34 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_2 2 1 34 33 35
Convolution convrelu_16 1 1 35 36 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_18 1 1 36 37 0=3 1=3 5=1 6=1728
Crop slice_46 1 1 15 38 -23309=2,20,20 -23310=2,-20,-20 -23311=2,1,2
BinaryOp add_3 2 1 37 38 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 10 11 12
Pooling mean_64 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_2 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_3 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 20 21 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 30 31 32
Pooling mean_65 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_4 2 1 31 35 36 0=2
Split splitncnn_5 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 41 42 43
Pooling mean_66 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_5 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 52 53 54
Pooling mean_67 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_7 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_8 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 63 64 0=3 1=3 5=1 6=1728
BinaryOp add_9 2 1 64 62 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=4 3=2 4=3 5=1 6=3072
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,57 @@
7767517
55 63
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 2 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 2 3 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_0 1 2 3 4 5
Convolution convrelu_2 1 1 5 6 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 6 7 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 7 8 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 8 9 10
Pooling mean_64 1 1 10 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 12 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 12 13 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 9 13 14 0=2
Crop pad_9 1 1 4 15 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 14 16 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 15 16 17
Convolution convrelu_6 1 1 17 18 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_48 1 1 18 19 0=3 1=5 3=3 4=2 5=1 6=4800
Split splitncnn_2 1 2 19 20 21
Convolution convrelu_7 1 1 21 22 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 22 23 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_3 1 2 23 24 25
Convolution convrelu_9 1 1 25 26 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 26 27 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 27 28 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 28 29 30
Pooling mean_65 1 1 30 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 32 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 32 33 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 29 33 34 0=2
Split splitncnn_5 1 2 34 35 36
Convolution convrelu_13 1 1 36 37 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 37 38 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 38 39 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_6 1 2 39 40 41
Pooling mean_66 1 1 41 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 43 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 43 44 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 40 44 45 0=2
Crop pad_10 1 1 35 46 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 45 47 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 46 47 48
Convolution convrelu_17 1 1 48 49 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 49 50 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 50 51 52
Pooling mean_67 1 1 52 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 54 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 54 55 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 51 55 56 0=2
Crop pad_11 1 1 24 57 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 56 58 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 57 58 59
Crop pad_12 1 1 20 60 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 59 61 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_46 1 1 61 62 0=3 1=3 5=1 6=1728
BinaryOp add_7 2 1 62 60 out0

Binary file not shown.

View File

@@ -0,0 +1,60 @@
7767517
58 66
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_2 1 2 10 11 12
Pooling mean_68 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_51 1 1 20 21 0=64 1=4 3=2 4=3 5=1 6=65536
Split splitncnn_3 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_5 1 2 30 31 32
Pooling mean_69 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 31 35 36 0=2
Split splitncnn_6 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 41 42 43
Pooling mean_70 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_8 1 2 52 53 54
Pooling mean_71 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_48 1 1 63 64 0=64 1=3 5=1 6=36864
BinaryOp add_7 2 1 64 62 65
Convolution conv_49 1 1 65 66 0=12 1=3 5=1 6=6912
Crop pad_13 1 1 66 67 -23309=2,1,1 -23310=2,-1,-1 -23311=2,-2,-1
PixelShuffle pixelshuffle_66 1 1 67 out0 0=2

Binary file not shown.

View File

@@ -0,0 +1,60 @@
7767517
58 66
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_2 1 2 10 11 12
Pooling mean_68 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_51 1 1 20 21 0=64 1=4 3=2 4=3 5=1 6=65536
Split splitncnn_3 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_5 1 2 30 31 32
Pooling mean_69 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 31 35 36 0=2
Split splitncnn_6 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 41 42 43
Pooling mean_70 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_8 1 2 52 53 54
Pooling mean_71 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_48 1 1 63 64 0=64 1=3 5=1 6=36864
BinaryOp add_7 2 1 64 62 65
Convolution conv_49 1 1 65 66 0=12 1=3 5=1 6=6912
Crop pad_13 1 1 66 67 -23309=2,1,1 -23310=2,-1,-1 -23311=2,-2,-1
PixelShuffle pixelshuffle_66 1 1 67 out0 0=2

Binary file not shown.

View File

@@ -0,0 +1,60 @@
7767517
58 66
Input in0 0 1 in0
Convolution convrelu_0 1 1 in0 4 0=32 1=3 5=1 6=864 9=2 -23310=1,1.000000e-01
Convolution convrelu_1 1 1 4 5 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_1 1 2 5 6 7
Convolution convrelu_2 1 1 7 8 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_3 1 1 8 9 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_4 1 1 9 10 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_2 1 2 10 11 12
Pooling mean_68 1 1 12 gap0 0=1 4=1
InnerProduct convrelu_5 1 1 gap0 14 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_21 1 1 14 15 0=64 1=1 2=512 9=4
BinaryOp mul_0 2 1 11 15 16 0=2
Crop pad_9 1 1 6 17 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_0 1 1 16 18 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_1 2 1 17 18 19
Convolution convrelu_6 1 1 19 20 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Deconvolution deconv_51 1 1 20 21 0=64 1=4 3=2 4=3 5=1 6=65536
Split splitncnn_3 1 2 21 22 23
Convolution convrelu_7 1 1 23 24 0=32 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Convolution convrelu_8 1 1 24 25 0=64 1=3 5=1 6=18432 9=2 -23310=1,1.000000e-01
Split splitncnn_4 1 2 25 26 27
Convolution convrelu_9 1 1 27 28 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
Convolution convrelu_10 1 1 28 29 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution convrelu_11 1 1 29 30 0=128 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Split splitncnn_5 1 2 30 31 32
Pooling mean_69 1 1 32 gap1 0=1 4=1
InnerProduct convrelu_12 1 1 gap1 34 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_22 1 1 34 35 0=128 1=1 2=2048 9=4
BinaryOp mul_2 2 1 31 35 36 0=2
Split splitncnn_6 1 2 36 37 38
Convolution convrelu_13 1 1 38 39 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
Convolution convrelu_14 1 1 39 40 0=256 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Convolution convrelu_15 1 1 40 41 0=128 1=3 5=1 6=294912 9=2 -23310=1,1.000000e-01
Split splitncnn_7 1 2 41 42 43
Pooling mean_70 1 1 43 gap2 0=1 4=1
InnerProduct convrelu_16 1 1 gap2 45 0=16 1=1 2=2048 9=1
InnerProduct convsigmoid_23 1 1 45 46 0=128 1=1 2=2048 9=4
BinaryOp mul_3 2 1 42 46 47 0=2
Crop pad_10 1 1 37 48 -23309=2,4,4 -23310=2,-4,-4 -23311=2,-2,-1
Deconvolution deconvrelu_1 1 1 47 49 0=128 1=2 3=2 5=1 6=65536 9=2 -23310=1,1.000000e-01
BinaryOp add_4 2 1 48 49 50
Convolution convrelu_17 1 1 50 51 0=64 1=3 5=1 6=73728 9=2 -23310=1,1.000000e-01
Convolution convrelu_18 1 1 51 52 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Split splitncnn_8 1 2 52 53 54
Pooling mean_71 1 1 54 gap3 0=1 4=1
InnerProduct convrelu_19 1 1 gap3 56 0=8 1=1 2=512 9=1
InnerProduct convsigmoid_24 1 1 56 57 0=64 1=1 2=512 9=4
BinaryOp mul_5 2 1 53 57 58 0=2
Crop pad_11 1 1 26 59 -23309=2,16,16 -23310=2,-16,-16 -23311=2,-2,-1
Deconvolution deconvrelu_2 1 1 58 60 0=64 1=2 3=2 5=1 6=16384 9=2 -23310=1,1.000000e-01
BinaryOp add_6 2 1 59 60 61
Crop pad_12 1 1 22 62 -23309=2,20,20 -23310=2,-20,-20 -23311=2,-2,-1
Convolution convrelu_20 1 1 61 63 0=64 1=3 5=1 6=36864 9=2 -23310=1,1.000000e-01
Convolution conv_48 1 1 63 64 0=64 1=3 5=1 6=36864
BinaryOp add_7 2 1 64 62 65
Convolution conv_49 1 1 65 66 0=12 1=3 5=1 6=6912
Crop pad_13 1 1 66 67 -23309=2,1,1 -23310=2,-1,-1 -23311=2,-2,-1
PixelShuffle pixelshuffle_66 1 1 67 out0 0=2

View File

@@ -10,6 +10,10 @@ extern "C" {
#include <spdlog/spdlog.h>
#include "conversions.h"
#include "logger_manager.h"
namespace video2x {
namespace avutils {
AVRational get_video_frame_rate(AVFormatContext *ifmt_ctx, int in_vstream_idx) {
AVRational frame_rate = ifmt_ctx->streams[in_vstream_idx]->avg_frame_rate;
@@ -75,7 +79,7 @@ AVPixelFormat get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat
);
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::error("Failed to get supported pixel formats: {}", errbuf);
logger()->error("Failed to get supported pixel formats: {}", errbuf);
return AV_PIX_FMT_NONE;
}
@@ -116,7 +120,7 @@ AVPixelFormat get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat
}
}
if (best_pix_fmt == AV_PIX_FMT_NONE) {
spdlog::error("No suitable pixel format found for encoder");
logger()->error("No suitable pixel format found for encoder");
}
if (target_pix_fmt != AV_PIX_FMT_NONE && best_pix_fmt != target_pix_fmt) {
@@ -133,12 +137,12 @@ AVPixelFormat get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat
float get_frame_diff(AVFrame *frame1, AVFrame *frame2) {
if (!frame1 || !frame2) {
spdlog::error("Invalid frame(s) provided for comparison");
logger()->error("Invalid frame(s) provided for comparison");
return -1.0f;
}
if (frame1->width != frame2->width || frame1->height != frame2->height) {
spdlog::error("Frame dimensions do not match");
logger()->error("Frame dimensions do not match");
return -1.0f;
}
@@ -147,11 +151,11 @@ float get_frame_diff(AVFrame *frame1, AVFrame *frame2) {
// Convert both frames to the target pixel format using the provided function
AVPixelFormat target_pix_fmt = AV_PIX_FMT_RGB24;
AVFrame *rgb_frame1 = convert_avframe_pix_fmt(frame1, target_pix_fmt);
AVFrame *rgb_frame2 = convert_avframe_pix_fmt(frame2, target_pix_fmt);
AVFrame *rgb_frame1 = conversions::convert_avframe_pix_fmt(frame1, target_pix_fmt);
AVFrame *rgb_frame2 = conversions::convert_avframe_pix_fmt(frame2, target_pix_fmt);
if (!rgb_frame1 || !rgb_frame2) {
spdlog::error("Failed to convert frames to target pixel format");
logger()->error("Failed to convert frames to target pixel format");
if (rgb_frame1) {
av_frame_free(&rgb_frame1);
}
@@ -208,3 +212,6 @@ void av_packet_deleter(AVPacket *packet) {
packet = nullptr;
}
}
} // namespace avutils
} // namespace video2x

View File

@@ -5,11 +5,16 @@
#include <spdlog/spdlog.h>
#include "logger_manager.h"
namespace video2x {
namespace conversions {
// Convert AVFrame format
AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) {
AVFrame *dst_frame = av_frame_alloc();
if (dst_frame == nullptr) {
spdlog::error("Failed to allocate destination AVFrame.");
logger()->error("Failed to allocate destination AVFrame.");
return nullptr;
}
@@ -19,7 +24,7 @@ AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) {
// Allocate memory for the converted frame
if (av_frame_get_buffer(dst_frame, 32) < 0) {
spdlog::error("Failed to allocate memory for AVFrame.");
logger()->error("Failed to allocate memory for AVFrame.");
av_frame_free(&dst_frame);
return nullptr;
}
@@ -39,7 +44,7 @@ AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) {
);
if (sws_ctx == nullptr) {
spdlog::error("Failed to initialize swscale context.");
logger()->error("Failed to initialize swscale context.");
av_frame_free(&dst_frame);
return nullptr;
}
@@ -69,7 +74,7 @@ ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame) {
if (frame->format != AV_PIX_FMT_BGR24) {
converted_frame = convert_avframe_pix_fmt(frame, AV_PIX_FMT_BGR24);
if (!converted_frame) {
spdlog::error("Failed to convert AVFrame to BGR24.");
logger()->error("Failed to convert AVFrame to BGR24.");
return ncnn::Mat();
}
} else {
@@ -107,7 +112,7 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
// Step 1: Allocate a destination AVFrame for the specified pixel format
AVFrame *dst_frame = av_frame_alloc();
if (!dst_frame) {
spdlog::error("Failed to allocate destination AVFrame.");
logger()->error("Failed to allocate destination AVFrame.");
return nullptr;
}
@@ -117,7 +122,7 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
// Allocate memory for the frame buffer
if (av_frame_get_buffer(dst_frame, 32) < 0) {
spdlog::error("Failed to allocate memory for destination AVFrame.");
logger()->error("Failed to allocate memory for destination AVFrame.");
av_frame_free(&dst_frame);
return nullptr;
}
@@ -125,7 +130,7 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
// Step 2: Convert ncnn::Mat to BGR AVFrame
AVFrame *bgr_frame = av_frame_alloc();
if (!bgr_frame) {
spdlog::error("Failed to allocate intermediate BGR AVFrame.");
logger()->error("Failed to allocate intermediate BGR AVFrame.");
av_frame_free(&dst_frame);
return nullptr;
}
@@ -136,7 +141,7 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
// Allocate memory for the intermediate BGR frame
if (av_frame_get_buffer(bgr_frame, 32) < 0) {
spdlog::error("Failed to allocate memory for BGR AVFrame.");
logger()->error("Failed to allocate memory for BGR AVFrame.");
av_frame_free(&dst_frame);
av_frame_free(&bgr_frame);
return nullptr;
@@ -166,7 +171,7 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
);
if (sws_ctx == nullptr) {
spdlog::error("Failed to initialize swscale context.");
logger()->error("Failed to initialize swscale context.");
av_frame_free(&bgr_frame);
av_frame_free(&dst_frame);
return nullptr;
@@ -188,10 +193,13 @@ AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
av_frame_free(&bgr_frame);
if (ret != dst_frame->height) {
spdlog::error("Failed to convert BGR AVFrame to destination pixel format.");
logger()->error("Failed to convert BGR AVFrame to destination pixel format.");
av_frame_free(&dst_frame);
return nullptr;
}
return dst_frame;
}
} // namespace conversions
} // namespace video2x

View File

@@ -2,6 +2,11 @@
#include <spdlog/spdlog.h>
#include "logger_manager.h"
namespace video2x {
namespace decoder {
AVPixelFormat Decoder::hw_pix_fmt_ = AV_PIX_FMT_NONE;
Decoder::Decoder() : fmt_ctx_(nullptr), dec_ctx_(nullptr), in_vstream_idx_(-1) {}
@@ -23,7 +28,7 @@ AVPixelFormat Decoder::get_hw_format(AVCodecContext *_, const AVPixelFormat *pix
return *p;
}
}
spdlog::error("Failed to get HW surface format.");
logger()->error("Failed to get HW surface format.");
return AV_PIX_FMT_NONE;
}
@@ -36,20 +41,20 @@ int Decoder::init(
// Open the input file
if ((ret = avformat_open_input(&fmt_ctx_, in_fpath.u8string().c_str(), nullptr, nullptr)) < 0) {
spdlog::error("Could not open input file '{}'", in_fpath.u8string());
logger()->error("Could not open input file '{}'", in_fpath.u8string());
return ret;
}
// Retrieve stream information
if ((ret = avformat_find_stream_info(fmt_ctx_, nullptr)) < 0) {
spdlog::error("Failed to retrieve input stream information");
logger()->error("Failed to retrieve input stream information");
return ret;
}
// Find the first video stream
ret = av_find_best_stream(fmt_ctx_, AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0);
if (ret < 0) {
spdlog::error("Could not find video stream in the input file");
logger()->error("Could not find video stream in the input file");
return ret;
}
@@ -59,7 +64,7 @@ int Decoder::init(
// Find the decoder for the video stream
const AVCodec *decoder = avcodec_find_decoder(video_stream->codecpar->codec_id);
if (!decoder) {
spdlog::error(
logger()->error(
"Failed to find decoder for codec ID {}",
static_cast<int>(video_stream->codecpar->codec_id)
);
@@ -69,13 +74,13 @@ int Decoder::init(
// Allocate the decoder context
dec_ctx_ = avcodec_alloc_context3(decoder);
if (!dec_ctx_) {
spdlog::error("Failed to allocate the decoder context");
logger()->error("Failed to allocate the decoder context");
return AVERROR(ENOMEM);
}
// Copy codec parameters from input stream to decoder context
if ((ret = avcodec_parameters_to_context(dec_ctx_, video_stream->codecpar)) < 0) {
spdlog::error("Failed to copy decoder parameters to input decoder context");
logger()->error("Failed to copy decoder parameters to input decoder context");
return ret;
}
@@ -93,7 +98,7 @@ int Decoder::init(
for (int i = 0;; i++) {
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
if (config == nullptr) {
spdlog::error(
logger()->error(
"Decoder {} does not support device type {}.",
decoder->name,
av_hwdevice_get_type_name(hw_type)
@@ -110,7 +115,7 @@ int Decoder::init(
// Open the decoder
if ((ret = avcodec_open2(dec_ctx_, decoder, nullptr)) < 0) {
spdlog::error("Failed to open decoder for stream #{}", stream_index);
logger()->error("Failed to open decoder for stream #{}", stream_index);
return ret;
}
@@ -130,3 +135,6 @@ AVCodecContext *Decoder::get_codec_context() const {
int Decoder::get_video_stream_index() const {
return in_vstream_idx_;
}
} // namespace decoder
} // namespace video2x

View File

@@ -6,9 +6,14 @@ extern "C" {
#include <libavutil/opt.h>
}
#include "logger_manager.h"
#include "avutils.h"
#include "conversions.h"
namespace video2x {
namespace encoder {
Encoder::Encoder()
: ofmt_ctx_(nullptr), enc_ctx_(nullptr), out_vstream_idx_(-1), stream_map_(nullptr) {}
@@ -43,14 +48,14 @@ int Encoder::init(
// Allocate the output format context
avformat_alloc_output_context2(&ofmt_ctx_, nullptr, nullptr, out_fpath.u8string().c_str());
if (!ofmt_ctx_) {
spdlog::error("Could not create output context");
logger()->error("Could not create output context");
return AVERROR_UNKNOWN;
}
// Find the encoder
const AVCodec *encoder = avcodec_find_encoder(enc_cfg.codec);
if (!encoder) {
spdlog::error(
logger()->error(
"Required video encoder not found for codec {}", avcodec_get_name(enc_cfg.codec)
);
return AVERROR_ENCODER_NOT_FOUND;
@@ -59,7 +64,7 @@ int Encoder::init(
// Create a new video stream in the output file
AVStream *out_vstream = avformat_new_stream(ofmt_ctx_, nullptr);
if (!out_vstream) {
spdlog::error("Failed to allocate the output video stream");
logger()->error("Failed to allocate the output video stream");
return AVERROR_UNKNOWN;
}
out_vstream_idx_ = out_vstream->index;
@@ -67,7 +72,7 @@ int Encoder::init(
// Allocate the encoder context
enc_ctx_ = avcodec_alloc_context3(encoder);
if (!enc_ctx_) {
spdlog::error("Failed to allocate the encoder context");
logger()->error("Failed to allocate the encoder context");
return AVERROR(ENOMEM);
}
@@ -116,16 +121,16 @@ int Encoder::init(
enc_ctx_->pix_fmt = enc_cfg.pix_fmt;
} else {
// Automatically select the pixel format
enc_ctx_->pix_fmt = get_encoder_default_pix_fmt(encoder, dec_ctx->pix_fmt);
enc_ctx_->pix_fmt = avutils::get_encoder_default_pix_fmt(encoder, dec_ctx->pix_fmt);
if (enc_ctx_->pix_fmt == AV_PIX_FMT_NONE) {
spdlog::error("Could not get the default pixel format for the encoder");
logger()->error("Could not get the default pixel format for the encoder");
return AVERROR(EINVAL);
}
spdlog::debug("Auto-selected pixel format: {}", av_get_pix_fmt_name(enc_ctx_->pix_fmt));
}
if (frm_rate_mul > 0) {
AVRational in_frame_rate = get_video_frame_rate(ifmt_ctx, in_vstream_idx);
AVRational in_frame_rate = avutils::get_video_frame_rate(ifmt_ctx, in_vstream_idx);
enc_ctx_->framerate = {in_frame_rate.num * frm_rate_mul, in_frame_rate.den};
enc_ctx_->time_base = av_inv_q(enc_ctx_->framerate);
} else {
@@ -146,8 +151,8 @@ int Encoder::init(
// Set extra AVOptions
for (const auto &[opt_name, opt_value] : enc_cfg.extra_opts) {
std::string opt_name_str = wstring_to_u8string(opt_name);
std::string opt_value_str = wstring_to_u8string(opt_value);
std::string opt_name_str = fsutils::wstring_to_u8string(opt_name);
std::string opt_value_str = fsutils::wstring_to_u8string(opt_value);
spdlog::debug("Setting encoder option '{}' to '{}'", opt_name_str, opt_value_str);
if (av_opt_set(enc_ctx_->priv_data, opt_name_str.c_str(), opt_value_str.c_str(), 0) < 0) {
@@ -162,14 +167,14 @@ int Encoder::init(
// Open the encoder
if ((ret = avcodec_open2(enc_ctx_, encoder, nullptr)) < 0) {
spdlog::error("Cannot open video encoder");
logger()->error("Cannot open video encoder");
return ret;
}
// Copy encoder parameters to output video stream
ret = avcodec_parameters_from_context(out_vstream->codecpar, enc_ctx_);
if (ret < 0) {
spdlog::error("Failed to copy encoder parameters to output video stream");
logger()->error("Failed to copy encoder parameters to output video stream");
return ret;
}
@@ -183,7 +188,7 @@ int Encoder::init(
stream_map_ =
reinterpret_cast<int *>(av_malloc_array(ifmt_ctx->nb_streams, sizeof(*stream_map_)));
if (!stream_map_) {
spdlog::error("Could not allocate stream mapping");
logger()->error("Could not allocate stream mapping");
return AVERROR(ENOMEM);
}
@@ -209,14 +214,14 @@ int Encoder::init(
// Create corresponding output stream for audio and subtitle streams
AVStream *out_stream = avformat_new_stream(ofmt_ctx_, nullptr);
if (!out_stream) {
spdlog::error("Failed allocating output stream");
logger()->error("Failed allocating output stream");
return AVERROR_UNKNOWN;
}
// Copy codec parameters from input to output
ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
if (ret < 0) {
spdlog::error("Failed to copy codec parameters");
logger()->error("Failed to copy codec parameters");
return ret;
}
out_stream->codecpar->codec_tag = 0;
@@ -234,7 +239,7 @@ int Encoder::init(
if (!(ofmt_ctx_->oformat->flags & AVFMT_NOFILE)) {
ret = avio_open(&ofmt_ctx_->pb, out_fpath.u8string().c_str(), AVIO_FLAG_WRITE);
if (ret < 0) {
spdlog::error("Could not open output file '{}'", out_fpath.u8string());
logger()->error("Could not open output file '{}'", out_fpath.u8string());
return ret;
}
}
@@ -242,7 +247,7 @@ int Encoder::init(
// Write the output file header
ret = avformat_write_header(ofmt_ctx_, nullptr);
if (ret < 0) {
spdlog::error("Error writing output file header");
logger()->error("Error writing output file header");
return ret;
}
@@ -253,16 +258,17 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
AVFrame *converted_frame = nullptr;
int ret;
// Set the frame's presentation timestamp if not set
if (frame->pts <= 0) {
frame->pts = frame_idx;
}
// Let the encoder decide the frame type
frame->pict_type = AV_PICTURE_TYPE_NONE;
// Calculate this frame's presentation timestamp (PTS)
frame->pts = av_rescale_q(frame_idx, av_inv_q(enc_ctx_->framerate), enc_ctx_->time_base);
// Convert the frame to the encoder's pixel format if needed
if (frame->format != enc_ctx_->pix_fmt) {
converted_frame = convert_avframe_pix_fmt(frame, enc_ctx_->pix_fmt);
converted_frame = conversions::convert_avframe_pix_fmt(frame, enc_ctx_->pix_fmt);
if (!converted_frame) {
spdlog::error("Error converting frame to encoder's pixel format");
logger()->error("Error converting frame to encoder's pixel format");
return AVERROR_EXTERNAL;
}
converted_frame->pts = frame->pts;
@@ -270,7 +276,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
AVPacket *enc_pkt = av_packet_alloc();
if (!enc_pkt) {
spdlog::error("Could not allocate AVPacket");
logger()->error("Could not allocate AVPacket");
return AVERROR(ENOMEM);
}
@@ -282,7 +288,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
ret = avcodec_send_frame(enc_ctx_, frame);
}
if (ret < 0) {
spdlog::error("Error sending frame to encoder");
logger()->error("Error sending frame to encoder");
av_packet_free(&enc_pkt);
return ret;
}
@@ -294,7 +300,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
av_packet_unref(enc_pkt);
break;
} else if (ret < 0) {
spdlog::error("Error encoding frame");
logger()->error("Error encoding frame");
av_packet_free(&enc_pkt);
return ret;
}
@@ -309,7 +315,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
ret = av_interleaved_write_frame(ofmt_ctx_, enc_pkt);
av_packet_unref(enc_pkt);
if (ret < 0) {
spdlog::error("Error muxing packet");
logger()->error("Error muxing packet");
av_packet_free(&enc_pkt);
return ret;
}
@@ -323,14 +329,14 @@ int Encoder::flush() {
int ret;
AVPacket *enc_pkt = av_packet_alloc();
if (!enc_pkt) {
spdlog::error("Could not allocate AVPacket");
logger()->error("Could not allocate AVPacket");
return AVERROR(ENOMEM);
}
// Send a NULL frame to signal the encoder to flush
ret = avcodec_send_frame(enc_ctx_, nullptr);
if (ret < 0) {
spdlog::error("Error sending NULL frame to encoder during flush");
logger()->error("Error sending NULL frame to encoder during flush");
av_packet_free(&enc_pkt);
return ret;
}
@@ -342,7 +348,7 @@ int Encoder::flush() {
av_packet_unref(enc_pkt);
break;
} else if (ret < 0) {
spdlog::error("Error encoding packet during flush");
logger()->error("Error encoding packet during flush");
av_packet_free(&enc_pkt);
return ret;
}
@@ -357,7 +363,7 @@ int Encoder::flush() {
ret = av_interleaved_write_frame(ofmt_ctx_, enc_pkt);
av_packet_unref(enc_pkt);
if (ret < 0) {
spdlog::error("Error muxing packet during flush");
logger()->error("Error muxing packet during flush");
av_packet_free(&enc_pkt);
return ret;
}
@@ -382,3 +388,6 @@ int Encoder::get_output_video_stream_index() const {
int *Encoder::get_stream_map() const {
return stream_map_;
}
} // namespace encoder
} // namespace video2x

View File

@@ -6,6 +6,10 @@
#include "fsutils.h"
#include "libplacebo.h"
#include "logger_manager.h"
namespace video2x {
namespace processors {
FilterLibplacebo::FilterLibplacebo(
uint32_t vk_device_index,
@@ -39,20 +43,20 @@ FilterLibplacebo::~FilterLibplacebo() {
int FilterLibplacebo::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *) {
// Construct the shader path
std::filesystem::path shader_full_path;
if (filepath_is_readable(shader_path_)) {
if (fsutils::filepath_is_readable(shader_path_)) {
// If the shader path is directly readable, use it
shader_full_path = shader_path_;
} else {
// Construct the fallback path using std::filesystem
shader_full_path = find_resource_file(
shader_full_path = fsutils::find_resource_file(
std::filesystem::path(STR("models")) / STR("libplacebo") /
(path_to_string_type(shader_path_) + STR(".glsl"))
(fsutils::path_to_string_type(shader_path_) + STR(".glsl"))
);
}
// Check if the shader file exists
if (!std::filesystem::exists(shader_full_path)) {
spdlog::error("libplacebo shader file not found: '{}'", shader_path_.u8string());
logger()->error("libplacebo shader file not found: '{}'", shader_path_.u8string());
return -1;
}
@@ -87,14 +91,14 @@ int FilterLibplacebo::filter(AVFrame *in_frame, AVFrame **out_frame) {
// Get the filtered frame
*out_frame = av_frame_alloc();
if (*out_frame == nullptr) {
spdlog::error("Failed to allocate output frame");
logger()->error("Failed to allocate output frame");
return -1;
}
// Feed the frame to the filter graph
ret = av_buffersrc_add_frame(buffersrc_ctx_, in_frame);
if (ret < 0) {
spdlog::error("Error while feeding the filter graph");
logger()->error("Error while feeding the filter graph");
av_frame_free(out_frame);
return ret;
}
@@ -115,7 +119,7 @@ int FilterLibplacebo::filter(AVFrame *in_frame, AVFrame **out_frame) {
int FilterLibplacebo::flush(std::vector<AVFrame *> &flushed_frames) {
int ret = av_buffersrc_add_frame(buffersrc_ctx_, nullptr);
if (ret < 0) {
spdlog::error("Error while flushing filter graph");
logger()->error("Error while flushing filter graph");
return ret;
}
@@ -156,3 +160,6 @@ void FilterLibplacebo::get_output_dimensions(
out_width = proc_cfg.width;
out_height = proc_cfg.height;
}
} // namespace processors
} // namespace video2x

207
src/filter_realcugan.cpp Normal file
View File

@@ -0,0 +1,207 @@
#include "filter_realcugan.h"
#include <cstdint>
#include <cstdio>
#include <filesystem>
#include <spdlog/spdlog.h>
#include "conversions.h"
#include "fsutils.h"
#include "logger_manager.h"
namespace video2x {
namespace processors {
FilterRealcugan::FilterRealcugan(
int gpuid,
bool tta_mode,
int scaling_factor,
int noise_level,
int num_threads,
int syncgap,
const fsutils::StringType model_name
)
: realcugan_(nullptr),
gpuid_(gpuid),
tta_mode_(tta_mode),
scaling_factor_(scaling_factor),
noise_level_(noise_level),
num_threads_(num_threads),
syncgap_(syncgap),
model_name_(std::move(model_name)) {}
FilterRealcugan::~FilterRealcugan() {
if (realcugan_) {
delete realcugan_;
realcugan_ = nullptr;
}
}
int FilterRealcugan::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *) {
// Construct the model paths using std::filesystem
std::filesystem::path model_param_path;
std::filesystem::path model_bin_path;
fsutils::StringType model_base_name =
STR("up") + fsutils::to_string_type(scaling_factor_) + STR("x-");
switch (noise_level_) {
case -1:
model_base_name += STR("conservative");
break;
case 0:
model_base_name += STR("no-denoise");
break;
default:
model_base_name += STR("denoise") + fsutils::to_string_type(noise_level_) + STR("x");
break;
}
fsutils::StringType param_file_name = model_base_name + STR(".param");
fsutils::StringType bin_file_name = model_base_name + STR(".bin");
// Find the model paths by model name if provided
model_param_path =
std::filesystem::path(STR("models")) / STR("realcugan") / model_name_ / param_file_name;
model_bin_path =
std::filesystem::path(STR("models")) / STR("realcugan") / model_name_ / bin_file_name;
// Get the full paths using a function that possibly modifies or validates the path
std::filesystem::path model_param_full_path = fsutils::find_resource_file(model_param_path);
std::filesystem::path model_bin_full_path = fsutils::find_resource_file(model_bin_path);
// Check if the model files exist
if (!std::filesystem::exists(model_param_full_path)) {
logger()->error("RealCUGAN model param file not found: {}", model_param_path.u8string());
return -1;
}
if (!std::filesystem::exists(model_bin_full_path)) {
logger()->error("RealCUGAN model bin file not found: {}", model_bin_path.u8string());
return -1;
}
// Create a new RealCUGAN instance
realcugan_ = new RealCUGAN(gpuid_, tta_mode_, num_threads_);
// Store the time bases
in_time_base_ = dec_ctx->time_base;
out_time_base_ = enc_ctx->time_base;
out_pix_fmt_ = enc_ctx->pix_fmt;
// Load the model
if (realcugan_->load(model_param_full_path, model_bin_full_path) != 0) {
logger()->error("Failed to load RealCUGAN model");
return -1;
}
// Set syncgap to 0 for models-nose
if (model_name_.find(STR("models-nose")) != fsutils::StringType::npos) {
syncgap_ = 0;
}
// Set realcugan parameters
realcugan_->scale = scaling_factor_;
realcugan_->noise = noise_level_;
realcugan_->prepadding = 10;
// Set prepadding based on scaling factor
if (scaling_factor_ == 2) {
realcugan_->prepadding = 18;
}
if (scaling_factor_ == 3) {
realcugan_->prepadding = 14;
}
if (scaling_factor_ == 4) {
realcugan_->prepadding = 19;
}
// Calculate tilesize based on GPU heap budget
uint32_t heap_budget = ncnn::get_gpu_device(gpuid_)->get_heap_budget();
if (scaling_factor_ == 2) {
if (heap_budget > 1300) {
realcugan_->tilesize = 400;
} else if (heap_budget > 800) {
realcugan_->tilesize = 300;
} else if (heap_budget > 400) {
realcugan_->tilesize = 200;
} else if (heap_budget > 200) {
realcugan_->tilesize = 100;
} else {
realcugan_->tilesize = 32;
}
}
if (scaling_factor_ == 3) {
if (heap_budget > 3300) {
realcugan_->tilesize = 400;
} else if (heap_budget > 1900) {
realcugan_->tilesize = 300;
} else if (heap_budget > 950) {
realcugan_->tilesize = 200;
} else if (heap_budget > 320) {
realcugan_->tilesize = 100;
} else {
realcugan_->tilesize = 32;
}
}
if (scaling_factor_ == 4) {
if (heap_budget > 1690) {
realcugan_->tilesize = 400;
} else if (heap_budget > 980) {
realcugan_->tilesize = 300;
} else if (heap_budget > 530) {
realcugan_->tilesize = 200;
} else if (heap_budget > 240) {
realcugan_->tilesize = 100;
} else {
realcugan_->tilesize = 32;
}
}
return 0;
}
int FilterRealcugan::filter(AVFrame *in_frame, AVFrame **out_frame) {
int ret;
// Convert the input frame to RGB24
ncnn::Mat in_mat = conversions::avframe_to_ncnn_mat(in_frame);
if (in_mat.empty()) {
logger()->error("Failed to convert AVFrame to ncnn::Mat");
return -1;
}
// Allocate space for output ncnn::Mat
int output_width = in_mat.w * realcugan_->scale;
int output_height = in_mat.h * realcugan_->scale;
ncnn::Mat out_mat = ncnn::Mat(output_width, output_height, static_cast<size_t>(3), 3);
ret = realcugan_->process(in_mat, out_mat);
if (ret != 0) {
logger()->error("RealCUGAN processing failed");
return ret;
}
// Convert ncnn::Mat to AVFrame
*out_frame = conversions::ncnn_mat_to_avframe(out_mat, out_pix_fmt_);
// Rescale PTS to encoder's time base
(*out_frame)->pts = av_rescale_q(in_frame->pts, in_time_base_, out_time_base_);
// Return the processed frame to the caller
return ret;
}
void FilterRealcugan::get_output_dimensions(
const ProcessorConfig &,
int in_width,
int in_height,
int &out_width,
int &out_height
) const {
out_width = in_width * scaling_factor_;
out_height = in_height * scaling_factor_;
}
} // namespace processors
} // namespace video2x

View File

@@ -8,12 +8,16 @@
#include "conversions.h"
#include "fsutils.h"
#include "logger_manager.h"
namespace video2x {
namespace processors {
FilterRealesrgan::FilterRealesrgan(
int gpuid,
bool tta_mode,
int scaling_factor,
const StringType model_name
const fsutils::StringType model_name
)
: realesrgan_(nullptr),
gpuid_(gpuid),
@@ -28,31 +32,31 @@ FilterRealesrgan::~FilterRealesrgan() {
}
}
int FilterRealesrgan::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *_) {
int FilterRealesrgan::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVBufferRef *) {
// Construct the model paths using std::filesystem
std::filesystem::path model_param_path;
std::filesystem::path model_bin_path;
StringType param_file_name =
model_name_ + STR("-x") + to_string_type(scaling_factor_) + STR(".param");
StringType bin_file_name =
model_name_ + STR("-x") + to_string_type(scaling_factor_) + STR(".bin");
fsutils::StringType param_file_name =
model_name_ + STR("-x") + fsutils::to_string_type(scaling_factor_) + STR(".param");
fsutils::StringType bin_file_name =
model_name_ + STR("-x") + fsutils::to_string_type(scaling_factor_) + STR(".bin");
// Find the model paths by model name if provided
model_param_path = std::filesystem::path(STR("models")) / STR("realesrgan") / param_file_name;
model_bin_path = std::filesystem::path(STR("models")) / STR("realesrgan") / bin_file_name;
// Get the full paths using a function that possibly modifies or validates the path
std::filesystem::path model_param_full_path = find_resource_file(model_param_path);
std::filesystem::path model_bin_full_path = find_resource_file(model_bin_path);
std::filesystem::path model_param_full_path = fsutils::find_resource_file(model_param_path);
std::filesystem::path model_bin_full_path = fsutils::find_resource_file(model_bin_path);
// Check if the model files exist
if (!std::filesystem::exists(model_param_full_path)) {
spdlog::error("RealESRGAN model param file not found: {}", model_param_path.u8string());
logger()->error("RealESRGAN model param file not found: {}", model_param_path.u8string());
return -1;
}
if (!std::filesystem::exists(model_bin_full_path)) {
spdlog::error("RealESRGAN model bin file not found: {}", model_bin_path.u8string());
logger()->error("RealESRGAN model bin file not found: {}", model_bin_path.u8string());
return -1;
}
@@ -66,7 +70,7 @@ int FilterRealesrgan::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVB
// Load the model
if (realesrgan_->load(model_param_full_path, model_bin_full_path) != 0) {
spdlog::error("Failed to load RealESRGAN model");
logger()->error("Failed to load RealESRGAN model");
return -1;
}
@@ -93,9 +97,9 @@ int FilterRealesrgan::filter(AVFrame *in_frame, AVFrame **out_frame) {
int ret;
// Convert the input frame to RGB24
ncnn::Mat in_mat = avframe_to_ncnn_mat(in_frame);
ncnn::Mat in_mat = conversions::avframe_to_ncnn_mat(in_frame);
if (in_mat.empty()) {
spdlog::error("Failed to convert AVFrame to ncnn::Mat");
logger()->error("Failed to convert AVFrame to ncnn::Mat");
return -1;
}
@@ -106,12 +110,12 @@ int FilterRealesrgan::filter(AVFrame *in_frame, AVFrame **out_frame) {
ret = realesrgan_->process(in_mat, out_mat);
if (ret != 0) {
spdlog::error("RealESRGAN processing failed");
logger()->error("RealESRGAN processing failed");
return ret;
}
// Convert ncnn::Mat to AVFrame
*out_frame = ncnn_mat_to_avframe(out_mat, out_pix_fmt_);
*out_frame = conversions::ncnn_mat_to_avframe(out_mat, out_pix_fmt_);
// Rescale PTS to encoder's time base
(*out_frame)->pts = av_rescale_q(in_frame->pts, in_time_base_, out_time_base_);
@@ -130,3 +134,6 @@ void FilterRealesrgan::get_output_dimensions(
out_width = in_width * scaling_factor_;
out_height = in_height * scaling_factor_;
}
} // namespace processors
} // namespace video2x

View File

@@ -10,6 +10,11 @@
#include <spdlog/spdlog.h>
#include "logger_manager.h"
namespace video2x {
namespace fsutils {
#if _WIN32
static std::filesystem::path get_executable_directory() {
std::vector<wchar_t> filepath(MAX_PATH);
@@ -17,7 +22,7 @@ static std::filesystem::path get_executable_directory() {
// Get the executable path, expanding the buffer if necessary
DWORD size = GetModuleFileNameW(NULL, filepath.data(), static_cast<DWORD>(filepath.size()));
if (size == 0) {
spdlog::error("Error getting executable path: {}", GetLastError());
logger()->error("Error getting executable path: {}", GetLastError());
return std::filesystem::path();
}
@@ -26,7 +31,7 @@ static std::filesystem::path get_executable_directory() {
filepath.resize(filepath.size() * 2);
size = GetModuleFileNameW(NULL, filepath.data(), static_cast<DWORD>(filepath.size()));
if (size == 0) {
spdlog::error("Error getting executable path: {}", GetLastError());
logger()->error("Error getting executable path: {}", GetLastError());
return std::filesystem::path();
}
}
@@ -41,7 +46,7 @@ static std::filesystem::path get_executable_directory() {
std::filesystem::path filepath = std::filesystem::read_symlink("/proc/self/exe", ec);
if (ec) {
spdlog::error("Error reading /proc/self/exe: {}", ec.message());
logger()->error("Error reading /proc/self/exe: {}", ec.message());
return std::filesystem::path();
}
@@ -120,7 +125,7 @@ std::string wstring_to_u8string(const std::string &str) {
}
#endif
StringType path_to_string_type(const std::filesystem::path &path) {
fsutils::StringType path_to_string_type(const std::filesystem::path &path) {
#if _WIN32
return path.wstring();
#else
@@ -128,10 +133,13 @@ StringType path_to_string_type(const std::filesystem::path &path) {
#endif
}
StringType to_string_type(int value) {
fsutils::StringType to_string_type(int value) {
#if _WIN32
return std::to_wstring(value);
#else
return std::to_string(value);
#endif
}
} // namespace fsutils
} // namespace video2x

View File

@@ -7,6 +7,10 @@
#include "conversions.h"
#include "fsutils.h"
#include "logger_manager.h"
namespace video2x {
namespace processors {
InterpolatorRIFE::InterpolatorRIFE(
int gpuid,
@@ -14,7 +18,7 @@ InterpolatorRIFE::InterpolatorRIFE(
bool tta_temporal_mode,
bool uhd_mode,
int num_threads,
const StringType model_name
const fsutils::StringType model_name
)
: rife_(nullptr),
gpuid_(gpuid),
@@ -39,25 +43,25 @@ int InterpolatorRIFE::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVB
model_param_dir = std::filesystem::path(STR("models")) / STR("rife") / model_name_;
// Get the full paths using a function that possibly modifies or validates the path
std::filesystem::path model_param_full_path = find_resource_file(model_param_dir);
std::filesystem::path model_param_full_path = fsutils::find_resource_file(model_param_dir);
// Check if the model files exist
if (!std::filesystem::exists(model_param_full_path)) {
spdlog::error("RIFE model param directory not found: {}", model_param_dir.u8string());
logger()->error("RIFE model param directory not found: {}", model_param_dir.u8string());
return -1;
}
// Automatically infer the RIFE model generation based on the model name
bool rife_v2 = false;
bool rife_v4 = false;
if (model_name_.find(STR("rife-v2")) != StringType::npos) {
if (model_name_.find(STR("rife-v2")) != fsutils::StringType::npos) {
rife_v2 = true;
} else if (model_name_.find(STR("rife-v3")) != StringType::npos) {
} else if (model_name_.find(STR("rife-v3")) != fsutils::StringType::npos) {
rife_v2 = true;
} else if (model_name_.find(STR("rife-v4")) != StringType::npos) {
} else if (model_name_.find(STR("rife-v4")) != fsutils::StringType::npos) {
rife_v4 = true;
} else if (model_name_.find(STR("rife")) == StringType::npos) {
spdlog::critical("Failed to infer RIFE model generation from model name");
} else if (model_name_.find(STR("rife")) == fsutils::StringType::npos) {
logger()->critical("Failed to infer RIFE model generation from model name");
return -1;
}
@@ -72,7 +76,7 @@ int InterpolatorRIFE::init(AVCodecContext *dec_ctx, AVCodecContext *enc_ctx, AVB
// Load the model
if (rife_->load(model_param_full_path) != 0) {
spdlog::error("Failed to load RIFE model");
logger()->error("Failed to load RIFE model");
return -1;
}
@@ -87,15 +91,15 @@ int InterpolatorRIFE::interpolate(
) {
int ret;
ncnn::Mat in_mat1 = avframe_to_ncnn_mat(prev_frame);
ncnn::Mat in_mat1 = conversions::avframe_to_ncnn_mat(prev_frame);
if (in_mat1.empty()) {
spdlog::error("Failed to convert AVFrame to ncnn::Mat");
logger()->error("Failed to convert AVFrame to ncnn::Mat");
return -1;
}
ncnn::Mat in_mat2 = avframe_to_ncnn_mat(in_frame);
ncnn::Mat in_mat2 = conversions::avframe_to_ncnn_mat(in_frame);
if (in_mat2.empty()) {
spdlog::error("Failed to convert AVFrame to ncnn::Mat");
logger()->error("Failed to convert AVFrame to ncnn::Mat");
return -1;
}
@@ -104,12 +108,12 @@ int InterpolatorRIFE::interpolate(
ret = rife_->process(in_mat1, in_mat2, time_step, out_mat);
if (ret != 0) {
spdlog::error("RIFE processing failed");
logger()->error("RIFE processing failed");
return ret;
}
// Convert ncnn::Mat to AVFrame
*out_frame = ncnn_mat_to_avframe(out_mat, out_pix_fmt_);
*out_frame = conversions::ncnn_mat_to_avframe(out_mat, out_pix_fmt_);
// Rescale PTS to encoder's time base
(*out_frame)->pts = av_rescale_q(in_frame->pts, in_time_base_, out_time_base_);
@@ -128,3 +132,6 @@ void InterpolatorRIFE::get_output_dimensions(
out_width = in_width;
out_height = in_height;
}
} // namespace processors
} // namespace video2x

View File

@@ -11,6 +11,11 @@ extern "C" {
#include <spdlog/spdlog.h>
#include "logger_manager.h"
namespace video2x {
namespace processors {
int init_libplacebo(
AVFilterGraph **filter_graph,
AVFilterContext **buffersrc_ctx,
@@ -29,20 +34,20 @@ int init_libplacebo(
&vk_hw_device_ctx, AV_HWDEVICE_TYPE_VULKAN, std::to_string(vk_device_index).c_str(), NULL, 0
);
if (ret < 0) {
spdlog::error("Failed to create Vulkan hardware device context for libplacebo.");
logger()->error("Failed to create Vulkan hardware device context for libplacebo.");
vk_hw_device_ctx = nullptr;
}
AVFilterGraph *graph = avfilter_graph_alloc();
if (!graph) {
spdlog::error("Unable to create filter graph.");
logger()->error("Unable to create filter graph.");
return AVERROR(ENOMEM);
}
// Create buffer source
const AVFilter *buffersrc = avfilter_get_by_name("buffer");
if (!buffersrc) {
spdlog::error("Filter 'buffer' not found.");
logger()->error("Filter 'buffer' not found.");
avfilter_graph_free(&graph);
return AVERROR_FILTER_NOT_FOUND;
}
@@ -79,7 +84,7 @@ int init_libplacebo(
spdlog::debug("Buffer source args: {}", args);
ret = avfilter_graph_create_filter(buffersrc_ctx, buffersrc, "in", args.c_str(), NULL, graph);
if (ret < 0) {
spdlog::error("Cannot create buffer source.");
logger()->error("Cannot create buffer source.");
avfilter_graph_free(&graph);
return ret;
}
@@ -89,7 +94,7 @@ int init_libplacebo(
// Create the libplacebo filter
const AVFilter *libplacebo_filter = avfilter_get_by_name("libplacebo");
if (!libplacebo_filter) {
spdlog::error("Filter 'libplacebo' not found.");
logger()->error("Filter 'libplacebo' not found.");
avfilter_graph_free(&graph);
return AVERROR_FILTER_NOT_FOUND;
}
@@ -112,7 +117,7 @@ int init_libplacebo(
&libplacebo_ctx, libplacebo_filter, "libplacebo", filter_args.c_str(), NULL, graph
);
if (ret < 0) {
spdlog::error("Cannot create libplacebo filter.");
logger()->error("Cannot create libplacebo filter.");
avfilter_graph_free(&graph);
return ret;
}
@@ -126,7 +131,7 @@ int init_libplacebo(
// Link buffersrc to libplacebo
ret = avfilter_link(last_filter, 0, libplacebo_ctx, 0);
if (ret < 0) {
spdlog::error("Error connecting buffersrc to libplacebo filter.");
logger()->error("Error connecting buffersrc to libplacebo filter.");
avfilter_graph_free(&graph);
return ret;
}
@@ -137,7 +142,7 @@ int init_libplacebo(
const AVFilter *buffersink = avfilter_get_by_name("buffersink");
ret = avfilter_graph_create_filter(buffersink_ctx, buffersink, "out", NULL, NULL, graph);
if (ret < 0) {
spdlog::error("Cannot create buffer sink.");
logger()->error("Cannot create buffer sink.");
avfilter_graph_free(&graph);
return ret;
}
@@ -145,7 +150,7 @@ int init_libplacebo(
// Link libplacebo to buffersink
ret = avfilter_link(last_filter, 0, *buffersink_ctx, 0);
if (ret < 0) {
spdlog::error("Error connecting libplacebo filter to buffersink.");
logger()->error("Error connecting libplacebo filter to buffersink.");
avfilter_graph_free(&graph);
return ret;
}
@@ -153,7 +158,7 @@ int init_libplacebo(
// Configure the filter graph
ret = avfilter_graph_config(graph, NULL);
if (ret < 0) {
spdlog::error("Error configuring the filter graph.");
logger()->error("Error configuring the filter graph.");
avfilter_graph_free(&graph);
return ret;
}
@@ -161,3 +166,6 @@ int init_libplacebo(
*filter_graph = graph;
return 0;
}
} // namespace processors
} // namespace video2x

View File

@@ -9,25 +9,24 @@ extern "C" {
#include "avutils.h"
#include "decoder.h"
#include "encoder.h"
#include "logging.h"
#include "logger_manager.h"
#include "processor.h"
#include "processor_factory.h"
namespace video2x {
VideoProcessor::VideoProcessor(
const ProcessorConfig proc_cfg,
const EncoderConfig enc_cfg,
const uint32_t vk_device_index,
const processors::ProcessorConfig proc_cfg,
const encoder::EncoderConfig enc_cfg,
const uint32_t vk_device_idx,
const AVHWDeviceType hw_device_type,
const Video2xLogLevel log_level,
const bool benchmark
)
: proc_cfg_(proc_cfg),
enc_cfg_(enc_cfg),
vk_device_index_(vk_device_index),
vk_device_idx_(vk_device_idx),
hw_device_type_(hw_device_type),
benchmark_(benchmark) {
set_log_level(log_level);
}
benchmark_(benchmark) {}
int VideoProcessor::process(
const std::filesystem::path in_fname,
@@ -40,7 +39,7 @@ int VideoProcessor::process(
// Format and log the error message
char errbuf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(error_code, errbuf, sizeof(errbuf));
spdlog::critical("{}: {}", msg, errbuf);
logger()->critical("{}: {}", msg, errbuf);
// Set the video processor state to failed and return the error code
state_.store(VideoProcessorState::Failed);
@@ -51,8 +50,8 @@ int VideoProcessor::process(
state_.store(VideoProcessorState::Running);
// Create a smart pointer to manage the hardware device context
std::unique_ptr<AVBufferRef, decltype(&av_bufferref_deleter)> hw_ctx(
nullptr, &av_bufferref_deleter
std::unique_ptr<AVBufferRef, decltype(&avutils::av_bufferref_deleter)> hw_ctx(
nullptr, &avutils::av_bufferref_deleter
);
// Initialize hardware device context
@@ -66,7 +65,7 @@ int VideoProcessor::process(
}
// Initialize input decoder
Decoder decoder;
decoder::Decoder decoder;
ret = decoder.init(hw_device_type_, hw_ctx.get(), in_fname);
if (ret < 0) {
return handle_error(ret, "Failed to initialize decoder");
@@ -77,8 +76,8 @@ int VideoProcessor::process(
int in_vstream_idx = decoder.get_video_stream_index();
// Create and initialize the appropriate filter
std::unique_ptr<Processor> processor(
ProcessorFactory::instance().create_processor(proc_cfg_, vk_device_index_)
std::unique_ptr<processors::Processor> processor(
processors::ProcessorFactory::instance().create_processor(proc_cfg_, vk_device_idx_)
);
if (processor == nullptr) {
return handle_error(-1, "Failed to create filter instance");
@@ -94,7 +93,7 @@ int VideoProcessor::process(
}
// Initialize the encoder
Encoder encoder;
encoder::Encoder encoder;
ret = encoder.init(
hw_ctx.get(),
out_fname,
@@ -140,9 +139,9 @@ int VideoProcessor::process(
// Process frames using the selected filter.
int VideoProcessor::process_frames(
Decoder &decoder,
Encoder &encoder,
std::unique_ptr<Processor> &processor
decoder::Decoder &decoder,
encoder::Encoder &encoder,
std::unique_ptr<processors::Processor> &processor
) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
int ret = 0;
@@ -156,29 +155,31 @@ int VideoProcessor::process_frames(
// Reference to the previous frame does not require allocation
// It will be cloned from the current frame
std::unique_ptr<AVFrame, decltype(&av_frame_deleter)> prev_frame(nullptr, &av_frame_deleter);
std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)> prev_frame(
nullptr, &avutils::av_frame_deleter
);
// Allocate space for the decoded frames
std::unique_ptr<AVFrame, decltype(&av_frame_deleter)> frame(
av_frame_alloc(), &av_frame_deleter
std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)> frame(
av_frame_alloc(), &avutils::av_frame_deleter
);
if (frame == nullptr) {
spdlog::critical("Error allocating frame");
logger()->critical("Error allocating frame");
return AVERROR(ENOMEM);
}
// Allocate space for the decoded packets
std::unique_ptr<AVPacket, decltype(&av_packet_deleter)> packet(
av_packet_alloc(), &av_packet_deleter
std::unique_ptr<AVPacket, decltype(&avutils::av_packet_deleter)> packet(
av_packet_alloc(), &avutils::av_packet_deleter
);
if (packet == nullptr) {
spdlog::critical("Error allocating packet");
logger()->critical("Error allocating packet");
return AVERROR(ENOMEM);
}
// Set the total number of frames in the VideoProcessingContext
spdlog::debug("Estimating the total number of frames to process");
total_frames_ = get_video_frame_count(ifmt_ctx, in_vstream_idx);
total_frames_ = avutils::get_video_frame_count(ifmt_ctx, in_vstream_idx);
if (total_frames_ <= 0) {
spdlog::warn("Unable to determine the total number of frames");
@@ -188,7 +189,7 @@ int VideoProcessor::process_frames(
}
// Set total frames for interpolation
if (processor->get_processing_mode() == ProcessingMode::Interpolate) {
if (processor->get_processing_mode() == processors::ProcessingMode::Interpolate) {
total_frames_.store(total_frames_.load() * proc_cfg_.frm_rate_mul);
}
@@ -201,7 +202,7 @@ int VideoProcessor::process_frames(
break;
}
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error reading packet: {}", errbuf);
logger()->critical("Error reading packet: {}", errbuf);
return ret;
}
@@ -210,7 +211,7 @@ int VideoProcessor::process_frames(
ret = avcodec_send_packet(dec_ctx, packet.get());
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error sending packet to decoder: {}", errbuf);
logger()->critical("Error sending packet to decoder: {}", errbuf);
return ret;
}
@@ -229,33 +230,33 @@ int VideoProcessor::process_frames(
break;
} else if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error decoding video frame: {}", errbuf);
logger()->critical("Error decoding video frame: {}", errbuf);
return ret;
}
// Process the frame based on the selected processing mode
AVFrame *proc_frame = nullptr;
switch (processor->get_processing_mode()) {
case ProcessingMode::Filter: {
case processors::ProcessingMode::Filter: {
ret = process_filtering(processor, encoder, frame.get(), proc_frame);
break;
}
case ProcessingMode::Interpolate: {
case processors::ProcessingMode::Interpolate: {
ret = process_interpolation(
processor, encoder, prev_frame, frame.get(), proc_frame
);
break;
}
default:
spdlog::critical("Unknown processing mode");
logger()->critical("Unknown processing mode");
return -1;
}
if (ret < 0 && ret != AVERROR(EAGAIN)) {
return ret;
}
av_frame_unref(frame.get());
frame_index_++;
spdlog::debug("Processed frame {}/{}", frame_index_.load(), total_frames_.load());
frame_idx_++;
spdlog::debug("Processed frame {}/{}", frame_idx_.load(), total_frames_.load());
}
} else if (enc_cfg_.copy_streams && stream_map[packet->stream_index] >= 0) {
ret = write_raw_packet(packet.get(), ifmt_ctx, ofmt_ctx, stream_map);
@@ -271,14 +272,14 @@ int VideoProcessor::process_frames(
ret = processor->flush(raw_flushed_frames);
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error flushing filter: {}", errbuf);
logger()->critical("Error flushing filter: {}", errbuf);
return ret;
}
// Wrap flushed frames in unique_ptrs
std::vector<std::unique_ptr<AVFrame, decltype(&av_frame_deleter)>> flushed_frames;
std::vector<std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)>> flushed_frames;
for (AVFrame *raw_frame : raw_flushed_frames) {
flushed_frames.emplace_back(raw_frame, &av_frame_deleter);
flushed_frames.emplace_back(raw_frame, &avutils::av_frame_deleter);
}
// Encode and write all flushed frames
@@ -287,31 +288,29 @@ int VideoProcessor::process_frames(
if (ret < 0) {
return ret;
}
frame_index_++;
frame_idx_++;
}
// Flush the encoder
ret = encoder.flush();
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error flushing encoder: {}", errbuf);
logger()->critical("Error flushing encoder: {}", errbuf);
return ret;
}
return ret;
}
int VideoProcessor::write_frame(AVFrame *frame, Encoder &encoder) {
int VideoProcessor::write_frame(AVFrame *frame, encoder::Encoder &encoder) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
int ret = 0;
if (!benchmark_) {
// Set the frame type to none to let the encoder decide
frame->pict_type = AV_PICTURE_TYPE_NONE;
ret = encoder.write_frame(frame, frame_index_);
ret = encoder.write_frame(frame, frame_idx_);
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error encoding/writing frame: {}", errbuf);
logger()->critical("Error encoding/writing frame: {}", errbuf);
}
}
return ret;
@@ -327,23 +326,23 @@ int VideoProcessor::write_raw_packet(
int ret = 0;
AVStream *in_stream = ifmt_ctx->streams[packet->stream_index];
int out_stream_index = stream_map[packet->stream_index];
AVStream *out_stream = ofmt_ctx->streams[out_stream_index];
int out_stream_idx = stream_map[packet->stream_index];
AVStream *out_stream = ofmt_ctx->streams[out_stream_idx];
av_packet_rescale_ts(packet, in_stream->time_base, out_stream->time_base);
packet->stream_index = out_stream_index;
packet->stream_index = out_stream_idx;
ret = av_interleaved_write_frame(ofmt_ctx, packet);
if (ret < 0) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error muxing audio/subtitle packet: {}", errbuf);
logger()->critical("Error muxing audio/subtitle packet: {}", errbuf);
}
return ret;
}
int VideoProcessor::process_filtering(
std::unique_ptr<Processor> &processor,
Encoder &encoder,
std::unique_ptr<processors::Processor> &processor,
encoder::Encoder &encoder,
AVFrame *frame,
AVFrame *proc_frame
) {
@@ -351,7 +350,7 @@ int VideoProcessor::process_filtering(
int ret = 0;
// Cast the processor to a Filter
Filter *filter = static_cast<Filter *>(processor.get());
processors::Filter *filter = static_cast<processors::Filter *>(processor.get());
// Process the frame using the filter
ret = filter->filter(frame, &proc_frame);
@@ -359,19 +358,20 @@ int VideoProcessor::process_filtering(
// Write the processed frame
if (ret < 0 && ret != AVERROR(EAGAIN)) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error filtering frame: {}", errbuf);
logger()->critical("Error filtering frame: {}", errbuf);
} else if (ret == 0 && proc_frame != nullptr) {
auto processed_frame =
std::unique_ptr<AVFrame, decltype(&av_frame_deleter)>(proc_frame, &av_frame_deleter);
auto processed_frame = std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)>(
proc_frame, &avutils::av_frame_deleter
);
ret = write_frame(processed_frame.get(), encoder);
}
return ret;
}
int VideoProcessor::process_interpolation(
std::unique_ptr<Processor> &processor,
Encoder &encoder,
std::unique_ptr<AVFrame, decltype(&av_frame_deleter)> &prev_frame,
std::unique_ptr<processors::Processor> &processor,
encoder::Encoder &encoder,
std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)> &prev_frame,
AVFrame *frame,
AVFrame *proc_frame
) {
@@ -379,7 +379,8 @@ int VideoProcessor::process_interpolation(
int ret = 0;
// Cast the processor to an Interpolator
Interpolator *interpolator = static_cast<Interpolator *>(processor.get());
processors::Interpolator *interpolator =
static_cast<processors::Interpolator *>(processor.get());
// Calculate the time step for each frame
float time_step = 1.0f / static_cast<float>(proc_cfg_.frm_rate_mul);
@@ -388,12 +389,10 @@ int VideoProcessor::process_interpolation(
// Check if a scene change is detected
bool skip_frame = false;
if (proc_cfg_.scn_det_thresh < 100.0 && prev_frame.get() != nullptr) {
float frame_diff = get_frame_diff(prev_frame.get(), frame);
float frame_diff = avutils::get_frame_diff(prev_frame.get(), frame);
if (frame_diff > proc_cfg_.scn_det_thresh) {
spdlog::debug(
"Scene change detected ({:.2f}%), skipping frame {}",
frame_diff,
frame_index_.load()
"Scene change detected ({:.2f}%), skipping frame {}", frame_diff, frame_idx_.load()
);
skip_frame = true;
}
@@ -418,29 +417,29 @@ int VideoProcessor::process_interpolation(
// Write the interpolated frame
if (ret < 0 && ret != AVERROR(EAGAIN)) {
av_strerror(ret, errbuf, sizeof(errbuf));
spdlog::critical("Error interpolating frame: {}", errbuf);
logger()->critical("Error interpolating frame: {}", errbuf);
return ret;
} else if (ret == 0 && proc_frame != nullptr) {
auto processed_frame = std::unique_ptr<AVFrame, decltype(&av_frame_deleter)>(
proc_frame, &av_frame_deleter
auto processed_frame = std::unique_ptr<AVFrame, decltype(&avutils::av_frame_deleter)>(
proc_frame, &avutils::av_frame_deleter
);
processed_frame->pts = frame_index_;
ret = write_frame(processed_frame.get(), encoder);
if (ret < 0) {
return ret;
}
}
frame_index_++;
frame_idx_++;
current_time_step += time_step;
}
// Write the original frame
frame->pts = frame_index_;
ret = write_frame(frame, encoder);
// Update the previous frame with the current frame
prev_frame.reset(av_frame_clone(frame));
return ret;
}
} // namespace video2x

116
src/logger_manager.cpp Normal file
View File

@@ -0,0 +1,116 @@
#include "logger_manager.h"
extern "C" {
#include <libavutil/log.h>
}
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
static spdlog::level::level_enum ffmpeg_level_to_spdlog(int av_level) {
if (av_level <= AV_LOG_PANIC) {
return spdlog::level::critical;
} else if (av_level <= AV_LOG_ERROR) {
return spdlog::level::err;
} else if (av_level <= AV_LOG_WARNING) {
return spdlog::level::warn;
} else if (av_level <= AV_LOG_INFO) {
return spdlog::level::info;
} else if (av_level <= AV_LOG_VERBOSE) {
return spdlog::level::debug;
} else if (av_level == AV_LOG_DEBUG) {
return spdlog::level::debug;
} else {
// AV_LOG_TRACE or beyond (if supported by FFmpeg)
return spdlog::level::trace;
}
}
static void ffmpeg_log_callback(void *avcl, int level, const char *fmt, va_list vargs) {
// Format the message the same way as the default callback
char line[1024];
int print_prefix = 1;
av_log_format_line(avcl, level, fmt, vargs, line, sizeof(line), &print_prefix);
// Trim trailing newlines
std::string message = line;
while (!message.empty() && (message.back() == '\n' || message.back() == '\r')) {
message.pop_back();
}
// Forward the formatted FFmpeg log message to the logger
video2x::logger()->log(ffmpeg_level_to_spdlog(level), "[FFmpeg] {}", message);
}
namespace video2x {
namespace logger_manager {
LoggerManager::LoggerManager() {
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
console_sink->set_pattern("%+");
console_sink->set_level(spdlog::level::info);
logger_ = std::make_shared<spdlog::logger>("video2x", console_sink);
spdlog::register_logger(logger_);
}
LoggerManager &LoggerManager::instance() {
static LoggerManager instance;
return instance;
}
std::shared_ptr<spdlog::logger> LoggerManager::logger() {
return logger_;
}
bool LoggerManager::reconfigure_logger(
const std::string &logger_name,
const std::vector<spdlog::sink_ptr> &sinks,
const std::string &pattern
) {
if (logger_name.empty() || sinks.empty()) {
return false;
}
// Create a new logger with the given name, sinks, and pattern
std::shared_ptr<spdlog::logger> new_logger =
std::make_shared<spdlog::logger>(logger_name, sinks.begin(), sinks.end());
new_logger->set_pattern(pattern);
// Maintain the log level from the previous logger
if (logger_ != nullptr) {
new_logger->set_level(logger_->level());
}
// If a logger with the same name exists, remove it first
std::shared_ptr<spdlog::logger> old_logger = spdlog::get(logger_name);
if (old_logger != nullptr) {
spdlog::drop(logger_name);
logger_ = nullptr;
}
// Replace the internal logger_ member and register the new one
logger_ = new_logger;
spdlog::register_logger(logger_);
return true;
}
bool LoggerManager::set_log_level(const std::string &level_str) {
spdlog::level::level_enum log_level = spdlog::level::from_str(level_str);
if (log_level == spdlog::level::off && level_str != "off") {
// Invalid level_str
return false;
}
logger_->set_level(log_level);
return true;
}
void LoggerManager::hook_ffmpeg_logging() {
av_log_set_callback(ffmpeg_log_callback);
}
void LoggerManager::unhook_ffmpeg_logging() {
av_log_set_callback(nullptr);
}
} // namespace logger_manager
} // namespace video2x

View File

@@ -1,44 +0,0 @@
#include "logging.h"
extern "C" {
#include <libavutil/avutil.h>
}
#include <spdlog/spdlog.h>
void set_log_level(Video2xLogLevel log_level) {
switch (log_level) {
case Video2xLogLevel::Trace:
av_log_set_level(AV_LOG_TRACE);
spdlog::set_level(spdlog::level::trace);
break;
case Video2xLogLevel::Debug:
av_log_set_level(AV_LOG_DEBUG);
spdlog::set_level(spdlog::level::debug);
break;
case Video2xLogLevel::Info:
av_log_set_level(AV_LOG_INFO);
spdlog::set_level(spdlog::level::info);
break;
case Video2xLogLevel::Warning:
av_log_set_level(AV_LOG_WARNING);
spdlog::set_level(spdlog::level::warn);
break;
case Video2xLogLevel::Error:
av_log_set_level(AV_LOG_ERROR);
spdlog::set_level(spdlog::level::err);
break;
case Video2xLogLevel::Critical:
av_log_set_level(AV_LOG_FATAL);
spdlog::set_level(spdlog::level::critical);
break;
case Video2xLogLevel::Off:
av_log_set_level(AV_LOG_QUIET);
spdlog::set_level(spdlog::level::off);
break;
default:
av_log_set_level(AV_LOG_INFO);
spdlog::set_level(spdlog::level::info);
break;
}
}

View File

@@ -4,8 +4,13 @@
#include <utility>
#include "filter_libplacebo.h"
#include "filter_realcugan.h"
#include "filter_realesrgan.h"
#include "interpolator_rife.h"
#include "logger_manager.h"
namespace video2x {
namespace processors {
// Access the singleton instance
ProcessorFactory &ProcessorFactory::instance() {
@@ -33,7 +38,7 @@ std::unique_ptr<Processor> ProcessorFactory::create_processor(
) const {
auto it = creators.find(proc_cfg.processor_type);
if (it == creators.end()) {
spdlog::critical(
logger()->critical(
"Processor type not registered: {}", static_cast<int>(proc_cfg.processor_type)
);
return nullptr;
@@ -51,11 +56,11 @@ void ProcessorFactory::init_default_processors(ProcessorFactory &factory) {
uint32_t vk_device_index) -> std::unique_ptr<Processor> {
const auto &config = std::get<LibplaceboConfig>(proc_cfg.config);
if (config.shader_path.empty()) {
spdlog::critical("Shader path must be provided for the libplacebo filter");
logger()->critical("Shader path must be provided for the libplacebo filter");
return nullptr;
}
if (proc_cfg.width <= 0 || proc_cfg.height <= 0) {
spdlog::critical(
logger()->critical(
"Output width and height must be provided for the libplacebo filter"
);
return nullptr;
@@ -75,11 +80,11 @@ void ProcessorFactory::init_default_processors(ProcessorFactory &factory) {
uint32_t vk_device_index) -> std::unique_ptr<Processor> {
const auto &config = std::get<RealESRGANConfig>(proc_cfg.config);
if (proc_cfg.scaling_factor <= 0) {
spdlog::critical("Scaling factor must be provided for the RealESRGAN filter");
logger()->critical("Scaling factor must be provided for the RealESRGAN filter");
return nullptr;
}
if (config.model_name.empty()) {
spdlog::critical("Model name must be provided for the RealESRGAN filter");
logger()->critical("Model name must be provided for the RealESRGAN filter");
return nullptr;
}
return std::make_unique<FilterRealesrgan>(
@@ -91,13 +96,38 @@ void ProcessorFactory::init_default_processors(ProcessorFactory &factory) {
}
);
factory.register_processor(
ProcessorType::RealCUGAN,
[](const ProcessorConfig &proc_cfg,
uint32_t vk_device_index) -> std::unique_ptr<Processor> {
const auto &config = std::get<RealCUGANConfig>(proc_cfg.config);
if (proc_cfg.scaling_factor <= 0) {
logger()->critical("Scaling factor must be provided for the RealCUGAN filter");
return nullptr;
}
if (config.model_name.empty()) {
logger()->critical("Model name must be provided for the RealCUGAN filter");
return nullptr;
}
return std::make_unique<FilterRealcugan>(
static_cast<int>(vk_device_index),
config.tta_mode,
proc_cfg.scaling_factor,
proc_cfg.noise_level,
config.num_threads,
config.syncgap,
config.model_name
);
}
);
factory.register_processor(
ProcessorType::RIFE,
[](const ProcessorConfig &proc_cfg,
uint32_t vk_device_index) -> std::unique_ptr<Processor> {
const auto &cfg = std::get<RIFEConfig>(proc_cfg.config);
if (cfg.model_name.empty()) {
spdlog::critical("Model name must be provided for the RIFE filter");
logger()->critical("Model name must be provided for the RIFE filter");
return nullptr;
}
return std::make_unique<InterpolatorRIFE>(
@@ -111,3 +141,6 @@ void ProcessorFactory::init_default_processors(ProcessorFactory &factory) {
}
);
}
} // namespace processors
} // namespace video2x

View File

@@ -5,10 +5,7 @@
// Structure to hold parsed arguments
struct Arguments {
Video2xLogLevel log_level = Video2xLogLevel::Info;
bool no_progress = false;
// General options
std::filesystem::path in_fname;
std::filesystem::path out_fname;
uint32_t vk_device_index = 0;
@@ -24,6 +21,6 @@ struct Arguments {
char *argv[],
#endif
Arguments &arguments,
ProcessorConfig &proc_cfg,
EncoderConfig &enc_cfg
video2x::processors::ProcessorConfig &proc_cfg,
video2x::encoder::EncoderConfig &enc_cfg
);

View File

@@ -1,15 +0,0 @@
#pragma once
#include <atomic>
#include <optional>
#include <libvideo2x/libvideo2x.h>
#include <spdlog/spdlog.h>
extern std::atomic<bool> newline_required;
void set_spdlog_level(Video2xLogLevel log_level);
std::optional<Video2xLogLevel> find_log_level_by_name(const StringType &log_level_name);
void newline_safe_ffmpeg_log_callback(void *ptr, int level, const char *fmt, va_list vl);

View File

@@ -0,0 +1,22 @@
#pragma once
#include <atomic>
#include <spdlog/sinks/ansicolor_sink.h>
class newline_safe_sink : public spdlog::sinks::ansicolor_stdout_sink_mt {
public:
newline_safe_sink() = default;
~newline_safe_sink() = default;
newline_safe_sink(const newline_safe_sink &) = delete;
newline_safe_sink &operator=(const newline_safe_sink &) = delete;
void log(const spdlog::details::log_msg &msg);
void set_needs_newline(bool needs_newline) { needs_newline_.store(needs_newline); };
bool get_needs_newline() { return needs_newline_.load(); };
private:
std::atomic<bool> needs_newline_ = false;
};

View File

@@ -61,8 +61,10 @@ void validate_greater_equal_one(const T &value, const std::string &option_name)
}
}
void validate_anime4k_shader_name(const StringType &shader_name);
void validate_anime4k_shader_name(const video2x::fsutils::StringType &shader_name);
void validate_realesrgan_model_name(const StringType &model_name);
void validate_realesrgan_model_name(const video2x::fsutils::StringType &model_name);
void validate_rife_model_name(const StringType &model_name);
void validate_realcugan_model_name(const video2x::fsutils::StringType &model_name);
void validate_rife_model_name(const video2x::fsutils::StringType &model_name);

View File

@@ -7,13 +7,13 @@
#include <cwchar>
#endif
#include <libvideo2x/logger_manager.h>
#include <libvideo2x/version.h>
#include <spdlog/spdlog.h>
#include <vulkan_utils.h>
#include <boost/program_options.hpp>
#include "logging.h"
#include "validators.h"
#include "vulkan_utils.h"
#ifdef _WIN32
#define BOOST_PROGRAM_OPTIONS_WCHAR_T
@@ -59,8 +59,8 @@ int parse_args(
char *argv[],
#endif
Arguments &arguments,
ProcessorConfig &proc_cfg,
EncoderConfig &enc_cfg
video2x::processors::ProcessorConfig &proc_cfg,
video2x::encoder::EncoderConfig &enc_cfg
) {
try {
// clang-format off
@@ -68,19 +68,20 @@ int parse_args(
all_opts.add_options()
("help", "Display this help page")
("version,V", "Print program version and exit")
("log-level", PO_STR_VALUE<StringType>()->default_value(STR("info"), "info"),
("log-level", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("info"), "info"),
"Set verbosity level (trace, debug, info, warn, error, critical, none)")
("no-progress", po::bool_switch(&arguments.no_progress),
"Do not display the progress bar")
("list-devices,l", "List the available Vulkan devices (GPUs)")
// General Processing Options
("input,i", PO_STR_VALUE<StringType>(), "Input video file path")
("output,o", PO_STR_VALUE<StringType>(), "Output video file path")
("processor,p", PO_STR_VALUE<StringType>(),
"Processor to use (libplacebo, realesrgan, rife)")
("hwaccel,a", PO_STR_VALUE<StringType>()->default_value(STR("none"), "none"),
"Hardware acceleration method (decoding)")
("input,i", PO_STR_VALUE<video2x::fsutils::StringType>(), "Input video file path")
("output,o", PO_STR_VALUE<video2x::fsutils::StringType>(), "Output video file path")
("processor,p", PO_STR_VALUE<video2x::fsutils::StringType>(),
"Processor to use (libplacebo, realesrgan, realcugan, rife)")
("hwaccel,a", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("none"), "none"), "Hardware acceleration method (decoding)")
("device,d", po::value<uint32_t>(&arguments.vk_device_index)->default_value(0),
"Vulkan device index (GPU ID)")
("benchmark,b", po::bool_switch(&arguments.benchmark),
@@ -90,10 +91,10 @@ int parse_args(
po::options_description encoder_opts("Encoder options");
encoder_opts.add_options()
("codec,c", PO_STR_VALUE<StringType>()->default_value(STR("libx264"), "libx264"),
"Output codec")
("codec,c", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("libx264"), "libx264"), "Output codec")
("no-copy-streams", "Do not copy audio and subtitle streams")
("pix-fmt", PO_STR_VALUE<StringType>(), "Output pixel format")
("pix-fmt", PO_STR_VALUE<video2x::fsutils::StringType>(), "Output pixel format")
("bit-rate", po::value<int64_t>(&enc_cfg.bit_rate)->default_value(0),
"Bitrate in bits per second")
("rc-buffer-size", po::value<int>(&enc_cfg.rc_buffer_size)->default_value(0),
@@ -118,8 +119,8 @@ int parse_args(
"Delay in milliseconds for encoder")
// Extra encoder options (key-value pairs)
("extra-encoder-option,e", PO_STR_VALUE<std::vector<StringType>>()->multitoken(),
"Additional AVOption(s) for the encoder (format: -e key=value)")
("extra-encoder-option,e", PO_STR_VALUE<std::vector<video2x::fsutils::StringType>>()
->multitoken(), "Additional AVOption(s) for the encoder (format: -e key=value)")
;
po::options_description upscale_opts("Upscaling options");
@@ -130,6 +131,8 @@ int parse_args(
->notifier([](int v) { validate_greater_equal_one(v, "height"); }), "Output height")
("scaling-factor,s", po::value<int>(&proc_cfg.scaling_factor)
->notifier([](int v) { validate_min(v, "scaling-factor", 2); }), "Scaling factor")
("noise-level,n", po::value<int>(&proc_cfg.noise_level)
->notifier([](int v) { validate_min(v, "noise-level", 0); }), "Noise level")
;
po::options_description interp_opts("Frame interpolation options");
@@ -144,7 +147,7 @@ int parse_args(
po::options_description libplacebo_opts("libplacebo options");
libplacebo_opts.add_options()
("libplacebo-shader", PO_STR_VALUE<StringType>()
("libplacebo-shader", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("anime4k-v4-a"), "anime4k-v4-a")
->notifier(validate_anime4k_shader_name),
"Name/path of the GLSL shader file to use (built-in: anime4k-v4-a, anime4k-v4-a+a, "
@@ -153,17 +156,29 @@ int parse_args(
po::options_description realesrgan_opts("RealESRGAN options");
realesrgan_opts.add_options()
("realesrgan-model", PO_STR_VALUE<StringType>()
("realesrgan-model", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("realesr-animevideov3"), "realesr-animevideov3")
->notifier(validate_realesrgan_model_name),
"Name of the RealESRGAN model to use (realesr-animevideov3, realesrgan-plus-anime, "
"realesrgan-plus)")
;
po::options_description realcugan_opts("RealCUGAN options");
realcugan_opts.add_options()
("realcugan-model", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("models-se"), "models-se")
->notifier(validate_realcugan_model_name),
"Name of the RealCUGAN model to use (models-nose, models-pro, models-se)")
("realcugan-threads", po::value<int>()->default_value(1),
"Number of threads to use for RealCUGAN")
("realcugan-syncgap", po::value<int>()->default_value(3),
"Sync gap mode; 0:no sync, 1: accurate sync: 2 = rough sync, 3: very rough sync")
;
po::options_description rife_opts("RIFE options");
rife_opts.add_options()
("rife-model", PO_STR_VALUE<StringType>()->default_value(STR("rife-v4.6"), "rife-v4.6")
->notifier(validate_rife_model_name),
("rife-model", PO_STR_VALUE<video2x::fsutils::StringType>()
->default_value(STR("rife-v4.6"), "rife-v4.6")->notifier(validate_rife_model_name),
"Name of the RIFE model to use (rife, rife-HD, rife-UHD, rife-anime, rife-v2, "
"rife-v2.3, rife-v2.4, rife-v3.0, rife-v3.1, rife-v4, rife-v4.6)")
("rife-uhd", "Enable Ultra HD mode")
@@ -176,6 +191,7 @@ int parse_args(
.add(interp_opts)
.add(libplacebo_opts)
.add(realesrgan_opts)
.add(realcugan_opts)
.add(rife_opts);
po::variables_map vm;
@@ -220,66 +236,69 @@ int parse_args(
}
if (vm.count("log-level")) {
std::optional<Video2xLogLevel> log_level =
find_log_level_by_name(vm["log-level"].as<StringType>());
if (!log_level.has_value()) {
spdlog::critical("Invalid log level specified.");
if (!video2x::logger_manager::LoggerManager::instance().set_log_level(
wstring_to_u8string(vm["log-level"].as<video2x::fsutils::StringType>())
)) {
video2x::logger()->critical("Invalid log level specified.");
return -1;
}
arguments.log_level = log_level.value();
}
set_spdlog_level(arguments.log_level);
video2x::logger_manager::LoggerManager::instance().hook_ffmpeg_logging();
// Print program banner
spdlog::info("Video2X version {}", LIBVIDEO2X_VERSION_STRING);
// spdlog::info("Copyright (C) 2018-2024 K4YT3X and contributors.");
// spdlog::info("Licensed under GNU AGPL version 3.");
video2x::logger()->info("Video2X version {}", LIBVIDEO2X_VERSION_STRING);
// video2x::logger()->info("Copyright (C) 2018-2024 K4YT3X and contributors.");
// video2x::logger()->info("Licensed under GNU AGPL version 3.");
// Assign positional arguments
if (vm.count("input")) {
arguments.in_fname = std::filesystem::path(vm["input"].as<StringType>());
spdlog::info("Processing file: {}", arguments.in_fname.u8string());
arguments.in_fname =
std::filesystem::path(vm["input"].as<video2x::fsutils::StringType>());
video2x::logger()->info("Processing file: {}", arguments.in_fname.u8string());
} else {
spdlog::critical("Input file path is required.");
video2x::logger()->critical("Input file path is required.");
return -1;
}
if (vm.count("output")) {
arguments.out_fname = std::filesystem::path(vm["output"].as<StringType>());
arguments.out_fname =
std::filesystem::path(vm["output"].as<video2x::fsutils::StringType>());
} else if (!arguments.benchmark) {
spdlog::critical("Output file path is required.");
video2x::logger()->critical("Output file path is required.");
return -1;
}
// Parse processor type
if (vm.count("processor")) {
StringType processor_type_str = vm["processor"].as<StringType>();
video2x::fsutils::StringType processor_type_str =
vm["processor"].as<video2x::fsutils::StringType>();
if (processor_type_str == STR("libplacebo")) {
proc_cfg.processor_type = ProcessorType::Libplacebo;
proc_cfg.processor_type = video2x::processors::ProcessorType::Libplacebo;
} else if (processor_type_str == STR("realesrgan")) {
proc_cfg.processor_type = ProcessorType::RealESRGAN;
proc_cfg.processor_type = video2x::processors::ProcessorType::RealESRGAN;
} else if (processor_type_str == STR("realcugan")) {
proc_cfg.processor_type = video2x::processors::ProcessorType::RealCUGAN;
} else if (processor_type_str == STR("rife")) {
proc_cfg.processor_type = ProcessorType::RIFE;
proc_cfg.processor_type = video2x::processors::ProcessorType::RIFE;
} else {
spdlog::critical(
"Invalid processor specified. Must be 'libplacebo', 'realesrgan', or 'rife'."
);
video2x::logger()->critical("Invalid processor specified.");
return -1;
}
} else {
spdlog::critical("Processor type is required.");
video2x::logger()->critical("Processor type is required.");
return -1;
}
// Parse hardware acceleration method
arguments.hw_device_type = AV_HWDEVICE_TYPE_NONE;
if (vm.count("hwaccel")) {
StringType hwaccel_str = vm["hwaccel"].as<StringType>();
video2x::fsutils::StringType hwaccel_str =
vm["hwaccel"].as<video2x::fsutils::StringType>();
if (hwaccel_str != STR("none")) {
arguments.hw_device_type =
av_hwdevice_find_type_by_name(wstring_to_u8string(hwaccel_str).c_str());
if (arguments.hw_device_type == AV_HWDEVICE_TYPE_NONE) {
spdlog::critical(
video2x::logger()->critical(
"Invalid hardware device type '{}'.", wstring_to_u8string(hwaccel_str)
);
return -1;
@@ -290,11 +309,13 @@ int parse_args(
// Parse codec to AVCodec
enc_cfg.codec = AV_CODEC_ID_H264;
if (vm.count("codec")) {
StringType codec_str = vm["codec"].as<StringType>();
video2x::fsutils::StringType codec_str = vm["codec"].as<video2x::fsutils::StringType>();
const AVCodec *codec =
avcodec_find_encoder_by_name(wstring_to_u8string(codec_str).c_str());
if (codec == nullptr) {
spdlog::critical("Codec '{}' not found.", wstring_to_u8string(codec_str));
video2x::logger()->critical(
"Codec '{}' not found.", wstring_to_u8string(codec_str)
);
return -1;
}
enc_cfg.codec = codec->id;
@@ -306,11 +327,12 @@ int parse_args(
// Parse pixel format to AVPixelFormat
enc_cfg.pix_fmt = AV_PIX_FMT_NONE;
if (vm.count("pix-fmt")) {
StringType pix_fmt_str = vm["pix-fmt"].as<StringType>();
video2x::fsutils::StringType pix_fmt_str =
vm["pix-fmt"].as<video2x::fsutils::StringType>();
if (!pix_fmt_str.empty()) {
enc_cfg.pix_fmt = av_get_pix_fmt(wstring_to_u8string(pix_fmt_str).c_str());
if (enc_cfg.pix_fmt == AV_PIX_FMT_NONE) {
spdlog::critical(
video2x::logger()->critical(
"Invalid pixel format '{}'.", wstring_to_u8string(pix_fmt_str)
);
return -1;
@@ -320,14 +342,17 @@ int parse_args(
// Parse extra AVOptions
if (vm.count("extra-encoder-option")) {
for (const auto &opt : vm["extra-encoder-option"].as<std::vector<StringType>>()) {
for (const auto &opt :
vm["extra-encoder-option"].as<std::vector<video2x::fsutils::StringType>>()) {
size_t eq_pos = opt.find('=');
if (eq_pos != StringType::npos) {
StringType key = opt.substr(0, eq_pos);
StringType value = opt.substr(eq_pos + 1);
if (eq_pos != video2x::fsutils::StringType::npos) {
video2x::fsutils::StringType key = opt.substr(0, eq_pos);
video2x::fsutils::StringType value = opt.substr(eq_pos + 1);
enc_cfg.extra_opts.push_back(std::make_pair(key, value));
} else {
spdlog::critical("Invalid extra AVOption format: {}", wstring_to_u8string(opt));
video2x::logger()->critical(
"Invalid extra AVOption format: {}", wstring_to_u8string(opt)
);
return -1;
}
}
@@ -335,69 +360,120 @@ int parse_args(
// Parse processor-specific configurations
switch (proc_cfg.processor_type) {
case ProcessorType::Libplacebo: {
case video2x::processors::ProcessorType::Libplacebo: {
if (!vm.count("libplacebo-shader")) {
spdlog::critical("Shader name/path must be set for libplacebo.");
video2x::logger()->critical("Shader name/path must be set for libplacebo.");
return -1;
}
if (proc_cfg.width <= 0 || proc_cfg.height <= 0) {
spdlog::critical("Output width and height must be set for libplacebo.");
video2x::logger()->critical(
"Output width and height must be set for libplacebo."
);
return -1;
}
proc_cfg.processor_type = ProcessorType::Libplacebo;
LibplaceboConfig libplacebo_config;
libplacebo_config.shader_path = vm["libplacebo-shader"].as<StringType>();
proc_cfg.processor_type = video2x::processors::ProcessorType::Libplacebo;
video2x::processors::LibplaceboConfig libplacebo_config;
libplacebo_config.shader_path =
vm["libplacebo-shader"].as<video2x::fsutils::StringType>();
proc_cfg.config = libplacebo_config;
break;
}
case ProcessorType::RealESRGAN: {
case video2x::processors::ProcessorType::RealESRGAN: {
if (!vm.count("realesrgan-model")) {
spdlog::critical("RealESRGAN model name must be set for RealESRGAN.");
video2x::logger()->critical("RealESRGAN model name must be set for RealESRGAN."
);
return -1;
}
if (proc_cfg.scaling_factor != 2 && proc_cfg.scaling_factor != 3 &&
proc_cfg.scaling_factor != 4) {
spdlog::critical("Scaling factor must be set to 2, 3, or 4 for RealESRGAN.");
if (proc_cfg.scaling_factor < 2 || proc_cfg.scaling_factor > 4) {
video2x::logger()->critical(
"Scaling factor must be set to 2, 3, or 4 for RealESRGAN."
);
return -1;
}
proc_cfg.processor_type = ProcessorType::RealESRGAN;
RealESRGANConfig realesrgan_config;
proc_cfg.processor_type = video2x::processors::ProcessorType::RealESRGAN;
video2x::processors::RealESRGANConfig realesrgan_config;
realesrgan_config.tta_mode = false;
realesrgan_config.model_name = vm["realesrgan-model"].as<StringType>();
realesrgan_config.model_name =
vm["realesrgan-model"].as<video2x::fsutils::StringType>();
proc_cfg.config = realesrgan_config;
break;
}
case ProcessorType::RIFE: {
if (!vm.count("rife-model")) {
spdlog::critical("RIFE model name must be set for RIFE.");
case video2x::processors::ProcessorType::RealCUGAN: {
if (!vm.count("realcugan-model")) {
video2x::logger()->critical("RealCUGAN model name must be set for RealCUGAN.");
return -1;
}
if (proc_cfg.frm_rate_mul < 2) {
spdlog::critical("Frame rate multiplier must be set to at least 2 for RIFE.");
if (vm.count("realcugan-threads") && vm["realcugan-threads"].as<int>() < 1) {
video2x::logger()->critical(
"Number of threads must be at least 1 for RealCUGAN."
);
return -1;
}
if (vm.count("realcugan-syncgap") && (vm["realcugan-syncgap"].as<int>() < 0 ||
vm["realcugan-syncgap"].as<int>() > 3)) {
video2x::logger()->critical(
"Sync gap mode must be set to 0, 1, 2, or 3 for RealCUGAN."
);
return -1;
}
if (proc_cfg.scaling_factor < 2 || proc_cfg.scaling_factor > 4) {
video2x::logger()->critical(
"Scaling factor must be set to 2, 3, or 4 for RealCUGAN."
);
return -1;
}
if (proc_cfg.noise_level < -1 || proc_cfg.noise_level > 3) {
video2x::logger()->critical(
"Noise level must be set to -1, 0, 1, 2, or 3 for RealCUGAN."
);
return -1;
}
proc_cfg.processor_type = ProcessorType::RIFE;
RIFEConfig rife_config;
proc_cfg.processor_type = video2x::processors::ProcessorType::RealCUGAN;
video2x::processors::RealCUGANConfig realcugan_config;
realcugan_config.tta_mode = false;
realcugan_config.model_name =
vm["realcugan-model"].as<video2x::fsutils::StringType>();
realcugan_config.num_threads = vm["realcugan-threads"].as<int>();
realcugan_config.syncgap = vm["realcugan-syncgap"].as<int>();
proc_cfg.config = realcugan_config;
break;
}
case video2x::processors::ProcessorType::RIFE: {
if (!vm.count("rife-model")) {
video2x::logger()->critical("RIFE model name must be set for RIFE.");
return -1;
}
if (proc_cfg.frm_rate_mul < 2) {
video2x::logger()->critical(
"Frame rate multiplier must be set to at least 2 for RIFE."
);
return -1;
}
proc_cfg.processor_type = video2x::processors::ProcessorType::RIFE;
video2x::processors::RIFEConfig rife_config;
rife_config.tta_mode = false;
rife_config.tta_temporal_mode = false;
rife_config.uhd_mode = vm.count("rife-uhd") > 0;
rife_config.num_threads = 0;
rife_config.model_name = vm["rife-model"].as<StringType>();
rife_config.model_name = vm["rife-model"].as<video2x::fsutils::StringType>();
proc_cfg.config = rife_config;
break;
}
default:
spdlog::critical("Invalid processor type.");
video2x::logger()->critical("Invalid processor type.");
return -1;
}
} catch (const po::error &e) {
spdlog::critical("Error parsing arguments: {}", e.what());
video2x::logger()->critical("Error parsing arguments: {}", e.what());
return -1;
} catch (const std::exception &e) {
spdlog::critical("Unexpected exception caught while parsing options: {}", e.what());
video2x::logger()->critical(
"Unexpected exception caught while parsing options: {}", e.what()
);
return -1;
}
@@ -406,17 +482,19 @@ int parse_args(
int get_vulkan_dev_ret = get_vulkan_device_prop(arguments.vk_device_index, &dev_props);
if (get_vulkan_dev_ret != 0) {
if (get_vulkan_dev_ret == -2) {
spdlog::critical("Invalid Vulkan device ID specified.");
video2x::logger()->critical("Invalid Vulkan device ID specified.");
return -1;
} else {
spdlog::warn("Unable to validate Vulkan device ID.");
video2x::logger()->warn("Unable to validate Vulkan device ID.");
return -1;
}
} else {
// Warn if the selected device is a CPU
spdlog::info("Using Vulkan device: {} ({:#x})", dev_props.deviceName, dev_props.deviceID);
video2x::logger()->info(
"Using Vulkan device: {} ({:#x})", dev_props.deviceName, dev_props.deviceID
);
if (dev_props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
spdlog::warn("The selected Vulkan device is a CPU device.");
video2x::logger()->warn("The selected Vulkan device is a CPU device.");
}
}
return 0;

View File

@@ -1,77 +0,0 @@
#include "logging.h"
#include <algorithm>
#include <unordered_map>
extern "C" {
#include <libavutil/log.h>
}
std::atomic<bool> newline_required = false;
void set_spdlog_level(Video2xLogLevel log_level) {
switch (log_level) {
case Video2xLogLevel::Trace:
spdlog::set_level(spdlog::level::trace);
break;
case Video2xLogLevel::Debug:
spdlog::set_level(spdlog::level::debug);
break;
case Video2xLogLevel::Info:
spdlog::set_level(spdlog::level::info);
break;
case Video2xLogLevel::Warning:
spdlog::set_level(spdlog::level::warn);
break;
case Video2xLogLevel::Error:
spdlog::set_level(spdlog::level::err);
break;
case Video2xLogLevel::Critical:
spdlog::set_level(spdlog::level::critical);
break;
case Video2xLogLevel::Off:
spdlog::set_level(spdlog::level::off);
break;
default:
spdlog::set_level(spdlog::level::info);
break;
}
}
std::optional<Video2xLogLevel> find_log_level_by_name(const StringType &log_level_name) {
// Static map to store the mapping
static const std::unordered_map<StringType, Video2xLogLevel> log_level_map = {
{STR("trace"), Video2xLogLevel::Trace},
{STR("debug"), Video2xLogLevel::Debug},
{STR("info"), Video2xLogLevel::Info},
{STR("warning"), Video2xLogLevel::Warning},
{STR("warn"), Video2xLogLevel::Warning},
{STR("error"), Video2xLogLevel::Error},
{STR("critical"), Video2xLogLevel::Critical},
{STR("off"), Video2xLogLevel::Off},
{STR("none"), Video2xLogLevel::Off}
};
// Normalize the input to lowercase
StringType normalized_name = log_level_name;
std::transform(
normalized_name.begin(), normalized_name.end(), normalized_name.begin(), ::tolower
);
// Lookup the log level in the map
auto it = log_level_map.find(normalized_name);
if (it != log_level_map.end()) {
return it->second;
}
return std::nullopt;
}
// Newline-safe log callback for FFmpeg
void newline_safe_ffmpeg_log_callback(void *ptr, int level, const char *fmt, va_list vl) {
if (level <= av_log_get_level() && newline_required.load()) {
putchar('\n');
newline_required.store(false);
}
av_log_default_callback(ptr, level, fmt, vl);
}

View File

@@ -0,0 +1,9 @@
#include "newline_safe_sink.h"
void newline_safe_sink::log(const spdlog::details::log_msg &msg) {
if (needs_newline_.exchange(false)) {
std::fputs("\n", stdout);
}
spdlog::sinks::ansicolor_stdout_sink_mt::log(msg);
}

View File

@@ -2,8 +2,8 @@
#include <unordered_set>
void validate_anime4k_shader_name(const StringType &shader_name) {
static const std::unordered_set<StringType> valid_anime4k_shaders = {
void validate_anime4k_shader_name(const video2x::fsutils::StringType &shader_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_anime4k_shaders = {
STR("anime4k-v4-a"),
STR("anime4k-v4-a+a"),
STR("anime4k-v4-b"),
@@ -22,8 +22,8 @@ void validate_anime4k_shader_name(const StringType &shader_name) {
}
}
void validate_realesrgan_model_name(const StringType &model_name) {
static const std::unordered_set<StringType> valid_realesrgan_models = {
void validate_realesrgan_model_name(const video2x::fsutils::StringType &model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_realesrgan_models = {
STR("realesrgan-plus"), STR("realesrgan-plus-anime"), STR("realesr-animevideov3")
};
if (valid_realesrgan_models.count(model_name) == 0) {
@@ -36,8 +36,21 @@ void validate_realesrgan_model_name(const StringType &model_name) {
}
}
void validate_rife_model_name(const StringType &model_name) {
static const std::unordered_set<StringType> valid_realesrgan_models = {
void validate_realcugan_model_name(const video2x::fsutils::StringType &model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_realcugan_models = {
STR("models-nose"), STR("models-pro"), STR("models-se")
};
if (valid_realcugan_models.count(model_name) == 0) {
throw po::validation_error(
po::validation_error::invalid_option_value,
"realcugan-model",
"realcugan-model must be one of: models-nose, models-pro, models-se"
);
}
}
void validate_rife_model_name(const video2x::fsutils::StringType &model_name) {
static const std::unordered_set<video2x::fsutils::StringType> valid_rife_models = {
STR("rife"),
STR("rife-HD"),
STR("rife-UHD"),
@@ -50,7 +63,7 @@ void validate_rife_model_name(const StringType &model_name) {
STR("rife-v4"),
STR("rife-v4.6"),
};
if (valid_realesrgan_models.count(model_name) == 0) {
if (valid_rife_models.count(model_name) == 0) {
throw po::validation_error(
po::validation_error::invalid_option_value,
"rife-model",

View File

@@ -9,10 +9,10 @@
#include <unistd.h>
#endif
#include <spdlog/spdlog.h>
#include <libvideo2x/logger_manager.h>
#include "argparse.h"
#include "logging.h"
#include "newline_safe_sink.h"
#include "timer.h"
// Set UNIX terminal input to non-blocking mode
@@ -53,10 +53,20 @@ int wmain(int argc, wchar_t *argv[]) {
#else
int main(int argc, char **argv) {
#endif
// Initialize arguments structures
// Initialize newline-safe logger with custom formatting pattern
std::shared_ptr<newline_safe_sink> logger_sink = std::make_shared<newline_safe_sink>();
std::vector<spdlog::sink_ptr> sinks = {logger_sink};
if (!video2x::logger_manager::LoggerManager::instance().reconfigure_logger(
"video2x", sinks, "[%Y-%m-%d %H:%M:%S] [%^%l%$] %v"
)) {
std::cerr << "Error: Failed to configure logger." << std::endl;
return 1;
}
// Initialize argument and configuration structs
Arguments arguments;
ProcessorConfig proc_cfg;
EncoderConfig enc_cfg;
video2x::processors::ProcessorConfig proc_cfg;
video2x::encoder::EncoderConfig enc_cfg;
// Parse command line arguments
int parse_ret = parse_args(argc, argv, arguments, proc_cfg, enc_cfg);
@@ -72,18 +82,10 @@ int main(int argc, char **argv) {
}
// Create video processor object
VideoProcessor video_processor = VideoProcessor(
proc_cfg,
enc_cfg,
arguments.vk_device_index,
arguments.hw_device_type,
arguments.log_level,
arguments.benchmark
video2x::VideoProcessor video_processor = video2x::VideoProcessor(
proc_cfg, enc_cfg, arguments.vk_device_index, arguments.hw_device_type, arguments.benchmark
);
// Register a newline-safe log callback for FFmpeg
av_log_set_callback(newline_safe_ffmpeg_log_callback);
// Create a thread for video processing
int proc_ret = 0;
std::atomic<bool> completed = false; // Use atomic for thread-safe updates
@@ -91,7 +93,7 @@ int main(int argc, char **argv) {
proc_ret = video_processor.process(arguments.in_fname, arguments.out_fname);
completed.store(true, std::memory_order_relaxed);
});
spdlog::info("Press [space] to pause/resume, [q] to abort.");
video2x::logger()->info("Press [space] to pause/resume, [q] to abort.");
// Setup timer
Timer timer;
@@ -123,14 +125,14 @@ int main(int argc, char **argv) {
if (ch == ' ' || ch == '\n') {
{
// Toggle pause state
if (video_processor.get_state() == VideoProcessorState::Paused) {
if (video_processor.get_state() == video2x::VideoProcessorState::Paused) {
video_processor.resume();
} else {
video_processor.pause();
}
// Print message based on current state and pause/resume the timer
if (video_processor.get_state() == VideoProcessorState::Paused) {
if (video_processor.get_state() == video2x::VideoProcessorState::Paused) {
std::cout
<< "\r\033[KProcessing paused; press [space] to resume, [q] to abort.";
std::cout.flush();
@@ -140,15 +142,11 @@ int main(int argc, char **argv) {
std::cout.flush();
timer.resume();
}
newline_required.store(true);
logger_sink->set_needs_newline(true);
}
} else if (ch == 'q' || ch == 'Q') {
// Abort processing
if (newline_required.load()) {
putchar('\n');
}
spdlog::warn("Aborting gracefully; press Ctrl+C to terminate forcefully.");
newline_required.store(false);
video2x::logger()->warn("Aborting gracefully; press Ctrl+C to terminate forcefully.");
video_processor.abort();
break;
}
@@ -159,7 +157,7 @@ int main(int argc, char **argv) {
int64_t total_frames = video_processor.get_total_frames();
// Print the progress bar if processing is not paused
if (video_processor.get_state() != VideoProcessorState::Paused &&
if (video_processor.get_state() != video2x::VideoProcessorState::Paused &&
(total_frames > 0 || processed_frames > 0)) {
double percentage = total_frames > 0 ? static_cast<double>(processed_frames) *
100.0 / static_cast<double>(total_frames)
@@ -192,7 +190,7 @@ int main(int argc, char **argv) {
<< ":" << std::setw(2) << std::setfill('0') << minutes_remaining << ":"
<< std::setw(2) << std::setfill('0') << seconds_remaining;
std::cout.flush();
newline_required.store(true);
logger_sink->set_needs_newline(true);
}
}
@@ -208,44 +206,43 @@ int main(int argc, char **argv) {
// Join the processing thread to ensure it completes before exiting
processing_thread.join();
// Print a newline if progress bar was displayed
if (newline_required.load()) {
std::cout << '\n';
}
// Print final message based on processing result
if (video_processor.get_state() == VideoProcessorState::Aborted) {
spdlog::warn("Video processing aborted");
if (video_processor.get_state() == video2x::VideoProcessorState::Aborted) {
video2x::logger()->warn("Video processing aborted");
return 2;
} else if (proc_ret != 0 || video_processor.get_state() == VideoProcessorState::Failed) {
spdlog::critical("Video processing failed with error code {}", proc_ret);
} else if (proc_ret != 0 ||
video_processor.get_state() == video2x::VideoProcessorState::Failed) {
video2x::logger()->critical("Video processing failed with error code {}", proc_ret);
return 1;
} else {
spdlog::info("Video processed successfully");
video2x::logger()->info("Video processed successfully");
}
// Calculate statistics
int64_t processed_frames = video_processor.get_processed_frames();
int time_elapsed = static_cast<int>(timer.get_elapsed_time() / 1000);
auto [hours_elapsed, minutes_elapsed, seconds_elapsed] =
calculate_time_components(time_elapsed);
float average_speed_fps = static_cast<float>(processed_frames) /
(time_elapsed > 0 ? static_cast<float>(time_elapsed) : 1);
// Print the processing summary if the log level is info or lower
if (video2x::logger()->level() <= spdlog::level::info) {
// Calculate statistics
int64_t processed_frames = video_processor.get_processed_frames();
int time_elapsed = static_cast<int>(timer.get_elapsed_time() / 1000);
auto [hours_elapsed, minutes_elapsed, seconds_elapsed] =
calculate_time_components(time_elapsed);
float average_speed_fps = static_cast<float>(processed_frames) /
(time_elapsed > 0 ? static_cast<float>(time_elapsed) : 1);
// Print processing summary
std::cout << "====== Video2X " << (arguments.benchmark ? "Benchmark" : "Processing")
<< " summary ======" << std::endl;
std::cout << "Video file processed: " << arguments.in_fname.u8string() << std::endl;
std::cout << "Total frames processed: " << processed_frames << std::endl;
std::cout << "Total time taken: " << std::setw(2) << std::setfill('0') << hours_elapsed << ":"
<< std::setw(2) << std::setfill('0') << minutes_elapsed << ":" << std::setw(2)
<< std::setfill('0') << seconds_elapsed << std::endl;
std::cout << "Average processing speed: " << std::fixed << std::setprecision(2)
<< average_speed_fps << " FPS" << std::endl;
// Print processing summary
std::cout << "====== Video2X " << (arguments.benchmark ? "Benchmark" : "Processing")
<< " summary ======" << std::endl;
std::cout << "Video file processed: " << arguments.in_fname.u8string() << std::endl;
std::cout << "Total frames processed: " << processed_frames << std::endl;
std::cout << "Total time taken: " << std::setw(2) << std::setfill('0') << hours_elapsed
<< ":" << std::setw(2) << std::setfill('0') << minutes_elapsed << ":"
<< std::setw(2) << std::setfill('0') << seconds_elapsed << std::endl;
std::cout << "Average processing speed: " << std::fixed << std::setprecision(2)
<< average_speed_fps << " FPS" << std::endl;
// Print additional information if not in benchmark mode
if (!arguments.benchmark) {
std::cout << "Output written to: " << arguments.out_fname.u8string() << std::endl;
// Print additional information if not in benchmark mode
if (!arguments.benchmark) {
std::cout << "Output written to: " << arguments.out_fname.u8string() << std::endl;
}
}
return 0;

View File

@@ -3,7 +3,7 @@
#include <iostream>
#include <vector>
#include <spdlog/spdlog.h>
#include <libvideo2x/logger_manager.h>
static int enumerate_vulkan_devices(VkInstance *instance, std::vector<VkPhysicalDevice> &devices) {
// Create a Vulkan instance
@@ -12,7 +12,7 @@ static int enumerate_vulkan_devices(VkInstance *instance, std::vector<VkPhysical
VkResult result = vkCreateInstance(&create_info, nullptr, instance);
if (result != VK_SUCCESS) {
spdlog::error("Failed to create Vulkan instance.");
video2x::logger()->error("Failed to create Vulkan instance.");
return -1;
}
@@ -20,7 +20,9 @@ static int enumerate_vulkan_devices(VkInstance *instance, std::vector<VkPhysical
uint32_t device_count = 0;
result = vkEnumeratePhysicalDevices(*instance, &device_count, nullptr);
if (result != VK_SUCCESS || device_count == 0) {
spdlog::error("Failed to enumerate Vulkan physical devices or no devices available.");
video2x::logger()->error(
"Failed to enumerate Vulkan physical devices or no devices available."
);
vkDestroyInstance(*instance, nullptr);
return -1;
}
@@ -28,7 +30,7 @@ static int enumerate_vulkan_devices(VkInstance *instance, std::vector<VkPhysical
devices.resize(device_count);
result = vkEnumeratePhysicalDevices(*instance, &device_count, devices.data());
if (result != VK_SUCCESS) {
spdlog::error("Failed to retrieve Vulkan physical devices.");
video2x::logger()->error("Failed to retrieve Vulkan physical devices.");
vkDestroyInstance(*instance, nullptr);
return -1;
}
@@ -96,7 +98,7 @@ int list_vulkan_devices() {
int get_vulkan_device_prop(uint32_t vk_device_index, VkPhysicalDeviceProperties *dev_props) {
if (dev_props == nullptr) {
spdlog::error("Invalid device properties pointer.");
video2x::logger()->error("Invalid device properties pointer.");
return -1;
}