forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on cbbd6e2ef6acafb00aeb55e460423f024126f90fFiltered to crates/ec-hw/src/dec/mod.rsClear filter

2026-08-20

feat(hw): expose HEVC prefix-SEI HDR peak and VUI colour tags on Frame/DecoderAhmet Kaan Gümüş · 7669974
feat(hw): expose HEVC prefix-SEI HDR peak and VUI colour tags on Frame/Decoder

edith's replica needs MaxCLL/MaxFALL for HDR films whose container never
carried them (they live only in HEVC content_light_level/mastering_display
SEI) — ec-hw's decode() dropped every SEI NAL on the floor. HevcDecoder now
merges ec_core::color::hevc_sei_light per access unit (sticky across frames
that carry none) and resolves VUI colour tags from the SPS; H264Decoder
resolves VUI tags only (no SEI parsing for that codec yet); VP9/AV1 report
None (not implemented). New Frame::colour()/Decoder::colour() surface it,
bundled as ec_hw::frame::Colour{description, light} over the existing
ec-core ColorDescription/ContentLight types.

Tests: hdr_film_light_level_sei_is_exposed pins MaxCLL/MaxFALL 1230/419 and
primaries/transfer/matrix 9/16/9 against the real ReelD rip;
sdr_h264_colour_never_panics proves the VUI-only path doesn't panic on an
SDR fixture (skips when no fixtures generated, same convention as the rest
of gpu.rs).

2026-08-14

fix(hw): HEVC picture order counts follow prevTid0Pic, not the last pictureAhmet Kaan Gümüş · 5f55768
fix(hw): HEVC picture order counts follow prevTid0Pic, not the last picture

A 4K HDR release decoded at 19 dB against the software decoder: right
most of the time, wrong wherever it mattered. Two clauses, one cause.

8.3.1 predicts the picture order count MSB from `prevTid0Pic` — the
previous picture with TemporalId 0 that is neither a leading picture nor
a sub-layer non-reference. Predicting from the previous picture instead
works on a stream without temporal sub-layers (every fixture here) and
puts the MSB a wrap out on one that has them, which hands the driver the
wrong references and the wrong output order.

The same NAL types say which pictures may be referenced at all: a "_N"
type is a sub-layer non-reference, and storing it as a short-term
reference lets the next picture's reference picture set match it by
picture order count.

Also passes `st_rps_bits` through, so a driver that skips a reference
picture set the slice header carried itself knows how long it was, and
adds an `EC_HW_DEBUG` trace of the per-picture DPB state — this bug was
found with it.

Five files from the real library now decode identically to the software
decoder, including the one that failed: 2160p HEVC Main10 HDR, 1080p
HEVC 10-bit, 1080p AV1 10-bit and two 1440p H.264 screen captures.
feat(hw): stateless decoding for H.264, HEVC, VP9 and AV1Ahmet Kaan Gümüş · eb589d4
feat(hw): stateless decoding for H.264, HEVC, VP9 and AV1

One decoder per codec behind one `Decoder`. The driver keeps nothing
between pictures, so everything the format spreads across frames lives
here: the H.264 decoded picture buffer with its picture order counts,
reference numbering, list initialisation and modification and marking
(clause 8.2); HEVC's reference picture sets and bumping; VP9's and AV1's
reference slots with `show_existing_frame`. Frames leave in display
order.

Three of the four incumbent defects are addressed by construction:

- The RT format follows the *stream's* bit depth, so a Main10 stream
  gets a 10-bit config and a P010 surface instead of losing two bits per
  sample.
- A `frame_num` gap is a normal condition — a seek, a lost packet, an
  encoder that skipped a picture — and the missing pictures are inferred
  per 8.2.5.2 rather than ending the hardware session. The inferred
  frames share the newest reference's surface, which is both a better
  guess than grey and the only choice this driver accepts.
- Surfaces come from a pool and mappings are guards, so a long export
  neither reallocates nor leaks.

The scaling matrices are sent for every H.264 picture whether or not the
stream carries any: a driver that never receives them dequantises with a
zero matrix and hands back a uniformly grey frame.