parse_picture_header read four flags before the GRFS channel flags; only three precede
them and the fourth trails the group:
{ multi_threading_r, num_chs, use_cube, rvs_enable, grfs_enable,
grfs_channel_flags[num_chs], lsbs_enable }
Reading four up-front shifted grfs_channel_flags one bit late, so every channel flag was
wrong — while still landing on the correct end_bit (437), because the extra leading bit
was cancelled by consuming one fewer channel flag. A cursor-position assertion catches
net drift, not compensating errors; the values it produced were silently wrong.
Found by deriving the residual-variance-scale (RVS) additive independently: the chroma
plane separates cleanly by cwg branch, so its true per-channel assignment is directly
derivable and pinned the channel flags to bit 337 (chroma) / 164 (luma) — one earlier
than assumed. With the corrected offsets the RVS reproduction is byte-exact on BOTH
planes (luma 40960/40960, chroma 24576/24576), which independently confirms the flag
counts are 5 (luma) and 10 (chroma), not 4 and 9.
Tests updated accordingly and re-validated: end_bit still 437, and the channel-flag
counts now match the independently-derived RVS assignment.
Co-Authored-By: Claude Opus 4.8 <[email protected]>