0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

417 Commits

Author SHA1 Message Date
Exeldro
6a567eded6 libobs: Don't check filter compatibility on not loaded sources 2020-04-19 09:11:32 +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
Jim
ffcfe4c9d9
Merge pull request #1951 from jpark37/audio-buffering
Fix audio buffering for devices like GV-USB2
2019-07-20 17:05:27 -07:00
Michael Fabian 'Xaymar' Dirks
3f6bbe2d49 libobs: Call both get_defaults and get_defaults2
Unlike get_properties, there is not reason to not call get_defaults if it is
given in addition to get_defaults2. Additonally this fixes the bug with
'init_encoder' which would only ever call get_defaults, resulting in broken
encoders if those used get_defaults2.
2019-07-13 00:49:18 +02:00
James Park
da87f08da4 libobs: Buffer-smoothing enhancements
If an audio source does not provide enough data at a steady pace, the
timestamp update does not happen, and buffering increases until it
maxes out. To counteract this, update the timestamp anyway.

Another issue for decoupled audio sources is that timing is not
adjusted for divergence from system time. Making this adjustment is
better for timing stability.

5+ hours of stable audio without any buffering on my GV-USB2 where it
used to add 21ms every 5 mintues or so.

Fixes https://obsproject.com/mantis/view.php?id=1269
2019-07-05 09:13:18 -07:00
jpark37
2ef25ceb85 libobs: Fix format selection
Fix ternary test to use BGRX render targets for YUV to RGB
conversions. The previous behavior may have been fine though since
the shaders fill the alpha channel with 1.0 anyway.
2019-06-27 08:57:41 -05:00
jp9000
f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
James Park
aa22b61e3e libobs: Full-screen triangle format conversions
The cache coherency of rasterization for full-screen passes is better
using an oversized triangle that is clipped rather than two triangles.
Traversal order of rasterization is GPU-specific, but will almost
certainly be better using an undivided primitive.

A smaller benefit is that quads along the diagonal are not evaluated
multiple times, but that's minor in comparison.

Redo format shaders to bypass vertex buffer, and input layout. Add
global shader bool "obs_glsl_compile" to make API-specific decisions,
i.e. handle upside-down UVs. gl_ortho is not needed for format
conversion because the vertex shader does not use ViewProj anymore.

This can be applied to more situations, but start small first.

Testbed full screen passes, Intel HD Graphics 530:
RGBA -> UYVX: 467 -> 439 us, ~6% savings
UYVX -> uv: 295 -> 239 us, ~19% savings
2019-06-18 22:29:07 -07:00
Jim
fafda14963
Merge pull request #1906 from jpark37/bgr-three
libobs: linux-v412: obs-ffmpeg: Add packed BGR3 video support
2019-06-15 16:40:44 -07:00
James Park
e72eb39e47 libobs: Disable blending when converting sources
This fixes the issue where limited-range RGB sources were being
composited with dirty render targets.
2019-06-12 22:23:51 -07:00
James Park
614025742b libobs: linux-v412: obs-ffmpeg: Add packed BGR3 video support
Someone mentioned this format preserves the most quality for a
particular capture card using V4L2.
2019-05-30 06:05:53 -07:00
James Park
ab8e895b12 libobs: Remove unreachable YUV decode paths
A previous refactoring to make DrawMatrix unnecessary has left behind
unreachable YUV conversions. Even if this code was somehow reachable,
DrawMatrix for YUV -> RGB doesn't exist anymore, so they would render
incorrectly anyway.
2019-05-19 21:27:18 -07:00
VodBox
52235ba86d libobs: Add transition and showing counter functions
This commit adds a function to forcefully stop a transition, and to
increment/decrement the showing counter for a source with the MAIN_VIEW
type.

These functions are needed for the transition previews to work as
intended.
2019-05-12 21:13:21 -07:00
James Park
f03b4dc965 libobs: Restore casts to fix Clang warnings
Clang doesn't like it if you convert T** to const T* const* without
casting even though it should be safe. Might be a C language thing.
2019-05-09 21:59:38 -07:00
James Park
a86710ec5b libobs: Support limited color range for RGB/Y800 sources
libobs: Add support for limited to full color range conversions when
using RGB or Y800 formats, and move RGB converison for Y800 formats to
the GPU.

decklink: Stop hiding color space/range properties for RGB formats, and
remove "YUV" from "YUV Color Space" and "YUV Color Range".

win-dshow: Remove "YUV" from "YUV Color Space" and "YUV Color Range".

UI: Remove "YUV" from "YUV Color Space" and "YUV Color Range".
2019-04-25 15:13:05 -07:00
jp9000
8d125dc01d libobs: Add better default source color range handling
Fixes handling of the `obs_source_frame::full_range` member variable,
which is often set to false by default by many plugins even when using
RGB, which would cause RGB to be marked as "partial range".  This change
is crucial for when partial range RBG support is implemented.

Adds `obs_source_frame2` structure that replaces the `full_range` member
variable with a `range` variable, which uses the `video_range_type` enum
to allow handling default range values.  This member variable treats
VIDEO_RANGE_DEFAULT as full range if the format is RGB, and partial
range if the format is YUV.

Also adds `obs_source_output_video2` and `obs_source_preload_video2`
functions which use the `obs_source_frame2` structure instead of the
`obs_source_frame` structure.

When using the original `obs_source_frame`, `obs_source_output_video`,
and `obs_source_preload_video` functions, RGB will always be full range
by default for backward compatibility purposes.
2019-04-25 15:12:08 -07:00
jp9000
f109d1c2bf Revert "libobs: libobs-d3d11: obs-filters: No excess alpha"
This reverts commit d91bd327d7, which
broke alpha with sources, scenes, and filter, causing them all to become
opaque unintentionally.
2019-04-25 08:36:41 -07:00
Jim
f1399b6d18
Merge pull request #1765 from jpark37/blend-alpha
libobs: libobs-d3d11: Fix blend alpha overflow
2019-04-14 00:22:20 -07:00
James Park
69c215345a libobs: Simplify YUV conversion
Currently several shaders need "DrawMatrix" techniques to support the
possibility that the input texture is a "YUV" format. Also, "DrawMatrix"
is overloaded for translation in both directions when it is written for
RGB to "YUV" only.

A cleaner solution is to handle "YUV" to RGB up-front as part of format
conversion, and ensure only RGB inputs reach the other shaders. This is
necessary to someday perform correct scale filtering without the cost of
redundant "YUV" conversions per texture tap.

A necessary prerequisite for this is to add conversion support for
VIDEO_FORMAT_I444, and that is now in place. There was already a hack in
place to cover VIDEO_FORMAT_Y800. All other "YUV" formats already have
conversion functions.

"DrawMatrix" has been removed from shaders that only supported "YUV" to
RGB conversions. It still exists in shaders that perform RGB to "YUV"
conversions, and the implementations have been sanitized accordingly.
2019-04-11 23:00:03 -07:00
James Park
21f4dd63d4 libobs: UI: Use graphics debug markers
Add D3D/GL debug markers to make RenderDoc captures easier to tranverse.

Also add obs_source_get_name_no_null() to avoid boilerplate for safe
string formatting.

Closes obsproject/obs-studio#1799
2019-04-08 02:05:37 -07:00