forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 5c8eff8ca5a0d547bfb22a690b3f7afb373da607Filtered to crates/ec-hw/tests/gpu.rsClear filter

2026-09-07

fix(tests): fixture selection matched the checkout path, not the file nameAhmet Kaan Gümüş · a8b31aa
fix(tests): fixture selection matched the checkout path, not the file name

The GPU decode tests picked their fixtures with
p.to_string_lossy().contains(codec), which sees the whole path. In a
worktree called edith_codecs-av1fast every .ivf matched "av1", so the
VP9 streams were handed to the AV1 decoder and came back as
Stream(Corrupt { context: "AV1 obu_forbidden_bit is set" }) after the
five real AV1 fixtures had decoded frame-exactly. Same shape swept in
ec-image (lossless/lossy/animated), ec-ogg and ec-mp4.
test(ec-hw): exercise the two 10-bit refusals; bench 10-bit row off the black leaderAhmet Kaan Gümüş · b19cdc4
test(ec-hw): exercise the two 10-bit refusals; bench 10-bit row off the black leader

The refusals are claims, so they are driven: a 10-bit HEVC config must
fail to build (High and Main are 8-bit profiles) and 8-bit pixels handed
to a 10-bit encoder must be refused. ec-bench's 10-bit row seeks a
minute in -- frame 0 of a film is its black leader, which coded to 1 kB
for 30 frames and benchmarked nothing (101 kB now).
feat(ec-hw): 10-bit BD row, 10-bit fps, ec-bench 10-bit row, docsAhmet Kaan Gümüş · ebea85e
feat(ec-hw): 10-bit BD row, 10-bit fps, ec-bench 10-bit row, docs

The 10-bit BD row is film B's own 1920x1024 native crop, every arm in
the 10-bit domain: hw AV1 10-bit is +36.7% BD-rate against librav1e
speed 6 10-bit and +52.9% against libaom cpu-used 6 10-bit, with all
three ladders asserted monotone. av1_encode_speed gains a 3840x1608
10-bit row, and ec-bench an 'ec-hw av1 10-bit' encode row that skips as
a row without a VA device.
feat(ec-hw): CBR, VBR and QVBR rate control for hardware encodeAhmet Kaan Gümüş · 5fcd26f
feat(ec-hw): CBR, VBR and QVBR rate control for hardware encode

