Repository navigation
libobs: Move the video output conversion plan into obs-video-plan.c - #1714
Merged
Merged
Conversation
Behavior-neutral extraction before the Rust port: the video output conversion plan moves from libobs/obs.c.h into libobs/obs-video-plan.c.h, the pure computation obs_reset_video() and the per-canvas video mix setup run before they touch the graphics device. calc_gpu_conversion_sizes(), the per-format plane table of obs_init_gpu_conversion() and obs_init_gpu_copy_surfaces(), the render-texture format and color-space choice of obs_init_textures(), size_valid() with OBS_SIZE_MIN/MAX, the output-size alignment masks of obs_reset_video_internal() and its scale-type name switch become one by-value entry point, obs_video_output_plan(format, colorspace, width, height) returning struct obs_video_output_plan (the techniques, texel sizes, each plane's size and gs_color_format, and the render format and space), plus obs_video_size_valid(), obs_video_align_output_size() and obs_video_scale_type_name(). They are declared in obs-internal.h without EXPORT; obs.c is the only caller. obs_init_gpu_conversion() and obs_init_gpu_copy_surfaces() now loop over plan.planes[] instead of a per-format switch, writing a plane for exactly the channels each format used before, at the same sizes and formats, in the same order; obs.c copies the rest of the plan into the mix. The gs_texture_create/gs_stagesurface_create calls, the NV12/P010 texture decision, graphics init, mix creation, canvases, encoder rebinding, logging and obs_init_video() stay in obs.c. The new file joins libobs.core just before obs.c.h (alphabetical), with libobs.pch.h. No group, PCH or source-sets.json change; the exported symbols are unchanged (1766) and the new functions are local. New test test_video_output_plan compiles the moved file into itself (C only, ASan and UBSan, no core, no display). It pins the plan for every video_format and video_colorspace (and one past each), odd/even/minimum/ alignment/maximum sizes, the written-out numbers for common formats, the formats without a conversion, that every technique it names is in format_conversion.effect, the size check edges, the alignment masks and the scale-type names. New test test_video_output_formats links the real libobs and its OpenGL renderer (Linux, under xvfb-run) and runs obs_reset_video() once per output format with a GPU conversion (I420, NV12, I444, I010, P010, P216, P416, with color spaces and both ranges) and BGRA/RGBA, checking each frame's plane sizes and sample values, the output-size alignment through obs_get_video_info(), and that an out-of-range size is refused before the old video is freed. Public API only, so it covers the Rust port in the hybrid build. Characterized, not endorsed: size_valid() accepts an output width of 2 or 3, and the alignment then masks it to 0. Refs obs-rust#1713
zackees
enabled auto-merge
October 22, 2026 04:41
6 of 7 tasks
This was referenced Oct 22, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 22, 2026
…ust#1734) * test: Expect obs_reset_video() to refuse an output width that aligns to 0 An output width of 2 or 3 passes the 2..32768 size check of obs_reset_video(), and the output alignment to a multiple of 4 then makes it 0. The reset has freed the old video by then, so it fails with no video left, and obs_get_video() then crashes on the missing main mix. obs-rust#1714 pinned this as characterized, not endorsed. test_video_output_plan now expects the new obs_video_output_size_valid() to refuse the widths 2 and 3 (any height) and to agree with obs_video_size_valid() for every other size, including the sizes just above the maximum. The alignment assertions are unchanged. test_video_output_formats gets a real-libobs case: a reset to a valid size, then to an output width of 2 or 3, which must return OBS_VIDEO_INVALID_PARAM and leave the old video running, then a later reset to a valid size, which must work. Refs obs-rust#1713 * libobs: Refuse an output size that the alignment makes invalid obs_reset_video() checked the output size (2..32768) before aligning the width down to a multiple of 4 and the height to a multiple of 2. An output width of 2 or 3 passed the check and was aligned to 0. By then the reset had freed the old video, so video_output_open() failed with no video left, and obs_get_video() then crashed on the missing main mix. The output size is now checked as given and once aligned, by the new hidden obs_video_output_size_valid() in obs-video-plan.c.h, before anything is freed. A width of 2 or 3 now returns OBS_VIDEO_INVALID_PARAM and the old video keeps running. Every other size is accepted or refused exactly as before: heights of 2 and 3 align to 2 and stay valid, and the alignment only lowers a size, so no size above the maximum becomes valid. The base size is not aligned and keeps its check. The Settings dialog (minimum 32) and obs-websocket SetVideoSettings (minimum 8) never send such a width; plugins and scripts can. obs_init_video() also checked pthread_mutex_init() for its three mutexes with < 0. pthread returns a positive error number, so a failure was never caught; it checks != 0 now, like the rest of obs.c.h. Refs obs-rust#1713
6 of 7 tasks
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 22, 2026
The Windows Tier 2 build stops before CTest with LNK2019, unresolved cm_print_error in check_plan: test_video_output_plan (from obs-rust#1714) calls fail_msg(), which expands to that private cmocka printer, and the Windows cmocka does not export it. obs-rust#1580 was the same failure in test_output_delay_e2e; obs-rust#1591 fixed it with fprintf(stderr, ...) and plain fail(), and added a check for that one file. ci/test_cmocka_windows_diagnostics.py generalizes that check. It reads every add_executable() in test/cmocka/CMakeLists.txt and tests.d/*.cmake, skips the ones an enclosing if() keeps off Windows (OS_LINUX, UNIX, NOT WIN32, or a plugin target that plugins/CMakeLists.txt only adds on other platforms; else() counts as Windows), and fails if any of their sources calls fail_msg(). Comments that mention fail_msg() do not count. As in obs-rust#1591, it also compiles the actual diagnostic helpers of test_video_output_plan (check_plan, techniques_exist_in_the_effect, size_check_edges, output_size_check_edges) against a model of the Windows link contract, a cm_print_error declaration with no definition, and expects each forced failure to print its diagnostic and fail. On master it fails twice: the scan finds four fail_msg() calls in test_video_output_plan.c and three in test_settings_track_rows.cpp (a Qt6::Widgets test that Windows builds), and the probe does not link (undefined reference to cm_print_error in all four helpers). Refs obs-rust#1713
rdoupe
added a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 22, 2026
The Windows Tier 2 build stops before CTest with LNK2019, unresolved cm_print_error in check_plan: test_video_output_plan (from obs-rust#1714) calls fail_msg(), which expands to that private cmocka printer, and the Windows cmocka does not export it. obs-rust#1580 was the same failure in test_output_delay_e2e; obs-rust#1591 fixed it with fprintf(stderr, ...) and plain fail(), and added a check for that one file. ci/test_cmocka_windows_diagnostics.py generalizes that check. It reads every add_executable() in test/cmocka/CMakeLists.txt and tests.d/*.cmake, skips the ones an enclosing if() keeps off Windows (OS_LINUX, UNIX, NOT WIN32, or a plugin target that plugins/CMakeLists.txt only adds on other platforms; else() counts as Windows), and fails if any of their sources calls fail_msg(). Comments that mention fail_msg() do not count. As in obs-rust#1591, it also compiles the actual diagnostic helpers of test_video_output_plan (check_plan, techniques_exist_in_the_effect, size_check_edges, output_size_check_edges) against a model of the Windows link contract, a cm_print_error declaration with no definition, and expects each forced failure to print its diagnostic and fail. On master it fails twice: the scan finds four fail_msg() calls in test_video_output_plan.c and three in test_settings_track_rows.cpp (a Qt6::Widgets test that Windows builds), and the probe does not link (undefined reference to cm_print_error in all four helpers). Refs obs-rust#1713
zackees
pushed a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 22, 2026
The Windows Tier 2 build stops before CTest with LNK2019, unresolved cm_print_error in check_plan: test_video_output_plan (from obs-rust#1714) calls fail_msg(), which expands to that private cmocka printer, and the Windows cmocka does not export it. obs-rust#1580 was the same failure in test_output_delay_e2e; obs-rust#1591 fixed it with fprintf(stderr, ...) and plain fail(), and added a check for that one file. ci/test_cmocka_windows_diagnostics.py generalizes that check. It reads every add_executable() in test/cmocka/CMakeLists.txt and tests.d/*.cmake, skips the ones an enclosing if() keeps off Windows (OS_LINUX, UNIX, NOT WIN32, or a plugin target that plugins/CMakeLists.txt only adds on other platforms; else() counts as Windows), and fails if any of their sources calls fail_msg(). Comments that mention fail_msg() do not count. As in obs-rust#1591, it also compiles the actual diagnostic helpers of test_video_output_plan (check_plan, techniques_exist_in_the_effect, size_check_edges, output_size_check_edges) against a model of the Windows link contract, a cm_print_error declaration with no definition, and expects each forced failure to print its diagnostic and fail. On master it fails twice: the scan finds four fail_msg() calls in test_video_output_plan.c and three in test_settings_track_rows.cpp (a Qt6::Widgets test that Windows builds), and the probe does not link (undefined reference to cm_print_error in all four helpers). Refs obs-rust#1713
5 of 7 tasks
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 22, 2026
* ci: Catch fail_msg() in cmocka tests that Windows builds The Windows Tier 2 build stops before CTest with LNK2019, unresolved cm_print_error in check_plan: test_video_output_plan (from obs-rust#1714) calls fail_msg(), which expands to that private cmocka printer, and the Windows cmocka does not export it. obs-rust#1580 was the same failure in test_output_delay_e2e; obs-rust#1591 fixed it with fprintf(stderr, ...) and plain fail(), and added a check for that one file. ci/test_cmocka_windows_diagnostics.py generalizes that check. It reads every add_executable() in test/cmocka/CMakeLists.txt and tests.d/*.cmake, skips the ones an enclosing if() keeps off Windows (OS_LINUX, UNIX, NOT WIN32, or a plugin target that plugins/CMakeLists.txt only adds on other platforms; else() counts as Windows), and fails if any of their sources calls fail_msg(). Comments that mention fail_msg() do not count. As in obs-rust#1591, it also compiles the actual diagnostic helpers of test_video_output_plan (check_plan, techniques_exist_in_the_effect, size_check_edges, output_size_check_edges) against a model of the Windows link contract, a cm_print_error declaration with no definition, and expects each forced failure to print its diagnostic and fail. On master it fails twice: the scan finds four fail_msg() calls in test_video_output_plan.c and three in test_settings_track_rows.cpp (a Qt6::Widgets test that Windows builds), and the probe does not link (undefined reference to cm_print_error in all four helpers). Refs obs-rust#1713 * test: Report track-row failures without fail_msg() The Windows cmocka does not export cm_print_error(), which fail_msg() expands to there, so a Windows-built test that calls it stops the Windows Tier 2 build with LNK2019 before CTest runs (obs-rust#1713: obs-rust#1741, obs-rust#1745 and obs-rust#1762 fixed test_video_output_plan). test_settings_track_rows (Qt6::Widgets only, so Windows builds it too) still had three such calls. It links on Windows today, but it is the only Windows-built test left that calls fail_msg(), and the new check holds every such test to the same rule. Each becomes fprintf(stderr, ...) with the same format and arguments and a terminating newline, then a plain fail(), under the same condition. No condition, loop, case or assertion changes. Refs obs-rust#1713
This was referenced Oct 22, 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 (PR 1 of the plan: the characterization and the extraction. The bug-4 fix and the port follow.)
What and why
This is a behaviour-neutral extraction before the Rust port, as the testing policy asks for part of a large file. The video output conversion plan moves from
libobs/obs.c.hintolibobs/obs-video-plan.c.h: the pure computationobs_reset_video()and the per-canvas video mix setup run before they touch the graphics device. There is no Rust, no behaviour change and no public header change.calc_gpu_conversion_sizes(), the per-format plane table ofobs_init_gpu_conversion()andobs_init_gpu_copy_surfaces(), the render-texture format and color-space choice ofobs_init_textures(),size_valid()withOBS_SIZE_MIN/MAX, the output-size alignment masks ofobs_reset_video_internal(), and its scale-type name switch. They become one by-value entry point,obs_video_output_plan(format, colorspace, width, height), returningstruct obs_video_output_plan(the techniques, the texel sizes, each plane's size andgs_color_format, and the render format and space), plusobs_video_size_valid(),obs_video_align_output_size()andobs_video_scale_type_name().gs_texture_create/gs_stagesurface_createand render-texture calls (now driven byplan.planes[]andplan.texture_format/plan.render_space), the NV12/P010 texture decision (it asks the device), graphics init, mix creation, canvases, encoder rebinding, logging andobs_init_video().obs.ccopies the plan into the mix, exactly the fields it set before.struct obs_video_output_plan,struct obs_video_planeand the four functions are declared inobs-internal.hwithoutEXPORT, so they are hidden. The caller is the only user; no struct internals reach the public API.libobs.coregroup just beforeobs.c.h, in alphabetical order, withlibobs.pch.h. The group, the PCH,source-sets.jsonand the CMake source lists are unchanged.t) symbols.Behaviour-neutral refactor note:
obs_init_gpu_conversion()andobs_init_gpu_copy_surfaces()now loop overplan.planes[]instead of a per-formatswitch. The plan writes a plane for exactly the channels each format used before (I420/I444/I010 three, NV12/P010/P216/P416 two, the rest none), with the same sizes andgs_color_format, so the same textures and surfaces are created in the same order. A scratch differential over every format x colorspace x a range of sizes (42525 cases) shows the plan's techniques, texel sizes, plane sizes (asgs_*call arguments), render format and render space are identical to the master code; a deliberate one-line mistake in the extracted copy makes 1575 of them differ.Tests
test_video_output_plancompiles the moved file into itself (C only, ASan and UBSan, no libobs core, no display), so it checks the C and runs on every platform. 9 cases:video_format(and one past the end) x everyvideo_colorspace(and one past) x odd, even, minimum (2), the 1366-aligns-to-1364 size and maximum (32768) widths and heights, each compared field by field against an expectation written out from the code (42875 plans).GS_RGBA16FinGS_CS_SRGB; an 8-bit format with an HDR color space still renders inGS_CS_709_EXTENDED.format_conversion.effect(the CMake build passes the effect path; the cc-build and the real-libobs test cover it otherwise).test_video_output_formatslinks the real libobs and its OpenGL renderer (Linux, under xvfb-run; skips without a display). It drivesobs_reset_video()and reads frames throughobs_add_raw_video_callback(), using the public API only, so it covers the Rust port in the hybrid build. 3 cases:obs_get_video_info()and the chroma-plane sizes.test_video_output_plan: driving it through real libobs frees the old video and then fails, and the core cannot be reset again (it crashes), so this file does not drive it.RED → GREEN
bd622f2a7libobs: Move the video output conversion plan into obs-video-plan.c.test_video_output_planpasses 9/9 andtest_video_output_formats3/3, run 3 times against each of libobs with the C backend, the hybrid libobs and libobs-c-reference. Both also pass against a libobs built from master'sobs.c.h(the libobs change reverted, the tests kept), so the move changes nothing they can see.OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON, both full builds. Fullctest -j4, headless (private Xvfb, private D-Bus, fresh HOME):OBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONNothing was skipped or failed to run. The tests were run on a885f89; the final rebase onto 51569f9 (#1709) brought in commits that touch none of the changed files (PulseAudio, CI and docs only), and
ci/test_build_groups.pypasses on the rebased head.uv run ci/local_gate.py --lane lintpassed, and--lane crosspassed. clang-format 23.1 and gersemi clean on the changed files.ci/test_build_groups.pyandci/platform_ifdef_ratchet.pypass.Windows/macOS: not built here. The moved code has no host conditional.
test_video_output_planis portable C (no cmocka range assertions) and builds everywhere;test_video_output_formatsis Linux-only (it needs the OpenGL renderer and a display).Checklist
masterdocs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): not applicable (no warning or flag change; no platform conditional moved)