Skip to content

libobs: Copy a reused canvas texture without blending - #581

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/subtract-blend-rescale
Oct 13, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/subtract-blend-rescale

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Description

With a source set to Subtract blending, a rescaled recording or stream no longer shows black where the program shows the subtracted colour.

An encoder with its own scaled size (Rescale Output, Enhanced Broadcasting renditions) gets its own video mix, which reuses the main mix's canvas texture by drawing it (draw_mix_texture() in obs-video.c). That draw used the default blending, which multiplies the colour by the texture's alpha. Subtract blending subtracts alpha too, so where an opaque source is subtracted from an opaque background the canvas holds colour with alpha 0; the main output ignores alpha, the reusing mix made it black. The copy is now drawn with blending off (state pushed and popped), so the reusing mix gets exactly what the main mix rendered. No public API changes.

  1. test/cmocka: Add failing test for a rescaled output of a subtracted canvas: test_scaled_mix_alpha puts an opaque grey background and an opaque darker box on the program, runs a raw video encoder on the main mix and one with a scaled size (GPU scaling, a second mix), and compares the mean luma. The cases are:
    • subtracted box: fails today (unscaled 172, scaled 16, black);
    • control: a normal box, both 71.
  2. libobs: Copy a reused canvas texture without blending: the fix. 2 of 2 pass (subtracted: 172 and 172).

Motivation and Context

Fixes #580 (upstream obsproject/obs-studio#10746, reported by skedgyedgy; confirmed there by cjmaxik with Enhanced Broadcasting).

Reproduced in the current release (AppImage 33.0.0-beta6-799), headless, private config, over obs-websocket: canvas 640x360, Advanced output recording, a dark red box with Subtract blending over a light grey background. Rescaled to 320x180, the subtracted area records as (0, 0, 0); without rescaling, as (149, 190, 190).

With the fix, the same steps in a frontend build of this branch record (149, 190, 190) with and without rescaling.

Why this one: wrong picture in recordings and streams for a documented blending mode, reported and confirmed by real users; a contained fix in libobs, reproduced in our release.

How Has This Been Tested?

Automated, in both libobs lanes (ENABLE_RUST_LIBOBS OFF and ON), on current master:

  • test_scaled_mix_alpha: 1 of 2 cases fails at the RED commit and 2 of 2 pass at GREEN in each lane (core video under Xvfb, both cases ran).
  • Full ctest at GREEN, rebased on current master: 170 of 170 in each lane, with every PipeWire and PulseAudio test actually run (TMPDIR unset; only the known open_crashes_without_obs_core skips).
  • clang-format and gersemi are clean.

By hand: the end-to-end runs above with a frontend build of this branch.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR
  • I am an AI agent being used to assist with this pull request: Claude Code (Claude Opus 5.5) wrote the code, commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 13, 2026 14:26
rdoupe and others added 2 commits October 13, 2026 07:33
…anvas

With a source set to Subtract blending, a rescaled recording or stream
shows solid black where the program shows the subtracted colour. In the
current release (Advanced output, recording rescaled from 640x360 to
320x180), a dark box subtracted from a light grey background records as
black (0,0,0); without rescaling it records the subtracted colour.

Subtract blending subtracts alpha too, so where an opaque source is
subtracted from an opaque background the canvas holds colour with alpha
0. The main output ignores alpha. An encoder with its own scaled size
gets its own video mix, which reuses the main mix's canvas texture
(draw_mix_texture() in obs-video.c) by drawing it with the default
blending, which multiplies the colour by that alpha.

The test puts an opaque grey background and an opaque darker box on the
program, runs a raw video encoder on the main mix and one with a scaled
size (GPU scaling, so a second mix), and compares the mean luma. On
master:

  subtracted box:  unscaled 172, scaled 16 (black)

1 of 2 cases fails. The control passes: with a normal box both encoders
see the same picture (71).

Core video needs a display on Linux; the cases skip without one (run
under xvfb-run).

