Commit Graph

252 Commits (master)

Author SHA1 Message Date
jpark37 37389ff243 libobs: Avoid display clear workaround if possible 2022-08-27 16:32:50 -07:00
jp9000 07df6548fd libobs: Increase texture encode buffering
Seems to solve lag encountered on the new AMF encoder. The SubmitInput
call in the AMF encoder can occasionally stall for quite a long amount
of time, but most take microseconds, so we can compensate by simply
increasing the buffering (3 to 10 textures).
2022-08-27 14:29:28 -07:00
jp9000 6abf89af21 Revert "libobs: Correctly set texture size"
This reverts commit 90a409fe58.

Reverts #7077 for now. This really shouldn't be done so close to
release. This crash technically only happens under very niche scenarios,
and the fix seems to have some other potential issues. Prematurely
merged by Jim.
2022-08-18 11:04:11 -07:00
tududweb 90a409fe58 libobs: Correctly set texture size
Correctly set texture size according to the frame to be rendered this time.
Fixes the mismatch between frame and texture when async-delay-filter on.
2022-08-18 03:43:22 -07:00
Chip Bradford eb1cc8d076 libobs: Fix gpu thread termination when additional video mixes are added 2022-08-13 01:33:34 -07:00
Chip Bradford 7e39ee291c libobs: Add support for multiple video mixes
Split render_texture and derived fields in obs_core_video into new
obs_core_video_mix struct. Add new APIs to add additional obs_view to the render loop, each with a separate render_texture / obs_core_video_mix.
2022-07-31 15:35:36 -07:00
jpark37 92d1ca41cc libobs: Fix warnings about type usage 2022-07-11 22:07:10 -07:00
tt2468 bb55cfbc05 libobs: Improve exponential backoff functionality
- Changes the default base exponent value to 1.5 from 2.0
- Applies a random skew of +-0.05 to the exponent to lessen the
"water hammer" effect caused by predictable backoff techniques
- Fixes the logging associated with exponential backoff to log the
true reconnect delay value
2022-06-25 17:06:00 -07:00
jpark37 d233065d60 libobs: Default 10-bit video to sRGB instead of PQ
Matches how VLC operates. HDR is only in effect with proper metadata.
2022-05-17 02:46:52 -07:00
jpark37 2a0d8d1c9c libobs: Add support for reading I420 PQ
Not normally a valid combination, but Xbox writes 8-bit HDR videos.
2022-05-08 14:12:41 -07:00
Jim 952988d9ec
Merge pull request #6231 from mvji/prores_pix_fmt
Add support for GPU conversion of YUV422P10LE, YUV444P12LE, YUVA444P12LE
2022-05-04 02:01:27 -07:00
jp9000 f482111791 libobs: Add ability to configure audio buffering latency
Allows a frontend the ability to set the maximum audio buffering
latency, and specify whether that audio buffering is either fixed (to
the maximum audio buffering latency), or dynamically increasing from 0.

This will be useful if the user wishes to output audio to devices or
through a virtual audio device at a guaranteed minimal latency.
2022-04-24 08:44:33 -07:00
jp9000 e3bdb4ca7b libobs: Add ability to use fixed audio buffering
This is in anticipation to adding low audio latency mode, will cause
audio buffering to be fixed rather than dynamically increasing. Having
fixed audio buffering means that audio latency always stays the same
rather than dynamically increasing.
2022-04-24 07:59:10 -07:00
mvji d3a8ef7128 libobs: Add support for YUV422P10LE, YUV444P12LE, YUVA444P12LE 2022-04-19 19:37:07 +02:00
jpark37 338608bd67 libobs,UI: Support HLG nominal peak level
HLG output uses MovieLabs-recommended procedure.

