Repository navigation
libobs: Move transition sizing, load and getters - #3588
Merged
Merged
Conversation
Characterization before the transition sizing and tick of obs-source-transition.c (get_cx(), get_cy(), the matrix and size recalculations and obs_transition_tick()) move to their own file and are ported. test_transition_scale_type pins the matrix of each scale type as a start builds it; nothing pinned the actual size, the render size, what the tick rebuilds or how it moves the manual value. test_source_transition_size creates transitions through the real libobs. 4 cases pin: - the actual size (obs_source_get_width() and _height()): the larger width and the larger height of the children, 0x0 with none, at once after a start, at the next tick after obs_transition_set(), and following a child's resize and an emptied slot at each tick; - a size set with obs_transition_set_size() is the size the render2 callback gets, one dimension at a time, while obs_source_get_width() still reports the children's size (characterized, not endorsed); - each slot's matrix, rebuilt by the tick from the child's size, the scale type and the alignment; - the manual value at each tick: snapped to the target with a torque of 0, stepped towards it with a torque, and at the target in one tick when the clamp is larger than the step. Each case waits for the tick it needs, not a fixed time. Transitions need core video, so it builds on Linux only and runs under xvfb-run; without a display the cases skip. It passes on the C, hybrid and C reference builds. Refs #3580.
get_cx(), get_cy(), recalculate_transition_matrices() and recalculate_transition_size() of obs-source-transition.c lose static (and inline) and become transition_get_cx(), transition_get_cy(), transition_recalculate_matrices() and transition_recalculate_size(), so the sizing file that moves out next can define them and the rest of the transition code can call them. The bare names would risk a clash in the unity group; no other file of libobs defines the new ones. obs-source-transition-size.h declares them, hidden in libobs (not EXPORT), and libobs.pch.h includes it after the seam header. Renaming the callers is the only change to them; the bodies are unchanged. No behaviour change: the export sets of the C, hybrid and C reference builds are unchanged (1767), with the four functions local. Refs #3580.
The add_alignment() declaration, transition_get_cx(), transition_get_cy(), recalculate_transition_matrix(), transition_recalculate_matrices(), transition_recalculate_size() and obs_transition_tick() move verbatim from obs-source-transition.c into obs-source-transition-size.c, ahead of their port to rust/obs-source. The file has its own copy of lock_transition(), unlock_transition(), trylock_textures() and unlock_textures(), #undef'd at its end (BUILD.md), and is live C in libobs.core-source, after the seam. No behaviour change: every moved line is byte-identical to the previous commit's, the export sets of the C, hybrid and C reference builds are unchanged (1767), with the four helpers local, and the transition tests, with test_source_transition_size, pass on all three. Refs #3580.
Characterization before obs_transition_load() of obs-source-transition.c moves to its own file and is ported. test_transition_scale_type pins the loaded scale type and test_transition_load_release the release of slot A's old source while the transition is shown; nothing pinned the other fields it writes, the keys it reads as 0, or the three outcomes of its lookup. test_source_transition_restore loads transitions with obs_load_sources(), as a scene collection does (the load is not exported), through the real libobs. 7 cases pin: - each field written from saved data, read back through the getters and obs_save_source(), slot A, and the actual size from its child at once; - a key the data does not hold writes 0: the alignment becomes OBS_ALIGN_CENTER rather than a new transition's left and top, and the missing name "" is looked up and logged as not found (characterized, not endorsed); - a scale type outside the enum (3, -1, the int64 limits) loads as MAX_ONLY, and the alignment, mode and size are cast as they are (characterized, not endorsed); - a found source goes into slot A as an active child: a shown transition shows it, and its clear takes it back; - a missing source is logged and slot A stays empty; - the transition named as its own slot A is refused with a log, and the reference its lookup took is given back; - the source slot A held before the load is released, whether the load puts a source there or not. Transitions need core video, so it builds on Linux only and runs under xvfb-run; without a display the cases skip. It passes on the C, hybrid and C reference builds. Refs #3581.
obs_transition_load() moves verbatim from obs-source-transition.c into obs-source-transition-restore.c, ahead of its port to rust/obs-source (obs-source-transition-load.c is taken by its ported rules). It calls the seam's valid_scale_type() and the sizing file's transition_recalculate_size() and transition_recalculate_matrices(). The file has its own copy of lock_transition() and unlock_transition(), #undef'd at its end (BUILD.md), and is live C in libobs.core-source, ahead of the seam. No behaviour change: every moved line is byte-identical to the previous commit's, the export sets of the C, hybrid and C reference builds are unchanged (1767), with obs_transition_load() local, and the transition tests, with test_source_transition_restore, pass on all three. Refs #3581.
Characterization before obs_transition_get_source(), obs_transition_get_active_source(), obs_transition_set_manual_torque() and obs_transition_set_manual_time() of obs-source-transition.c move to their own file and are ported. Other transition tests call the getters along the way and see the manual value move; nothing pinned the references the getters return, their refusals, or when a manual time ends the transition. test_source_transition_access creates transitions through the real libobs, and sees a child's last reference go through a weak reference. 6 cases pin: - obs_transition_get_source() for slot A and B, NULL for an empty slot, each a new reference of its own; - obs_transition_get_active_source(): A while idle, B while the transition runs in auto or manual mode, the given source once obs_transition_set() ends it, again a reference of its own; - NULL gives NULL and a debug line, which get_active_source logs under "obs_transition_get_source" (characterized, not endorsed); a source that is not a transition gives NULL with no line; - the torque and clamp the tick moves the manual value with, each call replacing both; - a manual time of 0 or -0 in manual mode ends the transition on slot A; 0.5, 1, NaN, or 0 in auto mode do not. The setters are called on transitions only, as neither checks its argument (characterized, not endorsed). Transitions need core video, so it builds on Linux only and runs under xvfb-run; without a display the cases skip. It passes on the C, hybrid and C reference builds. Refs #3582.
obs_transition_get_source(), obs_transition_get_active_source(), obs_transition_set_manual_torque() and obs_transition_set_manual_time() move verbatim from obs-source-transition.c into obs-source-transition-access.c, ahead of their port to rust/obs-source. The getters call the seam's transition_valid(); obs_transition_set_manual_time() still calls obs_transition_set(), which stays in obs-source-transition.c. The file has its own copy of lock_transition() and unlock_transition(), #undef'd at its end (BUILD.md), and is live C in libobs.core-source, ahead of the seam. No behaviour change: every moved line is byte-identical to the previous commit's, the export sets of the C, hybrid and C reference builds are unchanged (1767), and the transition tests, with test_source_transition_size, test_source_transition_restore and test_source_transition_access, pass on all three. Fixes #3580. Fixes #3581. Fixes #3582.
This was referenced Nov 3, 2026
5 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3580
Refs #3581
Refs #3582
Fixes #3580
Fixes #3581
Fixes #3582
What and why
Three steps of "Extracting a function before porting it" for the rest of
libobs/obs-source-transition.c.h, batched in one PR: same file, same unity group, and the load calls the sizing helpers. There is no Rust and no change in behaviour; the ports torust/obs-source/obs-source-seamcome next.get_cx(),get_cy(),recalculate_transition_matrices()andrecalculate_transition_size()losestatic(andinline) and becometransition_get_cx(),transition_get_cy(),transition_recalculate_matrices()andtransition_recalculate_size(), so the rest of the transition code can still call them once they move. The bare names would risk a clash in the unity group; nothing else in libobs defines the new ones. Renaming the callers is the only change to them.libobs/obs-source-transition-size.hdeclares them. It is marked "private adapter, not a new public API", nothing in it is EXPORT, andlibobs.pch.hincludes it after the seam header.add_alignment()declaration, the four helpers,recalculate_transition_matrix()andobs_transition_tick()then move verbatim intolibobs/obs-source-transition-size.c.h.obs_transition_load()moves verbatim intolibobs/obs-source-transition-restore.c.h. The ported rules already haveobs-source-transition-load.c.h, so this file is-restore.obs_transition_get_source(),obs_transition_get_active_source(),obs_transition_set_manual_torque()andobs_transition_set_manual_time()move verbatim intolibobs/obs-source-transition-access.c.h.obs_transition_set_manual_time()still callsobs_transition_set(), which stays behind.All three files are live C in
libobs.core-source, ahead ofobs-source-transition.c.h, in the group's sorted order. Each has its own copy of the lock macros it uses,#undef'd at its end (BUILD.md rule 5).obs-source-transition.c.hloses 229 lines.Characterization. Each move gets a test first. The tests create transitions through the real libobs (core video, so Linux under Xvfb, like the other transition tests). Each case that depends on the graphics thread's tick waits for the frame that shows what it checks, with a 5 s bound that only turns a hang into a failure. The same goes for a source's last reference: the graphics thread holds one on every source while it ticks them, so a check that a source is gone waits for its weak reference to expire. Odd behaviour is pinned as it is.
test_source_transition_size(4 cases):obs_source_get_width()/_height()): the larger width and the larger height of the two children, 0x0 with none. A start sets it at once,obs_transition_set()leaves it to the next tick, and each tick follows a child's resize and an emptied slot;obs_transition_set_size()is the size the render2 callback gets, one dimension at a time, whileobs_source_get_width()still reports the children's size (characterized, not endorsed);test_source_transition_restore(7 cases), throughobs_load_sources(), since the load is not exported:OBS_ALIGN_CENTERand not a new transition's left and top, and the missing name""is looked up and logged as not found (characterized, not endorsed);test_source_transition_access(6 cases):obs_transition_set();get_active_sourcelogs under"obs_transition_get_source"(characterized, not endorsed). A non-transition gives NULL with no log line;The two setters are only called on transitions, since neither checks its argument (characterized, not endorsed). Their port fixes that and the log name.
Checked against origin/master's functions. A scratch harness (not committed) extracts master's eleven moved functions with the lock macros, and the three new files whole. It builds each as its own program over one logging stand-in for
struct obs_sourceand every call they make: the clock, fit, offset, load and start rules, the child size reads, the matrix calls,add_alignment(),calc_torquef(), the texrender resets, theobs_datareads, the lookup, scriptedobs_source_add_active_child()results, refs and releases,transition_valid(),obs_transition_set(), the logs, and each lock and trylock (scripted results). Each call logs its arguments, and the program dumps every field of six sources after each call.The logs of 20,000 rounds of 12 random calls (240,000 calls) are byte-identical under gcc and clang at -O0, at -O2, and at -O1 with ASan and UBSan. The random inputs cover special floats, sizes up to
UINT32_MAX,int64_tedges for every loaded key, a NULL or missing name, and empty and self-held slots. Under clang's UBSan both builds report the same float-to-int cast of the matrix offset for a transition wider thanINT_MAX, at the same moved line. That is master's behaviour, and it moves unchanged.All 25 planted mutants are caught by the harness, in:
Nine of them, planted in the real libobs, also fail the new C tests.
The move commits are byte-identical to the text they replace (checked with
diffon each).RED → GREEN
libobs-c-reference(30/30), under Xvfb with none skipped.obs_transition_load()and the four sizing helpers are local (t).--test-diff origin/master: the workspace's 6432 nextest tests passed (6 skipped) and the doctests passed.--lane lintand--lane cross: clang-format, gersemi, ruff, the 343ci/test_*.pychecks, rustfmt, every clippy run, and the MSVC cross clippy all pass. The Dylint step didn't run locally because this machine has no Dylint driver for the pinned nightly, so PR CI runs it. No Rust changed../unittestpassed, Tier 2 in Docker included (714/714). The Windows--all-targetsclippy passed. The head is unstamped because the stamp's lint lane stops at the same Dylint step, so PR CI runs the full suite.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC