Commit Graph

435 Commits (a8aadff2f505cbb11387bf0ff14be4e2530ef49e)

Author SHA1 Message Date
Jim 2eca4d80b6
Merge pull request #2233 from VodBox/missing-files-dialog
libobs + UI: Add Missing Files API & Dialog
2021-01-31 08:02:16 -08:00
jpark37 66259560e0 libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.

A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.

Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.

Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.

Update obs_source_draw to use linear SRGB as needed.

Update render_filter_tex to use linear SRGB as needed.

Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.

Add SRGB helpers for vec4 struct.

Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-21 07:42:13 -08:00
VodBox fb95e1d1e9 libobs: Add missing file API to sources 2021-01-17 10:31:58 +13:00
Richard Stanway d0cbc83da2 libobs: Avoid unnecessary mallocs in audio processing 2021-01-02 14:53:19 +01:00
Colin Edwards 923f06bfa6 decklink: Add ability to ingest/embed cea 708 captions
(This commit also modifies libobs, UI)
2020-11-01 22:28:49 -08:00
Clayton Groeneveld 2b50263d5c UI, libobs: Add ability to copy/paste single filter 2020-10-15 10:14:22 -07:00
Richard Stanway c8f7a4563d libobs: Check data validity for media sources 2020-08-29 02:42:03 +02:00
Jim e36b9c309d
Merge pull request #3216 from Xaymar/pr-fix-obs_source_enum_full_tree
libobs: Call enum_all_sources in check for enum_all_sources
2020-08-22 15:09:42 -07:00
Valentin 4508cb03b5 libobs: Fix deferred update sometimes using stale data
Currently we use a bool flag to signal the video thread that it should
call obs_source_deferred_update. This does not work correctly when the
update callback is slow and the update is triggered faster than the
callback can complete.

For example:
* the settings are set to state A
* defer_update is set
* obs_source_deferred_update is called and enters into the callback
* the callback starts making use of the settings in state A
* the settings are set to state B
* defer_update stays set
* the callback finishes
* defer_update is set to false

Now defer_update is false but the callback has only observed settings in
state A but not B.

This commit fixes this bug by keeping an update counter. If the counter
has changed while we were in the callback we know that we need to update
again.

The counter is atomic. The current version uses a plain bool which is a
data race as the value is written and read in parallel.
2020-08-04 09:28:55 +02:00
jp9000 d117908440 libobs: Add func to set async video frame immediately
Allows the ability to directly override the current async frame
immediately.
2020-07-29 13:59:49 -07:00
Michael Fabian 'Xaymar' Dirks 127dce6bf6 libobs: Call enum_all_sources in check for enum_all_sources
Fixes a crash caused by checking for enum_all_sources and then calling
enum_active_sources instead of enum_all_sources. enum_active_sources is
not required for sources that specify enum_all_sources.
2020-07-27 01:53:58 +02:00
Richard Stanway 4f7767111a libobs: Update async texture when showing preloaded video
The previous preloaded video behavior updated the texture on preload
rather than when the video was shown, during which time the texture may
have been modified by other processes, resulting in the wrong frame
being displayed.
2020-07-23 23:54:10 +02:00
Jim 8b00f7d341
Merge pull request #3085 from eric/fix-audio-on-timestamp-jump
libobs: Reset audio data on timestamp jump
2020-07-10 17:35:44 -07:00
Jim 76c42215d6
Merge pull request #2755 from exeldro/keep_filters
libobs: Don't check filter compatibility on not loaded sources
2020-06-24 14:13:48 -07:00
Eric Lindvall f79f816b72 libobs: Reset audio data on timestamp jump
To prevent issues in audio mixing make sure the audio data is also cleared
when audio timing is reset.
2020-06-20 14:55:31 -07:00
Jim 665180350d
Merge pull request #2657 from hselasky/improvement
libobs: Implement and use better scaling function for 64-bit integers
2020-05-21 18:07:53 -07:00
Exeldro 6a567eded6 libobs: Don't check filter compatibility on not loaded sources 2020-04-19 09:11:32 +02:00
Exeldro 74b9ae07f3 libobs: Don't allow duplicating scene sources 2020-04-17 12:40:25 +02:00
Hans Petter Selasky 0e4ea14ba1 libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting
to uint64_t, may lead to numerical overflows. Sweep the code and use
util_mul_div64() where applicable.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>
2020-04-05 20:27:28 +02:00
jpark37 b12ab46e62 libobs: Fix size mismatch warning
memcpy unlikely to exceed 4 GB, but just make VS happy.
2020-03-19 11:22:15 -07:00
jp9000 cf0a5e5c97 libobs: Fix audio not playing back with audio lines
The fix for the race condition that was made in 432017b2c also broke
audio lines.  This fixes audio lines and moves the fix to just the case
where it actually applied.
2020-03-15 04:44:47 -07:00
jp9000 360af79db2 Revert "libobs: Add extra reference when source is displayed"
This reverts commit 9cff2ae6bb.
2020-03-14 10:54:37 -07:00
jp9000 7d491c7981 Revert "libobs: Only manipulate input source ref counts"
This reverts commit 6d5bb8b244.
2020-03-14 10:54:37 -07:00
jp9000 432017b2c9 libobs: Don't render audio if context not initialized
Fixes a race where the audio subsystem could call audio render callbacks
before the source was fully initialized.
2020-03-10 07:13:58 -07:00
jp9000 19068c2960 libobs: Handle removed plugins for versioned sources
When someone adds a source and the plugin is removed for whatever
reason, it would cause a crash with the new source versioning system.
This fixes that by ensuring the unversioned id is also backed up along
with the normal id.
2020-03-09 16:53:44 -07:00
jp9000 b2302902a3 libobs: Fix source type versioning system
(This also modifies image-source, obs-text, text-freetype2, and UI)