- If peak luminance is greater than 1000, use maxRGB EETF to 1000.
- Otherwise, don't tonemap.
- Then use normal HLG conversion procedure with gamma 1.2 (1000 nits).
2022-04-14 09:36:44 -07:00
jpark37 72224f0fae libobs: Remove redundant async_color_format member 2022-04-13 06:23:35 -07:00
jpark37 06111d5b10 libobs: Add high-precision sRGB support 2022-04-08 17:19:23 -07:00
jpark37 0ed0f2cdb4 libobs: Add I010/P010 support, TRC enum 2022-04-03 00:01:25 -07:00
jpark37 525f964b3d libobs: Add color space management
This provides the framework for automatically compositing SDR and HDR
sources together. Source will need to leverage the new
video_get_color_space to opt into HDR support.
2022-03-26 13:00:34 -07:00
jpark37 87ab39c412 libobs: Render main texture for active color space
Preview will draw SDR white luminance from settings (default 300 nits)
when displayed on an HDR monitor rather than CCCS 80 nits.
2022-03-23 22:35:27 -07:00
jpark37 01c0486aad libobs: Add obs_display_update_color_space 2022-03-23 22:35:26 -07:00
jpark37 cd22df09c9 libobs, UI: Add SDR white nits option 2022-03-23 22:35:26 -07:00
jpark37 c4fb34897e libobs: NV12 textures only for active GPU encoders
Intel GPUs in particular are slow to copy NV12/P010 textures. We can use
ordinary UNORM textures for CPU encoders.
2022-03-19 15:39:09 -07:00
Clayton Groeneveld 3df2f3e069 libobs: Add function to load private sources
If a private source is loaded with the obs_load_source function,
it is loaded as a normal source, so add a new function
to load private sources.
2022-03-08 01:49:24 -08:00
jpark37 5d1261eddb libobs: Only resize display if dimensions change 2022-02-26 01:09:07 -08:00
jp9000 edfd5ad604 libobs: Add obs_object abstraction and functions
With this, you can now cast normal obs objects (services, outputs,
sources, encoders) to an obs_object_t, and then use obs_object_*
functions to get references, release references, and similar for weak
object references as well. This allows the ability for the frontend to
use an object of any of those types interchangeably in certain
situations without having to handle each specific type individually.

This is useful because the properties view in particular doesn't care
what type of object it uses, it just needs to be able to hold weak
references to abstract OBS objects.
2022-02-02 22:35:56 -08:00
Richard Stanway 82b5a39ea4 libobs: Mark raw_active and gpu_encoder_active as volatile
These were operated on by atomic functions but were not marked as
volatile or loaded with os_atomic_load_long, potentially introducing
subtle race conditions. Detected by ThreadSanitizer.
2022-01-18 03:49:20 -08:00
jp9000 a5a8a7c32f libobs: Stop all source processing on destroy
Stops all video/audio IO when a source enters the destroy process.
Prevents any internal callbacks from being triggered and improves
performance.
2022-01-04 13:35:37 -08:00
jp9000 49f9a055dc libobs: Fix destruction order for destruction task queue
Destruction of the task queue should probably happen after the audio and
video threads have been destroyed and all audio/video processing has
stopped.
2021-12-21 11:48:29 -08:00
jp9000 8b3416c1e7 libobs: Implement deferred destruction of sources
(This also modifies the UI)

The purpose of deferring destruction of sources is to ensure that:
1.) Hard locks from enumeration cannot occur with source destruction.
  For example, if the browser source is destroyed while in the graphics
  thread, the browser thread would wait for the graphics thread, but the
  graphics thread would still be waiting for the browser thread, causing
  a hard lock.
2.) When destroys occur during source enumeration, that the integrity of
  the context's next pointer in the linked list can no longer be
  compromised
3.) Source releases are fully asynchronous rather than having the risk
  of stalling the calling thread
4.) We can wait for source destruction when switching scene collections
  or when shutting down rather than hoping for threads to be finished
  with sources.

