project: Code cleanup and reapply formatting

Changes applied:

* Moved utility files to /util/.
* Removed unused #includes.
* Removed unused ::ffmpeg::tools function.
* Removed unused variables.
* Fixed missing parentheses in the version macro.
* Fixed missing override on virtual function overrides and removed unnecessary virtual keyword from them.
* Disabled additional warning for ATL headers on MSVC only.
* Replaced direct printf parameters with their macro equivalent.
* Replaced C-style casts with C++-style casts.
* Applied clang-format again after an earlier change to the CMake file broke the integration for it.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-07-12 18:41:50 +02:00 committed by Michael Fabian Dirks
parent 6e02ee5fef
commit d332007ae0
64 changed files with 174 additions and 236 deletions

View file

@ -477,13 +477,13 @@ list(APPEND PROJECT_PRIVATE_SOURCE
"source/strings.hpp"
"source/plugin.hpp"
"source/plugin.cpp"
"source/utility.hpp"
"source/utility.cpp"
"source/util-event.hpp"
"source/util-profiler.cpp"
"source/util-profiler.hpp"
"source/util-threadpool.cpp"
"source/util-threadpool.hpp"
"source/util/utility.hpp"
"source/util/utility.cpp"
"source/util/util-event.hpp"
"source/util/util-profiler.cpp"
"source/util/util-profiler.hpp"
"source/util/util-threadpool.cpp"
"source/util/util-threadpool.hpp"
# Graphics
"source/gfx/gfx-source-texture.hpp"

View file

@ -21,7 +21,7 @@
#include <cinttypes>
#include <cstddef>
#define STREAMFX_MAKE_VERSION(major,minor,patch,tweak) ((uint64_t(major) & 0xFFFFull) << 48ull) | ((uint64_t(minor) & 0xFFFFull) << 32ull) | ((uint64_t(patch) & 0xFFFFull) << 16ull) | ((uint64_t(tweak) & 0xFFFFull))
#define STREAMFX_MAKE_VERSION(major,minor,patch,tweak) (((uint64_t(major) & 0xFFFFull) << 48ull) | ((uint64_t(minor) & 0xFFFFull) << 32ull) | ((uint64_t(patch) & 0xFFFFull) << 16ull) | ((uint64_t(tweak) & 0xFFFFull)))
#define STREAMFX_MASK_MAJOR 0xFFFF000000000000ull
#define STREAMFX_MASK_COMPAT 0xFFFFFFFF00000000ull

View file

@ -46,9 +46,10 @@
// Common Plugin includes
#include "strings.hpp"
#include "version.hpp"
#include "util-profiler.hpp"
#include "util-threadpool.hpp"
#include "utility.hpp"
#include "util/util-math.hpp"
#include "util/util-profiler.hpp"
#include "util/util-threadpool.hpp"
#include "util/utility.hpp"
// Common OBS includes
extern "C" {

View file

@ -44,8 +44,8 @@ streamfx::configuration::~configuration()
streamfx::configuration::configuration() : _data(), _config_path()
{
{ // Retrieve global configuration path.
char* path = obs_module_config_path("config.json");
_config_path = path;
char* path = obs_module_config_path("config.json");
_config_path = path;
bfree(path);
}
@ -53,7 +53,8 @@ streamfx::configuration::configuration() : _data(), _config_path()
if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) {
throw std::runtime_error("Configuration does not exist.");
} else {
obs_data_t* data = obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
obs_data_t* data =
obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
if (!data) {
throw std::runtime_error("Failed to load configuration from disk.");
} else {

View file

@ -20,7 +20,6 @@
// SOFTWARE.
#include "hevc.hpp"
#include "utility.hpp"
using namespace streamfx::encoder::codec;

View file

@ -30,7 +30,6 @@
#include "handlers/prores_aw_handler.hpp"
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#pragma warning(push)
@ -97,7 +96,8 @@ ffmpeg_instance::ffmpeg_instance(obs_data_t* settings, obs_encoder_t* self, bool
// Abort if user specified manual override.
if ((static_cast<AVPixelFormat>(obs_data_get_int(settings, KEY_FFMPEG_COLORFORMAT)) != AV_PIX_FMT_NONE)
|| (obs_data_get_int(settings, KEY_FFMPEG_GPU) != -1) || (obs_encoder_scaling_enabled(_self))) {
throw std::runtime_error("Selected settings prevent the use of hardware encoding, falling back to software.");
throw std::runtime_error(
"Selected settings prevent the use of hardware encoding, falling back to software.");
}
#ifdef WIN32
@ -262,32 +262,33 @@ bool ffmpeg_instance::update(obs_data_t* settings)
DLOG_INFO("[%s] Initializing...", _codec->name);
DLOG_INFO("[%s] FFmpeg:", _codec->name);
DLOG_INFO("[%s] Custom Settings: %s", _codec->name,
obs_data_get_string(settings, KEY_FFMPEG_CUSTOMSETTINGS));
obs_data_get_string(settings, KEY_FFMPEG_CUSTOMSETTINGS));
DLOG_INFO("[%s] Standard Compliance: %s", _codec->name,
::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance));
::ffmpeg::tools::get_std_compliance_name(_context->strict_std_compliance));
DLOG_INFO("[%s] Threading: %s (with %i threads)", _codec->name,
::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count);
::ffmpeg::tools::get_thread_type_name(_context->thread_type), _context->thread_count);
DLOG_INFO("[%s] Video:", _codec->name);
if (_hwinst) {
DLOG_INFO("[%s] Texture: %ldx%ld %s %s %s", _codec->name, _context->width, _context->height,
::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt),
::ffmpeg::tools::get_color_space_name(_context->colorspace),
av_color_range_name(_context->color_range));
DLOG_INFO("[%s] Texture: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _context->width, _context->height,
::ffmpeg::tools::get_pixel_format_name(_context->sw_pix_fmt),
::ffmpeg::tools::get_color_space_name(_context->colorspace),
av_color_range_name(_context->color_range));
} else {
DLOG_INFO("[%s] Input: %ldx%ld %s %s %s", _codec->name, _scaler.get_source_width(),
_scaler.get_source_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()),
::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()),
_scaler.is_source_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Output: %ldx%ld %s %s %s", _codec->name, _scaler.get_target_width(),
_scaler.get_target_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()),
::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()),
_scaler.is_target_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Input: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_source_width(),
_scaler.get_source_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_source_format()),
::ffmpeg::tools::get_color_space_name(_scaler.get_source_colorspace()),
_scaler.is_source_full_range() ? "Full" : "Partial");
DLOG_INFO("[%s] Output: %" PRId32 "x%" PRId32 " %s %s %s", _codec->name, _scaler.get_target_width(),
_scaler.get_target_height(), ::ffmpeg::tools::get_pixel_format_name(_scaler.get_target_format()),
::ffmpeg::tools::get_color_space_name(_scaler.get_target_colorspace()),
_scaler.is_target_full_range() ? "Full" : "Partial");
if (!_hwinst)
DLOG_INFO("[%s] On GPU Index: %lli", _codec->name, obs_data_get_int(settings, KEY_FFMPEG_GPU));
}
DLOG_INFO("[%s] Framerate: %ld/%ld (%f FPS)", _codec->name, _context->time_base.den, _context->time_base.num,
static_cast<double_t>(_context->time_base.den) / static_cast<double_t>(_context->time_base.num));
DLOG_INFO("[%s] Framerate: %" PRId32 "/%" PRId32 " (%f FPS)", _codec->name, _context->time_base.den,
_context->time_base.num,
static_cast<double_t>(_context->time_base.den) / static_cast<double_t>(_context->time_base.num));
DLOG_INFO("[%s] Keyframes: ", _codec->name);
if (_context->keyint_min != _context->gop_size) {
@ -360,7 +361,7 @@ bool ffmpeg_instance::encode_video(struct encoder_frame* frame, struct encoder_p
_scaler.convert(reinterpret_cast<std::uint8_t**>(frame->data), reinterpret_cast<int*>(frame->linesize),
0, _context->height, vframe->data, vframe->linesize);
if (res <= 0) {
DLOG_ERROR("Failed to convert frame: %s (%ld).", ::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to convert frame: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -700,7 +701,7 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr<AVFrame> frame, encoder_pac
sent_frame = true;
break;
default:
DLOG_ERROR("Failed to encode frame: %s (%ld).", ::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to encode frame: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -725,7 +726,7 @@ bool ffmpeg_instance::encode_avframe(std::shared_ptr<AVFrame> frame, encoder_pac
}
break;
default:
DLOG_ERROR("Failed to receive packet: %s (%ld).", ::ffmpeg::tools::get_error_description(res), res);
DLOG_ERROR("Failed to receive packet: %s (%" PRId32 ").", ::ffmpeg::tools::get_error_description(res), res);
return false;
}
}
@ -873,7 +874,7 @@ void ffmpeg_instance::parse_ffmpeg_commandline(std::string text)
int res = av_opt_set(_context, key.c_str(), value.c_str(), AV_OPT_SEARCH_CHILDREN);
if (res < 0) {
DLOG_WARNING("Option '%s' (key: '%s', value: '%s') encountered error: %s", opt.c_str(), key.c_str(),
value.c_str(), ::ffmpeg::tools::get_error_description(res));
value.c_str(), ::ffmpeg::tools::get_error_description(res));
}
} catch (const std::exception& ex) {
DLOG_ERROR("Option '%s' encountered exception: %s", opt.c_str(), ex.what());

View file

@ -26,7 +26,6 @@
#include <vector>
#include "handler.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#include <obs-properties.h>
@ -47,7 +46,7 @@ template<>
std::string to_string(int64_t value)
{
std::vector<char> buf(32);
snprintf(buf.data(), buf.size(), "%lld", value);
snprintf(buf.data(), buf.size(), "%" PRId64, value);
return std::string(buf.data(), buf.data() + buf.size());
}
@ -55,7 +54,7 @@ template<>
std::string to_string(uint64_t value)
{
std::vector<char> buf(32);
snprintf(buf.data(), buf.size(), "%llu", value);
snprintf(buf.data(), buf.size(), "%" PRIu64, value);
return std::string(buf.data(), buf.data() + buf.size());
}
@ -119,8 +118,8 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
} else {
auto unit_type = unit_types.find(opt->unit);
if (unit_type == unit_types.end()) {
DLOG_INFO(" [%s] Flag '%s' and help text '%s' with value '%lld'.", opt->unit, opt->name, opt->help,
opt->default_val.i64);
DLOG_INFO(" [%s] Flag '%s' and help text '%s' with value '%" PRId64 "'.", opt->unit, opt->name, opt->help,
opt->default_val.i64);
} else {
std::string out;
switch (unit_type->second) {
@ -148,7 +147,7 @@ void debug_handler::get_properties(obs_properties_t*, const AVCodec* codec, AVCo
}
DLOG_INFO(" [%s] Constant '%s' and help text '%s' with value '%s'.", opt->unit, opt->name,
opt->help, out.c_str());
opt->help, out.c_str());
}
}
} else {

View file

@ -60,7 +60,8 @@ namespace streamfx::encoder::ffmpeg {
virtual void get_properties(obs_properties_t* props, const AVCodec* codec, AVCodecContext* context,
bool hw_encode){};
virtual void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec, AVCodecContext* context){};
virtual void migrate(obs_data_t* settings, std::uint64_t version, const AVCodec* codec,
AVCodecContext* context){};
virtual void update(obs_data_t* settings, const AVCodec* codec, AVCodecContext* context){};

View file

@ -26,7 +26,6 @@
#include "ffmpeg/tools.hpp"
#include "nvenc_shared.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#ifdef _MSC_VER

View file

@ -26,7 +26,6 @@
#include "ffmpeg/tools.hpp"
#include "nvenc_shared.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#include <obs-module.h>

View file

@ -26,7 +26,6 @@
#include "../encoder-ffmpeg.hpp"
#include "ffmpeg/tools.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#include <obs-module.h>

View file

@ -22,7 +22,6 @@
#pragma once
#include <map>
#include "handler.hpp"
#include "utility.hpp"
extern "C" {
#ifdef _MSC_VER

View file

@ -24,7 +24,6 @@
#include "../codecs/prores.hpp"
#include "ffmpeg/tools.hpp"
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#include <obs-module.h>

View file

@ -25,7 +25,6 @@
#include <sstream>
#include <vector>
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
extern "C" {
#pragma warning(push)
@ -88,8 +87,9 @@ std::list<device> d3d11::enumerate_adapters()
dxgi_adapter->GetDesc1(&desc);
std::vector<char> buf(1024);
std::size_t len = snprintf(buf.data(), buf.size(), "%ls (VEN_%04x/DEV_%04x/SUB_%04x/REV_%04x)",
desc.Description, desc.VendorId, desc.DeviceId, desc.SubSysId, desc.Revision);
std::size_t len =
static_cast<size_t>(snprintf(buf.data(), buf.size(), "%ls (VEN_%04x/DEV_%04x/SUB_%04x/REV_%04x)",
desc.Description, desc.VendorId, desc.DeviceId, desc.SubSysId, desc.Revision));
device dev;
dev.name = std::string(buf.data(), buf.data() + len);

View file

@ -22,22 +22,17 @@
#pragma once
#include "base.hpp"
extern "C++" {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4191)
#pragma warning(disable : 4242)
#pragma warning(disable : 4244)
#pragma warning(disable : 4365)
#pragma warning(disable : 4777)
#pragma warning(disable : 4986)
#pragma warning(disable : 5039)
#pragma warning(disable : 5204)
#pragma warning(disable : 4191 4242 4244 4365 4777 4986 5039 5204)
#endif
#include <atlutil.h>
#include <d3d11.h>
#include <d3d11_1.h>
#include <dxgi.h>
#ifdef _MSC_VER
#pragma warning(pop)
}
#endif
namespace ffmpeg::hwapi {
class d3d11 : public ffmpeg::hwapi::base {

View file

@ -171,8 +171,10 @@ bool swscale::initialize(int flags)
throw std::invalid_argument("not all target parameters were set");
}
this->context = sws_getContext(source_size.first, source_size.second, source_format, target_size.first,
target_size.second, target_format, flags, nullptr, nullptr, nullptr);
this->context =
sws_getContext(static_cast<int>(source_size.first), static_cast<int>(source_size.second), source_format,
static_cast<int>(target_size.first), static_cast<int>(target_size.second), target_format, flags,
nullptr, nullptr, nullptr);
if (!this->context) {
return false;
}

View file

@ -25,7 +25,6 @@
#include <sstream>
#include <stdexcept>
#include "plugin.hpp"
#include "utility.hpp"
extern "C" {
#pragma warning(push)
@ -39,44 +38,6 @@ extern "C" {
using namespace ffmpeg;
std::string tools::translate_encoder_capabilities(int capabilities)
{
// Sorted by relative importance.
std::pair<int, std::string> caps[] = {
{AV_CODEC_CAP_EXPERIMENTAL, "Experimental"},
// Quality
{AV_CODEC_CAP_LOSSLESS, "Lossless"},
// Features
{AV_CODEC_CAP_PARAM_CHANGE, "Dynamic Parameter Change"},
{AV_CODEC_CAP_SUBFRAMES, "Sub-Frames"},
{AV_CODEC_CAP_VARIABLE_FRAME_SIZE, "Variable Frame Size"},
{AV_CODEC_CAP_SMALL_LAST_FRAME, "Small Final Frame"},
// Other
{AV_CODEC_CAP_TRUNCATED, "Truncated"},
{AV_CODEC_CAP_CHANNEL_CONF, "AV_CODEC_CAP_CHANNEL_CONF"},
{AV_CODEC_CAP_DRAW_HORIZ_BAND, "AV_CODEC_CAP_DRAW_HORIZ_BAND"},
{AV_CODEC_CAP_AVOID_PROBING, "AV_CODEC_CAP_AVOID_PROBING"},
};
std::stringstream sstr;
for (auto const kv : caps) {
if (capabilities & kv.first) {
capabilities &= ~kv.first;
sstr << kv.second;
if (capabilities != 0) {
sstr << ", ";
} else {
break;
}
}
}
return sstr.str();
}
const char* tools::get_pixel_format_name(AVPixelFormat v)
{
return av_get_pix_fmt_name(v);
@ -327,11 +288,11 @@ void tools::print_av_option_bool(AVCodecContext* ctx_codec, void* ctx_option, co
int64_t v = 0;
if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) {
DLOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
ffmpeg::tools::get_error_description(err));
ffmpeg::tools::get_error_description(err));
} else {
DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.c_str(),
(inverse ? v != 0 : v == 0) ? "Disabled" : "Enabled",
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
(inverse ? v != 0 : v == 0) ? "Disabled" : "Enabled",
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
}
}
@ -350,11 +311,11 @@ void tools::print_av_option_int(AVCodecContext* ctx_codec, void* ctx_option, con
DLOG_INFO("[%s] %s: <Default>", ctx_codec->codec->name, text.c_str());
} else {
DLOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
ffmpeg::tools::get_error_description(err));
ffmpeg::tools::get_error_description(err));
}
} else {
DLOG_INFO("[%s] %s: %lld %s%s", ctx_codec->codec->name, text.c_str(), v, suffix.c_str(),
is_default ? " <Default>" : "");
DLOG_INFO("[%s] %s: %" PRId64 " %s%s", ctx_codec->codec->name, text.c_str(), v, suffix.c_str(),
is_default ? " <Default>" : "");
}
}
@ -370,13 +331,13 @@ void tools::print_av_option_string(AVCodecContext* ctx_codec, void* ctx_option,
int64_t v = 0;
if (int err = av_opt_get_int(ctx_option, option, AV_OPT_SEARCH_CHILDREN, &v); err != 0) {
DLOG_INFO("[%s] %s: <Error: %s>", ctx_codec->codec->name, text.c_str(),
ffmpeg::tools::get_error_description(err));
ffmpeg::tools::get_error_description(err));
} else {
std::string name = "<Unknown>";
if (decoder)
name = decoder(v);
DLOG_INFO("[%s] %s: %s%s", ctx_codec->codec->name, text.c_str(), name.c_str(),
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
av_opt_is_set_to_default_by_name(ctx_option, option, AV_OPT_SEARCH_CHILDREN) > 0 ? " <Default>" : "");
}
}