This improves source definition versioning.  To do this, it now stores
two identifier names.  One "unversioned" which is the original name, and
one "versioned" with the version number appended.

This fixes both backward compatibility with older OBS versions, and
fixes the inability to use "add existing" in OBS itself on sources
created from older version definitions.
2020-03-09 06:12:22 -07:00
jpark37 6d5bb8b244 libobs: Only manipulate input source ref counts
Filters can be hidden without being shown, which can unbalance the ref
count and destroys them prematurely. We really only care about input
sources having a chance to clean up from the render thread from the hide
handler, Windows 10 window capture specifically.
2020-03-06 01:14:38 -08:00
jp9000 b9d6675e2c libobs: Add ability to rotate async sources 2020-03-01 03:39:54 -08:00
jpark37 9cff2ae6bb libobs: Add extra reference when source is displayed
This provides a chance to clean up resources on the graphics thread in
the hide callback, which Windows Graphics Capture requires.
2020-02-22 21:02:33 -08:00
Clayton Groeneveld f9ccea5235 libobs: Add media control support to backend 2020-01-30 21:40:20 -08:00
jp9000 2d35f863da libobs: Add manual transition "torque" support
Allows the ability for manual transitioning to smoothly flow
(interpolate) to the intended transition point over a short period of
time rather than simply setting a hard transition point number.  Doing
this allows manual transitioning to occur more smoothly, and in a more
visually pleasant way.
2019-12-27 16:38:20 -08:00
jp9000 c1522019e0 libobs: Do not include unrelated flags in filter check
Closes obsproject/obs-studio#2224
2019-12-10 09:22:18 -08:00
Clayton Groeneveld 82ffcdc827 UI: Add source icons 2019-11-24 20:50:42 -08:00
VodBox e8c1ec4035 libobs: Send activate and show signals to filters 2019-11-07 06:19:34 -08:00
Exeldro e5ae662e7a libobs: Export obs_group_from_source
Export obs_group_from_source to allow it to be used externally
2019-10-15 09:21:21 -07:00
jp9000 65c7e2d19d libobs: Add API to get last OBS version of a source
Allows the ability to change the behavior of a source depending on the
previous OBS version.
2019-09-20 00:13:51 -07:00
jp9000 33c09d91c2 libobs: Add funcs to determine whether audio active
Adds functions to allow sources to inform the UI whether the audio is
currently active or not.  Allows the ability to turn on/off the items in
the mixer.
2019-09-19 23:37:29 -07:00
jp9000 abaed69627 libobs: Check to swap BGRX/BGRA in async filters
If for whatever reason the format is swapped between BGRA/BGRX in an
async filter, swap the texture to compensate for that.  This allows
plugins to change the format if necessary.
2019-09-17 13:51:40 -07:00
Jim 1523acd726
Merge pull request #2055 from jpark37/video-warnings
Fix video format warnings
2019-08-31 21:16:23 -07:00
jp9000 23111c317f libobs: Remove redundant function param and for loop
Originally when the audio_submix function was created, it used all mixer
tracks, but at a certain point that was removed because it can only use
the first track, so some older code was unintentionally left over,
causing the same code to be executed 6 times mistakenly.  This cleans
that up by removing the unnecessary function parameter and for loop.
2019-08-31 01:15:19 -07:00
jpark37 42bf026a49 libobs: Fix video warnings 2019-08-30 22:13:03 -07:00
jp9000 0845844e5d libobs: Insert sources to linked lists after creation
This fixes a race condition where the audio/video backends/threads may
start using sources before their obs_source_info::create function has
been called.
2019-08-25 19:19:57 -07:00
jp9000 2557ffce7e libobs: Add missing static to function
This function is not used outside of the source file, so make it static.
2019-08-25 19:19:57 -07:00
jp9000 2c3ea4af55 libobs: Fix null potential pointer dereference
When a source type has been removed (i.e. its plugin has been removed)
info can be null, which is permitted.
2019-08-25 19:19:57 -07:00
jp9000 73704f20db libobs: Add audio lines
Adds the "audio_line" internal source type as a bare source type for the
sole purpose of outputting audio, and the obs_source_info::audio_mix
callback which allows mixing of those audio lines, which is then treated
as normal audio for the source.  Audio line objects should be added as
sub-sources when multiple audio lines from a single source are needed,
then mixed together with the audio_mix callback.