This introduces a new requirement when cleaning up scene/source data:
the obs_wait_for_destroy_queue() function. It is highly recommended that
this function be called after cleaning up sources. It will return true
if at least one or more sources were destroyed. Otherwise it will return
false. Forks are highly advised to call this function manually on source
cleanup -- preferably in a loop, in conjunction with processing
outstanding OBS signals and UI events.
2021-12-19 11:53:19 -08:00
jp9000 cf492ca271 libobs: Add ability to queue audio task
This is mostly framework for allowing the ability to wait for certain
threads
2021-12-19 11:53:14 -08:00
jp9000 408ce92146 Revert "libobs: Do not release while traversing sources for tick"
This reverts commit 080090c40e.
2021-12-19 11:25:57 -08:00
jp9000 080090c40e libobs: Do not release while traversing sources for tick
obs_source_release should not be called while iterating through the
global sources linked list, otherwise the linked list will be
compromised. Annoying.

Basically the same fix as obsproject/obs-studio#5600, but should be
slightly more optimal and a bit more explicit.
2021-12-15 11:57:52 -08:00
jp9000 9819cb2924 libobs: Add obs_weak_source_expired() 2021-10-15 22:10:33 -07:00
Richard Stanway 4772a99e3e libobs: Defer reconfiguring encoders to the encode threads
Fixes a long-standing issue with Dynamic Bitrate where the RTMP output
thread could try to reconfigure an encoder while the encoder is in the
middle of encoding. x264 seems to handle multithreaded calls well, but
NVENC would deadlock in this situation with no error visible to the
user.
2021-08-23 18:26:37 -07:00
jpark37 7c72fd1d4c libobs: Plumb texcoord hint to reduce GPU cost
In order to do linear-correct filtering cheaply when scale filtering is
disabled, we need to know whether or not texture coordinates will always
sample from texel centers. This can be computed at the scene item level
relatively easily, and passed along to sources when rendering. Scene
items will use obs_source_set_texcoords_centered to set hint status, and
sources will use obs_source_get_texcoords_centered to retrieve it.
2021-07-11 08:26:29 -07:00
jpark37 b94fbac7ef libobs: Fix warnings
Cast away truncation, and widen type before multiplication.
2021-07-06 14:08:28 -07:00
jpark37 1fa152092c libobs: Plumb linear alpha flag
Use union for backwards compatibility.
2021-06-04 19:04:08 -07:00
Ford Smith 60d95cb5bd UI/libobs: Undo/Redo Sources and Scenes
Implements the Undo/Redo for scenes and sources, ranging from renaming,
deletion, addition. It also adds several elements to libobs that were
designed to facilitate undo/redo, and should not affect the rest of
libobs.
2021-03-29 03:06:26 -04:00
jpark37 d48e77385c libobs: Update compare-exchange pattern
Use function that updates previous value automatically.

Also load initial value seq_cst to be safe.
2021-02-03 08:51:31 -08: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
Jim 53b65bb5fd
Merge pull request #3245 from e00E/fix-defer-update
libobs: Fix deferred update sometimes using stale data
2020-08-17 08:03:21 -07:00
jp9000 d45017370b libobs: Add functions to get locale text from modules
Useful for sharing translated text from modules with the frontend.  This
is technically already done via properties, but it would be nice to just
be able to explicitly look up locale text directly rather than have to
go through properties.
2020-08-10 12:24:01 -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
jpark37 6aa50b3ef1 libobs: Use autoreleasepool for graphics thread
Apparently necessary to clean up macOS leaks.
2020-06-08 13:16:35 -07:00
Richard Stanway 5dc9f989d6 libobs: Add support functions for encoder error handling
Similar to how outputs can pass errors, add the same functionality for
encoders so that if an output encoder has an error, it is made available
to the output and eventually the UI / user.
2020-04-12 17:05:19 +02:00
jp9000 8de20ab3be libobs: Add task scheduling features
(This commit also modifies the UI)

Adds the ability to schedule tasks for certain threads
2020-03-14 10:54:37 -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
jp9000 b9d6675e2c libobs: Add ability to rotate async sources 2020-03-01 03:39:54 -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