From aac52f736d804a1e8f7a4de0b7a19ce6f953e1c0 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 19 Apr 2019 09:42:15 +0200 Subject: [PATCH] project: Clang support Lots and lots of errors and warnings fixed with this single commit, in the name of clang support. Related #60, #47. --- CMakeLists.txt | 14 ++-- source/filters/filter-blur.cpp | 10 +-- source/filters/filter-custom-shader.cpp | 2 +- source/filters/filter-custom-shader.hpp | 2 +- source/filters/filter-displacement.cpp | 14 ++-- source/filters/filter-displacement.hpp | 1 - source/filters/filter-sdf-effects.cpp | 30 ++++---- source/filters/filter-transform.cpp | 26 +++---- source/gfx/blur/gfx-blur-base.cpp | 3 +- source/gfx/blur/gfx-blur-base.hpp | 8 +++ source/gfx/blur/gfx-blur-box-linear.cpp | 18 ++--- source/gfx/blur/gfx-blur-box-linear.hpp | 6 +- source/gfx/blur/gfx-blur-box.cpp | 30 ++++---- source/gfx/blur/gfx-blur-box.hpp | 6 +- source/gfx/blur/gfx-blur-dual-filtering.cpp | 4 +- source/gfx/blur/gfx-blur-dual-filtering.hpp | 6 +- source/gfx/blur/gfx-blur-gaussian-linear.cpp | 22 +++--- source/gfx/blur/gfx-blur-gaussian-linear.hpp | 8 +-- source/gfx/blur/gfx-blur-gaussian.cpp | 36 +++++----- source/gfx/blur/gfx-blur-gaussian.hpp | 8 +-- source/gfx/gfx-effect-source.cpp | 26 +++---- source/gfx/gfx-source-texture.cpp | 16 ++--- source/obs/gs/gs-effect.cpp | 8 +-- source/obs/gs/gs-mipmapper.cpp | 4 +- source/obs/gs/gs-texture.cpp | 10 +-- source/obs/gs/gs-vertex.cpp | 2 +- source/obs/gs/gs-vertexbuffer.cpp | 4 +- source/obs/obs-source-tracker.cpp | 14 ++-- source/obs/obs-source.cpp | 74 ++++++++++---------- source/obs/obs-tools.cpp | 4 +- source/plugin.hpp | 2 +- source/sources/source-mirror.cpp | 34 ++++----- source/sources/source-mirror.hpp | 2 +- source/util-math.hpp | 11 ++- source/util-memory.hpp | 14 ++-- source/utility.hpp | 8 --- 36 files changed, 244 insertions(+), 243 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07c2634..0c5de0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,17 +119,21 @@ if(WIN32) endif() # All Warnings, Extra Warnings, Pedantic -if(MSVC) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # using Clang + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-missing-braces -Wmissing-field-initializers -Wno-c++98-compat-pedantic -Wold-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-switch-enum") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # GCC: -fpermissive is required as GCC does not allow the same template to be in different namespaces. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -fpermissive -Wno-long-long -Wno-missing-braces -Wmissing-field-initializers") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + # using Intel C++ +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # Force to always compile with W4 if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") endif() -elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - # Update if necessary - # GCC: -fpermissive is required as GCC does not allow the same template to be in different namespaces. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wpedantic -fpermissive") endif() # C++ Standard and Extensions diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 41a83a1..0f6e09d 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -85,14 +85,14 @@ struct local_blur_subtype_t { const char* name; }; -std::map list_of_types = { +static std::map list_of_types = { {"box", {&::gfx::blur::box_factory::get, S_BLUR_TYPE_BOX}}, {"box_linear", {&::gfx::blur::box_linear_factory::get, S_BLUR_TYPE_BOX_LINEAR}}, {"gaussian", {&::gfx::blur::gaussian_factory::get, S_BLUR_TYPE_GAUSSIAN}}, {"gaussian_linear", {&::gfx::blur::gaussian_linear_factory::get, S_BLUR_TYPE_GAUSSIAN_LINEAR}}, {"dual_filtering", {&::gfx::blur::dual_filtering_factory::get, S_BLUR_TYPE_DUALFILTERING}}, }; -std::map list_of_subtypes = { +static std::map list_of_subtypes = { {"area", {::gfx::blur::type::Area, S_BLUR_SUBTYPE_AREA}}, {"directional", {::gfx::blur::type::Directional, S_BLUR_SUBTYPE_DIRECTIONAL}}, {"rotational", {::gfx::blur::type::Rotational, S_BLUR_SUBTYPE_ROTATIONAL}}, @@ -698,13 +698,13 @@ obs_properties_t* filter::blur::blur_instance::get_properties() obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_SOURCE))); obs_property_list_add_string(p, "", ""); obs::source_tracker::get()->enumerate( - [this, &p](std::string name, obs_source_t*) { + [&p](std::string name, obs_source_t*) { obs_property_list_add_string(p, std::string(name + " (Source)").c_str(), name.c_str()); return false; }, obs::source_tracker::filter_video_sources); obs::source_tracker::get()->enumerate( - [this, &p](std::string name, obs_source_t*) { + [&p](std::string name, obs_source_t*) { obs_property_list_add_string(p, std::string(name + " (Scene)").c_str(), name.c_str()); return false; }, @@ -947,7 +947,7 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) std::string technique = ""; switch (this->m_mask.type) { case Region: - if (this->m_mask.region.feather > 0.001) { + if (this->m_mask.region.feather > FLT_EPSILON) { if (this->m_mask.region.invert) { technique = "RegionFeatherInverted"; } else { diff --git a/source/filters/filter-custom-shader.cpp b/source/filters/filter-custom-shader.cpp index b55ab41..e5f2420 100644 --- a/source/filters/filter-custom-shader.cpp +++ b/source/filters/filter-custom-shader.cpp @@ -376,7 +376,7 @@ bool filter::CustomShader::Instance::apply_special_parameters(uint32_t, uint32_t .set_float2(float_t(imageTexture->get_width()), float_t(imageTexture->get_height())); } if (m_shader.effect->has_parameter("Image_SizeI" /*, gs::effect_parameter::type::Integer2*/)) { - m_shader.effect->get_parameter("Image_SizeI").set_int2(imageTexture->get_width(), imageTexture->get_height()); + m_shader.effect->get_parameter("Image_SizeI").set_int2(static_cast(imageTexture->get_width()), static_cast(imageTexture->get_height())); } if (m_shader.effect->has_parameter("Image_Texel", gs::effect_parameter::type::Float2)) { m_shader.effect->get_parameter("Image_Texel") diff --git a/source/filters/filter-custom-shader.hpp b/source/filters/filter-custom-shader.hpp index c107a7b..6d78ebf 100644 --- a/source/filters/filter-custom-shader.hpp +++ b/source/filters/filter-custom-shader.hpp @@ -63,7 +63,7 @@ namespace filter { public: Instance(obs_data_t*, obs_source_t*); - virtual ~Instance(); + virtual ~Instance() override; uint32_t get_width(); uint32_t get_height(); diff --git a/source/filters/filter-displacement.cpp b/source/filters/filter-displacement.cpp index c34e2b6..04a353c 100644 --- a/source/filters/filter-displacement.cpp +++ b/source/filters/filter-displacement.cpp @@ -171,10 +171,10 @@ void filter::displacement::displacement_instance::validate_file_texture(std::str if (os_stat(m_file_name.c_str(), &stats) != 0) { do_update = do_update || (stats.st_ctime != m_file_create_time); do_update = do_update || (stats.st_mtime != m_file_modified_time); - do_update = do_update || (stats.st_size != m_file_size); + do_update = do_update || (static_cast(stats.st_size) != m_file_size); m_file_create_time = stats.st_ctime; m_file_modified_time = stats.st_mtime; - m_file_size = stats.st_size; + m_file_size = static_cast(stats.st_size); } do_update = !m_file_texture || do_update; @@ -185,8 +185,8 @@ void filter::displacement::displacement_instance::validate_file_texture(std::str } filter::displacement::displacement_instance::displacement_instance(obs_data_t* data, obs_source_t* context) - : m_self(context), m_active(true), m_timer(0), m_effect(nullptr), m_distance(0), m_file_create_time(0), - m_file_modified_time(0), m_file_size(0) + : m_self(context), m_timer(0), m_effect(nullptr), m_distance(0), m_file_create_time(0), m_file_modified_time(0), + m_file_size(0) { char* effectFile = obs_module_file("effects/displace.effect"); try { @@ -235,13 +235,13 @@ void filter::displacement::displacement_instance::hide() {} void filter::displacement::displacement_instance::video_tick(float time) { m_timer += time; - if (m_timer >= 1.0) { - m_timer -= 1.0; + if (m_timer >= 1.0f) { + m_timer -= 1.0f; validate_file_texture(m_file_name); } } -float interp(float a, float b, float v) +static float interp(float a, float b, float v) { return (a * (1.0f - v)) + (b * v); } diff --git a/source/filters/filter-displacement.hpp b/source/filters/filter-displacement.hpp index dbbbd9e..88311ea 100644 --- a/source/filters/filter-displacement.hpp +++ b/source/filters/filter-displacement.hpp @@ -75,7 +75,6 @@ namespace filter { class displacement_instance { obs_source_t* m_self; - bool m_active; float_t m_timer; // Rendering diff --git a/source/filters/filter-sdf-effects.cpp b/source/filters/filter-sdf-effects.cpp index d526158..8204f80 100644 --- a/source/filters/filter-sdf-effects.cpp +++ b/source/filters/filter-sdf-effects.cpp @@ -333,7 +333,7 @@ filter::sdf_effects::sdf_effects_instance::sdf_effects_instance(obs_data_t* sett { { auto gctx = gs::context(); - vec4 transparent = {0, 0, 0, 0}; + vec4 transparent = {0}; this->m_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); this->m_sdf_write = std::make_shared(GS_RGBA32F, GS_ZS_NONE); @@ -482,7 +482,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { { this->m_outer_shadow = - obs_data_get_bool(data, P_SHADOW_OUTER) && (obs_data_get_double(data, P_SHADOW_OUTER_ALPHA) >= FLT_EPSILON); + obs_data_get_bool(data, P_SHADOW_OUTER) && (obs_data_get_double(data, P_SHADOW_OUTER_ALPHA) >= DBL_EPSILON); { union { uint32_t color; @@ -505,7 +505,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { this->m_inner_shadow = - obs_data_get_bool(data, P_SHADOW_INNER) && (obs_data_get_double(data, P_SHADOW_INNER_ALPHA) >= FLT_EPSILON); + obs_data_get_bool(data, P_SHADOW_INNER) && (obs_data_get_double(data, P_SHADOW_INNER_ALPHA) >= DBL_EPSILON); { union { uint32_t color; @@ -528,7 +528,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { this->m_outer_glow = - obs_data_get_bool(data, P_GLOW_OUTER) && (obs_data_get_double(data, P_GLOW_OUTER_ALPHA) >= FLT_EPSILON); + obs_data_get_bool(data, P_GLOW_OUTER) && (obs_data_get_double(data, P_GLOW_OUTER_ALPHA) >= DBL_EPSILON); { union { uint32_t color; @@ -545,15 +545,15 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) } this->m_outer_glow_width = float_t(obs_data_get_double(data, P_GLOW_OUTER_WIDTH)); this->m_outer_glow_sharpness = float_t(obs_data_get_double(data, P_GLOW_OUTER_SHARPNESS) / 100.0); - this->m_outer_glow_sharpness_inv = float_t(1.0f / (1.0 - this->m_outer_glow_sharpness)); - if (this->m_outer_glow_sharpness >= (1.0 - FLT_EPSILON)) { - this->m_outer_glow_sharpness = 1.0 - FLT_EPSILON; + this->m_outer_glow_sharpness_inv = float_t(1.0f / (1.0f - this->m_outer_glow_sharpness)); + if (this->m_outer_glow_sharpness >= (1.0f - FLT_EPSILON)) { + this->m_outer_glow_sharpness = 1.0f - FLT_EPSILON; } } { this->m_inner_glow = - obs_data_get_bool(data, P_GLOW_INNER) && (obs_data_get_double(data, P_GLOW_INNER_ALPHA) >= FLT_EPSILON); + obs_data_get_bool(data, P_GLOW_INNER) && (obs_data_get_double(data, P_GLOW_INNER_ALPHA) >= DBL_EPSILON); { union { uint32_t color; @@ -570,15 +570,15 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) } this->m_inner_glow_width = float_t(obs_data_get_double(data, P_GLOW_INNER_WIDTH)); this->m_inner_glow_sharpness = float_t(obs_data_get_double(data, P_GLOW_INNER_SHARPNESS) / 100.0); - this->m_inner_glow_sharpness_inv = float_t(1.0f / (1.0 - this->m_inner_glow_sharpness)); - if (this->m_inner_glow_sharpness >= (1.0 - FLT_EPSILON)) { - this->m_inner_glow_sharpness = 1.0 - FLT_EPSILON; + this->m_inner_glow_sharpness_inv = float_t(1.0f / (1.0f - this->m_inner_glow_sharpness)); + if (this->m_inner_glow_sharpness >= (1.0f - FLT_EPSILON)) { + this->m_inner_glow_sharpness = 1.0f - FLT_EPSILON; } } { this->m_outline = - obs_data_get_bool(data, P_OUTLINE) && (obs_data_get_double(data, P_OUTLINE_ALPHA) >= FLT_EPSILON); + obs_data_get_bool(data, P_OUTLINE) && (obs_data_get_double(data, P_OUTLINE_ALPHA) >= DBL_EPSILON); { union { uint32_t color; @@ -596,9 +596,9 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) this->m_outline_width = float_t(obs_data_get_double(data, P_OUTLINE_WIDTH)); this->m_outline_offset = float_t(obs_data_get_double(data, P_OUTLINE_OFFSET)); this->m_outline_sharpness = float_t(obs_data_get_double(data, P_OUTLINE_SHARPNESS) / 100.0); - this->m_outline_sharpness_inv = float_t(1.0f / (1.0 - this->m_outline_sharpness)); - if (this->m_outline_sharpness >= (1.0 - FLT_EPSILON)) { - this->m_outline_sharpness = 1.0 - FLT_EPSILON; + this->m_outline_sharpness_inv = float_t(1.0f / (1.0f - this->m_outline_sharpness)); + if (this->m_outline_sharpness >= (1.0f - FLT_EPSILON)) { + this->m_outline_sharpness = 1.0f - FLT_EPSILON; } } diff --git a/source/filters/filter-transform.cpp b/source/filters/filter-transform.cpp index 9576762..366fa29 100644 --- a/source/filters/filter-transform.cpp +++ b/source/filters/filter-transform.cpp @@ -365,24 +365,24 @@ void filter::transform::transform_instance::update(obs_data_t* data) m_camera_fov = (float)obs_data_get_double(data, ST_CAMERA_FIELDOFVIEW); // Source - m_position->x = (float)obs_data_get_double(data, ST_POSITION_X) / 100.0f; - m_position->y = (float)obs_data_get_double(data, ST_POSITION_Y) / 100.0f; - m_position->z = (float)obs_data_get_double(data, ST_POSITION_Z) / 100.0f; - m_scale->x = (float)obs_data_get_double(data, ST_SCALE_X) / 100.0f; - m_scale->y = (float)obs_data_get_double(data, ST_SCALE_Y) / 100.0f; + m_position->x = static_cast(obs_data_get_double(data, ST_POSITION_X) / 100.0); + m_position->y = static_cast(obs_data_get_double(data, ST_POSITION_Y) / 100.0); + m_position->z = static_cast(obs_data_get_double(data, ST_POSITION_Z) / 100.0); + m_scale->x = static_cast(obs_data_get_double(data, ST_SCALE_X) / 100.0); + m_scale->y = static_cast(obs_data_get_double(data, ST_SCALE_Y) / 100.0); m_scale->z = 1.0f; - m_rotation_order = (int)obs_data_get_int(data, ST_ROTATION_ORDER); - m_rotation->x = (float)(obs_data_get_double(data, ST_ROTATION_X) / 180.0f * PI); - m_rotation->y = (float)(obs_data_get_double(data, ST_ROTATION_Y) / 180.0f * PI); - m_rotation->z = (float)(obs_data_get_double(data, ST_ROTATION_Z) / 180.0f * PI); - m_shear->x = (float)obs_data_get_double(data, ST_SHEAR_X) / 100.0f; - m_shear->y = (float)obs_data_get_double(data, ST_SHEAR_Y) / 100.0f; + m_rotation_order = static_cast(obs_data_get_int(data, ST_ROTATION_ORDER)); + m_rotation->x = static_cast(obs_data_get_double(data, ST_ROTATION_X) / 180.0 * PI); + m_rotation->y = static_cast(obs_data_get_double(data, ST_ROTATION_Y) / 180.0 * PI); + m_rotation->z = static_cast(obs_data_get_double(data, ST_ROTATION_Z) / 180.0 * PI); + m_shear->x = static_cast(obs_data_get_double(data, ST_SHEAR_X) / 100.0); + m_shear->y = static_cast(obs_data_get_double(data, ST_SHEAR_Y) / 100.0); m_shear->z = 0.0f; // Mipmapping m_mipmap_enabled = obs_data_get_bool(data, ST_MIPMAPPING); m_mipmap_strength = obs_data_get_double(data, S_MIPGENERATOR_INTENSITY); - m_mipmap_generator = (gs::mipmapper::generator)obs_data_get_int(data, S_MIPGENERATOR); + m_mipmap_generator = static_cast(obs_data_get_int(data, S_MIPGENERATOR)); m_update_mesh = true; } @@ -572,7 +572,7 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec gs_enable_stencil_test(false); gs_enable_stencil_write(false); gs_enable_color(true, true, true, true); - gs_ortho(0, (float)width, 0, (float)height, -1, 1); + gs_ortho(0, static_cast(width), 0, static_cast(height), -1, 1); vec4 black; vec4_zero(&black); diff --git a/source/gfx/blur/gfx-blur-base.cpp b/source/gfx/blur/gfx-blur-base.cpp index be0e3f7..0b1dbb5 100644 --- a/source/gfx/blur/gfx-blur-base.cpp +++ b/source/gfx/blur/gfx-blur-base.cpp @@ -22,7 +22,8 @@ void gfx::blur::ibase::set_step_scale_x(double_t v) this->set_step_scale(v, this->get_step_scale_y()); } -void gfx::blur::ibase::set_step_scale_y(double_t v) { +void gfx::blur::ibase::set_step_scale_y(double_t v) +{ this->set_step_scale(this->get_step_scale_x(), v); } diff --git a/source/gfx/blur/gfx-blur-base.hpp b/source/gfx/blur/gfx-blur-base.hpp index 7262481..95284cd 100644 --- a/source/gfx/blur/gfx-blur-base.hpp +++ b/source/gfx/blur/gfx-blur-base.hpp @@ -32,6 +32,8 @@ namespace gfx { class ibase { public: + virtual ~ibase(){} + virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0; virtual ::gfx::blur::type get_type() = 0; @@ -59,6 +61,8 @@ namespace gfx { class ibase_angle { public: + virtual ~ibase_angle(){} + virtual double_t get_angle() = 0; virtual void set_angle(double_t angle) = 0; @@ -66,6 +70,8 @@ namespace gfx { class ibase_center { public: + virtual ~ibase_center(){} + virtual void set_center(double_t x, double_t y) = 0; virtual void set_center_x(double_t v); @@ -81,6 +87,8 @@ namespace gfx { class ifactory { public: + virtual ~ifactory(){} + virtual bool is_type_supported(::gfx::blur::type type) = 0; virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) = 0; diff --git a/source/gfx/blur/gfx-blur-box-linear.cpp b/source/gfx/blur/gfx-blur-box-linear.cpp index d75b92e..d6eff84 100644 --- a/source/gfx/blur/gfx-blur-box-linear.cpp +++ b/source/gfx/blur/gfx-blur-box-linear.cpp @@ -187,7 +187,7 @@ std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::dat } gfx::blur::box_linear::box_linear() - : m_size(1.), m_step_scale({1., 1.}), m_data(::gfx::blur::box_linear_factory::get().data()) + : m_data(::gfx::blur::box_linear_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) { m_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); m_rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); @@ -266,28 +266,28 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render() if (effect) { // Pass 1 effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), 0.); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } // Pass 2 effect->get_parameter("pImage").set_texture(m_rendertarget2->get_texture()); - effect->get_parameter("pImageTexel").set_float2(0., float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(0., float_t(1.f / height)); { auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } @@ -343,16 +343,16 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render() if (effect) { effect->get_parameter("pImage").set_texture(m_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1. / height * sin(m_angle))); + .set_float2(float_t(1. / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); { auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } diff --git a/source/gfx/blur/gfx-blur-box-linear.hpp b/source/gfx/blur/gfx-blur-box-linear.hpp index 8df8445..2658566 100644 --- a/source/gfx/blur/gfx-blur-box-linear.hpp +++ b/source/gfx/blur/gfx-blur-box-linear.hpp @@ -31,7 +31,7 @@ namespace gfx { public: box_linear_data(); - ~box_linear_data(); + virtual ~box_linear_data(); std::shared_ptr<::gs::effect> get_effect(); }; @@ -42,7 +42,7 @@ namespace gfx { public: box_linear_factory(); - virtual ~box_linear_factory(); + virtual ~box_linear_factory() override; virtual bool is_type_supported(::gfx::blur::type type) override; @@ -94,7 +94,7 @@ namespace gfx { public: box_linear(); - ~box_linear(); + virtual ~box_linear() override; virtual void set_input(std::shared_ptr<::gs::texture> texture) override; diff --git a/source/gfx/blur/gfx-blur-box.cpp b/source/gfx/blur/gfx-blur-box.cpp index e593f92..efe7372 100644 --- a/source/gfx/blur/gfx-blur-box.cpp +++ b/source/gfx/blur/gfx-blur-box.cpp @@ -194,7 +194,7 @@ std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data() return instance; } -gfx::blur::box::box() : m_size(1.), m_step_scale({1., 1.}), m_data(::gfx::blur::box_factory::get().data()) +gfx::blur::box::box() : m_data(::gfx::blur::box_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) { auto gctx = gs::context(); m_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); @@ -274,28 +274,28 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render() if (effect) { // Pass 1 effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), 0.); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } // Pass 2 effect->get_parameter("pImage").set_texture(m_rendertarget2->get_texture()); - effect->get_parameter("pImageTexel").set_float2(0., float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } @@ -351,16 +351,16 @@ std::shared_ptr<::gs::texture> gfx::blur::box_directional::render() if (effect) { effect->get_parameter("pImage").set_texture(m_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1. / height * sin(m_angle))); + .set_float2(float_t(1. / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); { auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } @@ -420,10 +420,10 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); if (effect) { effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); effect->get_parameter("pAngle").set_float(float_t(m_angle / m_size)); effect->get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); @@ -431,7 +431,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Rotate")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } @@ -481,17 +481,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); if (effect) { effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0 / (float_t(m_size) * 2.0 + 1.0))); + effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); effect->get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); { auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Zoom")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } } diff --git a/source/gfx/blur/gfx-blur-box.hpp b/source/gfx/blur/gfx-blur-box.hpp index e78fafc..a8994ec 100644 --- a/source/gfx/blur/gfx-blur-box.hpp +++ b/source/gfx/blur/gfx-blur-box.hpp @@ -31,7 +31,7 @@ namespace gfx { public: box_data(); - ~box_data(); + virtual ~box_data(); std::shared_ptr<::gs::effect> get_effect(); }; @@ -42,7 +42,7 @@ namespace gfx { public: box_factory(); - virtual ~box_factory(); + virtual ~box_factory() override; virtual bool is_type_supported(::gfx::blur::type type) override; @@ -94,7 +94,7 @@ namespace gfx { public: box(); - ~box(); + virtual ~box() override; virtual void set_input(std::shared_ptr<::gs::texture> texture) override; diff --git a/source/gfx/blur/gfx-blur-dual-filtering.cpp b/source/gfx/blur/gfx-blur-dual-filtering.cpp index ab7d7e1..30782f1 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.cpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.cpp @@ -16,9 +16,9 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "gfx-blur-dual-filtering.hpp" +#include "obs/gs/gs-helper.hpp" #include "plugin.hpp" #include "util-math.hpp" -#include "obs/gs/gs-helper.hpp" #ifdef _MSC_VER #pragma warning(push) @@ -180,7 +180,7 @@ std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_fact } gfx::blur::dual_filtering::dual_filtering() - : m_size(0), m_size_iterations(0), m_data(::gfx::blur::dual_filtering_factory::get().data()) + : m_data(::gfx::blur::dual_filtering_factory::get().data()), m_size(0), m_size_iterations(0) { auto gctx = gs::context(); m_rendertargets.resize(MAX_LEVELS + 1); diff --git a/source/gfx/blur/gfx-blur-dual-filtering.hpp b/source/gfx/blur/gfx-blur-dual-filtering.hpp index 05d2dca..1f8dfd7 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.hpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.hpp @@ -32,7 +32,7 @@ namespace gfx { public: dual_filtering_data(); - ~dual_filtering_data(); + virtual ~dual_filtering_data(); std::shared_ptr<::gs::effect> get_effect(); }; @@ -43,7 +43,7 @@ namespace gfx { public: dual_filtering_factory(); - virtual ~dual_filtering_factory(); + virtual ~dual_filtering_factory() override; virtual bool is_type_supported(::gfx::blur::type type) override; @@ -93,7 +93,7 @@ namespace gfx { public: dual_filtering(); - virtual ~dual_filtering(); + virtual ~dual_filtering() override; virtual void set_input(std::shared_ptr<::gs::texture> texture) override; diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.cpp b/source/gfx/blur/gfx-blur-gaussian-linear.cpp index 2b7a7fa..3e4f2ba 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.cpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.cpp @@ -232,7 +232,7 @@ std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_fa } gfx::blur::gaussian_linear::gaussian_linear() - : m_size(1.), m_step_scale({1., 1.}), m_data(::gfx::blur::gaussian_linear_factory::get().data()) + : m_data(::gfx::blur::gaussian_linear_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) { auto gctx = gs::context(); @@ -295,7 +295,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -322,14 +322,14 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > FLT_EPSILON) { - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), 0.); + if (m_step_scale.first > DBL_EPSILON) { + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -338,14 +338,14 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() } // Second Pass - if (m_step_scale.second > FLT_EPSILON) { - effect->get_parameter("pImageTexel").set_float2(0., float_t(1. / height)); + if (m_step_scale.second > DBL_EPSILON) { + effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -388,7 +388,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -411,7 +411,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() effect->get_parameter("pImage").set_texture(m_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1. / height * sin(m_angle))); + .set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); @@ -421,7 +421,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.hpp b/source/gfx/blur/gfx-blur-gaussian-linear.hpp index a16fd4c..74726cd 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.hpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.hpp @@ -31,7 +31,7 @@ namespace gfx { public: gaussian_linear_data(); - ~gaussian_linear_data(); + virtual ~gaussian_linear_data(); std::shared_ptr<::gs::effect> get_effect(); @@ -44,7 +44,7 @@ namespace gfx { public: gaussian_linear_factory(); - virtual ~gaussian_linear_factory(); + virtual ~gaussian_linear_factory() override; virtual bool is_type_supported(::gfx::blur::type type) override; @@ -96,7 +96,7 @@ namespace gfx { public: gaussian_linear(); - virtual ~gaussian_linear(); + virtual ~gaussian_linear() override; virtual void set_input(std::shared_ptr<::gs::texture> texture) override; @@ -124,7 +124,7 @@ namespace gfx { public: gaussian_linear_directional(); - virtual ~gaussian_linear_directional(); + virtual ~gaussian_linear_directional() override; virtual ::gfx::blur::type get_type() override; diff --git a/source/gfx/blur/gfx-blur-gaussian.cpp b/source/gfx/blur/gfx-blur-gaussian.cpp index e35f1b0..16afa10 100644 --- a/source/gfx/blur/gfx-blur-gaussian.cpp +++ b/source/gfx/blur/gfx-blur-gaussian.cpp @@ -240,7 +240,7 @@ std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data() } gfx::blur::gaussian::gaussian() - : m_size(1.), m_step_scale({1., 1.}), m_data(::gfx::blur::gaussian_factory::get().data()) + : m_data(::gfx::blur::gaussian_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) { auto gctx = gs::context(); m_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); @@ -302,7 +302,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -329,14 +329,14 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > FLT_EPSILON) { - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), 0.); + if (m_step_scale.first > DBL_EPSILON) { + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -345,14 +345,14 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() } // Second Pass - if (m_step_scale.second > FLT_EPSILON) { - effect->get_parameter("pImageTexel").set_float2(0., float_t(1. / height)); + if (m_step_scale.second > DBL_EPSILON) { + effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -391,11 +391,11 @@ void gfx::blur::gaussian_directional::set_angle(double_t angle) std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() { auto gctx = gs::context(); - + std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -419,7 +419,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() effect->get_parameter("pImage").set_texture(m_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1. / height * sin(m_angle))); + .set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); @@ -429,7 +429,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -450,7 +450,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -472,7 +472,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); effect->get_parameter("pAngle").set_float(float_t(m_angle / m_size)); @@ -484,7 +484,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Rotate")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } @@ -527,7 +527,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < FLT_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { return m_input_texture; } @@ -549,7 +549,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pImageTexel").set_float2(float_t(1. / width), float_t(1. / height)); + effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); effect->get_parameter("pSize").set_float(float_t(m_size)); effect->get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); @@ -560,7 +560,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Zoom")) { - gs_draw_sprite(0, 0, 1, 1); + gs_draw_sprite(nullptr, 0, 1, 1); } } diff --git a/source/gfx/blur/gfx-blur-gaussian.hpp b/source/gfx/blur/gfx-blur-gaussian.hpp index 01e33ba..ccbb94a 100644 --- a/source/gfx/blur/gfx-blur-gaussian.hpp +++ b/source/gfx/blur/gfx-blur-gaussian.hpp @@ -31,7 +31,7 @@ namespace gfx { public: gaussian_data(); - ~gaussian_data(); + virtual ~gaussian_data(); std::shared_ptr<::gs::effect> get_effect(); @@ -44,7 +44,7 @@ namespace gfx { public: gaussian_factory(); - virtual ~gaussian_factory(); + virtual ~gaussian_factory() override; virtual bool is_type_supported(::gfx::blur::type type) override; @@ -96,7 +96,7 @@ namespace gfx { public: gaussian(); - virtual ~gaussian(); + virtual ~gaussian() override; virtual void set_input(std::shared_ptr<::gs::texture> texture) override; @@ -124,7 +124,7 @@ namespace gfx { public: gaussian_directional(); - virtual ~gaussian_directional(); + virtual ~gaussian_directional() override; virtual ::gfx::blur::type get_type() override; diff --git a/source/gfx/gfx-effect-source.cpp b/source/gfx/gfx-effect-source.cpp index 1219254..c98c650 100644 --- a/source/gfx/gfx-effect-source.cpp +++ b/source/gfx/gfx-effect-source.cpp @@ -35,7 +35,7 @@ bool gfx::effect_source::property_type_modified(void*, obs_properties_t* props, obs_property_t*, obs_data_t* sett) { - switch ((InputTypes)obs_data_get_int(sett, D_TYPE)) { + switch (static_cast(obs_data_get_int(sett, D_TYPE))) { default: case InputTypes::Text: obs_property_set_visible(obs_properties_get(props, D_INPUT_TEXT), true); @@ -71,9 +71,9 @@ void gfx::effect_source::fill_source_list(obs_property_t* prop) { obs_enum_sources( [](void* ptr, obs_source_t* src) { - obs_property_t* prop = (obs_property_t*)ptr; + obs_property_t* pro = (obs_property_t*)ptr; const char* sname = obs_source_get_name(src); - obs_property_list_add_string(prop, sname, sname); + obs_property_list_add_string(pro, sname, sname); return true; }, prop); @@ -159,7 +159,7 @@ void gfx::effect_source::get_properties(obs_properties_t* properties) obs_properties_add_bool(properties, prm.second->ui.names[0], prm.second->ui.descs[0]); } else if (prm.first.second >= gs::effect_parameter::type::Integer && prm.first.second <= gs::effect_parameter::type::Integer4) { - size_t cnt = (size_t)prm.first.second - (size_t)gs::effect_parameter::type::Integer; + size_t cnt = static_cast(prm.first.second) - static_cast(gs::effect_parameter::type::Integer); for (size_t idx = 0; idx <= cnt; idx++) { obs_properties_add_int(properties, prm.second->ui.names[idx], prm.second->ui.descs[idx], INT_MIN, @@ -167,11 +167,11 @@ void gfx::effect_source::get_properties(obs_properties_t* properties) } } else if (prm.first.second >= gs::effect_parameter::type::Float && prm.first.second <= gs::effect_parameter::type::Float4) { - size_t cnt = (size_t)prm.first.second - (size_t)gs::effect_parameter::type::Float; + size_t cnt = static_cast(prm.first.second) - static_cast(gs::effect_parameter::type::Float); for (size_t idx = 0; idx <= cnt; idx++) { - obs_properties_add_float(properties, prm.second->ui.names[idx], prm.second->ui.descs[idx], -FLT_MAX, - FLT_MAX, 0.01); + obs_properties_add_float(properties, prm.second->ui.names[idx], prm.second->ui.descs[idx], -DBL_MAX, + DBL_MAX, 0.01); } } else if (prm.first.second == gs::effect_parameter::type::Texture) { // Switch between File and Source Input @@ -201,7 +201,7 @@ void gfx::effect_source::get_properties(obs_properties_t* properties) void gfx::effect_source::get_defaults(obs_data_t* data) { - obs_data_set_default_int(data, D_TYPE, (long long)InputTypes::Text); + obs_data_set_default_int(data, D_TYPE, static_cast(InputTypes::Text)); obs_data_set_default_string(data, D_INPUT_TEXT, ""); obs_data_set_default_string(data, D_INPUT_FILE, ""); } @@ -211,7 +211,7 @@ void gfx::effect_source::update(obs_data_t* data) obs_data_addref(data); // Update Shader - InputTypes input_type = (InputTypes)obs_data_get_int(data, D_TYPE); + InputTypes input_type = static_cast(obs_data_get_int(data, D_TYPE)); if (input_type == InputTypes::Text) { const char* text = obs_data_get_string(data, D_INPUT_TEXT); test_for_updates(text, nullptr); @@ -257,7 +257,7 @@ bool gfx::effect_source::test_for_updates(const char* text, const char* path) if (os_stat(m_shader.path.c_str(), &stats) == 0) { m_shader.file_info.modified = (m_shader.file_info.time_create != stats.st_ctime) | (m_shader.file_info.time_modified != stats.st_mtime) - | (m_shader.file_info.file_size != stats.st_size); + | (m_shader.file_info.file_size != static_cast(stats.st_size)); // Mark shader as different if the file was changed. is_shader_different = is_shader_different | m_shader.file_info.modified; @@ -265,7 +265,7 @@ bool gfx::effect_source::test_for_updates(const char* text, const char* path) // Update own information m_shader.file_info.time_create = stats.st_ctime; m_shader.file_info.time_modified = stats.st_mtime; - m_shader.file_info.file_size = stats.st_size; + m_shader.file_info.file_size = static_cast(stats.st_size); } // Increment timer so that the next check is a reasonable timespan away. @@ -278,12 +278,12 @@ bool gfx::effect_source::test_for_updates(const char* text, const char* path) std::ifstream fs(m_shader.path.c_str(), std::ios::binary); if (fs.good()) { - size_t beg = fs.tellg(); + size_t beg = static_cast(fs.tellg()); fs.seekg(0, std::ios::end); size_t sz = size_t(fs.tellg()) - beg; content.resize(sz + 1); fs.seekg(0, std::ios::beg); - fs.read(content.data(), sz); + fs.read(content.data(), static_cast(sz)); fs.close(); content[sz] = '\0'; diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 9deb55b..88b69fc 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -61,24 +61,24 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : source_texture(_name.c_str(), _parent) {} -gfx::source_texture::source_texture(std::shared_ptr child, std::shared_ptr parent) +gfx::source_texture::source_texture(std::shared_ptr pchild, std::shared_ptr pparent) { - if (!child) { + if (!pchild) { throw std::invalid_argument("child must not be null"); } - if (!parent) { + if (!pparent) { throw std::invalid_argument("parent must not be null"); } - if (!obs_source_add_active_child(parent->get(), child->get())) { + if (!obs_source_add_active_child(pparent->get(), pchild->get())) { throw std::runtime_error("parent is contained in child"); } - this->child = child; - this->parent = parent; + this->child = pchild; + this->parent = pparent; this->render_target = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::source_texture::source_texture(std::shared_ptr child, obs_source_t* _parent) - : source_texture(child, std::make_shared(_parent, false, false)) +gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) + : source_texture(_child, std::make_shared(_parent, false, false)) {} obs_source_t* gfx::source_texture::get_object() diff --git a/source/obs/gs/gs-effect.cpp b/source/obs/gs/gs-effect.cpp index 4b9f7f2..9a93ac6 100644 --- a/source/obs/gs/gs-effect.cpp +++ b/source/obs/gs/gs-effect.cpp @@ -67,7 +67,7 @@ gs::effect::effect(std::string file) throw std::runtime_error("Shader too large (>256mb)"); } - std::vector shader_buf(length + 1); + std::vector shader_buf(size_t(length + 1), 0); filestream.read(shader_buf.data(), length); char* errorMessage = nullptr; @@ -235,7 +235,7 @@ void gs::effect_parameter::set_float2(float_t x, float_t y) { if (get_type() != type::Float2) throw std::bad_cast(); - vec2 v = {x, y}; + vec2 v = {{x, y}}; gs_effect_set_vec2(m_param, &v); } @@ -250,7 +250,7 @@ void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z) { if (get_type() != type::Float3) throw std::bad_cast(); - vec3 v = {x, y, z}; + vec3 v = {{x, y, z, 0}}; gs_effect_set_vec3(m_param, &v); } @@ -265,7 +265,7 @@ void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w { if (get_type() != type::Float4) throw std::bad_cast(); - vec4 v = {x, y, z, w}; + vec4 v = {{x, y, z, w}}; gs_effect_set_vec4(m_param, &v); } diff --git a/source/obs/gs/gs-mipmapper.cpp b/source/obs/gs/gs-mipmapper.cpp index f91e902..aad8f25 100644 --- a/source/obs/gs/gs-mipmapper.cpp +++ b/source/obs/gs/gs-mipmapper.cpp @@ -35,7 +35,7 @@ #if defined(WIN32) || defined(WIN64) extern "C" { -#include +#include } #endif @@ -253,7 +253,7 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); effect->get_parameter("image").set_texture(target); - effect->get_parameter("level").set_int(uint32_t(mip - 1)); + effect->get_parameter("level").set_int(int32_t(mip - 1)); effect->get_parameter("imageTexel").set_float2(texel_width, texel_height); effect->get_parameter("strength").set_float(strength); diff --git a/source/obs/gs/gs-texture.cpp b/source/obs/gs/gs-texture.cpp index cdd05af..d1513f3 100644 --- a/source/obs/gs/gs-texture.cpp +++ b/source/obs/gs/gs-texture.cpp @@ -21,8 +21,8 @@ #include #include #include -#include "util-math.hpp" #include "obs/gs/gs-helper.hpp" +#include "util-math.hpp" // OBS #ifdef _MSC_VER @@ -76,9 +76,9 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f throw std::logic_error("mip_levels must be at least 1"); if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) { - bool isPOT = (pow(2, (int64_t)floor(log(width) / log(2))) == width) - && (pow(2, (int64_t)floor(log(height) / log(2))) == height) - && (pow(2, (int64_t)floor(log(depth) / log(2))) == depth); + 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)); if (!isPOT) throw std::logic_error("mip mapping requires power of two dimensions"); } @@ -104,7 +104,7 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, throw std::logic_error("mip_levels must be at least 1"); if (mip_levels > 1 || ((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps)) { - bool isPOT = (pow(2, (int64_t)floor(log(size) / log(2))) == size); + bool isPOT = util::math::is_equal(pow(2, (int64_t)floor(log(size) / log(2))), size); if (!isPOT) throw std::logic_error("mip mapping requires power of two dimensions"); } diff --git a/source/obs/gs/gs-vertex.cpp b/source/obs/gs/gs-vertex.cpp index 5bb3872..c69cae4 100644 --- a/source/obs/gs/gs-vertex.cpp +++ b/source/obs/gs/gs-vertex.cpp @@ -53,7 +53,7 @@ gs::vertex::~vertex() } gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS]) - : hasStore(false), position(p), normal(n), tangent(t), color(col) + : position(p), normal(n), tangent(t), color(col), hasStore(false) { if (uvs != nullptr) { for (size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) { diff --git a/source/obs/gs/gs-vertexbuffer.cpp b/source/obs/gs/gs-vertexbuffer.cpp index 799ae57..626c4c3 100644 --- a/source/obs/gs/gs-vertexbuffer.cpp +++ b/source/obs/gs/gs-vertexbuffer.cpp @@ -19,8 +19,8 @@ #include "gs-vertexbuffer.hpp" #include -#include "util-memory.hpp" #include "obs/gs/gs-helper.hpp" +#include "util-memory.hpp" // OBS #ifdef _MSC_VER @@ -133,7 +133,7 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers) gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb) { auto gctx = gs::context(); - gs_vb_data* vbd = gs_vertexbuffer_get_data(vb); + gs_vb_data* vbd = gs_vertexbuffer_get_data(vb); if (!vbd) throw std::runtime_error("vertex buffer with no data"); diff --git a/source/obs/obs-source-tracker.cpp b/source/obs/obs-source-tracker.cpp index 68ba6d2..a716b5d 100644 --- a/source/obs/obs-source-tracker.cpp +++ b/source/obs/obs-source-tracker.cpp @@ -43,7 +43,6 @@ void obs::source_tracker::source_create_handler(void* ptr, calldata_t* data) return; } - self->source_map.insert({std::string(name), weak}); } @@ -109,7 +108,8 @@ obs::source_tracker::~source_tracker() this->source_map.clear(); } -void obs::source_tracker::enumerate(enumerate_cb_t ecb, filter_cb_t fcb) { +void obs::source_tracker::enumerate(enumerate_cb_t ecb, filter_cb_t fcb) +{ // Need func-local copy, otherwise we risk corruption if a new source is created or destroyed. auto source_map_copy = this->source_map; for (auto kv : this->source_map) { @@ -136,29 +136,29 @@ void obs::source_tracker::enumerate(enumerate_cb_t ecb, filter_cb_t fcb) { } } -bool obs::source_tracker::filter_sources(std::string name, obs_source_t* source) +bool obs::source_tracker::filter_sources(std::string, obs_source_t* source) { return (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT); } -bool obs::source_tracker::filter_audio_sources(std::string name, obs_source_t* source) +bool obs::source_tracker::filter_audio_sources(std::string, obs_source_t* source) { uint32_t flags = obs_source_get_output_flags(source); return !(flags & OBS_SOURCE_AUDIO) || (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT); } -bool obs::source_tracker::filter_video_sources(std::string name, obs_source_t* source) +bool obs::source_tracker::filter_video_sources(std::string, obs_source_t* source) { uint32_t flags = obs_source_get_output_flags(source); return !(flags & OBS_SOURCE_VIDEO) || (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT); } -bool obs::source_tracker::filter_transitions(std::string name, obs_source_t* source) +bool obs::source_tracker::filter_transitions(std::string, obs_source_t* source) { return (obs_source_get_type(source) != OBS_SOURCE_TYPE_TRANSITION); } -bool obs::source_tracker::filter_scenes(std::string name, obs_source_t* source) +bool obs::source_tracker::filter_scenes(std::string, obs_source_t* source) { return (obs_source_get_type(source) != OBS_SOURCE_TYPE_SCENE); } diff --git a/source/obs/obs-source.cpp b/source/obs/obs-source.cpp index 7c8726b..b4b3418 100644 --- a/source/obs/obs-source.cpp +++ b/source/obs/obs-source.cpp @@ -367,7 +367,7 @@ obs::source::~source() #ifdef auto_signal_d #undef auto_signal_d #endif -#define auto_signal_d(SIGNAL) this->events.##SIGNAL.clear(); +#define auto_signal_d(SIGNAL) this->events.SIGNAL.clear() auto_signal_d(destroy); auto_signal_d(remove); auto_signal_d(save); @@ -410,7 +410,7 @@ obs::source::source() #endif #define auto_signal_c(SIGNAL) \ { \ - this->events.##SIGNAL.set_listen_callback([this] { \ + this->events.SIGNAL.set_listen_callback([this] { \ if (!this->self) \ return; \ auto sh = obs_source_get_signal_handler(this->self); \ @@ -418,7 +418,7 @@ obs::source::source() signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ } \ }); \ - this->events.##SIGNAL.set_silence_callback([this] { \ + this->events.SIGNAL.set_silence_callback([this] { \ if (!this->self) \ return; \ auto sh = obs_source_get_signal_handler(this->self); \ @@ -427,32 +427,32 @@ obs::source::source() } \ }); \ } - auto_signal_c(destroy); - auto_signal_c(remove); - auto_signal_c(save); - auto_signal_c(load); - auto_signal_c(activate); - auto_signal_c(deactivate); - auto_signal_c(show); - auto_signal_c(hide); - auto_signal_c(mute); - auto_signal_c(push_to_mute_changed); - auto_signal_c(push_to_mute_delay); - auto_signal_c(push_to_talk_changed); - auto_signal_c(push_to_talk_delay); - auto_signal_c(enable); - auto_signal_c(rename); - auto_signal_c(volume); - auto_signal_c(update_properties); - auto_signal_c(update_flags); - auto_signal_c(audio_sync); - auto_signal_c(audio_mixers); - auto_signal_c(filter_add); - auto_signal_c(filter_remove); - auto_signal_c(reorder_filters); - auto_signal_c(transition_start); - auto_signal_c(transition_video_stop); - auto_signal_c(transition_stop); + auto_signal_c(destroy) + auto_signal_c(remove) + auto_signal_c(save) + auto_signal_c(load) + auto_signal_c(activate) + auto_signal_c(deactivate) + auto_signal_c(show) + auto_signal_c(hide) + auto_signal_c(mute) + auto_signal_c(push_to_mute_changed) + auto_signal_c(push_to_mute_delay) + auto_signal_c(push_to_talk_changed) + auto_signal_c(push_to_talk_delay) + auto_signal_c(enable) + auto_signal_c(rename) + auto_signal_c(volume) + auto_signal_c(update_properties) + auto_signal_c(update_flags) + auto_signal_c(audio_sync) + auto_signal_c(audio_mixers) + auto_signal_c(filter_add) + auto_signal_c(filter_remove) + auto_signal_c(reorder_filters) + auto_signal_c(transition_start) + auto_signal_c(transition_video_stop) + auto_signal_c(transition_stop) #undef auto_signal_c // libOBS unfortunately does not use the event system for audio data callbacks, which is kind of odd as most other @@ -465,27 +465,27 @@ obs::source::source() } } -obs::source::source(std::string name, bool track_ownership, bool add_reference) : source() +obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) : ::obs::source::source() { this->self = obs_get_source_by_name(name.c_str()); if (!this->self) { throw std::runtime_error("source with name not found"); } - this->track_ownership = track_ownership; + this->track_ownership = ptrack_ownership; if (!add_reference) { obs_source_release(this->self); } } -obs::source::source(obs_source_t* source, bool track_ownership, bool add_reference) : source() +obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_reference) : ::obs::source::source() { this->self = source; if (!this->self) { throw std::invalid_argument("source must not be null"); } - this->track_ownership = track_ownership; + this->track_ownership = ptrack_ownership; if (add_reference) { obs_source_addref(this->self); } @@ -503,7 +503,7 @@ obs::source::source(source const& other) #ifdef auto_signal_c #undef auto_signal_c #endif -#define auto_signal_c(SIGNAL) this->events.##SIGNAL = other.events.##SIGNAL; +#define auto_signal_c(SIGNAL) this->events.SIGNAL = other.events.SIGNAL auto_signal_c(destroy); auto_signal_c(remove); auto_signal_c(save); @@ -555,7 +555,7 @@ obs::source& obs::source::operator=(source const& other) #ifdef auto_signal_c #undef auto_signal_c #endif -#define auto_signal_c(SIGNAL) this->events.##SIGNAL = other.events.##SIGNAL; +#define auto_signal_c(SIGNAL) this->events.SIGNAL = other.events.SIGNAL auto_signal_c(destroy); auto_signal_c(remove); auto_signal_c(save); @@ -597,7 +597,7 @@ obs::source::source(source&& other) : self(std::move(other.self)), track_ownersh #ifdef auto_signal_c #undef auto_signal_c #endif -#define auto_signal_c(SIGNAL) this->events.##SIGNAL = std::move(other.events.##SIGNAL); +#define auto_signal_c(SIGNAL) this->events.SIGNAL = std::move(other.events.SIGNAL) auto_signal_c(destroy); auto_signal_c(remove); auto_signal_c(save); @@ -647,7 +647,7 @@ obs::source& obs::source::operator=(source&& other) #ifdef auto_signal_c #undef auto_signal_c #endif -#define auto_signal_c(SIGNAL) this->events.##SIGNAL = std::move(other.events.##SIGNAL); +#define auto_signal_c(SIGNAL) this->events.SIGNAL = std::move(other.events.SIGNAL) auto_signal_c(destroy); auto_signal_c(remove); auto_signal_c(save); diff --git a/source/obs/obs-tools.cpp b/source/obs/obs-tools.cpp index 560a497..91c3573 100644 --- a/source/obs/obs-tools.cpp +++ b/source/obs/obs-tools.cpp @@ -28,13 +28,13 @@ struct scs_searchdata { static bool scs_contains(scs_searchdata& sd, obs_source_t* source); -static void scs_enum_active_cb(obs_source_t* , obs_source_t* child, void* searchdata) +static void scs_enum_active_cb(obs_source_t*, obs_source_t* child, void* searchdata) { scs_searchdata& sd = reinterpret_cast(*reinterpret_cast(searchdata)); scs_contains(sd, child); } -static bool scs_enum_items_cb(obs_scene_t* , obs_sceneitem_t* item, void* searchdata) +static bool scs_enum_items_cb(obs_scene_t*, obs_sceneitem_t* item, void* searchdata) { scs_searchdata& sd = reinterpret_cast(*reinterpret_cast(searchdata)); obs_source_t* source = obs_sceneitem_get_source(item); diff --git a/source/plugin.hpp b/source/plugin.hpp index 8df0dd7..f3e38a5 100644 --- a/source/plugin.hpp +++ b/source/plugin.hpp @@ -37,7 +37,7 @@ #define PLUGIN_NAME "Stream Effects" #include "version.hpp" -#define P_LOG(level, ...) blog(level, "[" PLUGIN_NAME "] " __VA_ARGS__); +#define P_LOG(level, ...) blog(level, "[" PLUGIN_NAME "] " __VA_ARGS__) #define P_LOG_ERROR(...) P_LOG(LOG_ERROR, __VA_ARGS__) #define P_LOG_WARNING(...) P_LOG(LOG_WARNING, __VA_ARGS__) #define P_LOG_INFO(...) P_LOG(LOG_INFO, __VA_ARGS__) diff --git a/source/sources/source-mirror.cpp b/source/sources/source-mirror.cpp index 0b14146..7e80943 100644 --- a/source/sources/source-mirror.cpp +++ b/source/sources/source-mirror.cpp @@ -150,25 +150,25 @@ bool source::mirror::mirror_factory::modified_properties(obs_properties_t* pr, o if (obs_properties_get(pr, P_SCALING_BOUNDS) == p) { obs_bounds_type scaling_type = static_cast(obs_data_get_int(data, P_SCALING_BOUNDS)); - obs_property_t* p = obs_properties_get(pr, P_SCALING_BOUNDS); + obs_property_t* p2 = obs_properties_get(pr, P_SCALING_BOUNDS); switch (scaling_type) { case obs_bounds_type::OBS_BOUNDS_STRETCH: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_STRETCH))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_STRETCH))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_INNER: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FIT))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FIT))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_OUTER: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILL))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILL))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_TO_WIDTH: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLWIDTH))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLWIDTH))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_TO_HEIGHT: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLHEIGHT))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLHEIGHT))); break; default: - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS))); + obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS))); break; } return true; @@ -379,10 +379,10 @@ void source::mirror::mirror_instance::acquire_input(std::string source_name) } source::mirror::mirror_instance::mirror_instance(obs_data_t*, obs_source_t* src) - : m_self(src), m_active(true), m_tick(0), m_scene_rendered(false), m_rescale_enabled(false), - m_rescale_keep_orig_size(false), m_rescale_width(1), m_rescale_height(1), - m_rescale_type(obs_scale_type::OBS_SCALE_BICUBIC), m_rescale_bounds(obs_bounds_type::OBS_BOUNDS_STRETCH), - m_audio_enabled(false), m_audio_kill_thread(false), m_audio_have_output(false), m_source_item(nullptr) + : m_self(src), m_active(true), m_tick(0), m_scene_rendered(false), m_rescale_enabled(false), m_rescale_width(1), + m_rescale_height(1), m_rescale_keep_orig_size(false), m_rescale_type(obs_scale_type::OBS_SCALE_BICUBIC), + m_rescale_bounds(obs_bounds_type::OBS_BOUNDS_STRETCH), m_audio_enabled(false), m_audio_kill_thread(false), + m_audio_have_output(false), m_source_item(nullptr) { // Initialize Video Rendering this->m_scene = @@ -505,16 +505,6 @@ void source::mirror::mirror_instance::deactivate() this->m_active = false; } -static inline void mix_audio(float* p_out, float* p_in, size_t pos, size_t count) -{ - float* out = p_out; - float* in = p_in + pos; - float* end = in + count; - - while (in < end) - *(out++) += *(in++); -} - void source::mirror::mirror_instance::video_tick(float time) { this->m_tick += time; @@ -693,7 +683,7 @@ void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_da { // Copy data std::bitset<8> layout; for (size_t plane = 0; plane < MAX_AV_PLANES; plane++) { - float* samples = (float*)audio->data[plane]; + float* samples = reinterpret_cast(audio->data[plane]); if (!samples) { mad->audio.data[plane] = nullptr; continue; diff --git a/source/sources/source-mirror.hpp b/source/sources/source-mirror.hpp index 6db61d4..1ee3eaa 100644 --- a/source/sources/source-mirror.hpp +++ b/source/sources/source-mirror.hpp @@ -83,8 +83,8 @@ namespace source { }; class mirror_instance { - bool m_active; obs_source_t* m_self; + bool m_active; float_t m_tick; // Video Rendering diff --git a/source/util-math.hpp b/source/util-math.hpp index 1f615f3..caaa81c 100644 --- a/source/util-math.hpp +++ b/source/util-math.hpp @@ -104,7 +104,7 @@ namespace util { { bool have_bit = false; for (size_t index = 0; index < (sizeof(T) * 8); index++) { - bool cur = (v & (1ull << index)) != 0; + bool cur = (v & (static_cast(1ull) << index)) != 0; if (cur) { if (have_bit) return false; @@ -144,6 +144,13 @@ namespace util { return uint64_t(ceil(log10(T(v)) / log10(2.0))); } + template + inline bool is_equal(T target, C value) + { + return (target > (value - std::numeric_limits::epsilon())) + && (target < (value + std::numeric_limits::epsilon())); + } + template inline T gaussian(T x, T o /*, T u = 0*/) { @@ -152,7 +159,7 @@ namespace util { static const double_t two_pi = pi * 2.; static const double_t two_pi_sqroot = 2.506628274631000502415765284811; //sqrt(two_pi); - if (o == 0) { + if (is_equal(0, o)) { return T(std::numeric_limits::infinity()); } diff --git a/source/util-memory.hpp b/source/util-memory.hpp index 23b26b7..a89f9b8 100644 --- a/source/util-memory.hpp +++ b/source/util-memory.hpp @@ -38,9 +38,9 @@ namespace util { template class AlignmentAllocator { public: - typedef T value_type; - typedef size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; @@ -49,13 +49,13 @@ namespace util { typedef const T& const_reference; public: - inline AlignmentAllocator() throw() {} + inline AlignmentAllocator() {} template - inline AlignmentAllocator(const AlignmentAllocator&) throw() + inline AlignmentAllocator(const AlignmentAllocator&) {} - inline ~AlignmentAllocator() throw() {} + inline ~AlignmentAllocator() {} inline pointer adress(reference r) { @@ -88,7 +88,7 @@ namespace util { p; } - inline size_type max_size() const throw() + inline size_type max_size() const { return size_type(-1) / sizeof(value_type); } diff --git a/source/utility.hpp b/source/utility.hpp index 395078d..d1ac517 100644 --- a/source/utility.hpp +++ b/source/utility.hpp @@ -48,14 +48,6 @@ typename std::enable_if::enable, Enum>::type oper #define vstr(s) dstr(s) #define dstr(s) #s -#ifndef __FUNCTION_NAME__ -#if defined(_WIN32) || defined(_WIN64) //WINDOWS -#define __FUNCTION_NAME__ __FUNCTION__ -#else //*NIX -#define __FUNCTION_NAME__ __func__ -#endif -#endif - #ifdef __cplusplus #define INITIALIZER(f) \ static void f(void); \