The AV1 path had only ever measured CQP because the VA config was
created without a VAConfigAttribRateControl at all: a driver configured
for CQP ignores a bitrate handed to it afterwards. The attribute is now
set from the mode, and VariableBitrate / Qvbr join the enum (VBR sends
the ask as a 1.5x ceiling at 66%, QVBR sends quality_factor, which
needed a field in VAEncMiscParameterRateControl's payload).

Root cause of a 20% CBR undershoot, found by comparing with ffmpeg's own
av1_vaapi on the same clip (it undershot 8%): the HRD buffer was two
rate windows starting half full. One window, three quarters full -- what
ffmpeg asks for -- brings CBR to -4.2/-5.1/-7.9% and VBR to
+1.0/-3.8/-6.9% at 2/6/12 Mbps on film A 1080p30.

Gate av1_encode_rate_control_lands prints the whole table (pix_fmt, mode,
target, delivered, PSNR) and asserts CBR within 15%, VBR within 25%,
PSNR monotone in the target, and QVBR under its ceiling.
feat(ec-hw): 10-bit AV1 hardware encodeAhmet Kaan Gümüş · 98dcdcf
feat(ec-hw): 10-bit AV1 hardware encode

His whole AV1 library is yuv420p10le, so an 8-bit-only hardware encoder
does not serve his files. EncoderConfig gains a bit_depth (8, or 10 for
AV1: H264High and HEVCMain are 8-bit profiles by definition, which is a
fact about the profiles this crate configures, not a driver refusal), a
10-bit encoder allocates P010 surfaces, uploads through encode_16, sets
bit_depth_minus8 = 2 in the sequence parameters and high_bitdepth in the
sequence header OBU it packs. encode_frame now passes a 10-bit decoded
surface straight through when the encoder is 10-bit too, and VPPs only
when the depths or the sizes differ.

Gate av1_10bit_encode_agrees_between_two_decoders on film B's own
1920x1024 native crop: ec-av1 and libdav1d agree sample for sample on
all 10 frames, ffprobe reads yuv420p10le out of the sequence header,
decoded peak luma 610 (> 255), worst frame 48.09 dB from the source in
the 10-bit domain.
test(ec-hw): a hardware AV1 quality row against librav1e and libaomAhmet Kaan Gümüş · c1c4cb5
test(ec-hw): a hardware AV1 quality row against librav1e and libaom

Four quantisers on a 1080p crop of a film and of a screen capture from
the real-library manifest, PSNR from ffmpeg, BD-rate over the shared
quality range. The number is printed, not asserted -- a fixed-function
encoder is not a search -- but the ladders are asserted monotone.
feat(ec-hw): AV1 encode on by default, and an ec-bench hardware rowAhmet Kaan Gümüş · 24f4e5c
feat(ec-hw): AV1 encode on by default, and an ec-bench hardware row

The opt-in existed because a 2026-08-14 submission crashed the GPU; on
mesa 26.1.8 the path encodes streams two decoders agree on, so the
refusal goes rather than outliving its evidence. ec-bench gains an
'ec-hw av1 encode' row that skips as a row when there is no VA device.
feat(ec-hw): AV1 hardware encode that two independent decoders agree onAhmet Kaan Gümüş · a518304
feat(ec-hw): AV1 hardware encode that two independent decoders agree on

The AV1 encode path submitted parameters no header described: radeonsi
parses the application's sequence and frame header OBUs and writes the
stream from them, so without those OBUs the coded buffer meant nothing.
This writes both (spec 5.5.1 / 5.9.1, the subset the driver advertises:
one tile, one reference, no CDEF, no restoration, no superres), fills
the picture parameter buffer to agree with them field for field, and
prepends the temporal delimiter the driver does not emit.

Gate: ec-av1 and ffmpeg's libdav1d decode every shown frame of a
640x384 and a 1920x1080 stream sample for sample, and the coded picture
is within 60 dB of the one submitted.

2026-08-28

fix(perf-gates): retry-once-on-marginal-miss for two contention-flaky wall-clock gatesAhmet Kaan Gümüş · 6af4e5c
fix(perf-gates): retry-once-on-marginal-miss for two contention-flaky wall-clock gates

p010_zero_copy_encode_is_realtime (ec-hw) and the WebP animation total-budget
gate (ec-image) both flaked once under parallel-lane contention: real timings
just over the hard bound while another process was compiling. Both now rerun
once when the miss lands within 1.5x of the bound and keep the better
attempt; a genuine regression stays slow on both runs and still fails.

2026-08-22

test(ec-hw): slice headers count frames for stateful decodersAhmet Kaan Gümüş · 645d130
test(ec-hw): slice headers count frames for stateful decoders

Phone-class HW decoders order output from frame_num / POC; a stream whose
every slice says 0/0 judders there while desktop decoders play it cleanly
(seen on edith main's cros-codecs exports, where radeonsi writes the slice
header). ec-hw packs its own slice headers, so prove it: 64-frame P-runs
through the GPU, ffmpeg trace_headers read back — H.264 frame_num steps
+1 mod MaxFrameNum under POC type 2 with level_idc from dims+fps, HEVC
slice_pic_order_cnt_lsb steps +1. Also proves packed slice headers do not
hang the VCN ring on radeonsi for either codec.

2026-08-20

feat(ec-hw): route coded-size-mismatched encode_frame sources through VPP region copyAhmet Kaan Gümüş · 58e23aa
feat(ec-hw): route coded-size-mismatched encode_frame sources through VPP region copy

Encoder::encode_frame refused any source whose coded_size differed from
the encoder's block-rounded one (HEVC rounds to 32, so a 3840x2160 source's
2160 stayed unrounded while the HEVC coded height became 2176). Add
Vpp::convert_region (crates/ec-va/src/vpp.rs) — a VAProcPipelineParameterBuffer
submission with explicit surface_region/output_region rectangles, no
scaling — and route both 10-bit (P010) and now 8-bit coded-size-mismatched
sources through it into the encoder's own NV12 pool, placed at (0,0) using
frame.display_size. Encoder's own SPS conformance window / frame_cropping
(already sized from EncoderConfig.width/height, independent of the source
frame) makes the produced stream report the true visible size, not the
padded coded one. The pool is painted black/neutral-chroma once on
creation (Encoder::fill_black) so the padding rows a region copy never
touches are deterministic rather than driver-fresh-allocation garbage.