View file

@ -38,8 +38,6 @@ extern "C" {
}
namespace ffmpeg::tools {
std::string translate_encoder_capabilities(int capabilities);
const char* get_pixel_format_name(AVPixelFormat v);
const char* get_color_space_name(AVColorSpace v);

View file

@ -31,7 +31,6 @@
#include "gfx/blur/gfx-blur-gaussian.hpp"
#include "obs/gs/gs-helper.hpp"
#include "obs/obs-source-tracker.hpp"
#include "util-math.hpp"
// OBS
#ifdef _MSC_VER
@ -333,7 +332,7 @@ void blur_instance::video_tick(float)
_mask.image.path_old = _mask.image.path;
} catch (...) {
DLOG_ERROR("<filter-blur> Instance '%s' failed to load image '%s'.", obs_source_get_name(_self),
_mask.image.path.c_str());
_mask.image.path.c_str());
}
}
} else if (_mask.type == mask_type::Source) {
@ -344,7 +343,7 @@ void blur_instance::video_tick(float)
_mask.source.name_old = _mask.source.name;
} catch (...) {
DLOG_ERROR("<filter-blur> Instance '%s' failed to grab source '%s'.", obs_source_get_name(_self),
_mask.source.name.c_str());
_mask.source.name.c_str());
}
}
}
@ -399,7 +398,7 @@ void blur_instance::video_render(gs_effect_t* effect)
gs_stencil_op(GS_STENCIL_BOTH, GS_KEEP, GS_KEEP, GS_KEEP);
// Orthographic Camera and clear RenderTarget.
gs_ortho(0, (float)baseW, 0, (float)baseH, -1., 1.);
gs_ortho(0, static_cast<float>(baseW), 0, static_cast<float>(baseH), -1., 1.);
//gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0);
// Render

