Repository navigation
Description
Unit
Port the video output conversion plan of libobs/obs.c.h to a new crate, rust/obs-core, as a module video_plan. It is the pure computation that obs_reset_video() and the per-canvas video mix setup run before they touch the graphics device: what output size is accepted, how the output size is aligned, and, for each output format and color space, the GPU conversion (the shader technique names and the texel sizes), the size and gs_color_format of each conversion plane, and the format and color space of the render textures.
From libobs/obs.c.h:
calc_gpu_conversion_sizes()(format x colorspace -> three technique names,conversion_needed,conversion_width_i,conversion_height_i);- the per-format plane table inside
obs_init_gpu_conversion()andobs_init_gpu_copy_surfaces()(each plane's width, height andgs_color_format: GS_R8/R8G8 for 8-bit, GS_R16/RG16 for the 10/16-bit formats, chroma divided per subsampling); - the render-texture format (
GS_BGRA, orGS_RGBA16Ffor the high-precision formats) and color space (GS_CS_709_EXTENDEDfor PQ/HLG,GS_CS_SRGB_16Ffor the SDR 16-bit formats, elseGS_CS_SRGB) ofobs_init_textures(); size_valid()withOBS_SIZE_MIN/MAX, the output-size alignment masks ofobs_reset_video_internal(), and the scale-type name switch of its log.
About 170 lines. All of it is our code (the conversion rebind chain #1109/#470, the HDR formats #1565). It is pure: the inputs are a video_format, a video_colorspace and the width and height; the output is a by-value plan struct. The gs_texture_create/gs_stagesurface_create calls, the NV12/P010 texture decision (which asks the device), graphics init, mix creation, canvases, encoder rebinding, logging and obs_init_video() stay C.
Phase and position
Phase 6 (#444), libobs core through opaque seams. libobs/obs.c.h is one of our modified files and has no Rust yet, so this unit starts a new crate. It is part of a very large file, so it enters through function extraction (testing-policy.md, "Extracting a function before porting it"), as the caption text, the interleaver and the hotkey units did. Its Rust tests join the new crate's tests/ harness; no new C test binary.
Crate name
Coordinator decided on #444 (2026-10-20) that a libobs area gets one crate named after it, with a module per extracted file, and that per-file crates (obs-scene-bounds, obs-scene-blend) are the exceptions to fold away. By that rule libobs/obs.c.h's pieces belong in one crate for the libobs core. naming.md's table maps each top-level file to its own obs-<area> crate (obs-data, obs-properties, obs-output, obs-scene), so the natural name for obs.c.h is rust/obs-core, with later obs.c.h units joining it as modules. This is a layout question, not a design one; this plan uses rust/obs-core and adds the naming.md row in PR 2 (the port). If the coordinator wants another name (for example obs-video split out later), say so on the claim comment before PR 2 lands; PR 1 adds no crate, so it does not depend on the answer.
What to ask on the claim comment: "Starting libobs/obs.c.h: PR 1 is a behaviour-neutral C extraction (no crate). The port (PR 2) wants a crate; by the #444 one-crate-per-area rule I will use rust/obs-core for obs.c.h, later obs.c.h units joining it as modules, unless you would rather carve obs-video out now."
Dependencies and existing tests
- It writes
struct obs_core_video_mixfieldsconversion_techs[3],conversion_needed,conversion_width_i,conversion_height_i, and feeds thegs_texture_create/gs_stagesurface_createand render-texture calls. No accessor is needed: the moved C returnsstruct obs_video_output_planby value (declared inobs-internal.h, not EXPORT), andobs.ccopies the techniques and sizes into the mix and creates the textures and surfaces fromplanes[]. - The technique names are read later by
obs-video.c.h(render_convert_texture), so they are'staticNUL-terminated strings that must matchlibobs/data/format_conversion.effectexactly. - Enum values (
video_format,video_colorspace,gs_color_format,gs_color_space,obs_scale_type) come from the public headers (obs-sys bindings). - About 70 real-libobs tests call
obs_reset_video(), but their output formats are only NV12 (52), BGRA (15) and RGBA (3). I420, I444, I010, P010, P216, P416 are covered by nothing.test_texture_encoder_raw_formatandtest_scaled_mix_alphacome closest. PR 1 adds both a pure characterization that pins the plan for every format, color space and edge size, and a real-libobs test that runsobs_reset_video()once per output format and checks the frames.
Plan
- Extraction and characterization PR (behaviour-neutral, as in libobs: Move the caption text wrap into obs-output-caption-text.c #1618/libobs: Move the hotkey key-name translations into obs-hotkey-translations.c #1657):
- The functions above move verbatim from
obs.c.hintolibobs/obs-video-plan.c.h, which exposes one entry point,struct obs_video_output_plan obs_video_output_plan(format, colorspace, width, height), plusobs_video_size_valid(),obs_video_align_output_size()andobs_video_scale_type_name(). They are declared inobs-internal.hwithoutEXPORT, so they are hidden;obs.ccalls them. The new file joins the existinglibobs.coreunity group (just beforeobs.c.h, alphabetical), withlibobs.pch.h. The exported symbols are unchanged. - New test
test_video_output_plan, which compiles the moved file into itself (C only, ASan and UBSan, no libobs core and no display). It pins the plan for everyvideo_format(and one past the end), everyvideo_colorspace(and one past), odd and even sizes, the minimum (2), the 1366-that-aligns-to-1364 case and the maximum (32768), comparing every field; the size check at its edges; the alignment masks; and the scale-type names. The width-2/3 edge (bug 4 below) is pinned here as "characterized, not endorsed". - New test
test_video_output_formats, which links the real libobs and its OpenGL renderer and runsobs_reset_video()once per output format with a GPU conversion (I420, NV12, I444, I010, P010, P216, P416, each with its color spaces and both ranges) and BGRA/RGBA, checking each frame's plane sizes and sample values (so a wrong plane size or technique shows). It also checks the output-size alignment throughobs_get_video_info()(1366 -> 1364) and that an out-of-range size is refused before the old video is freed. It uses the public API only, so with the hybrid libobs it covers the Rust port once there is one. Linux only (needs a display; skips without one, under xvfb-run).
- The functions above move verbatim from
- A C fix for bug 4, and bug 6 (RED, then GREEN; see below for reachability).
size_valid()accepts an output width of 2 or 3, and the alignment then masks it to 0. Validate after the alignment (or lift the minimum to 4 for the output width), soobs_reset_video()refuses it withOBS_VIDEO_INVALID_PARAMbefore it frees the old video, instead of failing with no video. It gives API callers a new return code, so it is its own PR with a test change. - Port PR (RED, then GREEN):
obs_core::video_plangets the safe core (the enum lookups and the1.f / (float)wreciprocals), andsrc/ffi/video_plan.rsthe C ABI shim returningstruct obs_video_output_plan. The C file moves to its own ported group,libobs.ported-video-plan, with its own.pch.h,source-sets.jsonentry and export fragment (rust-exports.map,rust-hidden.txt,rust-unexports-macos.txt).- Parity: an exhaustive oracle over every enum value (there are few) and a proptest over sizes, comparing the floats bit for bit. Tier 2 with
OBS_LIBOBS_BACKEND=Cand HYBRID +libobs-c-referenceunchanged;test_video_output_formatssees the swap. Tier 4 does not apply. - Docs: the new
rust/README.mdrow and thedocs/rust-port/naming.mdrow (libobs/obs.c.h->rust/obs-core).
Bugs found while reading (characterized, not fixed in PR 1)
- Bug 4 (output width 2 or 3).
size_valid()(OBS_SIZE_MIN 2) accepts an output width of 2 or 3, andobs_reset_video_internal()then masks the width to a multiple of 4, which gives 0. The 0-widevideo_output_open()fails, but by thenobs_reset_video()has freed the old video, so the call returns with no video at all, and a later reset of that core crashes. Only API/script callers can reach it: the Settings dialog minimum is 32, obs-websocketSetVideoSettingsrequires >= 8. Characterized intest_video_output_plan(the size check passes, the alignment makes 0); PR 2 validates after the alignment. Severity: low. - Bug 6 (
pthread_mutex_init(...) < 0).obs_init_video()checkspthread_mutex_init(...) < 0for its three mutexes. pthread returns a positive errno on failure, so a failure is never caught. Cosmetic/robustness; fix alongside bug 4 or in a small follow-up, as!= 0. Severity: very low.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 22, 2026
Claiming: #1713
libobs/obs-video-plan.c.h(behaviour-neutral, no crate), withtest_video_output_plan(pure, every format and colorspace) andtest_video_output_formats(real libobs). Opening it now.pthread_mutex_initcheck.rust/obs-coreforobs.c.h, with laterobs.c.hunits joining it as modules, unless you'd rather carve out anobs-videocrate now.libobs: Move the video output conversion plan into obs-video-plan.c (o…
zackees commentedon Oct 22, 2026
Observed Windows Tier2 build blocker in #1269's defined full experiment on446a12945 (base9f2253334, which includes #1714). Job119662888783 completed FAILURE before CTest:
test/cmocka/test_video_output_plan.c:220uses fail_msg in check_plan; additional fail_msg sites are416/444. #1580 documents the same cmocka diagnostic-symbol link contract for a different test, fixed in #1591 via fprintf(stderr,...) plus plain fail while retaining all conditions/arguments/assertions. #1580 itself is CLOSED/resolved and is not reopened by this distinct test regression. #1714 introduced this test (07988d6).Please address under the existing #1713 ownership with focused RED→GREEN diagnostic-link coverage and real Windows Tier2. This is evidence/coordination, not a claim of #1713 or a proposal to weaken assertions. My #1269 branch changes no existing C test/public header or WebSocket plugin. No workflow retry or guessed source fix. The full experiment remains live; its Flatpak probe result is a separate observation.
libobs: Refuse an output size that the alignment makes invalid
libobs: Refuse an output size that the alignment makes invalid (obs-r…
rdoupe commentedon Oct 22, 2026
Windows link fix for test_video_output_plan is up in #1743. #1741 converted three of the four fail_msg() calls, but the one in output_size_check_edges (from #1734) is still on master, so the Windows link still fails. #1743 converts it (fprintf(stderr) + fail(), same as #1591) and adds a CI check that catches fail_msg() in any cmocka test Windows builds. It carries ci-full so the Windows Tier 2 run proves the link.
ci: Catch fail_msg() in cmocka tests that Windows builds
test: Report cmocka failures without fail_msg() where Windows builds …
ci: Catch fail_msg() in cmocka tests that Windows builds
test: Report cmocka failures without fail_msg() where Windows builds …
ci: Catch fail_msg() in cmocka tests that Windows builds
test: Report cmocka failures without fail_msg() where Windows builds …
test: Report track-row failures without fail_msg()
ci: Catch fail_msg() in cmocka tests that Windows builds (obs-rust#1743)
libobs: Add Tier 1 tests for the video output plan port
libobs: Port the video output plan to obs-core
obs-c-oracle: Compare the video output plan port with the original C
docs: Add the obs-core rows for the video output plan port
libobs: Port the video output plan to obs-core (obs-rust#1773)
zackees commentedon Oct 24, 2026
Claiming: the last part of #1713, rejecting fps 0 (#1773 left it out).
obs_reset_video()passesfps_numtoutil_mul_div64as the divisor (obs.c.h:471) without checking it. Plan: (1) RED: a cmocka test that callsobs_reset_videowith fps_num 0 and with fps_den 0 and expectsOBS_VIDEO_INVALID_PARAM; (2) GREEN: reject both next to the existing size checks. Then close #1713. PR within the hour.test: format test_video_reset_fps.cmake (#1713)
zackees commentedon Oct 24, 2026
Closed by #2174:
obs_reset_video()now refuses a zerofps_numorfps_denwithOBS_VIDEO_INVALID_PARAMbefore teardown (test_video_reset_fps). With #1714, #1734, #1743 and #1773 that completes this unit; nothing left.libobs: Refuse a zero frame rate in obs_reset_video (obs-rust#1713) (o…