Commit Graph

535 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks 5a4d38d249 project: Fix a massive list of dangerous warnings
This is a massive improvement to stability and safety when using the plugin, as all exceptions should now no longer be leaked into C controlled code, which can't actually handle exceptions at all.

Warnings fixed:

* Potentially throwing exception during library load.
* Possibly throwing function passed to C.
* Statement does nothing.
* Variable is initialized but not referenced.
* Variable overloads variable in parent scope.
2019-09-05 18:42:28 +02:00
Michael Fabian 'Xaymar' Dirks 2a4a3bf501 util-memory: Cast to intptr_t 2019-09-05 18:09:33 +02:00
Michael Fabian 'Xaymar' Dirks 4c44496b87 source-mirror: Handle uncaught exceptions in C callbacks
Fixes various crashes and undefined behavior due to exceptions falling into C code where they now wreak havoc with the current stack.
2019-09-04 20:52:37 +02:00
Michael Fabian 'Xaymar' Dirks f65dfcbbf0 filter-blur: Don't throw exceptions into C code
It is extremely problematic to throw C++ exceptions into C code, especially because C code usually does not handle C++ exceptions at all. Therefore we have to prevent any exception from leaving the function and define it as noexcept.
2019-09-04 20:43:40 +02:00
Michael Fabian 'Xaymar' Dirks f61cdeb582 utility-event: Fix compile errors 2019-09-04 20:30:16 +02:00
Michael Fabian 'Xaymar' Dirks 29ab00633c utility-event: Safer event handling with proper lifetime
The util::event code suffers from the problem that it could call into a class that no longer exists, corrupting memory or even crashing. By tracking lifetime using std::weak_ptr<void> this can be avoided and the dead listeners can be automatically removed.
2019-09-04 16:36:32 +02:00
Michael Fabian 'Xaymar' Dirks da9124fc1a util-memory: Avoid MSVC specific C++ and use Std++ if available 2019-09-04 03:22:05 +02:00
Michael Fabian 'Xaymar' Dirks 82faab4380 project: Re-apply formatting 2019-09-04 03:03:41 +02:00
Michael Fabian 'Xaymar' Dirks ce7e4c97d4 project: Don't use non-standard strcmpi 2019-09-04 03:02:19 +02:00
Michael Fabian 'Xaymar' Dirks 03c704de1a project: Correct usage of exceptions and include stdexcept 2019-09-04 02:59:04 +02:00
Michael Fabian 'Xaymar' Dirks 4765c57828 filter-sdf-effects: Don't define structs in nameless unions 2019-09-04 02:49:04 +02:00
Michael Fabian 'Xaymar' Dirks f27320c6c9 project: Remove use of P_INITIALIZER
Does not support cross-platform very well and breaks on Apple for no apparent reason.

Add resolution scale to shader filter.
2019-09-04 02:47:27 +02:00
Michael Fabian 'Xaymar' Dirks 9ace96285d filter-dynamic-mask: Use snprintf instead of sprintf_s 2019-09-04 02:39:59 +02:00
Michael Fabian 'Xaymar' Dirks 2e98c2e754 color-grade: Fix and improve advanced options
These new options allow further control over the Tint tool in Color grading.
2019-09-04 02:18:40 +02:00
Michael Fabian 'Xaymar' Dirks 781307fbe6 color-grade: Add further Tint options 2019-09-04 01:41:15 +02:00
Michael Fabian 'Xaymar' Dirks deeb6719c4 project: Apply formatting 2019-08-24 12:59:32 +02:00
Michael Fabian 'Xaymar' Dirks 250dc97603 gfx-effect-source: enumerate child sources correctly 2019-08-07 20:40:04 +02:00
Michael Fabian 'Xaymar' Dirks a04d102568 gfx-effect-source: Support for textures and some crash resistance 2019-08-07 20:22:12 +02:00
Michael Fabian 'Xaymar' Dirks f945f08ab0 strings: Texture formats 2019-08-07 20:21:39 +02:00
Michael Fabian 'Xaymar' Dirks d7e66b17f1 filter-shader: Don't ignore all properties 2019-08-07 19:22:10 +02:00
Michael Fabian 'Xaymar' Dirks b8fc0d5284 source-shader: Fix rendering 2019-08-07 19:20:44 +02:00
Michael Fabian 'Xaymar' Dirks 7fdd9498a0 filter-shader: Fix blending 2019-08-07 19:20:32 +02:00
Michael Fabian 'Xaymar' Dirks 90699f6b6f gfx-effect-source: Implement defaults for bool, value and matrix 2019-08-07 19:19:56 +02:00
Michael Fabian 'Xaymar' Dirks 39e6959c67 source-shader: Fix rendering and reapply parameters on change 2019-08-07 18:43:34 +02:00
Michael Fabian 'Xaymar' Dirks 181df6e3d9 filter-shader: Reapply parameters if there was a change 2019-08-07 18:43:19 +02:00
Michael Fabian 'Xaymar' Dirks 9be36d5ec4 gfx-effect-source: Add function to get "default" value 2019-08-07 18:42:54 +02:00
Michael Fabian 'Xaymar' Dirks 2b2f87e6fc gfx-effect-source: Fix validity check
Had the check inverted oops.
2019-08-07 18:16:20 +02:00
Michael Fabian 'Xaymar' Dirks c88535c7ab gfx-effect-source: Remove/replace old defines 2019-08-07 18:11:46 +02:00
Michael Fabian 'Xaymar' Dirks c670ab60a1 source-shader: Use custom draw video_render 2019-08-07 18:10:44 +02:00
Michael Fabian 'Xaymar' Dirks 8cb2ddaa82 source-shader, cmake: 'Shader' source 2019-08-07 18:06:48 +02:00
Michael Fabian 'Xaymar' Dirks 1b34e5210a gfx-effect-source: Expose defines to set default file and technique 2019-08-07 18:06:24 +02:00
Michael Fabian 'Xaymar' Dirks 9ad93c0ee9 filter-shader: Rename from Custom shader 2019-08-07 18:05:49 +02:00
Michael Fabian 'Xaymar' Dirks 98a18480d0 gfx-effect-source: Fix UI mode detection 2019-08-07 17:45:32 +02:00
Michael Fabian 'Xaymar' Dirks 8ec8a22928 filter-custom-shader: Add new callbacks 2019-08-07 17:37:52 +02:00
Michael Fabian 'Xaymar' Dirks 335847945d gfx-effect-source: Allow overriding value and visibility of parameters 2019-08-07 17:37:34 +02:00
Michael Fabian 'Xaymar' Dirks ff4a556f3f filter-custom-shader: Update to use new gfx::effect_source::effect_source 2019-08-07 17:15:46 +02:00
Michael Fabian 'Xaymar' Dirks bde4e278bf gfx-effect-source: Further work on rewrite
This partially implements most behavior to an acceptable degree for use right now.
2019-08-07 17:14:44 +02:00
Michael Fabian 'Xaymar' Dirks 845a2cbb21 gs-effect: Don't include the null character in strings 2019-08-07 17:14:14 +02:00
Michael Fabian 'Xaymar' Dirks b88cc0fe01 gs-effect: Check correct size in get_default_string 2019-08-07 17:07:54 +02:00
Michael Fabian 'Xaymar' Dirks 8603fef897 gs-effect: Fix get_string and get_default_string 2019-08-07 16:41:26 +02:00
Michael Fabian 'Xaymar' Dirks c6559d84ba gs-effect: Check if effect is nullptr, not if its a valid ptr
Woops, that somehow went completely by me without checking.
2019-08-07 16:17:12 +02:00
Michael Fabian 'Xaymar' Dirks 7b0159947e gs-effect: Add helpers and fix bad enable_shared_from_this 2019-08-07 16:11:09 +02:00
Michael Fabian 'Xaymar' Dirks e59bc2fdd2 filter-custom-shader: Rewrite from scratch 2019-08-07 12:43:23 +02:00
Michael Fabian 'Xaymar' Dirks 1092dc1de1 gfx-effect-source: Complete rewrite from scratch 2019-08-07 12:42:25 +02:00
Michael Fabian 'Xaymar' Dirks 087cd79a7a filter-color-grade: Always return something in get_width/get_height 2019-08-07 12:41:34 +02:00
Michael Fabian 'Xaymar' Dirks f5b4c1f7a1 filter-color-grade: Fix crash if color-grade.effect is missing 2019-08-04 23:20:35 +02:00
Michael Fabian 'Xaymar' Dirks 71b223dcb5 gs-effect: Add ::create for shared_ptr and remove default constructor 2019-08-04 23:19:38 +02:00
Michael Fabian 'Xaymar' Dirks 9db7cd8da2 filter-displacement: Fix crash on nullptr file path 2019-08-04 23:14:43 +02:00
Michael Fabian 'Xaymar' Dirks 0c447f4055 gs-effect: Use std::shared_ptr and track effect lifetime
This fixes the case where the effect vanishes, but we still hold an invalid pointer to a parameter of that effect. With the new code, the effect will not vanish as long as an effect pointer exists.