View file

@ -21,7 +21,6 @@
#include "strings.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"
// OBS
#ifdef _MSC_VER

View file

@ -233,7 +233,7 @@ void dynamic_mask_instance::video_render(gs_effect_t* in_effect)
gs_enable_stencil_write(false);
gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS);
gs_stencil_op(GS_STENCIL_BOTH, GS_KEEP, GS_KEEP, GS_KEEP);
gs_ortho(0, (float)width, 0, (float)height, -1., 1.);
gs_ortho(0, static_cast<float>(width), 0, static_cast<float>(height), -1., 1.);
obs_source_process_filter_end(_self, default_effect, width, height);

View file

@ -24,7 +24,6 @@
#include "nvidia/cuda/nvidia-cuda-context-stack.hpp"
#include "obs/gs/gs-helper.hpp"
#include "obs/obs-tools.hpp"
#include "utility.hpp"
#define ST "Filter.Nvidia.FaceTracking"
#define ST_ROI "Filter.Nvidia.FaceTracking.ROI"
@ -74,12 +73,11 @@ face_tracking_instance::face_tracking_instance(obs_data_t* settings, obs_source_
#endif
{ // Create render target, vertex buffer, and CUDA stream.
auto gctx = gs::context{};
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
_geometry = std::make_shared<gs::vertex_buffer>(4, 1);
auto cctx = std::make_shared<::nvidia::cuda::context_stack>(_cuda, _cuda_ctx);
_cuda_stream =
std::make_shared<::nvidia::cuda::stream>(_cuda, ::nvidia::cuda::stream_flags::NON_BLOCKING, 0);
auto gctx = gs::context{};
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
_geometry = std::make_shared<gs::vertex_buffer>(uint32_t(4), uint8_t(1));
auto cctx = std::make_shared<::nvidia::cuda::context_stack>(_cuda, _cuda_ctx);
_cuda_stream = std::make_shared<::nvidia::cuda::stream>(_cuda, ::nvidia::cuda::stream_flags::NON_BLOCKING, 0);
}
{ // Asynchronously load Face Tracking.
@ -235,7 +233,7 @@ void face_tracking_instance::async_track(std::shared_ptr<void> ptr)
gs::debug_marker marker{gs::debug_color_allocate, "Reallocate GPU Buffer"};
#endif
_ar_texture =
std::make_shared<gs::texture>(_size.first, _size.second, GS_RGBA, 1, nullptr, gs::texture::flags::None);
std::make_shared<gs::texture>(_size.first, _size.second, GS_RGBA, uint32_t(1), nullptr, gs::texture::flags::None);
_ar_texture_cuda_fresh = false;
}
@ -593,10 +591,10 @@ bool face_tracking_instance::button_profile(obs_properties_t* props, obs_propert
};
for (auto& kv : profilers) {
DLOG_INFO(" %-20s: %8lldµs %10lld %8lldµs %8lldµs %8lldµs", kv.first.c_str(),
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->total_duration()).count(),
kv.second->count(), static_cast<std::int64_t>(kv.second->average_duration() / 1000.0),
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->percentile(0.999)).count(),
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->percentile(0.95)).count());
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->total_duration()).count(),
kv.second->count(), static_cast<std::int64_t>(kv.second->average_duration() / 1000.0),
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->percentile(0.999)).count(),
std::chrono::duration_cast<std::chrono::microseconds>(kv.second->percentile(0.95)).count());
}
return false;

