Decodes the complete PIH substream into a PictureHeader struct: the fixed prefix
(profile, synthesis transforms, level, dimensions, sub-sampling, colour_transform_idx,
model_id), then CCS_SGMM::decode_header (multi_threading_z, the quantizer beta F/O
headers with independent_beta_uv, region_partitioning), then the per-component tool
groups (multi_threading_r, num_chs, and the tools in sub-tool order: use_cube_flags,
lsbs_enable, rvs_enable, grfs_enable + per-channel flags), gain_3D_enable, and
synthesis_tile_enable per component.
Field order and conditionals ported from the reference decode_header sources
(ccs_sgmm_tool, quantization, sep_chan_tool, res_var_scale, skip_mode); notably
use_cube_flags precedes lsbs_enable, and synthesis_tile_enable trails the component
groups (both differ from the header_spec.json listing order).
Validated on real test256.bin: 256x256 4:4:4, colour_transform_idx=1, num_chs 160/96,
per-component tool flags, and end_bit=437 — i.e. EVERY field consumed exactly, up to
the 3-bit pad closing the 49-byte PIH. The grfs channel-flag counts (4 luma, 9 chroma)
independently match the sigma-additions gain fixture. Branches not exercised by this
4:4:4 single-tile stream (region sub-splits, independent beta, signalled colour matrix,
multi-threading) follow the reference syntax but are untested.
Co-Authored-By: Claude Opus 4.8 <[email protected]>