Repository navigation
libobs: Fix Yadif 2x field order for bottom field first - #317
Merged
Merged
Conversation
zackees
approved these changes
Oct 12, 2026
A test async source outputs interlaced BGRA frames at 30 fps into a 60 fps canvas. Every field carries its capture index in its rows and its parity in green, so each output frame can be classified by the field it kept. The fields shown must never go back in time, for Yadif 2x, Linear 2x and Discard 2x (Retro), top and bottom field first. On master Yadif 2x with bottom field first shows the fields as 1 3 0 5 2 7 4 9 6 ... (35 steps back in time over 36 frames), while top field first and the Linear 2x and Discard 2x cases are in order. Reported upstream in obsproject/obs-studio#6061 by ray890. Refs obs-rust#316. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Yadif keeps one field and interpolates the other from the previous and current frames. load_at() picked the frame by row parity alone: top rows from the current frame, bottom rows from the previous one. That is right for top field first, where the 2x pass shows the previous frame's bottom field and then the current frame's top field. For bottom field first it shows the current frame's top field and then the previous frame's bottom field, so every other output frame went back three fields in time (1 3 0 5 2 7 4 ...), and the kept field was not between the two frames it was interpolated from. Take the first field of a frame (the parity opposite field_order) from the current frame and the second from the previous one. Top field first output is unchanged; bottom field first now shows 1 2 3 4 ... like top field first, also with single-rate Yadif keeping the field between its neighbours. rob-fi found this condition while testing on DV footage in the upstream issue. Fixes obs-rust#316. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=dd2d92fb3593d4f6e85152bd669a590c6abd405d secs=116 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791782082,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ed7f2cdfee5b155a7f9f37a67a15f779ce6c81312e2b31af7d38cce8a9928569","lane":"lint","parents":["a52bee134a202a877decfbf16d80192e0d6e6c8c"],"secs":16,"stamp":"a9c18a3452b68a735f1668ac173c72d3","tree":"dd2d92fb3593d4f6e85152bd669a590c6abd405d","v":1,"via":"run"} Ci-Attestation: {"at":1791782082,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ed7f2cdfee5b155a7f9f37a67a15f779ce6c81312e2b31af7d38cce8a9928569","lane":"lint","parents":["a52bee134a202a877decfbf16d80192e0d6e6c8c"],"secs":16,"stamp":"781597a0cbe580e2eb8d71e9e02dc92e","tree":"dd2d92fb3593d4f6e85152bd669a590c6abd405d","v":1,"via":"run"} Ci-Attestation: {"at":1791782082,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ea9e096a176bf244ead39c5f119d69f4c58c329cf3b1d8da651ce3f052e412c6","lane":"rust-test","parents":["a52bee134a202a877decfbf16d80192e0d6e6c8c"],"secs":46,"stamp":"8cedae9ccc6b9163759e735f0e883a2a","tree":"dd2d92fb3593d4f6e85152bd669a590c6abd405d","v":1,"via":"run"} Ci-Attestation: {"at":1791782083,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4db66a04d528e856ae47878c87435d449fbd2b7f1416eae9f3c795862a012f26","lane":"tier2-linux","parents":["a52bee134a202a877decfbf16d80192e0d6e6c8c"],"secs":54,"stamp":"743c39309cfa72c7de48b64824448969","tree":"dd2d92fb3593d4f6e85152bd669a590c6abd405d","v":1,"via":"run"}
Member
|
Verified locally on master. The test renders through libobs-opengl, so I ran it with
Merging once CI is green. |
zackees
force-pushed
the
fix/6061-yadif-2x-field-order
branch
from
October 12, 2026 05:14
715344f to
a316e42
Compare
This was referenced Oct 12, 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.
Description
Yadif 2x deinterlacing of bottom-field-first video now shows the fields in capture order instead of jumping back and forth.
In
deinterlace_base.effect,load_at()picks the frame by row parity only (even rows from the current frame, odd rows from the previous one), andtexel_at_yadif_2x()keeps rows of parityfield_orderon the first pass and the other parity on the second (field_orderis 1 for top field first, 0 for bottom field first,obs-source-deinterlace.c). For top field first that shows the previous frame's bottom field and then the current frame's top field, which is in order; for bottom field first it showed the current frame's top field and then the previous frame's bottom field, so every other output frame went back three fields in time. Upstream 84ce107 (2016) flipped the linear and discard 2x modes and kept yadif 2x as "correct due to how it operates", which only holds for top field first.test: Check double-rate deinterlacing keeps fields in capture order:test_deinterlace_2x_field_orderregisters an async BGRA source that outputs 36 interlaced frames at 30 fps into a 60 fps canvas, with each field's rows carrying its capture index and parity, and classifies every output frame (obs_add_raw_video_callback) by the field it kept. It asserts the shown fields never go back in time and that at least 36 fields appear, for Yadif 2x, Linear 2x and Discard 2x, each top and bottom field first. Today only Yadif 2x bottom field first fails:1 3 0 5 2 7 4 9 6 ..., 35 steps back in 71 fields.libobs: Fix Yadif 2x field order for bottom field first: one line in the form of rob-fi's workaround from the upstream thread — the first field of a frame now comes from the current frame and the second from the previous one, so the kept field always sits between the two frames it is interpolated from. Top field first output is mathematically unchanged. All 6 cases pass (1 2 3 4 ...).Side effect: single-rate Yadif with bottom field first now keeps the previous frame's top field rather than the current one, matching what top field first already did (one field of latency, correct yadif bracketing).
Motivation and Context
Fixes #316 (upstream obsproject/obs-studio#6061, reported by ray890; also faradey8951 and rob-fi)
Why this one: Yadif 2x is the recommended deinterlacer, and with bottom-field-first sources (DV and many capture devices) it visibly judders; open since 2022 with users' own shader patches. No upstream fix exists.
How Has This Been Tested?
Automated, in both libobs lanes (
ENABLE_RUST_LIBOBSOFF and ON), rebased on current master:test_deinterlace_2x_field_order: 1 of 6 fails at the RED commit (Yadif 2x BFF), 6 of 6 pass at GREEN (5 repeated runs).ci/test_registration.pyare clean; the test is registered for Linux only, with its working directory inside that guard.Not tested: Blend 2x (its shader ignores
field_order; possibly a separate bug), single-rate Yadif with BFF, real interlaced media, GPU-converted async formats (NV12/I420), and the D3D11 and Metal backends (the change is a plain integer comparison in the shared effect; only OpenGL/llvmpipe was run).Types of changes
Checklist:
🤖 Generated with Claude Code