The difference between the new obs_source_info::audio_mix callback and
obs_source_info::audio_render is that obs_source_info::audio_mix (along
with the audio_line source) are only one track, and it outputs audio to
the source automatically via obs_source_output_audio() when the call
completes.  This allows the mixed audio to be treated like a normal
source's audio, in that you can filter it, change its volume, or monitor
it.

This change was necessary because the CEF (used with the browser source)
outputs multiple audio streams at once to a single browser source, so
it's the program's responsibility to mix those streams together itself.
2019-08-21 15:19:19 -07:00
SoraYuki 21135f1483 libobs: Merge obs_source_process_filter_(tech_)?end functions 2019-08-14 14:03:34 +08:00
jpark37 3d6f5c8ad6 libobs: Add YUV alpha formats
This will allow YUV alpha formats to be converted to RGBA on the GPU.
2019-08-11 11:26:22 -07:00
jpark37 bdd8d64053 libobs: Separate textures for YUV input
The shaders to unpack YUV information from the same texture were rather
complicated. Breaking them up into separate textures makes the shaders
much simpler, and we can remove the PRECISION_OFFSET hack.

Performance also gets a nice boost on Intel for planar textures.

Intel GPA, SetStablePowerState, Intel HD Graphics 530, 1920x1080

UYVY: 473 us -> 457 us
YUY2: 492 us -> 422 us
YVYU: 491 us -> 441 us
I420: 1637 us -> 505 us
I422: 1644 us -> 482 us
I444: 1653 us -> 504 us
NV12: 1656 us -> 369 us
Y800 (limited): 270 us -> 277 us
Y800 (full): 263 us -> 289 us
RGB (limited): 341 us -> 411 us
BGR3 (limited): 512 us -> 509 us
BGR3 (full): 527 us -> 534 us
2019-08-09 21:14:29 -07:00
jpark37 b0e7c5d0d3 libobs: Fix stale format in async frame cache
The video format is not updated if switching between cache-compatible
formats, e.g. YUY2 and YVYU, resulting in the wrong conversion technique
being used. This change ensures the format is always up-to-date.
2019-08-07 06:47:27 -07:00
James Park 37f663a789 libobs: obs-ffmpeg: win-dshow: Planar 4:2:2 video
This format has been seen when using FFmpeg MJPEG decompression.
2019-07-25 20:11:37 -07:00