On macOS 11 every H.264 picture above AppleGVA's size floor decoded to an
all-zero frame. AppleGVA 11 (108.7.2) parses the SPS header in H.264's
older syntax: four constraint flags, then one field for the four bits after
them. Later releases hold six flags and two reserved bits there. So in 11's
parsed SPS every field from level_idc on sits 8 bytes earlier than the
driver's Sps. The driver read the record as Sps and sent the host an SPS
with the wrong level, reference count and size. The host refused it
("max_num_ref_frames is out of range", then "PPS 0 has not been received"
for each picture after), and AppleGVA's H.264 decoder reports no failure,
so the guest got untouched frames with errors=0.
The record does not say its layout, so the driver now takes, once a
session, the one layout in which the record describes the picture
(chooseSpsLayout). The checks are ones a misplaced record cannot pass by
chance:
- profile_idc and level_idc are values H.264 defines;
- the SPS's seq_parameter_set_id is its PPS's;
- the coded size is the one the output surface's size rounds up to, in
whole macroblocks (of a field pair where frame_mbs_only_flag is 0).
A record that fits no layout, or both, is refused and logged. So is a later
picture of the session that does not fit the session's layout. Nothing is
guessed. The four header bits of 11's field come back as
constraint_set4_flag, constraint_set5_flag and the reserved bits, and the
SPS written holds them as the stream did.
The layouts were measured on the guest (780M host, 2026-11-08) from a
640x480 x264 stream's records. 11.7.11 holds level_idc at 0x1c, the size at
0x820 and 0x824 and max_num_ref_frames at 0x818; 12.7.6, 13.7.8 and 26.7.2
hold them where Sps does. This matches AppleGVA 108.7.2's own reads (read
from its code). The parsed PPS has one layout on all four releases.
Tests: each of the seven x264 streams is read back whole from records of
both layouts, and only in its own, at its shown size and its coded size but
not a macroblock smaller, and not against a PPS of another SPS. The four
header bits are written back. A record that fits no layout and one that
fits both are refused. A driver session keeps the layout its first picture
showed, and refuses the other layout, a record of neither and a surface too
narrow, sending nothing of them to the host.
AppleGVA parses a stream's SPS and PPS itself and hands the video driver
only its parsed records, one 32-bit field per syntax element, with each
picture's slices. The host decodes access units as a stream gives them, so
the driver writes the parameter sets back out as Annex-B NAL units: the SPS
without its VUI, which holds nothing a decoder needs, and the PPS whole. A
scaling list's trailing run is cut short only where that is no longer, as
encoders write it, so the PPS comes out byte for byte.
The records' layout is placed by H.264's syntax order between the fields
the calls' use states. On the guest, the sets written from AppleGVA's
records of six x264 streams equal the streams' own (the SPS up to its VUI
flag): Constrained Baseline with POC type 2, Main with B-frames and weighted
prediction, High with cropping, default and custom scaling matrices (stored
in coded order) and chroma QP offsets. That check also showed each record
starts with a word that is no syntax element. The tests check the writer
against those streams' parameter sets on the Mac (`make test`).