Real 4K HEVC Main10 mkv (3840x2160):
- encode_frame_accepts_p010_via_vpp: HEVC now accepted and round-trips
  (worst Y inf dB, worst UV 96.2 dB vs the CPU path; H264 worst Y/UV inf
  dB), and ffprobe confirms the produced stream is 3840x2160 for both
  targets.
- p010_zero_copy_encode_is_realtime (--release): H264 zero-copy 6.52
  ms/frame median (CPU path 18.80), HEVC zero-copy 5.29 ms/frame median
  (CPU path 16.95) — both under the 20 ms/frame target.

cargo test -p ec-va -- --test-threads=1: 13 + 6 doctests, all green.
cargo test -p ec-hw --release --test gpu -- --test-threads=1: 27 passed.
test(ec-va,ec-hw): verify VPP filter probe, struct layout, and P010 zero-copy encode against a real 4K HEVC HDR fileAhmet Kaan Gümüş · cffd9af
test(ec-va,ec-hw): verify VPP filter probe, struct layout, and P010 zero-copy encode against a real 4K HEVC HDR file

ec-va/tests/gpu.rs: vpp_filters_probe (vaQueryVideoProcFilters on the real
display — radeonsi advertises only VAProcFilterDeinterlacing (2), no
HighDynamicRangeToneMapping) and vpp_converts_p010_to_nv12 (Vpp::convert
end to end).

ec-va/src/sys.rs: a const size_of/offset_of assert block for
VAProcPipelineParameterBuffer against va_vpp.h:886 (224 bytes on this
target, field offsets checked through va_reserved) plus
VAProcColorProperties — the layout was already correct, this just pins it.

ec-hw/tests/gpu.rs, against a real HEVC Main10 P010 4K HDR mkv:
- encode_frame_accepts_p010_via_vpp: encode_frame (zero-copy, P010 via VPP)
  vs to_i420()+encode (CPU path), decoded back and compared. H.264: worst Y
  and UV PSNR both infinite (byte-identical after decode). H.265 is refused
  by encode_frame's own documented contract ("frame's coded size does not
  match this encoder's ... the VPP conversion pass does not resize") because
  this file's SPS pic_height_in_luma_samples (2160) is a multiple of the
  H.264 encode block size (16) but not the HEVC one (32) — an existing,
  intentional design choice, not a defect this round touched.
- p010_zero_copy_encode_is_realtime: median 6.14 ms/frame for
  decode+encode_frame (H.264, the target that isn't refused on this file)
  vs 22.55 ms/frame for decode+to_i420+encode — zero-copy is ~3.7x faster
  and well inside the 20 ms budget.

cargo test -p ec-va -- --test-threads=1: 13 passed (+2 doctests, +4
compile-fail doctests).
cargo test -p ec-hw --release --test gpu -- --test-threads=1: 27 passed, 0
failed (most non-P010 tests skip: no generated bitstream fixtures on this
checkout).
Merge branch 'ec-hw-colour-meta'Ahmet Kaan Gümüş · a5703e8Browse files
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).
Merge branch 'h264-seek-leading'Ahmet Kaan Gümüş · 665fedeBrowse files
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.
Merge branch 'ec-hw-10bit-path'Ahmet Kaan Gümüş · e7509e8Browse files
diag(hw): bench + verify the 4K 10-bit frame path, no source defect foundAhmet Kaan Gümüş · a6922c1
diag(hw): bench + verify the 4K 10-bit frame path, no source defect found

