Repository navigation
libobs: Port the video output plan to obs-core - #1773
Merged
Merged
Conversation
This was referenced Oct 22, 2026
RED for the port of libobs/obs-video-plan.c.h to a new crate, rust/obs-core, module video_plan: the crate for the units extracted from libobs/obs.c.h, as the claim on obs-rust#1713 proposed. The safe core is a stub (todo!()): size_valid(), align_output_size(), output_size_valid(), scale_type_name() and output_plan(). The C enums it takes or returns, gs_color_format, gs_color_space and obs_scale_type, are plain data in header order (GsColorFormat, GsColorSpace, ObsScaleType); video_format and video_colorspace are obs-media-io's. A value outside its enum is None, the C's default: branch. tests/obs_core/video_plan.rs ports test_video_output_plan 1:1: its 10 cases under the same names, in the same order, with the same inputs and the same expected values, including the written-out plan per format and the bit-for-bit float comparison over every format x colorspace x size. techniques_exist_in_the_effect reads libobs/data/format_conversion.effect from the source tree, with CR removed as the C test does. Edge cases: the enum tables in header order, the size bounds, a zero size (infinite texel size, as 1.f / (float)0), u32::MAX sizes, technique names as C identifiers, techniques and planes in pairs, and two proptests over any u32 sizes: the plan against the written-out rules, and the alignment and the output size check. The tests are a module of the existing core category binary, obs-tests-core; no new test binary (8 of 8). soldr cargo test -p obs-data --test obs-tests-core obs_core:: fails 17 of 18 with "not yet implemented"; only enum_tables_in_header_order passes. Refs obs-rust#1713
Ports libobs/obs-video-plan.c.h to the video_plan module of a new crate, rust/obs-core, for the units extracted from libobs/obs.c.h. The plan tells obs_reset_video() which sizes it takes and how it aligns the output, and tells the mix setup, per output format, the GPU conversion (the techniques of format_conversion.effect and their texel sizes), the size and format of each conversion plane, and the render texture format and color space. obs.c.h (still C) creates the textures and surfaces from it; the hybrid libobs drops the C file and links the Rust shims. Safe core (src/video_plan.rs): size_valid() with OBS_SIZE_MIN and OBS_SIZE_MAX, align_output_size(), output_size_valid() (valid as given and after the alignment, obs-rust#1734), scale_type_name(), and output_plan() with the C's three steps: the techniques and texel sizes, the planes, and the render textures. Technique names are 'static c"..." strings. The texel sizes are 1.0 / size as f32, the C's 1.f / (float)size bit for bit (infinite for a zero size, as in C). The sizes come from profiles, obs-websocket SetVideoSettings and scripts, so the module denies clippy's indexing_slicing, arithmetic_side_effects, unwrap_used, expect_used, panic, todo, unimplemented and unreachable; nothing panics for any input. Shim (src/ffi/video_plan.rs): the five functions with the C signatures, and #[repr(C)] struct obs_video_plane and struct obs_video_output_plan, returned by value. The enums cross as c_ints; a value outside its enum takes the C's default: branch. Intentional difference: a null pointer to obs_video_align_output_size is skipped (C dereferences it); the other pointer is still aligned. C side: the file leaves libobs.core for its own group, libobs.ported-video-plan (LIBOBS_PORTED_SOURCES), whose PCH is obs-internal.h, so the C reference and the C backend keep compiling it. The functions are declared in obs-internal.h without EXPORT, so the shims are hidden: rust-hidden.txt, rust-exports.map and rust-unexports-macos.txt. libobs-rust depends on obs-core and re-exports its ffi. Results: test_video_output_plan (10 of 10) and test_video_output_formats (4 of 4, under a private Xvfb) pass against the C-backend libobs, the hybrid libobs and libobs-c-reference. The exported symbol sets are identical, 1766 in each. Tier 1: obs_core:: 18 of 18. Refs obs-rust#1713
The oracle, oracle/video_plan.c, is libobs/obs-video-plan.c.h, unmodified, with its five functions renamed to oracle_*. The rename also renames the struct tag obs_video_output_plan, in obs-internal.h and the file alike, which leaves the layout as it is. It also reports the layout of struct obs_video_plane and struct obs_video_output_plan, the width of the enums, and the gs_color_format, gs_color_space, obs_scale_type, video_format and video_colorspace values. Tier 3 (tests/obs_core/video_plan_parity.rs), in obs-tests-core: - the layout and the enum values against the C header; - exhaustively, every video_format and video_colorspace value, with -1, one and two past the end, INT_MIN and INT_MAX, at 24 sizes (the characterization's, 0, 32769, 65536, 2^31 - 1, 2^31, 2^32 - 2 and 2^32 - 1) for each of width and height: 31 x 11 x 24 x 24 plans, every field, technique names byte for byte, floats bit for bit; - every obs_scale_type value and values outside it; - the size checks and the alignment at those sizes; - proptests (4096 cases each) over any format and color space value and any u32 sizes, sizes up to 65536, and the size checks over any u32 and near the bounds. Excluded, the one intentional difference: a null pointer to obs_video_align_output_size, which the shim skips and C dereferences; a shim-only test pins it. 11 of 11 pass. Deliberate breaks, not committed, each caught: the P216 chroma plane at half height (3 tests fail), the output size not checked again after the alignment (the edge sweep fails), the PQ and HLG technique sets of P416 swapped (3), and the texel size from a different rounding (3). Refs obs-rust#1713
naming.md: libobs/obs.c.h and the units extracted from it (obs-video-plan.c.h so far) go in rust/obs-core. rust/README.md: the obs-core layout row and the obs-video-plan.c.h row of the ported table, with its one intentional difference. testing-policy.md: obs-core's tests are a module of the core category binary, obs-tests-core. Refs obs-rust#1713
zackees
force-pushed
the
port/video-plan-obs-core
branch
from
October 22, 2026 11:12
31a8bf0 to
6e10e34
Compare
This was referenced Oct 24, 2026
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 #1713
What and why
Step 3 of #1713: ports
libobs/obs-video-plan.c.h, the video output plan that #1714 moved out ofobs.c.hand #1734 fixed, to Rust. As the claim on #1713 said, it goes in a new crate,rust/obs-core, modulevideo_plan. That crate is for the units extracted fromlibobs/obs.c.h, and laterobs.c.hunits join it as modules.The plan is what
obs_reset_video()accepts and how it aligns the output size, plus, for each output format, the GPU conversion (theformat_conversion.effecttechniques and their texel sizes), each conversion plane's size and texture format, and the render texture format and color space.obs.c.h(still C) creates the textures and surfaces from it. The hybridlibobsdrops the C file and links the Rust shims instead.src/video_plan.rs):size_valid,align_output_size,output_size_valid(checked as given and again after the alignment, libobs: Refuse an output size that the alignment makes invalid #1734),scale_type_nameandoutput_plan, which follows the C's three steps. Technique names are'staticc"..."strings, becauseobs-video.ckeeps them and looks them up by name. Texel sizes are the C's1.f / (float)size, bit for bit, and infinite for a zero size as in C. The sizes come from profiles, obs-websocketSetVideoSettingsand scripts, so the module denies clippy's panic, indexing and arithmetic lints, and no input can make it panic.src/ffi/video_plan.rs): the five functions with their C signatures, and#[repr(C)]struct obs_video_plane/struct obs_video_output_plan, returned by value. The enums cross asc_ints. A value outside its enum takes the C'sdefault:branch.libobs.coreinto its own group,libobs.ported-video-plan(inLIBOBS_PORTED_SOURCES, PCHobs-internal.h), so the C reference and the C backend still compile it. The five functions are declared inobs-internal.hwithoutEXPORT, so the shims are hidden (rust-hidden.txt,rust-exports.map,rust-unexports-macos.txt).libobs-rustdepends onobs-coreand re-exports its ffi.obs-tests-core, so the test-binary count stays at 8 of 8.Intentional difference from C (listed in the parity test header and
rust/README.md): a null pointer toobs_video_align_output_sizeis skipped, where C dereferences it. The other pointer is still aligned.The fps = 0 rejection (steps 4 and 5 in the planning notes) is separate, so this PR uses
Refs.RED → GREEN
c85322c21. Tier 1 portstest_video_output_plan1:1 (its 10 cases, same names, same order), plus 8 edge cases. Against thetodo!()core,soldr cargo test -p obs-data --test obs-tests-core obs_core::fails 17 of 18 with "not yet implemented". Onlyenum_tables_in_header_orderpasses.1879a13b1(port),98b2d62cf(oracle and Tier 3),31a8bf0b7(docs).obs_core::video_plan18 of 18.test_video_output_planpasses 10 of 10 against the C-backendlibobs, hybridlibobsandlibobs-c-reference.test_video_output_formatspasses 4 of 4 against all three, under a private Xvfb.libobs-c-reference365 of 365. Hybridlibobs364 of 365:test_pulse_monitor_devicefailed once under-j4(the default-sink check indefault_device_follows_default_output; the test does not touch the video plan) and passed 5 of 5 run alone. 0 skips in either run.obs_core::video_plan::*), and the C reference has no Rust symbols.obs_core::video_plan_parity11 of 11.video_formatandvideo_colorspacevalue, plus -1, one and two past the end,INT_MINandINT_MAX, at 24 widths × 24 heights. That is 31 × 11 × 576 plans, compared field by field, with technique names byte for byte and floats bit for bit.obs_scale_typevalue and values outside it.u32size.uv run ci/local_gate.py --lane lintand--lane crossboth pass.ci/test_ported_sources.py,ci/test_build_groups.py,ci/test_binary_cap.py,ci/test_naming.pyandci/test_rust_scope.pypass.test_video_output_formatsrunsobs_reset_video()and real frames through the hybrid for every converted format.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