mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
obs/source-factory: Add support for color spaces
This commit is contained in:
parent
15eaec2e09
commit
5b978a20e0
2 changed files with 67 additions and 36 deletions
|
@ -1,20 +1,21 @@
|
||||||
/*
|
// Copyright (c) 2018 Michael Fabian Dirks <info@xaymar.com>
|
||||||
* Modern effects for a modern Streamer
|
//
|
||||||
* Copyright (C) 2018 Michael Fabian Dirks
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
*
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
* This program is free software; you can redistribute it and/or modify
|
// in the Software without restriction, including without limitation the rights
|
||||||
* it under the terms of the GNU General Public License as published by
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
* (at your option) any later version.
|
// furnished to do so, subject to the following conditions:
|
||||||
*
|
//
|
||||||
* This program is distributed in the hope that it will be useful,
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// copies or substantial portions of the Software.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU General Public License for more details.
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
*
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* You should have received a copy of the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* along with this program; if not, write to the Free Software
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
*/
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
|
||||||
#include "obs-source-factory.hpp"
|
#include "obs-source-factory.hpp"
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
/*
|
// Copyright (c) 2018-2022 Michael Fabian Dirks <info@xaymar.com>
|
||||||
* Modern effects for a modern Streamer
|
//
|
||||||
* Copyright (C) 2018 Michael Fabian Dirks
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
*
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
* This program is free software; you can redistribute it and/or modify
|
// in the Software without restriction, including without limitation the rights
|
||||||
* it under the terms of the GNU General Public License as published by
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
* (at your option) any later version.
|
// furnished to do so, subject to the following conditions:
|
||||||
*
|
//
|
||||||
* This program is distributed in the hope that it will be useful,
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// copies or substantial portions of the Software.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//
|
||||||
* GNU General Public License for more details.
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
*
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* You should have received a copy of the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* along with this program; if not, write to the Free Software
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
*/
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
@ -223,6 +224,30 @@ namespace streamfx::obs {
|
||||||
}
|
}
|
||||||
|
|
||||||
public /* Instance > Video */:
|
public /* Instance > Video */:
|
||||||
|
void support_color_space(bool v)
|
||||||
|
{
|
||||||
|
if (v) {
|
||||||
|
_info.video_get_color_space = _video_get_color_space;
|
||||||
|
} else {
|
||||||
|
_info.video_get_color_space = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gs_color_space _video_get_color_space(void* data, size_t count, const gs_color_space* preferred_spaces)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (data)
|
||||||
|
return reinterpret_cast<_instance*>(data)->video_get_color_space(count, preferred_spaces);
|
||||||
|
return GS_CS_SRGB;
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
DLOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what());
|
||||||
|
return GS_CS_SRGB;
|
||||||
|
} catch (...) {
|
||||||
|
DLOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
|
||||||
|
return GS_CS_SRGB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _video_tick(void* data, float seconds) noexcept
|
static void _video_tick(void* data, float seconds) noexcept
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -839,6 +864,11 @@ namespace streamfx::obs {
|
||||||
virtual void filter_remove(obs_source_t* source) {}
|
virtual void filter_remove(obs_source_t* source) {}
|
||||||
|
|
||||||
public /* Instance > Video */:
|
public /* Instance > Video */:
|
||||||
|
virtual gs_color_space video_get_color_space(size_t count, const gs_color_space* preferred_spaces)
|
||||||
|
{
|
||||||
|
return GS_CS_SRGB;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void video_tick(float_t seconds) {}
|
virtual void video_tick(float_t seconds) {}
|
||||||
|
|
||||||
virtual void video_render(gs_effect_t* effect) {}
|
virtual void video_render(gs_effect_t* effect) {}
|
||||||
|
|
Loading…
Reference in a new issue