View file

@ -106,7 +106,7 @@ sdf_effects_instance::sdf_effects_instance(obs_data_t* settings, obs_source_t* s
kv.second = gs::effect::create(path);
} catch (const std::exception& ex) {
DLOG_ERROR(LOG_PREFIX "Failed to load _effect '%s' (located at '%s') with error(s): %s", kv.first, path,
ex.what());
ex.what());
}
bfree(path);
}
@ -312,7 +312,7 @@ void sdf_effects_instance::video_render(gs_effect_t* effect)
#endif
auto op = _source_rt->render(baseW, baseH);
gs_ortho(0, (float)baseW, 0, (float)baseH, -1, 1);
gs_ortho(0, static_cast<float>(baseW), 0, static_cast<float>(baseH), -1, 1);
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &color_transparent, 0, 0);
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) {

View file

@ -21,7 +21,6 @@
#include "strings.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
#define ST "Filter.Shader"

View file

@ -22,7 +22,6 @@
#include <algorithm>
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"
// OBS
#ifdef _MSC_VER
@ -130,7 +129,7 @@ void transform_instance::update(obs_data_t* settings)
{
// Camera
_camera_orthographic = obs_data_get_int(settings, ST_CAMERA) == 0;
_camera_fov = (float)obs_data_get_double(settings, ST_CAMERA_FIELDOFVIEW);
_camera_fov = static_cast<float_t>(obs_data_get_double(settings, ST_CAMERA_FIELDOFVIEW));
// Source
_position->x = static_cast<float_t>(obs_data_get_double(settings, ST_POSITION_X) / 100.0);
@ -365,8 +364,9 @@ void transform_instance::video_render(gs_effect_t* effect)
std::size_t mip_levels = std::max(util::math::get_power_of_two_exponent_ceil(cache_width),
util::math::get_power_of_two_exponent_ceil(cache_height));
_mipmap_texture = std::make_shared<gs::texture>(cache_width, cache_height, GS_RGBA, mip_levels, nullptr,
gs::texture::flags::None);
_mipmap_texture =
std::make_shared<gs::texture>(cache_width, cache_height, GS_RGBA, static_cast<uint32_t>(mip_levels),
nullptr, gs::texture::flags::None);
}
_mipmapper.rebuild(_cache_texture, _mipmap_texture);
@ -457,7 +457,7 @@ const char* transform_factory::get_name()
void transform_factory::get_defaults2(obs_data_t* settings)
{
obs_data_set_default_int(settings, ST_CAMERA, (int64_t)CameraMode::Orthographic);
obs_data_set_default_int(settings, ST_CAMERA, static_cast<int64_t>(CameraMode::Orthographic));
obs_data_set_default_double(settings, ST_CAMERA_FIELDOFVIEW, 90.0);
obs_data_set_default_double(settings, ST_POSITION_X, 0);
obs_data_set_default_double(settings, ST_POSITION_Y, 0);
@ -465,7 +465,7 @@ void transform_factory::get_defaults2(obs_data_t* settings)
obs_data_set_default_double(settings, ST_ROTATION_X, 0);
obs_data_set_default_double(settings, ST_ROTATION_Y, 0);
obs_data_set_default_double(settings, ST_ROTATION_Z, 0);
obs_data_set_default_int(settings, ST_ROTATION_ORDER, RotationOrder::ZXY);
obs_data_set_default_int(settings, ST_ROTATION_ORDER, static_cast<int64_t>(RotationOrder::ZXY));
obs_data_set_default_double(settings, ST_SCALE_X, 100);
obs_data_set_default_double(settings, ST_SCALE_Y, 100);
obs_data_set_default_double(settings, ST_SHEAR_X, 0);
@ -475,7 +475,7 @@ void transform_factory::get_defaults2(obs_data_t* settings)
static bool modified_properties(obs_properties_t* pr, obs_property_t*, obs_data_t* d) noexcept
try {
switch ((CameraMode)obs_data_get_int(d, ST_CAMERA)) {
switch (static_cast<CameraMode>(obs_data_get_int(d, ST_CAMERA))) {
case CameraMode::Orthographic:
obs_property_set_visible(obs_properties_get(pr, ST_CAMERA_FIELDOFVIEW), false);
obs_property_set_visible(obs_properties_get(pr, ST_POSITION_Z), false);
@ -507,8 +507,10 @@ obs_properties_t* transform_factory::get_properties2(transform_instance* data)
auto p = obs_properties_add_list(grp, ST_CAMERA, D_TRANSLATE(ST_CAMERA), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CAMERA)));
obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC), (int64_t)CameraMode::Orthographic);
obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_PERSPECTIVE), (int64_t)CameraMode::Perspective);
obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC),
static_cast<int64_t>(CameraMode::Orthographic));
obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_PERSPECTIVE),
static_cast<int64_t>(CameraMode::Perspective));
obs_property_set_modified_callback(p, modified_properties);
}
{ // Field Of View

View file

@ -21,7 +21,6 @@
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"
#ifdef _MSC_VER
#pragma warning(push)

View file

@ -21,7 +21,6 @@
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"
#ifdef _MSC_VER
#pragma warning(push)

View file

@ -19,7 +19,6 @@
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"
#ifdef _MSC_VER
#pragma warning(push)
@ -260,7 +259,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
// Downsample
for (std::size_t n = 1; n <= actual_iterations; n++) {
#ifdef ENABLE_PROFILING
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Down %lld", n);
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Down %" PRIuMAX, n);
#endif
// Select Texture
@ -297,7 +296,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render()
// Upsample
for (std::size_t n = actual_iterations; n > 0; n--) {
#ifdef ENABLE_PROFILING
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Up %lld", n);
auto gdm = gs::debug_marker(gs::debug_color_azure_radiance, "Up %" PRIuMAX, n);
#endif
// Select Texture

View file

@ -18,7 +18,6 @@
#include "gfx-blur-gaussian-linear.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"
#ifdef _MSC_VER
#pragma warning(push)

View file

@ -19,7 +19,6 @@
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"
#ifdef _MSC_VER
#pragma warning(push)

View file

@ -123,10 +123,10 @@ std::shared_ptr<gs::texture> gfx::source_texture::render(std::size_t width, std:
auto cctr =
gs::debug_marker(gs::debug_color_capture, "gfx::source_texture '%s'", obs_source_get_name(_child->get()));
#endif
auto op = _rt->render((uint32_t)width, (uint32_t)height);
auto op = _rt->render(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
vec4 black;
vec4_zero(&black);
gs_ortho(0, (float_t)width, 0, (float_t)height, 0, 1);
gs_ortho(0, static_cast<float>(width), 0, static_cast<float_t>(height), 0, 1);
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
obs_source_video_render(_child->get());
}

View file

@ -96,9 +96,9 @@ gfx::shader::basic_parameter::basic_parameter(gs::effect_parameter param, std::s
_keys[0] = get_key();
} else {
for (std::size_t idx = 0; idx < get_size(); idx++) {
snprintf(string_buffer, sizeof(string_buffer), "[%d]", static_cast<int32_t>(idx));
snprintf(string_buffer, sizeof(string_buffer), "[%" PRId32 "]", static_cast<int32_t>(idx));
_names[idx] = std::string(string_buffer, string_buffer + strnlen(string_buffer, sizeof(string_buffer)));
snprintf(string_buffer, sizeof(string_buffer), "%s[%d]", get_key().data(), static_cast<int32_t>(idx));
snprintf(string_buffer, sizeof(string_buffer), "%s[%" PRId32 "]", get_key().data(), static_cast<int32_t>(idx));
_keys[idx] = std::string(string_buffer, string_buffer + strnlen(string_buffer, sizeof(string_buffer)));
}
}
@ -203,7 +203,7 @@ void gfx::shader::bool_parameter::update(obs_data_t* settings)
// TODO: Support for bool[]
if (get_size() == 1) {
_data[0] = obs_data_get_int(settings, get_key().data());
_data[0] = static_cast<int32_t>(obs_data_get_int(settings, get_key().data()));
}
}

View file

@ -101,13 +101,13 @@ namespace gfx {
bool_parameter(gs::effect_parameter param, std::string prefix);
virtual ~bool_parameter();
virtual void defaults(obs_data_t* settings);
void defaults(obs_data_t* settings) override;
virtual void properties(obs_properties_t* props, obs_data_t* settings) override;
void properties(obs_properties_t* props, obs_data_t* settings) override;
virtual void update(obs_data_t* settings) override;
void update(obs_data_t* settings) override;
virtual void assign() override;
void assign() override;
};
struct float_parameter : public basic_parameter {
@ -117,13 +117,13 @@ namespace gfx {
float_parameter(gs::effect_parameter param, std::string prefix);
virtual ~float_parameter();
virtual void defaults(obs_data_t* settings);
void defaults(obs_data_t* settings) override;
virtual void properties(obs_properties_t* props, obs_data_t* settings) override;
void properties(obs_properties_t* props, obs_data_t* settings) override;
virtual void update(obs_data_t* settings) override;
void update(obs_data_t* settings) override;
virtual void assign() override;
void assign() override;
};
struct int_parameter : public basic_parameter {
@ -133,13 +133,13 @@ namespace gfx {
int_parameter(gs::effect_parameter param, std::string prefix);
virtual ~int_parameter();
virtual void defaults(obs_data_t* settings);
void defaults(obs_data_t* settings) override;
virtual void properties(obs_properties_t* props, obs_data_t* settings) override;
void properties(obs_properties_t* props, obs_data_t* settings) override;
virtual void update(obs_data_t* settings) override;
void update(obs_data_t* settings) override;
virtual void assign() override;
void assign() override;
};
} // namespace shader

View file

@ -23,7 +23,7 @@
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4191 4365 4777 5039 5204)
#pragma warning(disable : 4191 4242 4244 4365 4777 4986 5039 5204)
#endif
#include <atlutil.h>
#ifdef _MSC_VER

View file

@ -24,10 +24,10 @@
namespace nvidia::cuda {
class context {
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
::nvidia::cuda::context_t _ctx;
::nvidia::cuda::context_t _ctx;
// Primary Device Context
bool _has_device;
bool _has_device;
::nvidia::cuda::device_t _device;
private:

View file

@ -28,10 +28,10 @@ namespace nvidia::cuda {
class gstexture {
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
std::shared_ptr<gs::texture> _texture;
graphics_resource_t _resource;
graphics_resource_t _resource;
bool _is_mapped;
array_t _pointer;
array_t _pointer;
std::shared_ptr<nvidia::cuda::stream> _stream;
public:
@ -39,6 +39,6 @@ namespace nvidia::cuda {
~gstexture();
array_t map(std::shared_ptr<nvidia::cuda::stream> stream);
void unmap();
void unmap();
};
} // namespace nvidia::cuda

View file

@ -25,7 +25,7 @@
namespace nvidia::cuda {
class memory {
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
device_ptr_t _pointer;
device_ptr_t _pointer;
std::size_t _size;
public:

View file

@ -24,12 +24,11 @@
namespace nvidia::cuda {
class stream {
std::shared_ptr<::nvidia::cuda::cuda> _cuda;
::nvidia::cuda::stream_t _stream;
::nvidia::cuda::stream_t _stream;
public:
stream(std::shared_ptr<::nvidia::cuda::cuda> cuda,
::nvidia::cuda::stream_flags flags = ::nvidia::cuda::stream_flags::DEFAULT,
std::int32_t priority = 0);
::nvidia::cuda::stream_flags flags = ::nvidia::cuda::stream_flags::DEFAULT, std::int32_t priority = 0);
~stream();
::nvidia::cuda::stream_t get();

View file

@ -18,10 +18,10 @@
*/
#pragma once
#include "common.hpp"
#include <cstddef>
#include <functional>
#include <memory>
#include "utility.hpp"
#ifdef WIN32
#pragma warning(push)

View file

@ -31,12 +31,12 @@ gs::index_buffer::index_buffer(std::uint32_t maximumVertices)
gs::index_buffer::index_buffer() : index_buffer(MAXIMUM_VERTICES) {}
gs::index_buffer::index_buffer(index_buffer& other) : index_buffer((uint32_t)other.size())
gs::index_buffer::index_buffer(index_buffer& other) : index_buffer(static_cast<uint32_t>(other.size()))
{
std::copy(other.begin(), other.end(), this->end());
}
gs::index_buffer::index_buffer(std::vector<uint32_t>& other) : index_buffer((uint32_t)other.size())
gs::index_buffer::index_buffer(std::vector<uint32_t>& other) : index_buffer(static_cast<uint32_t>(other.size()))
{
std::copy(other.begin(), other.end(), this->end());
}

View file

@ -25,7 +25,7 @@
#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201 4365 5039)
#pragma warning(disable : 4191 4242 4244 4365 4777 4986 5039 5204)
#endif
#include <Windows.h>
#include <atlutil.h>
@ -118,7 +118,6 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
ID3D11Resource* d3d_source = nullptr;
ID3D11Resource* d3d_target = nullptr;
if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) {
D3D11_TEXTURE2D_DESC td;
d3d_source = reinterpret_cast<ID3D11Resource*>(gs_texture_get_obj(source->get_object()));
d3d_target = reinterpret_cast<ID3D11Resource*>(gs_texture_get_obj(target->get_object()));
d3d_device = reinterpret_cast<ID3D11Device*>(gs_get_device_obj());
@ -138,14 +137,14 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
{
#ifdef ENABLE_PROFILING
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %lld", 0);
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %" PRId64 "", 0);
#endif
#ifdef _WIN32
if (gs_get_device_type() == GS_DEVICE_DIRECT3D_11) {
{ // Retrieve maximum mip map level.
D3D11_TEXTURE2D_DESC td;
reinterpret_cast<ID3D11Texture2D*>(d3d_target)->GetDesc(&td);
static_cast<ID3D11Texture2D*>(d3d_target)->GetDesc(&td);
max_mip_level = td.MipLevels;
}
@ -165,13 +164,13 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
// Render each mip map level.
for (size_t mip = 1; mip < max_mip_level; mip++) {
#ifdef ENABLE_PROFILING
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %lld", mip);
auto cctr = gs::debug_marker(gs::debug_color_azure_radiance, "Mip Level %" PRIuMAX, mip);
#endif
uint32_t cwidth = std::max<uint32_t>(width >> mip, 1);
uint32_t cheight = std::max<uint32_t>(height >> mip, 1);
float_t iwidth = 1. / static_cast<float_t>(cwidth);
float_t iheight = 1. / static_cast<float_t>(cheight);
float_t iwidth = 1.f / static_cast<float_t>(cwidth);
float_t iheight = 1.f / static_cast<float_t>(cheight);
// Set up rendering state.
gs_load_vertexbuffer(_vb->update(false));
@ -187,7 +186,7 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
gs_set_cull_mode(GS_NEITHER);
try {
auto op = _rt->render(width, height);
gs_set_viewport(0, 0, cwidth, cheight);
gs_set_viewport(0, 0, static_cast<int>(cwidth), static_cast<int>(cheight));
gs_ortho(0, 1, 0, 1, 0, 1);
vec4 black = {1., 1., 1., 1};

View file

@ -19,7 +19,6 @@
#include "gs-sampler.hpp"
#include <stdexcept>
#include "utility.hpp"
gs::sampler::sampler()
{

View file

@ -22,7 +22,6 @@
#include <stdexcept>
#include <sys/stat.h>
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"
static std::uint32_t decode_flags(gs::texture::flags texture_flags)
{
@ -74,9 +73,9 @@ gs::texture::texture(std::uint32_t width, std::uint32_t height, std::uint32_t de
throw std::logic_error("mip_levels must be at least 1");
if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) {
bool isPOT = (util::math::is_equal(pow(2, (int64_t)floor(log(width) / log(2))), width)
&& util::math::is_equal(pow(2, (int64_t)floor(log(height) / log(2))), height)
&& util::math::is_equal(pow(2, (int64_t)floor(log(depth) / log(2))), depth));
bool isPOT = (util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(width) / log(2)))), width)
&& util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(height) / log(2)))), height)
&& util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(depth) / log(2)))), depth));
if (!isPOT)
throw std::logic_error("mip mapping requires power of two dimensions");
}
@ -102,7 +101,7 @@ gs::texture::texture(std::uint32_t size, gs_color_format format, std::uint32_t m
throw std::logic_error("mip_levels must be at least 1");
if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) {
bool isPOT = util::math::is_equal(pow(2, (int64_t)floor(log(size) / log(2))), size);
bool isPOT = util::math::is_equal(pow(2, static_cast<int64_t>(floor(log(size) / log(2)))), size);
if (!isPOT)
throw std::logic_error("mip mapping requires power of two dimensions");
}

View file

@ -19,7 +19,6 @@
#pragma once
#include "common.hpp"
#include "utility.hpp"
namespace gs {
class texture {

View file

@ -19,7 +19,6 @@
#include "gs-vertex.hpp"
#include <stdexcept>
#include "utility.hpp"
gs::vertex::vertex()
: position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr)

View file

@ -20,7 +20,6 @@
#include "gs-vertexbuffer.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
{
@ -37,10 +36,10 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
_data = std::make_shared<decltype(_data)::element_type>();
_data->num = _capacity;
_data->num_tex = _layers;
_data->points = _positions = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity);
_data->normals = _normals = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity);
_data->tangents = _tangents = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity);
_data->colors = _colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * _capacity);
_data->points = _positions = static_cast<vec3*>(util::malloc_aligned(16, sizeof(vec3) * _capacity));
_data->normals = _normals = static_cast<vec3*>(util::malloc_aligned(16, sizeof(vec3) * _capacity));
_data->tangents = _tangents = static_cast<vec3*>(util::malloc_aligned(16, sizeof(vec3) * _capacity));
_data->colors = _colors = static_cast<uint32_t*>(util::malloc_aligned(16, sizeof(uint32_t) * _capacity));
// Clear the allocated memory of any data.
memset(_positions, 0, sizeof(vec3) * _capacity);
@ -51,9 +50,10 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
if (_layers == 0) {
_data->tvarray = nullptr;
} else {
_data->tvarray = _uv_layers = (gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers);
_data->tvarray = _uv_layers =
static_cast<gs_tvertarray*>(util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers));
for (uint8_t n = 0; n < _layers; n++) {
_uv_layers[n].array = _uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * _capacity);
_uv_layers[n].array = _uvs[n] = static_cast<vec4*>(util::malloc_aligned(16, sizeof(vec4) * _capacity));
_uv_layers[n].width = 4;
memset(_uvs[n], 0, sizeof(vec4) * _capacity);
}
@ -62,18 +62,18 @@ void gs::vertex_buffer::initialize(uint32_t capacity, uint8_t layers)
// Allocate actual GPU vertex buffer.
{
auto gctx = gs::context();
_buffer =
decltype(_buffer)(gs_vertexbuffer_create(_data.get(), GS_DYNAMIC | GS_DUP_BUFFER), [this](gs_vertbuffer_t* v) {
try {
auto gctx = gs::context();
gs_vertexbuffer_destroy(v);
} catch (...) {
if (obs_get_version() < MAKE_SEMANTIC_VERSION(26, 0, 0)) {
// Fixes a memory leak with OBS Studio versions older than 26.x.
gs_vbdata_destroy(_obs_data);
}
}
});
_buffer = decltype(_buffer)(gs_vertexbuffer_create(_data.get(), GS_DYNAMIC | GS_DUP_BUFFER),
[this](gs_vertbuffer_t* v) {
try {
auto gctx = gs::context();
gs_vertexbuffer_destroy(v);
} catch (...) {
if (obs_get_version() < MAKE_SEMANTIC_VERSION(26, 0, 0)) {
// Fixes a memory leak with OBS Studio versions older than 26.x.
gs_vbdata_destroy(_obs_data);
}
}
});
_obs_data = gs_vertexbuffer_get_data(_buffer.get());
}