Reported upstream by skedgyedgy; confirmed there by cjmaxik.

Refs obs-rust#580.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An encoder with its own scaled size (Rescale Output) gets its own video
mix, which reuses the main mix's canvas texture by drawing it into its
own (draw_mix_texture()). That draw used the default blending, which
multiplies the colour by the texture's alpha. Subtract blending leaves
colour with alpha 0 where an opaque source is subtracted from an opaque
background, so in a rescaled recording or stream those areas were black,
while the program showed the subtracted colour.

Draw the copy with blending off, so the reusing mix gets exactly the
canvas the main mix rendered.

Fixes obs-rust#580.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=e79a8e6a1b5b3ffc6227cd343dc601ee45c41900 secs=406 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791902421,"gate":"rust/all/fmt","host":"linux-x86_64","key":"a8e0d5e3fa9fc8dd56dba4064bb79e156fa4f16ac2d129c27e50ff0ce4a355c7","lane":"lint","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":37,"stamp":"d24413e11ce44103d98a4e0e10895850","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"a8e0d5e3fa9fc8dd56dba4064bb79e156fa4f16ac2d129c27e50ff0ce4a355c7","lane":"lint","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":37,"stamp":"072f859b73cc536d9ce8ca4c25dd16b9","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"33e42b31809dd85f17d10b4fec54d8d2594b803280ad495ca403745bd303dace","lane":"rust-test","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":148,"stamp":"04935f237eb8c700ea0c8751d726cc68","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"a0964ee322644585ba2d3fb97216f16b","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"2b37eca6ebc00f3e12b386d9ba6b2db3","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"735964c413c0a025963e4f2f0dfac893","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"e52d57788bce8f91eddc4ae50faaf056","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"67bd068cec1621063cc2815a674664b6","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"ca7f86fcc5d848316dd5d46f1ca5c98a160c823f8c2a3566509d43da0a25b2de","lane":"cross","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":106,"stamp":"8e8c2b54aad377465cb9d834b17a9c5f","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
Ci-Attestation: {"at":1791902421,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"0ca3d802d26bb9cc12f1c892191078ef80ff5dd3436a8a2c4d7722aaa4610e02","lane":"tier2-linux","parents":["b177a901d28936f68c3437827292ea640557e9ae"],"secs":114,"stamp":"10b807e2d2d415d6133fa50e327fb4a2","tree":"e79a8e6a1b5b3ffc6227cd343dc601ee45c41900","v":1,"via":"run"}
@zackees

zackees commented Oct 13, 2026

Copy link
Copy Markdown
Member

Verified locally under xvfb-run (Tier 2 image + mesa):

  • RED 452e304: test_scaled_mix_alpha fails subtracted_canvas_reaches_scaled_encoder
  • GREEN 5399a66: 2/2. It needs a display, so plain CI skips it.
  • Rebased on master, local gate passed; pushed as c524a8a.

@zackees
zackees force-pushed the fix/subtract-blend-rescale branch from 5399a66 to c524a8a Compare October 13, 2026 14:40
@zackees
zackees merged commit 96600fd into obs-rust:master Oct 13, 2026
19 checks passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 24, 2026
…2133)

* libobs: Move the output frame copy plan and scale effect into obs-video-copy-plan.c

Behaviour-neutral extraction before the Rust port. The decisions of
set_gpu_converted_plane(), set_gpu_converted_data(), copy_rgbx_frame(),
get_scale_effect_internal(), resolution_close(), get_scale_effect() and the
per-mix match of can_reuse_mix_texture() move to
libobs/obs-video-copy-plan.c.h, as five functions on plain values declared in
the new libobs/obs-video-copy-plan.h without EXPORT (hidden, as
-fvisibility=hidden keeps them):