However, all effects must be created either through std::shared_ptr or std::make_shared. If they were not made through one of those means, the code will crash on the ->shared_from_this() call.
2019-08-04 23:12:30 +02:00
Michael Fabian 'Xaymar' Dirks ff6f4d5ddf gs-effect: Add string support, get accessors and annotations 2019-08-04 22:44:46 +02:00
Michael Fabian 'Xaymar' Dirks 9be02e6f2b project: Fix up previous commit 2019-08-04 20:29:04 +02:00
Michael Fabian 'Xaymar' Dirks 0e350415b3 project: Apply new coding guidelines 2019-08-04 16:20:26 +02:00
Michael Fabian 'Xaymar' Dirks 533de01061 filter-color-grade: Always return true in tool_modified 2019-08-04 12:34:54 +02:00
Michael Fabian 'Xaymar' Dirks 2ca15bb28c source-mirror: Allow overriding audio layout 2019-08-04 12:34:42 +02:00
Michael Fabian 'Xaymar' Dirks 93ba39545f filter-color-grade: Implement Tool selection for OBS Studio 24.x 2019-08-03 12:29:47 +02:00
Michael Fabian 'Xaymar' Dirks 721f2bdf8f filter-color-grade: Fully feature Color Grading filter
Allows controlling Lift, Gamma, Gain, Offset, Tint and various Correction factors directly from within OBS without having to create a new LUT.
2019-08-02 23:49:18 +02:00
Michael Fabian 'Xaymar' Dirks a6ce6c5860 utility: Add some extra functionality 2019-08-02 23:49:17 +02:00
Michael Fabian 'Xaymar' Dirks ad270bc6ee gs-effect: Fix uninitialized member variable 2019-08-02 23:49:17 +02:00
Michael Fabian 'Xaymar' Dirks c716e75ba3 project: Fix various catch-by-value locations 2019-07-27 19:57:50 +02:00
Michael Fabian 'Xaymar' Dirks e887a53463 filter-sdf-effects: Fix a crash due to failed rendering
For whatever reason, the initial render target render fails when an async source is being used.
2019-07-27 19:57:49 +02:00
Michael Fabian 'Xaymar' Dirks 2c94852ba8 source-mirror: Allow changing source alignment
Adds a new property to control the alignment of the source within the calculated boundary when rescaling the source. Also fixes the permanently left aligned mirror at the same time.
2019-05-28 20:04:26 +02:00
Michael Fabian 'Xaymar' Dirks 45728702ff utility: Add recursive text lookup function
Similar to the one used in enc-amf, allows looking up string containing other strings, thus drastically simplifying the necessary time to build translated strings, while also caching them for future use.
2019-05-28 19:54:23 +02:00
Michael Fabian 'Xaymar' Dirks 95b1e81ee5 filter-dynamic-mask: Don't crash if a texture is missing
When copying or re-ordering filters, an occasional crash can be observed due to the rendering not being possible yet. With this, it will simply revert back to the original source instead of crashing.
2019-05-28 02:51:27 +02:00
Michael Fabian 'Xaymar' Dirks ccc4c6ea22 filter-sdf-effects: Fix and improve effect rendering
Fixes the bug that rendering an outline would remove all other effects not directly under the outline, while also improving the rendering speed drastically by only initializing and clearing the rendertarget once instead of for each effect.
2019-05-28 02:51:27 +02:00
Michael Fabian 'Xaymar' Dirks 9e7894c9c3 filter-dynamic-mask: Implement Dynamic Mask filter
This filter allows the use of another source as a mask, allowing complex filter graphs and trippy effects, such as creating a text source with three animated videos, each using a different color channel as the mask.

