Repository navigation
Decode frame pictures of streams that permit field coding (#16) - #26
Merged
Merged
Conversation
frame_mbs_only_flag == 0 only permits field coding. x264's fake-interlaced (needed for Blu-ray 1080p25/30) sets it while coding every picture as a progressive frame, and those streams were refused at the SPS. Now the SPS reads mb_adaptive_frame_field_flag and refuses only MBAFF; the height is counted in field map units (FrameHeightInMbs = 2 * PicHeightInMapUnits) and the vertical crop unit is 4. Slice headers read field_pic_flag and refuse only field pictures. Everything else about a frame picture decodes as before. Fixes #16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fake_interlaced.rs covered the decode path and the MBAFF refusal at the
SPS; the other half of the change, the per-slice field_pic_flag refusal,
had no vector. field_pic.264 is fake_interlaced.264 with field_pic_flag
set in the first IDR slice header (one bit, NAL bit 21). The test requires
Unsupported("... (field picture)") from decode_stream and from per-AU
decode, and that no later AU then yields a frame.
Real field-coded streams were also checked by hand against this branch
(JVT conformance CVFI1_Sony_D, all field pictures; CVPA1_TOSHIBA_B, PAFF;
CAMA1_Sony_C / CVMA1_TOSHIBA_B / CAPAMA3_Sand_F and x264 interlaced=1,
MBAFF): every one is refused with an Unsupported error, no panic, serial
and RS_H264_FRAME_THREADS=4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 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.
Carries @rickeyski's fix from #22 unchanged (commit 7da3ea0, authorship kept), plus one commit adding a field-picture refusal vector. Opened from this repo's branch because CI for fork PRs needs approval and the extra test had to ride along; #22 will be closed in favour of this with thanks. (#23, the High 10 work that stacks on #22, is untouched.)
Fixes #16.
The fix (from #22)
frame_mbs_only_flag == 0only permits field coding. The SPS now readsmb_adaptive_frame_field_flagand refuses only MBAFF. Height is counted in map units (FrameHeightInMbs = 2 × PicHeightInMapUnits), and CropUnitY becomes 4. Both slice-header parsers (lib.rsand the frame-MT POC peek inframe_mt.rs; I grepped, there are no others) readfield_pic_flagand refuse field pictures. Frame pictures decode as before.Added here
field_pic.264is the PR'sfake_interlaced.264withfield_pic_flagset in the first IDR slice (one bit).field_picture_is_refusedrequiresUnsupported("… (field picture)")fromdecode_streamand from per-AUdecode, and that no later AU produces a frame.Evidence: CLI
decodevsffmpeg -f rawvideofake-interlaced=1:pic-struct=1veryfast (B-frames)interlaced=1(MBAFF)… (MBAFF)… (MBAFF)… (field picture)decode_stream: refused… (field picture)No panics on any of them, serial or
RS_H264_FRAME_THREADS=4. Per-AUDecoder::decodeon CVPA1: every field AU errors, and the P/B frame pictures that depend on them error too ("inter without reference" / "B without references" / "bitstream truncated"). The only frame produced is AU 46, a non-IDR I frame picture, which has no dependencies. No garbage frames are emitted.A fake-interlaced stream with
no-deblock=1still shows the #15 bottom-row bug on this branch alone (49/50 frames differ). That is fixed by #25 and is re-checked after both merge.🤖 Generated with Claude Code