- obs_video_gpu_copy_plan(format, width, height, in_linesize, out_linesize):
  the copies of set_gpu_converted_data(), one per plane: one memcpy() of
  width * height when the row size and both line sizes match, else height
  rows of the row size at the two strides. The switch is moved as it was,
  with its uint32_t row sizes (width * 2, width * 4, width / 2) and its
  size_t product; the UV copy of a packed NV12 or P010 frame (input
  linesize[1] of 0) is marked to start where plane 0's source ended, at
  linesize[0];
- obs_video_rgbx_copy_plan(width, height, in_linesize, out_linesize):
  copy_rgbx_frame()'s one copy of linesize * height when the line sizes
  match, else rows of (size_t)width * 4;
- obs_video_scale_resolution_close(): resolution_close(), still in long;
- obs_video_scale_effect_choice(input): get_scale_effect() with
  get_scale_effect_internal(): the default effect when close, else the
  bilinear low resolution effect when the output is under half the base size
  on both axes, else the scale type's, with the bicubic-else-default
  fallback when that effect did not load. Which effects loaded comes in as
  a bit mask; the result is an enum;
- obs_video_mix_reuse_match(other, mix): one comparison of
  can_reuse_mix_texture() (view, render space, base size, other rendered).

obs-video.c.h keeps every memcpy(): set_gpu_converted_plane() now runs one
copy of the plan and returns where its source ended, set_gpu_converted_data()
gets the plan and runs its copies in order (copy i from input plane i or
from plane 0's end, into output plane i), and copy_rgbx_frame() runs its one
copy. It also keeps the frame lock and unlock, video_output_get_info(), the
effect pointers (scale_effect_pointer() maps the enum to obs->video's,
loaded_scale_effects() builds the mask), and the walk of the mix list.

What changes in what the C reads, not in what it does:
- get_scale_effect() reads which effects loaded (five pointer reads) before
  deciding. video_output_get_info() is still called only when the target is
  not close to the base size, as before;
- can_reuse_mix_texture() reads the five fields of each earlier mix (and of
  this mix's texture_rendered, which the match ignores) before comparing,
  instead of stopping at the first that differs.

Checked in a scratch harness (not committed) that compiles origin/master's
functions verbatim against the moved ones and the new callers, on stand-in
mixes and frames: 1,200,000 GPU and 1,200,000 RGBX copies on real buffers
(under ASan) write the same bytes; 6,000,000 of each with full-range u32
sizes and line sizes (the width * 2 and * 4 wraps included) make the same
memcpy() calls (destination, source, size, in order); 24,000,000 scale
effect choices return the same pointer with the same video_output_get_info()
calls, resolution_close() agrees on the same 24,000,000, and 21,000,000 mix
walks return the same result and index. Deliberately broken moves (P416's
width * 4, the RGBX row size, the packed UV stride, the close bound, the
fallback, the rendered check) all fail it.

The scale types are copied into the header, so it needs only
media-io/video-io.h; obs-video.c.h checks them against obs.h, and
OBS_VIDEO_COPY_MAX against NUM_CHANNELS, with _Static_assert. The new file
joins libobs.core-output, before obs-video.c.h, with libobs.pch.h, which
includes the new header; source-sets.json lists it.
docs/rust-port/naming.md maps it to rust/obs-core. The exported symbol sets
are unchanged (1766); the five functions are local.

git log -L on each moved function shows only upstream history. The fork's
obs-rust#581 changed draw_mix_texture() (the reused texture is drawn without
blending), which stays in obs-video.c.h unchanged; the reuse match it
depends on is moved as it was.

Refs obs-rust#2118

* test: Characterize the output frame copy plan and scale effect

test_video_copy_plan_steps compiles libobs/obs-video-copy-plan.c.h into
itself (ASan and UBSan) and calls only its five hidden functions, through
obs-video-copy-plan.h. 22 cases pin:

- every video_format: the seven with a GPU conversion (I420, NV12, I444,
  I010, P010, P216, P416) make their 3 or 2 copies, every other format and
  two values outside the enum (VIDEO_FORMAT_R10L + 1, 0x7fffffff) none;
- each format's copies by value: row sizes (width, width / 2, width * 2,
  width * 4), rows (height, height / 2), the strides, and one copy of
  row * rows only when the row size equals both line sizes;
