filter/upscaling: 'Video Super-Resolution' -> 'Upscaling'

The previous name was too strict on what could be put into the effect, and would result in additional clutter in the Filter menu when we eventually decide to support other Upscaling methods than Super-Resolution networks.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2021-09-28 00:16:21 +02:00
parent 03e6ce0dbc
commit 843a76d1c6
5 changed files with 141 additions and 149 deletions

View file

@ -305,8 +305,8 @@ set(${PREFIX}ENABLE_FILTER_NVIDIA_FACE_TRACKING ON CACHE BOOL "Enable NVIDIA Fac
set(${PREFIX}ENABLE_FILTER_SDF_EFFECTS ON CACHE BOOL "Enable SDF Effects Filter")
set(${PREFIX}ENABLE_FILTER_SHADER ON CACHE BOOL "Enable Shader Filter")
set(${PREFIX}ENABLE_FILTER_TRANSFORM ON CACHE BOOL "Enable Transform Filter")
set(${PREFIX}ENABLE_FILTER_VIDEO_SUPERRESOLUTION ON CACHE BOOL "Enable Video Super-Resolution filter")
set(${PREFIX}ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA ON CACHE BOOL "Enable NVIDIA Video Super-Resolution for Video Super-Resolution Filter")
set(${PREFIX}ENABLE_FILTER_UPSCALING ON CACHE BOOL "Enable Upscaling Filter")
set(${PREFIX}ENABLE_FILTER_UPSCALING_NVIDIA ON CACHE BOOL "Enable NVIDIA provider(s) for Upscaling Filter")
## Sources
set(${PREFIX}ENABLE_SOURCE_MIRROR ON CACHE BOOL "Enable Mirror Source")
@ -696,20 +696,20 @@ function(feature_filter_transform RESOLVE)
is_feature_enabled(FILTER_TRANSFORM T_CHECK)
endfunction()
function(feature_filter_video_superresolution RESOLVE)
is_feature_enabled(FILTER_VIDEO_SUPERRESOLUTION T_CHECK)
function(feature_filter_upscaling RESOLVE)
is_feature_enabled(FILTER_UPSCALING T_CHECK)
if(RESOLVE AND T_CHECK)
# Verify that the requirements for the providers are available
if(NOT HAVE_NVIDIA_VFX_SDK)
message(WARNING "${LOGPREFIX}: 'NVIDIA Video Effects SDK' is missing. Disabling Video Super-Resolution provider...")
set_feature_disabled(FILTER_VIDEO_SUPERRESOLUTION_NVIDIA ON)
message(WARNING "${LOGPREFIX}: 'NVIDIA Video Effects SDK' is missing. Disabling NVIDIA provider(s)...")
set_feature_disabled(FILTER_UPSCALING_NVIDIA ON)
endif()
# Verify that we have at least one provider for Video Super-Resolution.
is_feature_enabled(FILTER_VIDEO_SUPERRESOLUTION_NVIDIA T_CHECK_NVIDIA)
is_feature_enabled(FILTER_UPSCALING_NVIDIA T_CHECK_NVIDIA)
if (NOT T_CHECK_NVIDIA)
message(WARNING "${LOGPREFIX}: Video Super-Resolution has no available providers. Disabling...")
set_feature_disabled(FILTER_VIDEO_SUPERRESOLUTION ON)
message(WARNING "${LOGPREFIX}: Upscaling has no available providers. Disabling...")
set_feature_disabled(FILTER_UPSCALING ON)
endif()
elseif(T_CHECK)
set(REQUIRE_NVIDIA_VFX_SDK ON PARENT_SCOPE)
@ -771,7 +771,7 @@ feature_filter_nvidia_face_tracking(OFF)
feature_filter_sdf_effects(OFF)
feature_filter_shader(OFF)
feature_filter_transform(OFF)
feature_filter_video_superresolution(OFF)
feature_filter_upscaling(OFF)
feature_source_mirror(OFF)
feature_source_shader(OFF)
feature_transition_shader(OFF)
@ -926,7 +926,7 @@ feature_filter_nvidia_face_tracking(ON)
feature_filter_sdf_effects(ON)
feature_filter_shader(ON)
feature_filter_transform(ON)
feature_filter_video_superresolution(ON)
feature_filter_upscaling(ON)
feature_source_mirror(ON)
feature_source_shader(ON)
feature_transition_shader(ON)
@ -1391,19 +1391,19 @@ if(T_CHECK)
endif()
# Filter/Video Super-Resolution
is_feature_enabled(FILTER_VIDEO_SUPERRESOLUTION T_CHECK)
is_feature_enabled(FILTER_UPSCALING T_CHECK)
if(T_CHECK)
list(APPEND PROJECT_PRIVATE_SOURCE
"source/filters/filter-video-superresolution.hpp"
"source/filters/filter-video-superresolution.cpp"
"source/filters/filter-upscaling.hpp"
"source/filters/filter-upscaling.cpp"
)
list(APPEND PROJECT_DEFINITIONS
ENABLE_FILTER_VIDEO_SUPERRESOLUTION
ENABLE_FILTER_UPSCALING
)
is_feature_enabled(FILTER_VIDEO_SUPERRESOLUTION_NVIDIA T_CHECK)
is_feature_enabled(FILTER_UPSCALING_NVIDIA T_CHECK)
if (T_CHECK)
list(APPEND PROJECT_DEFINITIONS
ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
ENABLE_FILTER_UPSCALING_NVIDIA
)
endif()
endif()

View file

@ -335,15 +335,15 @@ Filter.Transform.Rotation.Order.ZXY="Roll, Pitch, Yaw"
Filter.Transform.Rotation.Order.ZYX="Roll, Yaw, Pitch"
Filter.Transform.Mipmapping="Enable Mipmapping"
# Filter - Video Super-Resolution
Filter.VideoSuperResolution="Video Super-Resolution"
Filter.VideoSuperResolution.Provider="Provider"
Filter.VideoSuperResolution.Provider.NVIDIAVideoSuperResolution="NVIDIA Video Super-Resolution, powered by NVIDIA Broadcast"
Filter.VideoSuperResolution.NVIDIA.SuperRes="NVIDIA Video Super-Resolution"
Filter.VideoSuperResolution.NVIDIA.SuperRes.Scale="Scale"
Filter.VideoSuperResolution.NVIDIA.SuperRes.Strength="Strength"
Filter.VideoSuperResolution.NVIDIA.SuperRes.Strength.Weak="Weak"
Filter.VideoSuperResolution.NVIDIA.SuperRes.Strength.Strong="Strong"
# Filter - Upscaling
Filter.Upscaling="Upscaling"
Filter.Upscaling.Provider="Provider"
Filter.Upscaling.Provider.NVIDIAVideoSuperResolution="NVIDIA Video Super-Resolution, powered by NVIDIA Broadcast"
Filter.Upscaling.NVIDIA.SuperRes="NVIDIA Video Super-Resolution"
Filter.Upscaling.NVIDIA.SuperRes.Scale="Scale"
Filter.Upscaling.NVIDIA.SuperRes.Strength="Strength"
Filter.Upscaling.NVIDIA.SuperRes.Strength.Weak="Weak"
Filter.Upscaling.NVIDIA.SuperRes.Strength.Strong="Strong"
# Source - Mirror
Source.Mirror="Source Mirror"

View file

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "filter-video-superresolution.hpp"
#include "filter-upscaling.hpp"
#include <algorithm>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
@ -38,12 +38,12 @@
#define D_LOG_DEBUG(...) P_LOG_DEBUG(ST_PREFIX __VA_ARGS__)
#endif
#define ST_I18N "Filter.VideoSuperResolution"
#define ST_I18N "Filter.Upscaling"
#define ST_KEY_PROVIDER "Provider"
#define ST_I18N_PROVIDER ST_I18N "." ST_KEY_PROVIDER
#define ST_I18N_PROVIDER_NVIDIA_SUPERRES ST_I18N_PROVIDER ".NVIDIAVideoSuperResolution"
#define ST_I18N_PROVIDER_NVIDIA_SUPERRES ST_I18N_PROVIDER ".NVIDIA.VideoSuperResolution"
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
#define ST_KEY_NVIDIA_SUPERRES "NVIDIA.SuperRes"
#define ST_I18N_NVIDIA_SUPERRES ST_I18N "." ST_KEY_NVIDIA_SUPERRES
#define ST_KEY_NVIDIA_SUPERRES_STRENGTH "NVIDIA.SuperRes.Strength"
@ -54,35 +54,35 @@
#define ST_I18N_NVIDIA_SUPERRES_SCALE ST_I18N "." ST_KEY_NVIDIA_SUPERRES_SCALE
#endif
using streamfx::filter::video_superresolution::video_superresolution_factory;
using streamfx::filter::video_superresolution::video_superresolution_instance;
using streamfx::filter::video_superresolution::video_superresolution_provider;
using streamfx::filter::upscaling::upscaling_factory;
using streamfx::filter::upscaling::upscaling_instance;
using streamfx::filter::upscaling::upscaling_provider;
static constexpr std::string_view HELP_URL =
"https://github.com/Xaymar/obs-StreamFX/wiki/Filter-Video-Super-Resolution";
"https://github.com/Xaymar/obs-StreamFX/wiki/Filter-Upscaling";
/** Priority of providers for automatic selection if more than one is available.
*
*/
static video_superresolution_provider provider_priority[] = {
video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION,
static upscaling_provider provider_priority[] = {
upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION,
};
const char* streamfx::filter::video_superresolution::cstring(video_superresolution_provider provider)
const char* streamfx::filter::upscaling::cstring(upscaling_provider provider)
{
switch (provider) {
case video_superresolution_provider::INVALID:
case upscaling_provider::INVALID:
return "N/A";
case video_superresolution_provider::AUTOMATIC:
case upscaling_provider::AUTOMATIC:
return D_TRANSLATE(S_STATE_AUTOMATIC);
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
return D_TRANSLATE(ST_I18N_PROVIDER_NVIDIA_SUPERRES);
default:
throw std::runtime_error("Missing Conversion Entry");
}
}
std::string streamfx::filter::video_superresolution::string(video_superresolution_provider provider)
std::string streamfx::filter::upscaling::string(upscaling_provider provider)
{
return cstring(provider);
}
@ -90,11 +90,11 @@ std::string streamfx::filter::video_superresolution::string(video_superresolutio
//------------------------------------------------------------------------------
// Instance
//------------------------------------------------------------------------------
video_superresolution_instance::video_superresolution_instance(obs_data_t* data, obs_source_t* self)
upscaling_instance::upscaling_instance(obs_data_t* data, obs_source_t* self)
: obs::source_instance(data, self),
_in_size(1, 1), _out_size(1, 1), _provider_ready(false), _provider(video_superresolution_provider::INVALID),
_provider_lock(), _provider_task(), _input(), _output(), _dirty(false)
_in_size(1, 1), _out_size(1, 1), _provider_ready(false), _provider(upscaling_provider::INVALID), _provider_lock(),
_provider_task(), _input(), _output(), _dirty(false)
{
{
::streamfx::obs::gs::context gctx;
@ -110,13 +110,13 @@ video_superresolution_instance::video_superresolution_instance(obs_data_t* data,
}
}
video_superresolution_instance::~video_superresolution_instance()
upscaling_instance::~upscaling_instance()
{
// TODO: Make this asynchronous.
std::unique_lock<std::mutex> ul(_provider_lock);
switch (_provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_unload();
break;
#endif
@ -125,20 +125,19 @@ video_superresolution_instance::~video_superresolution_instance()
}
}
void video_superresolution_instance::load(obs_data_t* data)
void upscaling_instance::load(obs_data_t* data)
{
update(data);
}
void video_superresolution_instance::migrate(obs_data_t* data, uint64_t version) {}
void upscaling_instance::migrate(obs_data_t* data, uint64_t version) {}
void video_superresolution_instance::update(obs_data_t* data)
void upscaling_instance::update(obs_data_t* data)
{
// Check if the user changed which Denoising provider we use.
video_superresolution_provider provider =
static_cast<video_superresolution_provider>(obs_data_get_int(data, ST_KEY_PROVIDER));
if (provider == video_superresolution_provider::AUTOMATIC) {
provider = video_superresolution_factory::get()->find_ideal_provider();
upscaling_provider provider = static_cast<upscaling_provider>(obs_data_get_int(data, ST_KEY_PROVIDER));
if (provider == upscaling_provider::AUTOMATIC) {
provider = upscaling_factory::get()->find_ideal_provider();
}
// Check if the provider was changed, and if so switch.
@ -151,8 +150,8 @@ void video_superresolution_instance::update(obs_data_t* data)
std::unique_lock<std::mutex> ul(_provider_lock);
switch (_provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_update(data);
break;
#endif
@ -162,11 +161,11 @@ void video_superresolution_instance::update(obs_data_t* data)
}
}
void streamfx::filter::video_superresolution::video_superresolution_instance::properties(obs_properties_t* properties)
void streamfx::filter::upscaling::upscaling_instance::properties(obs_properties_t* properties)
{
switch (_provider_ui) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_properties(properties);
break;
#endif
@ -175,17 +174,17 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::pr
}
}
uint32_t streamfx::filter::video_superresolution::video_superresolution_instance::get_width()
uint32_t streamfx::filter::upscaling::upscaling_instance::get_width()
{
return std::max<uint32_t>(_out_size.first, 1);
}
uint32_t streamfx::filter::video_superresolution::video_superresolution_instance::get_height()
uint32_t streamfx::filter::upscaling::upscaling_instance::get_height()
{
return std::max<uint32_t>(_out_size.second, 1);
}
void video_superresolution_instance::video_tick(float_t time)
void upscaling_instance::video_tick(float_t time)
{
auto target = obs_filter_get_target(_self);
auto width = obs_source_get_base_width(target);
@ -198,8 +197,8 @@ void video_superresolution_instance::video_tick(float_t time)
std::unique_lock<std::mutex> ul(_provider_lock);
switch (_provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_size();
break;
#endif
@ -211,7 +210,7 @@ void video_superresolution_instance::video_tick(float_t time)
_dirty = true;
}
void video_superresolution_instance::video_render(gs_effect_t* effect)
void upscaling_instance::video_render(gs_effect_t* effect)
{
auto parent = obs_filter_get_parent(_self);
auto target = obs_filter_get_target(_self);
@ -285,8 +284,8 @@ void video_superresolution_instance::video_render(gs_effect_t* effect)
::streamfx::obs::gs::debug_marker profiler1{::streamfx::obs::gs::debug_color_convert, "Process"};
#endif
switch (_provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_process();
break;
#endif
@ -320,11 +319,10 @@ void video_superresolution_instance::video_render(gs_effect_t* effect)
}
struct switch_provider_data_t {
video_superresolution_provider provider;
upscaling_provider provider;
};
void streamfx::filter::video_superresolution::video_superresolution_instance::switch_provider(
video_superresolution_provider provider)
void streamfx::filter::upscaling::upscaling_instance::switch_provider(upscaling_provider provider)
{
std::unique_lock<std::mutex> ul(_provider_lock);
@ -353,11 +351,10 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::sw
// 3. Then spawn a new task to switch provider.
_provider_task = streamfx::threadpool()->push(
std::bind(&video_superresolution_instance::task_switch_provider, this, std::placeholders::_1), spd);
std::bind(&upscaling_instance::task_switch_provider, this, std::placeholders::_1), spd);
}
void streamfx::filter::video_superresolution::video_superresolution_instance::task_switch_provider(
util::threadpool_data_t data)
void streamfx::filter::upscaling::upscaling_instance::task_switch_provider(util::threadpool_data_t data)
{
std::shared_ptr<switch_provider_data_t> spd = std::static_pointer_cast<switch_provider_data_t>(data);
@ -370,8 +367,8 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::ta
try {
// 3. Unload the previous provider.
switch (spd->provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_unload();
break;
#endif
@ -381,8 +378,8 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::ta
// 4. Load the new provider.
switch (_provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
nvvfxsr_load();
{
auto data = obs_source_get_settings(_self);
@ -407,18 +404,18 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::ta
}
}
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_load()
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_load()
{
_nvidia_fx = std::make_shared<::streamfx::nvidia::vfx::superresolution>();
}
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_unload()
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_unload()
{
_nvidia_fx.reset();
}
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_size()
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_size()
{
if (!_nvidia_fx) {
return;
@ -428,7 +425,7 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::nv
_nvidia_fx->size(in_size, _in_size, _out_size);
}
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_process()
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_process()
{
if (!_nvidia_fx) {
_output = _input->get_texture();
@ -438,8 +435,7 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::nv
_output = _nvidia_fx->process(_input->get_texture());
}
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_properties(
obs_properties_t* props)
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_properties(obs_properties_t* props)
{
obs_properties_t* grp = obs_properties_create();
obs_properties_add_group(props, ST_KEY_NVIDIA_SUPERRES, D_TRANSLATE(ST_I18N_NVIDIA_SUPERRES), OBS_GROUP_NORMAL,
@ -460,7 +456,7 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::nv
}
}
void streamfx::filter::video_superresolution::video_superresolution_instance::nvvfxsr_update(obs_data_t* data)
void streamfx::filter::upscaling::upscaling_instance::nvvfxsr_update(obs_data_t* data)
{
if (!_nvidia_fx)
return;
@ -475,14 +471,14 @@ void streamfx::filter::video_superresolution::video_superresolution_instance::nv
//------------------------------------------------------------------------------
// Factory
//------------------------------------------------------------------------------
video_superresolution_factory::~video_superresolution_factory() {}
upscaling_factory::~upscaling_factory() {}
video_superresolution_factory::video_superresolution_factory()
upscaling_factory::upscaling_factory()
{
bool any_available = false;
// 1. Try and load any configured providers.
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
try {
// Load CVImage and Video Effects SDK.
_nvcuda = ::streamfx::nvidia::cuda::obs::get();
@ -520,16 +516,16 @@ video_superresolution_factory::video_superresolution_factory()
finish_setup();
}
const char* video_superresolution_factory::get_name()
const char* upscaling_factory::get_name()
{
return D_TRANSLATE(ST_I18N);
}
void video_superresolution_factory::get_defaults2(obs_data_t* data)
void upscaling_factory::get_defaults2(obs_data_t* data)
{
obs_data_set_default_int(data, ST_KEY_PROVIDER, static_cast<int64_t>(video_superresolution_provider::AUTOMATIC));
obs_data_set_default_int(data, ST_KEY_PROVIDER, static_cast<int64_t>(upscaling_provider::AUTOMATIC));
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
obs_data_set_default_double(data, ST_KEY_NVIDIA_SUPERRES_SCALE, 150.);
obs_data_set_default_double(data, ST_KEY_NVIDIA_SUPERRES_STRENGTH, 0.);
#endif
@ -546,14 +542,14 @@ try {
return false;
}
obs_properties_t* video_superresolution_factory::get_properties2(video_superresolution_instance* data)
obs_properties_t* upscaling_factory::get_properties2(upscaling_instance* data)
{
obs_properties_t* pr = obs_properties_create();
#ifdef ENABLE_FRONTEND
{
obs_properties_add_button2(pr, S_MANUAL_OPEN, D_TRANSLATE(S_MANUAL_OPEN),
video_superresolution_factory::on_manual_open, nullptr);
obs_properties_add_button2(pr, S_MANUAL_OPEN, D_TRANSLATE(S_MANUAL_OPEN), upscaling_factory::on_manual_open,
nullptr);
}
#endif
@ -570,10 +566,9 @@ obs_properties_t* video_superresolution_factory::get_properties2(video_superreso
OBS_COMBO_FORMAT_INT);
obs_property_set_modified_callback(p, modified_provider);
obs_property_list_add_int(p, D_TRANSLATE(S_STATE_AUTOMATIC),
static_cast<int64_t>(video_superresolution_provider::AUTOMATIC));
obs_property_list_add_int(
p, D_TRANSLATE(ST_I18N_PROVIDER_NVIDIA_SUPERRES),
static_cast<int64_t>(video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION));
static_cast<int64_t>(upscaling_provider::AUTOMATIC));
obs_property_list_add_int(p, D_TRANSLATE(ST_I18N_PROVIDER_NVIDIA_SUPERRES),
static_cast<int64_t>(upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION));
}
}
@ -581,7 +576,7 @@ obs_properties_t* video_superresolution_factory::get_properties2(video_superreso
}
#ifdef ENABLE_FRONTEND
bool video_superresolution_factory::on_manual_open(obs_properties_t* props, obs_property_t* property, void* data)
bool upscaling_factory::on_manual_open(obs_properties_t* props, obs_property_t* property, void* data)
try {
streamfx::open_url(HELP_URL);
return false;
@ -594,12 +589,11 @@ try {
}
#endif
bool streamfx::filter::video_superresolution::video_superresolution_factory::is_provider_available(
video_superresolution_provider provider)
bool streamfx::filter::upscaling::upscaling_factory::is_provider_available(upscaling_provider provider)
{
switch (provider) {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
case video_superresolution_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
case upscaling_provider::NVIDIA_VIDEO_SUPERRESOLUTION:
return _nvidia_available;
#endif
default:
@ -607,36 +601,35 @@ bool streamfx::filter::video_superresolution::video_superresolution_factory::is_
}
}
video_superresolution_provider
streamfx::filter::video_superresolution::video_superresolution_factory::find_ideal_provider()
upscaling_provider streamfx::filter::upscaling::upscaling_factory::find_ideal_provider()
{
for (auto v : provider_priority) {
if (video_superresolution_factory::get()->is_provider_available(v)) {
if (upscaling_factory::get()->is_provider_available(v)) {
return v;
break;
}
}
return video_superresolution_provider::AUTOMATIC;
return upscaling_provider::AUTOMATIC;
}
std::shared_ptr<video_superresolution_factory> _video_superresolution_factory_instance = nullptr;
std::shared_ptr<upscaling_factory> _video_superresolution_factory_instance = nullptr;
void video_superresolution_factory::initialize()
void upscaling_factory::initialize()
try {
if (!_video_superresolution_factory_instance)
_video_superresolution_factory_instance = std::make_shared<video_superresolution_factory>();
_video_superresolution_factory_instance = std::make_shared<upscaling_factory>();
} catch (const std::exception& ex) {
D_LOG_ERROR("Failed to initialize due to error: %s", ex.what());
} catch (...) {
D_LOG_ERROR("Failed to initialize due to unknown error.", "");
}
void video_superresolution_factory::finalize()
void upscaling_factory::finalize()
{
_video_superresolution_factory_instance.reset();
}
std::shared_ptr<video_superresolution_factory> video_superresolution_factory::get()
std::shared_ptr<upscaling_factory> upscaling_factory::get()
{
return _video_superresolution_factory_instance;
}

View file

@ -28,42 +28,42 @@
#include "plugin.hpp"
#include "util/util-threadpool.hpp"
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
#include "nvidia/vfx/nvidia-vfx-superresolution.hpp"
#endif
namespace streamfx::filter::video_superresolution {
enum class video_superresolution_provider {
namespace streamfx::filter::upscaling {
enum class upscaling_provider {
INVALID = -1,
AUTOMATIC = 0,
NVIDIA_VIDEO_SUPERRESOLUTION = 1,
};
const char* cstring(video_superresolution_provider provider);
const char* cstring(upscaling_provider provider);
std::string string(video_superresolution_provider provider);
std::string string(upscaling_provider provider);
class video_superresolution_instance : public ::streamfx::obs::source_instance {
class upscaling_instance : public ::streamfx::obs::source_instance {
std::pair<uint32_t, uint32_t> _in_size;
std::pair<uint32_t, uint32_t> _out_size;
std::atomic<bool> _provider_ready;
std::atomic<video_superresolution_provider> _provider;
video_superresolution_provider _provider_ui;
std::mutex _provider_lock;
std::shared_ptr<util::threadpool::task> _provider_task;
std::atomic<upscaling_provider> _provider;
upscaling_provider _provider_ui;
std::atomic<bool> _provider_ready;
std::mutex _provider_lock;
std::shared_ptr<util::threadpool::task> _provider_task;
std::shared_ptr<::streamfx::obs::gs::rendertarget> _input;
std::shared_ptr<::streamfx::obs::gs::texture> _output;
bool _dirty;
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
std::shared_ptr<::streamfx::nvidia::vfx::superresolution> _nvidia_fx;
#endif
public:
video_superresolution_instance(obs_data_t* data, obs_source_t* self);
~video_superresolution_instance() override;
upscaling_instance(obs_data_t* data, obs_source_t* self);
~upscaling_instance() override;
void load(obs_data_t* data) override;
void migrate(obs_data_t* data, uint64_t version) override;
@ -77,10 +77,10 @@ namespace streamfx::filter::video_superresolution {
void video_render(gs_effect_t* effect) override;
private:
void switch_provider(video_superresolution_provider provider);
void switch_provider(upscaling_provider provider);
void task_switch_provider(util::threadpool_data_t data);
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
void nvvfxsr_load();
void nvvfxsr_unload();
void nvvfxsr_size();
@ -90,11 +90,10 @@ namespace streamfx::filter::video_superresolution {
#endif
};
class video_superresolution_factory
: public ::streamfx::obs::source_factory<
::streamfx::filter::video_superresolution::video_superresolution_factory,
::streamfx::filter::video_superresolution::video_superresolution_instance> {
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION_NVIDIA
class upscaling_factory
: public ::streamfx::obs::source_factory<::streamfx::filter::upscaling::upscaling_factory,
::streamfx::filter::upscaling::upscaling_instance> {
#ifdef ENABLE_FILTER_UPSCALING_NVIDIA
bool _nvidia_available;
std::shared_ptr<::streamfx::nvidia::cuda::obs> _nvcuda;
std::shared_ptr<::streamfx::nvidia::cv::cv> _nvcvi;
@ -102,25 +101,25 @@ namespace streamfx::filter::video_superresolution {
#endif
public:
virtual ~video_superresolution_factory();
video_superresolution_factory();
virtual ~upscaling_factory();
upscaling_factory();
virtual const char* get_name() override;
virtual void get_defaults2(obs_data_t* data) override;
virtual obs_properties_t* get_properties2(video_superresolution_instance* data) override;
virtual obs_properties_t* get_properties2(upscaling_instance* data) override;
#ifdef ENABLE_FRONTEND
static bool on_manual_open(obs_properties_t* props, obs_property_t* property, void* data);
#endif
bool is_provider_available(video_superresolution_provider);
video_superresolution_provider find_ideal_provider();
bool is_provider_available(upscaling_provider);
upscaling_provider find_ideal_provider();
public: // Singleton
static void initialize();
static void finalize();
static std::shared_ptr<::streamfx::filter::video_superresolution::video_superresolution_factory> get();
static void initialize();
static void finalize();
static std::shared_ptr<::streamfx::filter::upscaling::upscaling_factory> get();
};
} // namespace streamfx::filter::video_superresolution
} // namespace streamfx::filter::upscaling

View file

@ -59,8 +59,8 @@
#ifdef ENABLE_FILTER_TRANSFORM
#include "filters/filter-transform.hpp"
#endif
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION
#include "filters/filter-video-superresolution.hpp"
#ifdef ENABLE_FILTER_UPSCALING
#include "filters/filter-upscaling.hpp"
#endif
#ifdef ENABLE_SOURCE_MIRROR
@ -167,8 +167,8 @@ try {
#ifdef ENABLE_FILTER_TRANSFORM
streamfx::filter::transform::transform_factory::initialize();
#endif
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION
streamfx::filter::video_superresolution::video_superresolution_factory::initialize();
#ifdef ENABLE_FILTER_UPSCALING
streamfx::filter::upscaling::upscaling_factory::initialize();
#endif
}
@ -256,8 +256,8 @@ try {
#ifdef ENABLE_FILTER_TRANSFORM
streamfx::filter::transform::transform_factory::finalize();
#endif
#ifdef ENABLE_FILTER_VIDEO_SUPERRESOLUTION
streamfx::filter::video_superresolution::video_superresolution_factory::finalize();
#ifdef ENABLE_FILTER_UPSCALING
streamfx::filter::upscaling::upscaling_factory::finalize();
#endif
}