You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: media-io: let video_scaler_scale write straight into the output frame #3192
libobs/media-io/video-scaler-ffmpeg.c.h:234-260 runs sws_scale into its own buffer, then memcpys each plane into the caller's preallocated frame (video-io.c.h:98-105). About 1.2 ms per frame at 4K NV12.
Proposed change
Pass output[]/out_linesize to sws_scale; keep the internal buffer only for mismatched linesizes.
Acceptance criteria
Before/after numbers (Criterion bench of video_scaler_scale at 1080p and 4K (BGRA to NV12, 4K to 1080p)) in the PR; nothing lands unmeasured.
RED then GREEN; Tier 3 parity stays bit-exact unless this issue says otherwise.
Found by a read-only code scout and not yet measured. Parent: #3176.
Claiming: perf: media-io: let video_scaler_scale write straight into the output frame
Plan, one PR:
RED: a new cmocka test scales BGRA→NV12 (1080p, and 4K→1080p) twice. Once into a frame whose planes match the scaler's internal layout (32-byte aligned pointers, linesizes ≥ the av_image_alloc linesizes and multiples of 32), and once into a frame with an odd linesize (+16). It requires identical visible bytes from both, which pins bit-exactness between the direct and the fallback path. A timing line per case (ns per frame, median of N) goes into the PR. The C oracle's copy of video_scaler_scale (rust/obs-c-oracle/oracle/video_io.c) stays the reference and is not changed, so a Criterion bench through the oracle would measure the old code. The before/after numbers therefore come from the same C test binary built on master and on the branch.
GREEN: when every output plane meets that layout, sws_scale writes into output[]/out_linesize directly. Rows then have the same padding as the internal buffer, so swscale's SIMD row writes stay inside each row and the bytes are identical. Otherwise the internal buffer and plane copy stay as today. Frames from video_frame_init use the 32-byte base alignment, so the common 1080p/720p NV12 and I420 cases take the direct path.
Tiers: libobs C only, Tier 2 (the new test and the existing scaler tests). Tier 3 is unchanged, since the oracle copy is untouched.
Activity
zackees commentedon Oct 31, 2026
/ready
zackees commentedon Nov 1, 2026
Claiming: perf: media-io: let video_scaler_scale write straight into the output frame
Plan, one PR:
av_image_alloclinesizes and multiples of 32), and once into a frame with an odd linesize (+16). It requires identical visible bytes from both, which pins bit-exactness between the direct and the fallback path. A timing line per case (ns per frame, median of N) goes into the PR. The C oracle's copy ofvideo_scaler_scale(rust/obs-c-oracle/oracle/video_io.c) stays the reference and is not changed, so a Criterion bench through the oracle would measure the old code. The before/after numbers therefore come from the same C test binary built on master and on the branch.sws_scalewrites intooutput[]/out_linesizedirectly. Rows then have the same padding as the internal buffer, so swscale's SIMD row writes stay inside each row and the bytes are identical. Otherwise the internal buffer and plane copy stay as today. Frames fromvideo_frame_inituse the 32-byte base alignment, so the common 1080p/720p NV12 and I420 cases take the direct path.First PR next tick.
perf(media-io): video_scaler_scale writes straight into a matching fr…