Commits
Commits on
00c1b3ff2d80d84fef71bb6208110dedbbd95fc4Filtered to crates/ec-hw/src/dec/dpb264.rsClear filter2026-08-20
fix(h264): drop leading pictures after a seek's open-GOP recovery pointAhmet Kaan Gümüş · 03dc6e9
fix(h264): drop leading pictures after a seek's open-GOP recovery point Root cause (crates/ec-h264/src/dpb.rs, crates/ec-h264/src/decoder.rs; mirrored in crates/ec-hw/src/dec/dpb264.rs, crates/ec-hw/src/dec/h264.rs): an open-GOP I picture is not an IDR — it is a plain I slice whose predecessors in decode order can still be referenced by pictures that follow it. A decoder started fresh at that I (exactly what a seek does) has none of those earlier references, so `build_ref_lists` pads the missing entries with whatever it has. The old code decoded and output those leading pictures anyway, handing back frames predicted from padded (garbage) references before the stream ever reaches a picture whose references are all real. Annex D.2.8 defines a `recovery_point` SEI whose absence (the common case, and this fixture's case) defaults `recovery_frame_cnt` to 0: the recovery point is the RAP's own POC, i.e. only pictures with a POC at or after the leading I's own POC are guaranteed fully referenced. The SEI itself is deliberately not parsed — the default already gives the correct threshold for the case that matters (mid-GOP seek), and a real non-zero `recovery_frame_cnt` is out of scope for this fix. `build_ref_lists` now returns whether it had to pad a list ((lists, padded)); `Decoder`/`H264Decoder` OR that per-slice into `cur_ref_padded`/`Current::ref_padded`, latch the first post-reset picture's POC into `recovery_poc` on `end_picture`/`finish_picture`, and compute `output_ok = !(ref_padded && poc < recovery_poc)`. `Dpb::store` takes that flag and marks the picture `Mark::Unused`-eligible for output gating (`pic.output = output_ok`) — it still joins the DPB as a reference and for bookkeeping, but a gated picture is never handed to a caller. `reset_pictures` clears `recovery_poc` so a later seek gets its own threshold. New test `h264_seek_matches_linear_open_gop` in both suites drives this through the real entry surface: fixtures/video/h264-open-gop.mp4 (x264 open-GOP, generated via scripts/gen-fixtures.sh) primes a fresh decoder with the leading IDR's parameter sets, resets picture state (a seek's exact contract), feeds it from the open-GOP I access unit before display frame 30, and asserts the first decoded picture matches a linear decode of frame 30. Confirmed failing before this fix (forcing output_ok true reproduces the mismatch) and passing after, on both the software decoder (crates/ec-h264/tests/conformance.rs) and the VA-API path (crates/ec-hw/tests/gpu.rs, real hardware). cargo test -p ec-h264: 70 lib + 23 conformance + 8 encode passed, 0 failed. cargo test -p ec-hw --test gpu -- --test-threads=1: 19 passed (18 pre-existing + the new one), 0 failed.
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.