- the packed NV12 and P010 frame (input linesize[1] of 0): the UV copy
  starts where plane 0 ended and uses input linesize[0]; linesize[2] does
  not matter, and P216 with linesize[1] of 0 is not packed;
- each input and output line size moved off the row size alone, for every
  format, turning only the copies that read it into rows;
- widths 0, 1, 2, 3, 639, 640, 1919, 1921 against heights 0, 1, 2, 3, 359,
  1081, tight and padded (the halves round down);
- characterized, not endorsed: widths near the wrap (0x40000000,
  0x7fffffff, 0x80000000, 0x80000001, 0xffffffff) with heights up to
  0xffffffff: width * 2 and width * 4 wrap in uint32_t (P416's plane 1 of a
  0x40000000-wide frame is 0 bytes, and with line sizes of 0 it is one copy
  of 0), while the single copy's size is a size_t product;
- copy_rgbx_frame(): matching line sizes are one copy of line size *
  height, even under width * 4 (characterized, not endorsed); otherwise
  rows of (size_t)width * 4, which does not wrap at 2^32;
- resolution_close() at -17, -16, -15, 0, 15, 16, 17 on each axis and
  both, one close axis not being enough, and the ends of the sizes
  obs_reset_video() allows (2 and 32768);
- the scale effect: close is the default for every type, output size and
  loaded mask; the type table (bilinear is the default effect; disable,
  point and values outside the enum are bicubic); the low resolution rule
  (strictly under half on both axes of the output's size, the halves
  rounding down, never for a base of 0 or 1); each type x low resolution or
  not x each of the five effects missing; and each type x low resolution or
  not x close or not x all 32 loaded masks;
- the mix reuse match: each of view, render space, base width and height
  and the other mix's rendered flag, with this mix's flag ignored.

The test is in the core suite of the test graph and links libm except on
MSVC. test_video_output_formats, test_scaled_mix_alpha,
test_encoding_lag_rescale and test_video_output_plan cover the callers
through the real libobs.

Refs obs-rust#2118

* obs-core: Add Tier 1 tests for the output frame copy plan port

The safe API of obs_core::video_copy_plan, with todo!() bodies: FrameCopy
and CopyPlan (struct obs_video_copy and struct obs_video_copy_plan),
ScaleEffect and its loaded bits, ScaleInput, MixReuseKey, and
gpu_copy_plan(), rgbx_copy_plan(), resolution_close(), scale_effect() and
mix_reuse_match(). Formats and scale types outside their C enums are None,
which takes the C's default.

tests/obs_core/video_copy_plan.rs ports test_video_copy_plan_steps.c 1:1:
its 22 cases as steps_*, under the same names, in the same order, with the
same values, the "characterized, not endorsed" ones included. Eight new
edge_* cases add:
- resolution_close() against a 32-bit long (MSVC: the conversion and the
  subtraction emulated in i32, overflow detected) for every size
  obs_video_size_valid() allows (2 to 32768) against every size within 40
  of it and the two ends, and for every size below 2^31 in a proptest; and
  against an i64 subtraction for full-range u32 sizes;
- proptests (4096 cases each) over every format with full-range u32 sizes
  and line sizes, biased to the row sizes so the single copy is taken, the
  packed NV12 and P010 included; values outside the enum; the RGBX copy;
  the scale effect over full-range sizes, every type and loaded mask, and
  targets near the base size; and the reuse match over full-range keys with
  each field flipped.

soldr cargo test -p obs-data --test obs-tests-core --
obs_core::video_copy_plan:: fails 29 of 30 with "not yet implemented";
steps_constants, which reads only the constants, passes.

Refs obs-rust#2118

* obs-core: Port the output frame copy plan and scale effect