Root-caused the four consumer symptoms against the real ReelD HDR film:

1. Frame-path speed (ec-hw/tests/gpu.rs::ten_bit_4k_frame_path_is_realtime):
   120-frame bench, decode-only / +to_i420 / +to_i420_16 / +export_prime,
   pending-4 back-pressure. In --release: decode+to_i420_16 median 10.36 ms
   (39 ms budget, 3.8x headroom); export_prime 1.25 ms confirming sync()
   itself isn't the cost. In debug (unoptimized): 139.88 ms -- most of the
   consumer's 1352.5 ms/frame is optimization level plus consumer-side work,
   not a defect in Frame::to_i420_16/to_i420/with_planes, which already do
   the cached-vaGetImage, row-at-a-time, no-vaDeriveImage things the charter
   asked to check for.

2/3. P010 chroma correctness (ec-hw/tests/gpu.rs::ten_bit_4k_chroma_is_not_grey):
   3 real frames, to_i420 and to_i420_16 vs `ffmpeg -pix_fmt yuv420p{,10le}`,
   Y and UV PSNR measured separately. Both bit-exact (Y and UV both inf dB)
   at 8- and 10-bit -- the "grey chroma" symptom is not in frame.rs's P010
   unpack on this file.

4. Colour metadata (ec-matroska/tests/matroska.rs::
   real_hdr_film_container_states_no_light_metadata): the Matroska Colour
   element for this file states primaries/transfer/matrix correctly
   (bt2020/smpte2084/bt2020nc, matching ffprobe) but genuinely carries no
   MaxCLL/MaxFALL/MasteringMetadata children -- confirmed against
   `ffprobe -show_entries stream=side_data_list`, which is also empty.
   ffprobe's 1230/419 comes from a `content_light_level_information` HEVC SEI
   message on frame 0, not the container. ec-matroska is reading the
   container correctly; the gap is that nothing in this workspace calls the
   existing `ec_core::color::hevc_sei_light` reader (only self-tested in
   ec-h265-syntax) from a real decode path -- named here, not implemented,
   since ec-hw exposes no colour/light metadata surface at all today and
   building one has no reachable consumer in this repo.

cargo test -p ec-hw --test gpu -- --test-threads=1: 20/20 green.
cargo test -p ec-matroska --lib: 9/9 green (the 3 --test matroska failures
are pre-existing missing-fixture errors, `scripts/gen-fixtures.sh` not run;
unrelated to this diff, the new matroska test passed).
Merge branch 'ec-hw-enc-surface'Ahmet Kaan Gümüş · a2fc9d8Browse files
feat(ec-hw): zero-copy decode-to-encode surface path, VUI colour descriptionAhmet Kaan Gümüş · fc705c7
feat(ec-hw): zero-copy decode-to-encode surface path, VUI colour description

Encoder::encode_frame submits a Frame's decoded VA surface directly as the
encoder's source picture, with no to_i420 CPU read-back and no re-upload —
what the consumer's previous backend did for a decode-then-encode pipeline.
Refuses a cross-Display frame, a 10-bit (P010) source (no Main10 profile is
built here), or a coded-size mismatch with a typed Error.

EncoderConfig::colour(primaries, transfer, matrix, full_range) reaches the
VUI of both the H.264 and HEVC packed SPS writers
(video_signal_type_present_flag / colour_description_present_flag), so an
HDR or BT.709 export stops reading back as "unspecified".

