Commit graph

142 commits

Author SHA1 Message Date
Ruwen Hahn c288d42cfd libobs: Add obs_encoder_group_keyframe_aligned_encoders
Ensures grouped encoders start on the same input frame
2024-04-12 14:52:32 -07:00
Kurt Kartaltepe ccfcbc2699 libobs: Copy both converted textures on stall for OpenGL
As the comment mentions this only occurs during an encoder stall on the
first frame. On D3D both gs_texture_t's are actually a single D3D
texture object and both planes are copied during gs_copy_texture, for
everyone else we need to copy the textures separately as they are
independent OpenGL textures.
2024-01-30 22:15:41 -06:00
Kurt Kartaltepe 02c90207fc libobs,libobs-opengl: enable GPU encoding for OpenGL
Enable all of the previously Windows only paths for OpenGL backends that
support encode_texture2

Co-authored-by: Torge Matthies <openglfreak@googlemail.com>
2024-01-26 20:01:58 -05:00
derrod 2963959e71 libobs: Replace circlebuf with deque 2024-01-16 16:45:09 +01:00
derrod f5b7c98d2d libobs: Reuse matching mix's render texture if possible
Avoids re-rendering a view if a previous mix with identical settings
has already rendered it
2023-12-02 17:36:48 -06:00
jpark37 7669da1ea8 libobs: Add VIDEO_FORMAT_R10L
Support 10-bit packed format that DeckLink uses.
2023-07-29 16:41:31 -07:00
Lain 1aed7ed114 libobs: Use da_clear() to clear obs_core_data::sources_to_tick
Makes it a bit more clear what's going on
2023-06-10 14:30:44 -07:00
Exeldro a77789b266 libobs: Don't keep the sources mutex in tick_sources
Allow other threads to use sources while the graphics thread does
video_tick, update, activate and deactivate on sources
2023-06-10 14:20:13 -07:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
PatTheMav 90f46a9d4d libobs: Add missing VIDEO_FORMAT_V210 handling in switch statements
Format was added to enum but not handled in all switch statement
handling the enum.
2023-03-26 13:48:01 -04:00
jpark37 8f3bf0a0e3 libobs: Keep output as premultiplied alpha
Simplify code until someone needs straight alpha.
2023-03-25 03:19:26 -07:00
jpark37 e32c2c1427 libobs: Add callback for main texture rendered
Useful for redirecting main texture to DeckLink output for example.
2023-03-24 15:18:45 -07:00
derrod c68eeaef1d libobs: Use uthash for source objects
All sources are part of a hash table that allows a lookup by UUID.
Public sources additionally are in a hash table allowing lookup by name.
2023-03-18 10:47:49 +01:00
jpark37 463bf0dff5 libobs,UI: Add P216/P416 pixel formats
Will be useful for ProRes.
2023-02-21 18:48:44 +01:00
PatTheMav db3a01db6b libobs: Remove unused variables 2023-02-18 15:22:33 -08:00
Antti Tapaninen c7f4c78a69 libobs: Allow overriding video resolution per view 2022-11-19 15:34:54 -08:00
Richard Stanway a282b1c64d libobs: Add ifdef for Windows-only variable assignment 2022-10-15 16:17:46 -07:00
jpark37 a34fae0327 libobs,UI: Swap red/blue render/output channels
Don't need to unswizzle channels for DeckLink output in the future.
2022-09-24 16:06:34 -07:00
jpark37 1ddabc5c7c libobs: Remove unnecessary branch
Fast path for output texture shouldn't care what the effect is.
2022-09-10 15:34:29 -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 0a87797a21 libobs: Format changes for multiple video mixes 2022-07-31 15:35:37 -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
tytan652 348cf1b872 libobs: Remove unused parameters 2022-07-20 08:21:20 +02:00
PatTheMav ff7f756886 libobs: Explicitly mark variables as unused 2022-07-10 09:59:55 +10:00
jpark37 1ac758a2ef libobs: Ensure active copy surfaces are active
Stale surfaces can cause improper downloads from GPU, and lead to video
corruption in certain cases.
2022-06-03 01:17:07 -07:00
jpark37 11da542a0d libobs: Add max_luminance to obs_source_frame
Used in situations where source luminance is greater than HDR nominal
peak setting to avoid clipping by applying BT.2408 maxRGB EETF.
2022-05-27 14:56:47 -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
tytan652 56d673d55c libobs: Fix sign-compare warning
`diff` is used only if greater than `interval_ns` which is unsigned.
So casting it as unsigned will not change its sign.
2022-05-04 01:37: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
Jim 7f990677c0
Merge pull request #6158 from jpark37/hdr-format-trc
Add I010/P010 support, video_trc enum
2022-04-04 18:28:14 -07:00
jpark37 737696950d libobs: Fix sign mismatch 2022-04-04 00:44:32 -07:00
jpark37 0ed0f2cdb4 libobs: Add I010/P010 support, TRC enum 2022-04-03 00:01:25 -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 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
jpark37 4e5906d2b0 libobs: Clamp video timing for safety
os_gettime_ns and os_sleepto_ns may not match up exactly.
2022-02-28 10:11:03 -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
wangshaohui bb59dfd060 libobs: Move position for calling execute_graphics_tasks
The new order is as below:
[message pump]
output_frame
render_displays
execute_graphics_tasks
2021-12-31 17:34:20 -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 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 b2c09d3523 libobs: Fix potentially unsafe linked list traversal
Fixes an issue pointed out in obsproject/obs-browser#333 where a source
may destroy the next source in obs_source_video_tick(), thus
invalidating the next source in the linked list. Get the next source in
the list *after* calling obs_source_video_tick() rather than before.

Closes obsproject/obs-studio#5600
2021-12-14 10:34:53 -08:00
jpark37 71bd5860ce libobs: Final downsample with SRGB formats 2021-01-21 07:42:57 -08:00
jpark37 6aa50b3ef1 libobs: Use autoreleasepool for graphics thread
Apparently necessary to clean up macOS leaks.
2020-06-08 13:16:35 -07:00
jpark37 5734ab7a9b libobs: WinRT and dispatcher init on graphics thread
Suspected necessary for WGC stability.
2020-05-21 09:25:54 -07: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
jpark37 3703581472 libobs: Pump graphics loop one final time for cleanup 2020-02-23 19:43:10 -08:00
jpark37 82cdc6e8c6 libobs: Pump Win32 messages on the graphics thread
Necessary for upcoming Windows Graphics Capture support.
2020-02-22 21:02:33 -08:00
jpark37 ade65df2aa libobs: Add gs_begin_frame for duplicators
We really shouldn't be resetting duplicator state as part of gs_flush.
gs_begin_scene is not ideal because it is called twice per frame, and
only after duplicators have been ticked. Even though it makes no
user-facing difference, it makes more logical sense to reset at the top
of the frame than the bottom.
2019-10-10 21:06:01 -07:00
jpark37 42bf026a49 libobs: Fix video warnings 2019-08-30 22:13:03 -07:00