Ports libobs/obs-video-copy-plan.c.h, the output frame copy plan and the
scale effect choice of obs-video.c, to the video_copy_plan module of
rust/obs-core, next to video_plan (which sizes the conversion textures this
copies from; the two stay separate). obs-video.c.h stays C around it: every
memcpy() (set_gpu_converted_plane() runs each copy), the frame lock and
unlock, video_output_get_info() (still only when the target is not close to
the base size), the effect pointers and the walk of the mix list. The hybrid
libobs drops the C file and links the Rust shims in its place.

Safe core (src/video_copy_plan.rs):
- gpu_copy_plan(): per format, the copies of each plane: one copy of
  row * rows when the row size equals both line sizes, else rows of the
  row size at the two strides; the packed NV12 / P010 UV copy (input
  linesize[1] of 0) continues input plane 0 at its line size. The row sizes
  are u32 with wrapping_mul (width * 2 and * 4 wrap, as in C); the single
  copy's size is a usize wrapping product, as size_t. Every format is
  matched by name, so a new one must be placed;
- rgbx_copy_plan(): one copy of linesize * height when the line sizes
  match, else rows of width * 4 as a usize product;
- resolution_close(): u32::abs_diff <= 16 on both axes. That is
  |(i64)a - (i64)b| for every u32 pair, which is the C's long on LP64, and
  equals a 32-bit long (MSVC) for every size below 2^31: Tier 1 checks it
  for every size obs_video_size_valid() allows against every size near it,
  and a scratch check (not committed) compared all 1,073,676,289 pairs of
  sizes from 2 to 32768 (and all of 0 to 65536) per axis;
- scale_effect(): Default when close; else BilinearLowres when the output
  is under half the base size on both axes, else the type's (Bilinear is
  Default; Bicubic, Disable, Point and None are Bicubic); then Bicubic,
  else Default, when the pick did not load;
- mix_reuse_match(): view, render space and base size equal, and the other
  mix rendered.
The module denies clippy's arithmetic, indexing, unwrap, expect, panic,
todo, unimplemented and unreachable lints, keeps no state and takes no
lock.

Shims (src/ffi/video_copy_plan.rs): the five functions keep the C
signatures. struct obs_video_copy, struct obs_video_copy_plan, struct
obs_video_scale_input and struct obs_video_mix_reuse_key are mirrored
#[repr(C)]; the enums cross as c_int (outside the enum is None, the C's
default:) and the effect returns as u32. The line sizes are read as the C
reads them, the first three of each array. No intentional differences.

C side: the file leaves libobs.core-output for its own group,
libobs.ported-video-copy-plan (LIBOBS_PORTED_SOURCES), whose PCH is
stdlib.h and obs-video-copy-plan.h; libobs.pch.h keeps the header for
obs-video.c. The functions are not EXPORT, so the shims are hidden:
rust-hidden.txt, the local: list of rust-exports.map and
rust-unexports-macos.txt. libobs-rust already links the crate's ffi. The
exported symbol sets are unchanged and equal: 1766 on the C backend, the
hybrid and libobs-c-reference; the five functions are local in all three,
and the hybrid's come from the Rust archive (no C object of the group in
the hybrid libobs). ci/test_ported_sources.py checks the group on every
host.

test_video_copy_plan_steps still compiles the C file into itself,
unchanged. It has no _rust variant: linking it against libobs_rust-static
was tried and fails with 404 undefined references, because the shims'
archive member (an obs_core codegen unit) also holds the context names, the
module locale and source rules, the audio mix and the source profiler,
which need libobs (blog, bmalloc, the graphics timers, obs_queue_task). The
real-libobs tests (test_video_output_formats, test_scaled_mix_alpha,
test_encoding_lag_rescale, test_video_output_plan) see the swap through the
hybrid.

Tier 1 obs_core::video_copy_plan passes 30/30.

Refs obs-rust#2118

* obs-core: Check the output frame copy plan port against the C