Live-GPU tests in gpu.rs cover both: encode_frame vs the CPU-path baseline
on the same decoded frames (PSNR compared, further: they came back byte
identical on this driver), and ffprobe reading BT.2020/PQ/BT.2020nc back off
a written stream while the no-colour-set case stays deterministic.
fix(ec-hw-hevc): drop RASL pictures after a seek's random-access CRAAhmet Kaan Gümüş · e1b58c9
fix(ec-hw-hevc): drop RASL pictures after a seek's random-access CRA

Root cause (crates/ec-hw/src/dec/hevc.rs): a CRA that opens a mid-stream
random-access point stores its RASL leading pictures *after* itself in
decode order even though they display *before* it (H.265 open-GOP coding).
Those RASL pictures predict from pictures before the CRA, which a decoder
started at that CRA — exactly what a seek does — never decoded. The old
code decoded and output them anyway: bump() orders output purely by POC,
so the (garbage) RASL pictures came out ahead of the CRA itself, shifting
every subsequent output index by however many RASL pictures the GOP has.

Per 8.1.3, `NoRaslOutputFlag` is 1 for the first picture of a coded video
sequence — which the first IRAP after a `reset()` (mid-stream start)
always is. RASL pictures (nal_type 8/9) associated with such an IRAP must
not be decoded or output (8.1.3 / C.5.2.2). `HevcDecoder` now tracks that
flag (`no_rasl_output`, set in `start_picture` on every IRAP) and skips
`start_picture` entirely for a RASL access unit while it holds, so the
picture is dropped whole rather than handed to the driver or bumped out.

New test `hevc_seek_matches_linear_mkv` (crates/ec-hw/tests/gpu.rs) drives
this through the real entry surface: it primes a fresh `Decoder` with the
stream's parameter sets, `reset()`s it (a seek's exact contract per the
existing reset() doc comment), feeds it from the CRA access unit
preceding display frame 30 of test_hevc.mkv, and asserts the first
decoded picture matches a linear decode of frame 30. Confirmed failing
before this fix (mismatched I420 planes) and passing after.

cargo test -p ec-hw --test gpu -- --test-threads=1: 18 passed (17
pre-existing + the new one), 0 failed.

2026-08-19

test(hw): the reference feed keeps the film's own cadence, and RSS is measured aloneAhmet Kaan Gümüş · 3c2d14b
test(hw): the reference feed keeps the film's own cadence, and RSS is measured alone

Three fixes to the live GPU suite:
- the reference decode now passes pictures through at their coded cadence
  instead of conforming to the container's nominal rate, which duplicated or
  dropped frames on films whose real cadence differs and read as every frame
  being one off from some point onward
- elementary-stream extraction is bounded to the frames under comparison plus
  a reorder margin, instead of piping a whole feature film through memory
- the resident-set leak check re-runs itself in a child process: VmRSS is
  process-wide, and a sibling test allocating between baseline and end showed
  up as a 200 MB leak that no code caused

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.
test(hw): live GPU tests against ffmpeg, and Annex B fixturesAhmet Kaan Gümüş · 43c8097
test(hw): live GPU tests against ffmpeg, and Annex B fixtures

Every test here talks to the real driver — a hardware crate whose tests
do not touch the hardware tests nothing — and none is `#[ignore]`d; they
skip when there is no VA display or the fixtures are missing. ffmpeg's
software decoder is the oracle: each fixture is decoded both ways and
compared frame by frame, at the stream's own bit depth (converting a
10-bit reference down to 8 dithers, which would hide a real difference
behind a fake 53 dB one).

Alongside the four codecs: the `frame_num` gap synthesis, a 719-frame
decode-and-read-back loop watching `VmRSS`, the DRM PRIME export, the
encoders round-tripping through ffmpeg *and* through this crate's own
decoder, and a spot check against his real library rather than the
fixtures alone.

`scripts/gen-bitstream-fixtures.sh` gains the H.264 and HEVC elementary
streams — including B-frame clips, so output reordering is exercised
rather than assumed.