View file

@ -21,7 +21,6 @@
#include "common.hpp"
#include "gs-limits.hpp"
#include "gs-vertex.hpp"
#include "utility.hpp"
namespace gs {
class vertex_buffer {

View file

@ -19,7 +19,7 @@
#pragma once
#include "common.hpp"
#include "util-event.hpp"
#include "util/util-event.hpp"
namespace obs {
template<typename T>

View file

@ -785,7 +785,7 @@ obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source&& ot
obs_source_type obs::deprecated_source::type()
{
if (!_self) {
return (obs_source_type)-1;
return static_cast<obs_source_type>(-1);
}
return obs_source_get_type(_self);
}

View file

@ -19,7 +19,7 @@
#pragma once
#include "common.hpp"
#include "util-event.hpp"
#include "util/util-event.hpp"
namespace obs {
class deprecated_source {

View file

@ -21,8 +21,8 @@
#include <fstream>
#include <stdexcept>
#include "configuration.hpp"
#include "obs/obs-source-tracker.hpp"
#include "obs/gs/gs-vertexbuffer.hpp"
#include "obs/obs-source-tracker.hpp"
#ifdef ENABLE_ENCODER_FFMPEG
#include "encoders/encoder-ffmpeg.hpp"
@ -86,7 +86,7 @@ try {
// GS Stuff
{
_gs_fstri_vb = std::make_shared<gs::vertex_buffer>(3, 1);
_gs_fstri_vb = std::make_shared<gs::vertex_buffer>(uint32_t(3), uint8_t(1));
{
auto vtx = _gs_fstri_vb->at(0);
vec3_set(vtx.position, 0, 0, 0);

View file

@ -21,7 +21,6 @@
#include "strings.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
#define ST "Source.Shader"

View file

@ -21,14 +21,13 @@
#include "strings.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "utility.hpp"
#define ST "Transition.Shader"
using namespace streamfx::transition::shader;
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self)
: obs::source_instance(data, self), _is_main(false)
: obs::source_instance(data, self)
{
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Transition);
@ -110,7 +109,8 @@ bool shader_instance::audio_render(uint64_t* ts_out, obs_source_audio_mix* audio
[](void*, float_t t) { return t; });
}
void shader_instance::transition_start() {
void shader_instance::transition_start()
{
_fx->set_active(true);
}

View file

@ -28,8 +28,6 @@ namespace streamfx::transition::shader {
class shader_instance : public obs::source_instance {
std::shared_ptr<gfx::shader::shader> _fx;
bool _is_main;
public:
shader_instance(obs_data_t* data, obs_source_t* self);
virtual ~shader_instance();

View file

@ -70,6 +70,8 @@ streamfx::ui::about_entry::about_entry(QWidget* parent, streamfx::ui::about::ent
case streamfx::ui::about::role_type::CREATOR:
title->setText(D_TRANSLATE(i18n_role_creator.data()));
break;
default:
break;
}
std::tuple<streamfx::ui::about::link_type, std::string, std::string, QPushButton*, QUrl&> els[]{
@ -99,6 +101,8 @@ streamfx::ui::about_entry::about_entry(QWidget* parent, streamfx::ui::about::ent
case streamfx::ui::about::link_type::SOCIAL_FACEBOOK:
std::get<3>(el)->setIcon(QIcon(":/linktype/facebook"));
break;
default:
break;
}
std::get<3>(el)->setText(QString::fromUtf8(std::get<2>(el).c_str()));
std::get<4>(el).setUrl(QString::fromStdString(std::get<1>(el)));

View file

@ -34,7 +34,7 @@ void util::profiler::track(std::chrono::nanoseconds duration)
std::unique_lock<std::mutex> ul(_timings_lock);
auto itr = _timings.find(duration);
if (itr == _timings.end()) {
_timings.insert({duration, 1});
_timings.emplace(duration, 1u);
} else {
itr->second++;
}
@ -113,10 +113,7 @@ std::chrono::nanoseconds util::profiler::percentile(double_t percentile, bool by
// Find largest and smallest time.
std::chrono::nanoseconds smallest = copy_timings.begin()->first;
std::chrono::nanoseconds largest = copy_timings.rbegin()->first;
std::chrono::nanoseconds variance = largest - smallest;
std::chrono::nanoseconds threshold =
std::chrono::nanoseconds(smallest.count() + int64_t(variance.count() * percentile));
for (auto kv : copy_timings) {
double_t kv_pct = double_t((kv.first - smallest).count()) / double_t(variance.count());

View file

@ -101,12 +101,14 @@ void util::threadpool::work()
try {
local_work->_callback(local_work->_data);
} catch (std::exception const& ex) {
DLOG_WARNING(LOCAL_PREFIX "Worker %lX caught exception from task (%tX, %tX) with message: %s",
local_number, local_work->_callback.target<ptrdiff_t>(),
DLOG_WARNING(LOCAL_PREFIX "Worker %" PRIx32 " caught exception from task (%" PRIxPTR ", %" PRIxPTR
") with message: %s",
local_number, reinterpret_cast<ptrdiff_t>(local_work->_callback.target<void>()),
reinterpret_cast<ptrdiff_t>(local_work->_data.get()), ex.what());
} catch (...) {
DLOG_WARNING(LOCAL_PREFIX "Worker %lX caught exception of unknown type from task (%tX, %tX).",
local_number, local_work->_callback.target<ptrdiff_t>(),
DLOG_WARNING(LOCAL_PREFIX "Worker %" PRIx32 " caught exception of unknown type from task (%" PRIxPTR
", %" PRIxPTR ").",
local_number, reinterpret_cast<ptrdiff_t>(local_work->_callback.target<void>()),
reinterpret_cast<ptrdiff_t>(local_work->_data.get()));
}
}