rust/obs-c-oracle/oracle/video_copy_plan.c compiles the unchanged
libobs/obs-video-copy-plan.c.h with its five functions renamed oracle_*,
plus its constants and the layout of its four structs.
tests/obs_core/video_copy_plan_parity.rs (13 tests) runs the shim, the C and
the safe core on every input and compares the results exactly: each copy
of a plan field by field with the count and the unused slots, the effect as
its C value, the close and reuse answers as bools.

- the 16 constants, and the size, alignment and every offset of the four
  structs (and the two enums' sizes), against the C;
- exhaustive over format x line-size equality: every C format value (the 26
  of the enum, VIDEO_FORMAT_R10L + 1, -1, INT_MIN, INT_MAX) against every
  pattern of the six line sizes, each the plane's row size, off it or 0
  (729), over 14 widths (0, 1, odd, even and the u32 wrap edges) and 5
  heights: 1,530,900 frames, every kind of copy reached; and every format
  with the line sizes real frames have over 14 x 14 sizes;
- the RGBX copy over 14^3 sizes with equal and unequal line sizes;
- the scale effect over every scale type from -2 to 7 and the int ends, all
  64 six-bit loaded masks and two with high bits, targets at +-15, 16, 17
  and far, and outputs at the half edges, for six base sizes (266,112
  calls, each of the five effects chosen); resolution_close around every
  edge; the reuse match with each field flipped and both rendered flags;
- proptests (8192 cases each) over full-range u32 sizes and line sizes
  biased to the row sizes and 0, full-range scale inputs (types as any
  int) and full-range reuse keys.

With a 32-bit long (MSVC) the oracle's resolution_close() is compared only
for sizes below 2^31: the C makes a size of 2^31 or more a negative long and
its subtraction can overflow. The port's i64 answer equals the C's for
every size below that, so for every size obs_video_size_valid() allows;
the shim is still compared with the core there. That is the one
intentional difference, MSVC only and unreachable.

The parity module passed 10 runs in a row with fresh seeds.
test_video_copy_plan_steps passed 22/22 run once on its own under ASan and
UBSan (detect_leaks, halt_on_error). The committed regression files hold
the seeds proptest saved while mutants failed; all pass on the port.

Mutation check (not committed): 49 mutants, 41 in the core and 8 in the
shims, each run against Tier 1 (30 tests) and Tier 3 (13). 45 fail; the 4
that survive are equivalent (a size_t product that cannot wrap on a 64-bit
host saturating instead, the one-copy size taken from the other of two
equal line sizes, twice, and a scale type outside the enum read as
bicubic, which is what outside the enum means). Tier 1 does not reach the
shims; Tier 3 kills every shim mutant. A resolution_close() done as a
32-bit long is killed by Tier 3 only (the oracle is LP64 here).

Refs obs-rust#2118

* docs: Record the output frame copy plan port

rust/README.md gets the obs-core crate row and a port row for
libobs/obs-video-copy-plan.c.h: the five hidden functions, what
obs-video.c.h keeps (every memcpy(), the frame lock, video_output_get_info(),
the effect pointers, the mix walk, obs-rust#581's draw_mix_texture()), the C's
wrapping arithmetic kept, the MSVC-only resolution_close() note, why there
is no _rust variant, and what Tier 2 and Tier 3 cover. The crate's
description and lib.rs list the module; video_copy_plan.rs and the shims
carry the intentional difference: with a 32-bit long (MSVC) the C's
resolution_close() overflows for sizes of 2^31 and up, where the port
answers as i64; no texture or video size comes near.

port_comparison gets its own bench file, port_comparison/video_copy_plan.rs:
1024 copy plans over the GPU formats and BGRA at 1080p, 720p and 4K, tight
and padded, NV12 and P010 packed now and then; 1024 scale effect choices;
1024 RGBX plans with reuse matches. Each side folds its results into a
checksum both must match.

Fixes obs-rust#2118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: Subtract blending shows black in a rescaled recording or stream (upstream obsproject/obs-studio#10746)

2 participants