Fixes #18.
2019-04-27 17:56:10 +02:00
Michael Fabian 'Xaymar' Dirks c46e881697 obs-source: Don't un/register audio capture with no source
Fixes the log spam if a source could not be found.
2019-04-27 16:08:54 +02:00
Michael Fabian 'Xaymar' Dirks 8bb1ca50ac obs-source-tracker: Also keep track of sources being renamed
When a source was renamed, obs::source_tracker did not use the new name and instead relied on the old name. This caused source lists with this feature to slowly degrade over time as sources were renamed, until libobs was restarted.

With this fix the renamed sources are now properly tracked, updating as expected.

Related Issue: #64
2019-04-27 16:07:50 +02:00
Michael Fabian 'Xaymar' Dirks f6687c7ed6 filter-displacement: Don't crash if the file can't be found
Fixes a user reported issue where obs-studio began crashing out of nowhere.
2019-04-23 17:20:18 +02:00
Michael Fabian 'Xaymar' Dirks bbcde070f3 filter-displacement: Do not allow zero-length file names
Fixes a crash when using c_str() on an empty string, causing an unexpected crash.
2019-04-23 17:00:18 +02:00
Michael Fabian 'Xaymar' Dirks f8e685cf42 project: Apply clang-format manually again 2019-04-19 20:40:07 +02:00
Michael Fabian 'Xaymar' Dirks be4d42312d project: Fix all remaining portability issues
Clang on Windows and Clang on Linux behave differently, and of course GCC on Windows (MinGW) and GCC on Linux do too. This is the point where using either compiler on either platform should successfully compile the project without any issues.

Clang and GCC have a ton of warnings however, which definitely need to be fixed in the near future. Some of them are great warnings, like old C style casts, others are non-sense like suggest brackets.

Fixes #47
Fixes #60
2019-04-19 14:18:29 +02:00
Michael Fabian 'Xaymar' Dirks aac52f736d project: Clang support
Lots and lots of errors and warnings fixed with this single commit, in the name of clang support.

Related #60, #47.
2019-04-19 09:42:15 +02:00
Michael Fabian 'Xaymar' Dirks 432b8e8c14 source-mirror: Automatically update hover text for Bounds Type 2019-04-19 08:20:33 +02:00
Michael Fabian 'Xaymar' Dirks e24b9a61fa filter-blur: Update long description of Type and Subtype fields
Automatically updates the long description (hover text) if the Type or Subtype field is changed, allowing for more contextual information about what the selected information does.
2019-04-15 12:54:19 +02:00
Michael Fabian 'Xaymar' Dirks c59ec2511b filter-sdf-effects: Refactor to include Glow and Stroke (#2, #4)
This refactors the SDF Effects to use a normal blend function instead of doing the blend in the effect itself, improving quality and reducing problematic sampling issues. In addition to this, the effect files have been cleaned up slightly and renamed to their proper names. Glow and Stroke are now supported, which solves both #2 and #4 in one go.

The caching optimization has also now been implemented, reducing the number of renders for this filter to 1 for each tick.
2019-04-14 14:19:59 +02:00
Michael Fabian 'Xaymar' Dirks 787409b2d9 filter-transform: Fix description for Position, Rotation, Scale & Shear
This would previously incorrectly reference descriptions that don't exist, and thus not translate correctly.
2019-04-06 18:19:35 +02:00
Michael Fabian 'Xaymar' Dirks 86e09b6f72 obs-source: Explicitly clear events and copy events 2019-04-03 06:44:04 +02:00
Michael Fabian 'Xaymar' Dirks fa60be1593 source-mirror: Fix incorrect source alignment
This bug was introduced in 0.6.0 and had sources render half offscreen to the left, as the alignment 4 meant "center left" instead of just "center".
2019-04-03 06:13:23 +02:00
Michael Fabian 'Xaymar' Dirks 2a53e84bdb filter-blur: Fix more compiler warnings 2019-04-03 02:59:48 +02:00
Michael Fabian 'Xaymar' Dirks bdf6b893ab source-mirror: Fix a dead lock issue and use a queue system
This fixes a dead lock due to attempting to lock the same filter mutex twice, causing libOBS to completely lock up on every mutex. This extends the fix for 4fc25cfd8d.

Additionally this switches to a proper queue system for audio, so we no longer cause audio stuttering or audio skipping.
2019-04-03 02:58:54 +02:00
Michael Fabian 'Xaymar' Dirks 721bdaf642 project: Reapply clang-format globally 2019-04-03 00:19:01 +02:00
Michael Fabian 'Xaymar' Dirks b1d7814c64 gs-helper: Add managed obs graphics context
To further distance the code from having to do too much manually, the graphics context is now available as a managed class. All places that previously used obs_enter_graphics and obs_leave_graphics are now using the new gs::context class instead.
2019-04-03 00:16:13 +02:00
Michael Fabian 'Xaymar' Dirks 8ebdde5d36 obs-source: Fix additional compiler warnings 2019-04-02 22:58:50 +02:00
Michael Fabian 'Xaymar' Dirks ad22341ab0 source-mirror: Fix a few compiler warnings 2019-04-02 22:46:11 +02:00
Michael Fabian 'Xaymar' Dirks 4fc25cfd8d source-mirror: Don't render scene items with 0 size
libOBS will simply forget to unlock a mutex if you set the boundary size to zero, resulting in the filters dialog for that source simply getting stuck. Why video rendering can affect the audio filter dialogs is a question for another time, but it's best to just accept it and move on.
2019-04-02 22:10:23 +02:00
Michael Fabian 'Xaymar' Dirks 5738e51e73 obs-source: Also move events in move constructor and operator 2019-04-02 22:08:20 +02:00
Michael Fabian 'Xaymar' Dirks 381aa3ecd4 source-mirror: Correctly check for Audio and Video source
Previously this would not do anything correctly, as the call to obs_source_get_flags does not return anything for most sources. Instead obs_source_get_output_flags should be used to verify that we actually have a video or audio capable source to work with.
2019-04-02 20:19:40 +02:00
Michael Fabian 'Xaymar' Dirks 4d66938832 source-mirror: Replace obs_enum_* with obs::source_tracker
obs::source_tracker allows us to do more over more versions of OBS Studio, so we are able to enumerate any and all Sources, Scenes and Transitions that weren't created private. If we were to rely on libOBS for this, we would need to limit ourselves to version 23 or higher, but with this we can go very far back - as far back as the global event system was fully supported.
2019-04-02 20:19:10 +02:00
Michael Fabian 'Xaymar' Dirks ee97321319 filter-blur: Add empty entry to the Mask Source input 2019-04-02 19:58:14 +02:00
Michael Fabian 'Xaymar' Dirks ddf75d3e9f obs-audio-capture: Remove unused code 2019-04-02 19:45:10 +02:00
Michael Fabian 'Xaymar' Dirks bcf5b56c44 source-mirror: Switch to obs::source audio capture 2019-04-02 19:44:48 +02:00
Michael Fabian 'Xaymar' Dirks 8fb7d193f5 obs-source: Add audio capture and selectively listen to events
Audio capture previously needed an additional class, however there is no need for this if this can be done together with the actual obs::source object. So obs::source now has a new audio_data event that can be listened to, which handles capturing audio data if requested.

Additionally all other events are now selectively listened to, instead of permanently listening to them. This should drastically reduce the overhead of using obs::source.
2019-04-02 19:30:25 +02:00
Michael Fabian 'Xaymar' Dirks 1b7de8b6b1 util-event: Automatically clear event listeners when destructed 2019-04-02 19:11:26 +02:00
Michael Fabian 'Xaymar' Dirks 8e9e39a88e project: Remove unused content 2019-04-02 04:37:37 +02:00
Michael Fabian 'Xaymar' Dirks 21eef998ec filter-blur: Refactor to use new Blur code
This removes the ridiculous amount of hardcoded values and functions and moves everything to the more modular blur approach.

Fixes #45
Fixes #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 7c4d46c1fe gfx/blur/dual-filtering: Implement Dual Filtering Blur
Dual Filtering (or Dual Kawase) is an approximation of Gaussian Blur that can reach much higher Blur sizes at a much lower cost. However it is locked to a 2^n size, which means that currently it isn't possible to use it for blur sizes like 19, 24 and 31.

The Blur works by using the linear sampling of a GPU, combined with down- and upsampling and carefully placed sampling points. This means that there is no need for a linear optimized version of this Blur.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks b6d45ce73c gfx/blur/gaussian-linear: Refactor Linear Gaussian Blur
While Gaussian Blur is not a Blur type that really benefits much from linear sampling, it can be used for a slight quality and gpu usage reduction. However for Area and Directional Blur there is a better alternative: Dual Filtering Blur. And as with all other currently implement Linear versions of Blur, only Area and Directional Blur are supported.

This type of Gaussian Blur also has the loading hitch that exists in normal Gaussian Blur.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks fedc8e075c gfx/blur/gaussian: Refactor Gaussian Blur
Gaussian Blur is another Blur that now supports the new system, increasing the maxium Blur size to 128 and adding support for Rotational and Zoom blur. Various optimizations were done to the actual shader code which further reduced the GPU usage.

Currently the Gaussian curve is recalculated when the blur is first created, which can lead to a short hitch due to it having to search for the correct kernels. This is currently unavoidable and expected behavior until a better solution is found.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 68a8fb9224 gfx/blur/box-linear: Refactor Linear Box Blur
Box Blur is a prime candidate for Linear optimizations, and as such reducing the total necessary samples by about half. However due to the reduction in samples, only Area and Directional Blur are supported.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 8c5dc3c630 gfx/blur/box: Refactor Box Blur
Box Blur is the first to be on the new system and has received all the new features and optimizations available. The maximum Blur size has been increased to 128, Rotational and Zoom Blur are supported and a small optimization has been done to the shader.

Related: #45, #6
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 395e284a37 gfx/blur/base: Newly refactored blur code base
This is the new code base for blur effects, which is much more effective at being re-usable than the old code base. It allows for much better extendable behavior and uses an interface and factory pattern, instead of hardcoding supported features.
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 3f92e1cc89 utility: Move helper macros
As not everything in the plugin needs to use these, they have no place in the plugin header, and thus are now in utility.hpp
2019-04-02 03:50:01 +02:00
Michael Fabian 'Xaymar' Dirks 18b8cc2b5c obs-source-tracker: Use the output flags instead of flags
This fixes being able to filter by the source type (audio, video).
2019-03-01 20:38:49 +01:00
Michael Fabian 'Xaymar' Dirks f902f8f0f5 filter-blur: Actually call load in the load signal 2019-03-01 20:38:06 +01:00
Michael Fabian 'Xaymar' Dirks ba00fbb97e project: Fix even more warnings 2019-03-01 12:00:30 +01:00
Michael Fabian 'Xaymar' Dirks da6feda981 source-mirror: Remove double mutex lock 2019-03-01 11:37:24 +01:00
Michael Fabian 'Xaymar' Dirks c0f951d855 project: Fix various warnings 2019-03-01 11:33:19 +01:00
Michael Fabian 'Xaymar' Dirks 133978bbca util-math: Remove alignment from vec2a 2019-03-01 11:14:06 +01:00
Michael Fabian 'Xaymar' Dirks fa502734ce filter-blur: Allow direct rendering
Small performance optimization as this removes the extra texture render that would be done by libobs which we don't actually need as we already have a texture to render to for it.
2019-03-01 10:59:11 +01:00
Michael Fabian 'Xaymar' Dirks 1c072d67cb filter-transform: Validate source size each tick
Rendering happens with cached Geometry that is only updated when necessary, such as when the user changes settings. This optimization was necessary to reduce CPU and GPU usage as we can simply re-use the same geomtry instead of recalculating it.

However, the actual source size was never checked. That meant that when a source changed size through any means, the filter would not update the geomtry accordingly, and the result was a squished or stretched image.

With this, the source size is now checked each tick.

Fixes #48
2019-02-15 13:52:44 +01:00
Michael Fabian 'Xaymar' Dirks 3bf1333c84 project: Restructure of the file system
The number of files in the source directory was a little bit much and just made file naming more complex than it had to be. Therefore all files were moved into subdirectories where it matters.

Filters now reside in source/filters/, Sources in source/sources/, OBS Wrappers in obs/, OBS GS Wrappers in obs/gs/, Transitions will reside in source/transitions, Graphics Helpers will be in gfx/.
2019-02-11 04:03:57 +01:00
Michael Fabian 'Xaymar' Dirks 3e4930e6e0 filter-transform: Fix incorrect names for properties and options
MipGenerator.Strength was renamed to MipGenerator.Intensity, which better fits the actual intention of the property. Additionally all the mipmap generator options are now correctly named.
2019-02-11 04:03:56 +01:00
Michael Fabian 'Xaymar' Dirks 9f28144b0b filter-blur: Properly set Image(s) filter for path property 2019-02-01 19:58:05 +01:00
Michael Fabian 'Xaymar' Dirks 43136b00c4 filter-blur: Precalculate correct filter width for Gaussian
Gaussian blur used to have a hard edge which was caused by the filter width being wider than the actual sampling range, which is what is determined by the size option. In order to fix this, we have to figure out the proper filter width for a sampling range, so that we avoid any and all hard edges.

Additionally removes the old texture method entirely.

Fixes #44
2019-02-01 08:35:58 +01:00
Michael Fabian 'Xaymar' Dirks 10f7047042 util-math: Add templated gaussian function 2019-02-01 08:35:58 +01:00
Michael Fabian 'Xaymar' Dirks 3ee815b152 filter-sdf-effects: Extend shadow range to -16...16 2019-01-31 04:53:39 +01:00
Michael Fabian 'Xaymar' Dirks cfc828f0f8 source-mirror: Fix crash with audio sources and late video sources
Source Mirror would incorrectly crash if an Audio only source was selected, as it expected a video frame to be present of any size. This fixes the problem by first testing if there is any video information to render and then just catching any exception that happens during rendering.
2019-01-31 02:57:18 +01:00
Michael Fabian 'Xaymar' Dirks f5424d1aad gs-effect: Replace OBS cached file loading with custom one
The normal OBS behavior is to cache files that are loaded from disk, however this is not the behavior we want at all, as it can miss file updates as it never checks the disk for an updated file.

So instead of relying on OBS, this implements the file reading and effect creation without the cache. If a cache is necessary, it would not be the job of this class.
2019-01-31 02:30:18 +01:00
Michael Fabian 'Xaymar' Dirks 75009c617a filter-sdf-effects: Support for scaling SDF Texture Size
This allows increasing or decreasing the accuracy of the Signed Distance Field at runtime without requiring the initial source to be resized. Use case for this would be small text where the higher quality would only be noticable on the shadow and not the text itself.
2019-01-30 03:12:12 +01:00
Michael Fabian 'Xaymar' Dirks 493ef5da23 filter-sdf-effects: Move factory definitions before instance 2019-01-30 02:39:42 +01:00
Michael Fabian 'Xaymar' Dirks 7cf3e17b9b filter-sdf-effects: Fix black border and add inverse gradient shadow
Sources were rendering with a black border around them if they had a soft fade, which is due to how the shadow calculated the image sample. With the new shader code this is now fixed and the source looks like it should be. Additionally this removes the bug where enabling any shadow would cause only the texels to draw that were above the threshold.

Additionally this adds support for inverse gradients (min > max) and negative gradients for outer shadows instead of only positive gradients. This technically allows for cleaner shadows.
2019-01-30 02:38:34 +01:00
Michael Fabian 'Xaymar' Dirks 3ebbc84ee2 filter-sdf-effects: Rename Shadow (SDF) Filter (Part 2)
This finalizes the rename started in the previous commit by changing the class name and also updating the locale strings
2019-01-29 07:35:14 +01:00
Michael Fabian 'Xaymar' Dirks a7161b51e0 filter-sdf-effects: Rename Shadow (SDF) Filter (Part 1)
The nature of this Signed Distance Field based Filter is not to only draw shadows, but to also draw an outline or even glow around a source. Therefore the name "Inner/Outer Shadow (SDF)" does not fit well with the intent of the actual Filter.
2019-01-29 04:35:12 +01:00
Michael Fabian 'Xaymar' Dirks a56cbf89a9 filter-blur: Refactoring 2019-01-28 01:08:13 +01:00
Michael Fabian 'Xaymar' Dirks 4eb3197720 gfx-source-texture: Don't create two references to the same source 2019-01-28 00:47:36 +01:00
Michael Fabian 'Xaymar' Dirks c529e45cfd filter-blur: Refactoring, one-time rendering, fix mask logic
Unfortunately load is never called on filters.
2019-01-28 00:00:45 +01:00
Michael Fabian 'Xaymar' Dirks 97bf38633b gfx-source-texture: Release child source if add_active_child fails 2019-01-27 23:33:38 +01:00
Michael Fabian 'Xaymar' Dirks 10c0081f32 project: Refactoring Part 2 2019-01-27 23:33:12 +01:00
Michael Fabian 'Xaymar' Dirks 39b0600aa3 filter-blur: Update in load and create 2019-01-27 23:30:37 +01:00
Michael Fabian 'Xaymar' Dirks 8a64e360c4 filter-blur: Switch to obs-source-tracker
Completely eliminates the need for obs_emum_sources and obs_enum_scenes, thus improving backwards compatibility.
2019-01-27 23:19:09 +01:00
Michael Fabian 'Xaymar' Dirks fa4a81bb54 gfx-source-texture: Delete copy and move constructors and operators 2019-01-27 22:50:35 +01:00
Michael Fabian 'Xaymar' Dirks a15f1934b3 filter-custom-shader: Do not build for release
This feature is postponed until 0.6.0 for stability and UI/UX issues.
2019-01-27 22:44:45 +01:00
Michael Fabian 'Xaymar' Dirks 551cbb83b1 obs-source-tracker: Source Tracking Compatibility Layer
Allows for enumerating any kind of source, as long as it has a name and is not private. As obs_enum_scenes is a 23.x and above function, this class should be used instead to remain backwards compatible.
2019-01-27 22:43:49 +01:00
Michael Fabian 'Xaymar' Dirks d56c0d6f25 project: Refactoring Part 1 2019-01-25 17:55:36 +01:00
Cat Stevens b91700e74f filter-blur: delete pointer in destroy() (#42) 2019-01-25 17:40:59 +01:00
Michael Fabian 'Xaymar' Dirks 3ac7e46628 filter-shadow-sdf: Remove shadow_sdf namespace, rename shadow_sdf_instance to shadow_sdf 2019-01-25 00:55:40 +01:00
Michael Fabian 'Xaymar' Dirks 7708dd0792 filter-shadow-sdf: Refactoring, fix and optimize rendering
Fixes the m_source_texture = nullptr bug, which happened due to m_tick and m_last_tick both being 0, as no video_tick is called when the source is first created. Instead a boolean flag is now used that is reset to false on each video_tick.
2019-01-25 00:54:34 +01:00
Michael Fabian 'Xaymar' Dirks d29f5ce477 filter-transform: Transform to transform, ...Addon to ..._factory 2019-01-25 00:38:20 +01:00
Michael Fabian 'Xaymar' Dirks 2aa4595bd3 filter-displacement: Rename Displacement to displacement, ...Addon to ..._factory 2019-01-25 00:38:01 +01:00
Michael Fabian 'Xaymar' Dirks 7a61006d2b source-mirror: Rename Mirror to mirror, ...Addon to ..._factory 2019-01-25 00:36:54 +01:00
Michael Fabian 'Xaymar' Dirks a37d9bbb59 filter-shadow-sdf: Actually delete instances in destroy()
This fixes a memory leak discovered by @catb0t.

Related #33
2019-01-25 00:31:50 +01:00
Michael Fabian 'Xaymar' Dirks ddfb08f39e filter-displacement: Update file logic and rendering
This replaces the use of gs_texture_t* with gs::texture, further improving stability. Additionally some of the useless checks were replaced or reduced.
2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks 0bdf8e3bba filter-displacement: Use gs::effect instead of gs_effect_t*
The managed gs::effect class handles all acquire and release calls for us. Also slightly simplifies the video_render logic.
2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks fedb6e3259 filter-displacement: Further refactoring 2019-01-25 00:28:06 +01:00
Michael Fabian 'Xaymar' Dirks c1995c03a9 filter-displacement: Refactor to match new class structure 2019-01-25 00:28:05 +01:00
Cat Stevens c749f5dd62 obs-audio-capture.hpp: missing memory include 2019-01-24 23:30:42 +01:00
Michael Fabian 'Xaymar' Dirks 160ad3b5a9 locale: Replace file filters with file types
The filters are always the same for every language and should not be translated, instead only the file type should be translated. This way bad translations will not affect the options that the user can select.
2019-01-24 20:34:28 +01:00
Michael Fabian 'Xaymar' Dirks 0ae120835a filter-transform: Optimize rendering, fix bad property names
The Transform filter will now no longer render the child source more than once per tick(), resulting in an overall speed up for heavy sources. This also applies to mipmapping and shape rendering. Any other calls to video_render will instead just use the cached texture.

Additionally the crash on exit has been fixed which was caused by strings.hpp containing static const char*s and using these directly in obs calls. Instead we now use #define for those property names
2019-01-24 20:20:34 +01:00
Michael Fabian 'Xaymar' Dirks e28334d27b util-memory: Fix alligned_alloc for MSVC
Microsofts _aligned_malloc has size and alignment switched around, which causes an unwanted exception.
2019-01-24 20:18:28 +01:00
Michael Fabian 'Xaymar' Dirks b3c2845d15 filter-transform: Refactoring and formatting 2019-01-24 15:57:33 +01:00
Michael Fabian 'Xaymar' Dirks e4a534fbfe plugin: Remove legacy instance references
The modern system is a self-registering system using initializers and finalizers
2019-01-24 14:26:08 +01:00
Michael Fabian 'Xaymar' Dirks 406326b378 util-math: Add 16-byte aligned version of vec2 2019-01-24 05:14:17 +01:00
Michael Fabian 'Xaymar' Dirks 98baa0d98b filter-transform: Fix order of functions 2019-01-24 04:35:22 +01:00
Michael Fabian 'Xaymar' Dirks ff6176d7bc filter-transform: Destructor comes before Constructors 2019-01-24 04:33:56 +01:00
Michael Fabian 'Xaymar' Dirks c1441e72c0 filter-transform: Refactor to match source-mirror structure 2019-01-24 04:32:14 +01:00
Michael Fabian 'Xaymar' Dirks 9d55013ec2 source-mirror: Improve rendering and add new rescaling options
Rendering will now use a cached version of the mirrored source in order to reduce rendering cost drastically for heavy sources or scenes. Additionally rescaling now uses the internal scene instead of being a custom implementation, allowing for some new things.

Rescaling now has a new option: Bounds Type! This option allows control over just how a source is scaled, by default it is set to Stretch, but there are other options that can keep the aspect ratio of the mirrored source in tact.

Additionally the ScalingMethod struct has been replaced with obs_scale_type, which means that Bilinear Low Resolution is now no longer an option.

Implements #35
2019-01-24 04:28:11 +01:00
Michael Fabian 'Xaymar' Dirks 82f64d16eb source-mirror: Refactoring and partially revert 4bb32a71bc
Initialization happens in the constructor again, as using a delayed initialization only caused update() to be slower.

Additionally refactored some variable names to make more sense.
2019-01-24 01:12:48 +01:00
Michael Fabian 'Xaymar' Dirks 144323bec3 source-mirror: Revert thread name from c5e02af178 2019-01-24 01:00:38 +01:00
Michael Fabian 'Xaymar' Dirks 6b7ef2d3ed gfx-source-texture: Allocate a render target in constructor
Can't really render without one.
2019-01-24 00:12:42 +01:00
Michael Fabian 'Xaymar' Dirks bf35b54957 gs-rendertarget: Don't ignore failed creation of render target 2019-01-24 00:08:26 +01:00
Michael Fabian 'Xaymar' Dirks 04ddf76920 source-mirror: Release reference in modified_properties callback
Fixes the problem where additional references to other sources would appear if properties are opened or modified.

Fixes #34
2019-01-23 23:23:49 +01:00
Michael Fabian 'Xaymar' Dirks 4bb32a71bc source-mirror: Use load() and update() for initialization
load() is guaranteed to happen after all sources have been created and no earlier, and we can use update() to guarantee that we don't need to duplicate our initialization code in case we go back to initializing earlier than load().
2019-01-23 22:25:48 +01:00
Michael Fabian 'Xaymar' Dirks b2b3f5fde8 source-mirror: Add empty list entry to select no source 2019-01-23 22:04:25 +01:00
Michael Fabian 'Xaymar' Dirks c5e02af178 source-mirror: Remove unused references, set scene and thread name 2019-01-23 22:03:47 +01:00
Michael Fabian 'Xaymar' Dirks 73b96b8900 source-mirror: Fix various issues, reformat, redesign
This fixes the multi-reference issue that caused Source Mirror to keep a permanent reference to a source that should have been released.

The obs::audio_capture was also updated to now use the util::event code for improved callback support. There are a bunch of new additional checks in the acquire_input function that prevent bad references from happening, and is also now self-cleaning through the use of obs::source
2019-01-23 21:06:05 +01:00
Michael Fabian 'Xaymar' Dirks 911b8a1cf4 obs-audio-capture: Use util::event and delete move and copy operator
By using util::event a single obs::audio_capture can now have multiple callbacks for the same data, without requiring additional obs::audio_capture to be present. Additionally it allows us to stop listening on an obs callback if there are no actual listeners, and start listening as soon as there is a listener.

Move and Copy constructors are currently not supported by this class and thus have been marked deleted. Internally also now using obs::source to keep track of the used source.
2019-01-23 20:06:30 +01:00
Michael Fabian 'Xaymar' Dirks 52af973014 util-event: Listen, Silence callbacks and other operators 2019-01-23 20:02:50 +01:00
Michael Fabian 'Xaymar' Dirks 9848c5aa28 obs-source: Implement copy and move constructors and operators
There was no proper implementation for all copy and move constructors and operators before, which meant that occasionally the default behavior took over. This is not what we want, as the default behavior doesn't deal well with reference counted pointers.

Related: #32, #33
2019-01-23 18:49:20 +01:00
Michael Fabian 'Xaymar' Dirks f910312a2d gfx-effect-source: Make destructor virtual 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks 5a54a67946 project: Remove unused parameters and fix additional warnings 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks f0fa36a19e source-mirror: Fix format string and remove unused parameters 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks 52f4e4641f project: Additional #ifdef _MSC_VER checks 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks f41bd2c7c1 source-mirror: Remove unnecessary register keyword
This keyword also no longer exists in C++17
2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks ec544bddb3 gs-texture: Move ENABLE_BITMAPS_OPERATORS to global scope 2019-01-23 02:26:32 +01:00
Michael Fabian 'Xaymar' Dirks e0e2d9fe80 project: Improve Linux support (#27 and #13)
While Linux was not an original goal of the project, it should still be supported out of the box. Therefore a number of changes are contained in this changeset:

- All C++ .h files were renamed to .hpp.
- All C includes (<....h>) were replaced with C++ includes (<c...>) and missing includes were added.
- std::memset and std::memcpy was replaced with memset and memcpy.
- All anonymous structs were removed where necessary.
- `extern "C"` was removed where it wasn't needed.
- #pragma warning was placed behind an #ifdef _MSC_VER
- The macros for `min`, `max` and `clamp` were removed as they were not used.
- `-fpedantic` was added to the GCC flags for bitmask support.
- `gs::rendertarget_op` is now declared before use.
- std::exception(const char*) was replaced with std::runtime_error(const char*).
- Added aligned_alloc and aligned_free macros for GCC and MSVC support.
- Replaced use of `sprintf_s` with `snprintf`.
- Placed additional guards around windows only code.

Additonally some changes were made that do not affect Linux:
- `NOMINMAX` and `NOINOUT` were removed.

Fixes: #27
Fixes: #13
2019-01-14 22:31:35 +01:00
Michael Fabian 'Xaymar' Dirks ca1e26fd20 filter-shadow-sdf: Fix crash when adding source
I'm not sure how this one passed by me. Or how this worked, as I have screenshots and videos of it working before applying this fix.
2018-12-23 23:48:08 +01:00
Michael Fabian 'Xaymar' Dirks 95fdcff3a9 cmake: Reworked build system for Installers and Archives 2018-12-23 21:15:05 +01:00
Michael Fabian 'Xaymar' Dirks c94a3fa11f util-math: Use C++ math header 2018-12-23 19:57:07 +01:00
Michael Fabian 'Xaymar' Dirks 3952c33c60 filter-blur: Add Directional Blur (Motion Blur) and Step Scaling
Directional Blur (also known as Motion Blur in some art software) enables full control over the direction the passes are applied in, which can further be combined with the scaling option. With this very simple blur effects can have a massively bigger influence.

Step Scaling allows for improved control over individual Blur passes and can be combined with Directional Blur to imitate certain effects. It also allows smaller Blur sizes to cover a larger area, although with a drastic loss in final quality. For example, if someone is streaming at 720p and wants to have their dynamic 2160p background blurry to a very high degree, this option would allow that at next to no quality loss in the final stream. The actual values that need to be used vary for each source and encoder however, so they will have to be chosen carefully.
2018-12-23 19:54:57 +01:00
Michael Fabian 'Xaymar' Dirks ad97eeebe7 filter-blur: Fix translucent source rendering and modernize code
Translucent sources previously rendered with wrong alpha, which caused sources to look different than they should. With the new code, this is no longer the case and instead now renders the source correctly.

Additionally the modernized code should reduce any problems with rendering by reducing the amount of duplicated manually written code and instead using classes.
2018-12-23 18:27:24 +01:00
Michael Fabian 'Xaymar' Dirks fd14fd62a6 gs-rendertarget: Add function to get texture directly 2018-12-23 17:56:52 +01:00
Michael Fabian 'Xaymar' Dirks a6f9451654 filter-blur: Switch to Kernel Array instead of Kernel Texture
This speeds up Gaussian Blur and Linear Gaussian Blur drastically reduces time spent reading textures and instead uses existing registers - maximizing time spent reading the actual image texture.

See Also: #21 Blur Quality
2018-12-23 02:00:30 +01:00
Michael Fabian 'Xaymar' Dirks 92c4b54177 filter-blur: Add Linear Gaussian Blur
Similar to Linear Box Blur, this version of Gaussian Blur reduces the total number of sample by up to n. This results in a total sample count (per pass) of O(n+1) for even radii and O(n+2) for odd radii. The quality sacrificed to do this is higher this time, though careful adjustment of the halfTexelDelta value can bring it much closer to normal Gaussian Blur. The current offset however had no noticable effects on visual quality.

See Also: #21 Blur Quality
2018-12-22 22:54:30 +01:00
Michael Fabian 'Xaymar' Dirks 93df9b50b8 filter-blur: Add Linear Box Blur and combine all effects
Linear Box Blur abuses the fact that with Linear Sampling we can sample up to four adjacent texels at the same time and get a correct result for Box Blur back. Using this the total number of sample for Box Blur is reduced by n, making the total either n+1 (Even Radius) or n (Odd Radius).

Additionally all blur effect files have been merged into a single blur.effect file to reduce the time required to change a single parameter name. New blur effects should be added as a new technique instead of as a new effect file.

See Also: #21 Blur Quality
2018-12-22 22:08:55 +01:00
Michael Fabian 'Xaymar' Dirks 0c92f3dbf5 filter-shadow-sdf: Inner/Outer shadow based on signed distance fields
Adds Inner/Outer Shadows for dynamic sources based on signed distance field generation. This is fast, but does add a bit of latency when it comes to updates - which means that moving objects will leave a trail before the generator has a chance to update.

Fixes #3
2018-11-08 13:52:43 +01:00
Michael Fabian 'Xaymar' Dirks c0cb20300b filter-blur: Rename factory and instance to blur_* 2018-11-08 11:16:55 +01:00
Michael Fabian 'Xaymar' Dirks 1aa42c58f0 plugin: Fix double plugin name in log line 2018-11-08 11:16:33 +01:00
Michael Fabian 'Xaymar' Dirks 844fcee0bd source-mirror: Additional protections against crashes on impossible behavior 2018-11-08 08:17:04 +01:00
Michael Fabian 'Xaymar' Dirks ac06ff48bc source-mirror: Fix crash caused by source renames and forced destroy of a source 2018-11-08 08:08:38 +01:00
Michael Fabian 'Xaymar' Dirks 9ffe53754b obs-source: Add support for all signals on a source 2018-11-08 08:08:06 +01:00
Michael Fabian 'Xaymar' Dirks 79daeb5a75 util-event: Template event handler class 2018-11-08 08:07:49 +01:00
Michael Fabian 'Xaymar' Dirks e4a5b34745 gfx-source-texture: Check for valid child and parent 2018-11-08 04:26:01 +01:00
Michael Fabian 'Xaymar' Dirks 6d25342302 obs-source: Check for early source destruction
This should prevent problems where the source is destroyed but a pointer is still around to it.
2018-11-08 04:25:21 +01:00
Michael Fabian 'Xaymar' Dirks 11fc32f935 source-mirror: Fix crash with audio mirroring
Fixes #23
2018-11-07 15:29:24 +01:00
Michael Fabian 'Xaymar' Dirks b87ca70796 project: Formatting 2018-11-07 15:24:25 +01:00
Michael Fabian 'Xaymar' Dirks 16f55ca583 source-mirror: Fix crash with audio data on obs_shutdown (#22)
Due to the lack of checking aud and aoi, a rare race condition crash can be observed with audio mirroring enabled on closing OBS. In this case, aoi is used even though it is null, causing OBS to crash instead of closing normally.

Fixes #22
2018-11-07 14:44:07 +01:00
Michael Fabian 'Xaymar' Dirks b5339b4429 source-mirror: Add support for scenes and fix last commit 2018-11-07 14:44:07 +01:00
Michael Fabian 'Xaymar' Dirks c084a0bfd0 source-mirror: Use a private scene source for rendering 2018-11-07 14:44:07 +01:00
Michael Fabian 'Xaymar' Dirks 0be79842e7 filter-transform: Fix various warnings 2018-11-07 14:44:07 +01:00
Michael Fabian 'Xaymar' Dirks eef9f0697d gfx-effect-source: Fix various warnings 2018-11-07 14:44:07 +01:00