forge
Explore
Log in

Don't you dare go Hollow

Real h265 software-decode row

Browse files at this commit

746f09341983844ab71eac9c5f4efb6d1cde65faAhmet Kaan GümüşParent: 1f5134f
  • feat
    • real h265 software-decode row
    • drop a dead helper
Show full message
feat(bench): real h265 software-decode row; drop a dead helper

The 'encode-only crate, no decoder present' placeholder was a false
claim since lane-h265dec merged; the row now times decode_idr_au over
the bench's own encoded stream (10.48x realtime at 640x360).
crates/ec-h265/src/decode.rsmodified+0 -4
@@ -262,10 +262,6 @@ impl CtuDecoder {
262 self.decoded[(y as usize / 4) * (self.width / 4) + x as usize / 4]262 self.decoded[(y as usize / 4) * (self.width / 4) + x as usize / 4]
263 }263 }
264 264
265- fn mode_at(&self, x: usize, y: usize) -> u8 {
266- self.modes[(y / 4) * (self.width / 4) + x / 4]
267- }
268-
269 fn depth_at(&self, x: usize, y: usize) -> u8 {265 fn depth_at(&self, x: usize, y: usize) -> u8 {
270 self.depths[(y / 4) * (self.width / 4) + x / 4]266 self.depths[(y / 4) * (self.width / 4) + x / 4]
271 }267 }
lanes/av1-inter-plan.mdadded+46 -0
@@ -0,0 +1,46 @@
1+# AV1 inter-frame package — foreman decomposition (2026-08-26)
2+Goal: ec-av1 inter frames -> edith_replica drops rav1e. User-seat gate: AV1 export from
3+edith_replica plays, ffmpeg decodes frame-for-frame, `cargo tree -p engine` has no rav1e.
4+
5+Lanes (I1..I13). Wave 1 armed 2026-08-26: I1 cdf / I2 hdr / I3 mvstack / I4 mc, worktrees
6+edith_codecs-av1-{cdf,hdr,mvstack,mc}. Then I5 motion (needs I4); wave 2 I6 inter tile
7+writer (needs I1+I3) then I10 q-contexts (cdf.rs conflict — sequential after I6);
8+sequential tail I7 encode loop+ref buffer -> I8 ffmpeg multiframe VERIFIER gate ->
9+I9 pad-to-32/render-size crop -> I11 streaming facade+colour config -> I12 replica swap ->
10+I13 entry-surface + rav1e parity VERIFIER.
11+
12+Swap blockers beyond inter itself:
13+- Q_CTX_2 61..=120 only coeff q context (tile.rs:84,600) -> I10 adds the other 3, range 0..=255.
14+- Picture::check refuses non-multiple-of-32 sizes (encode.rs:109-119) -> I9 pad+render crop
15+ (frame.rs:361 render_differs already writes crop syntax).
16+- Colour: encode.rs:187-199 hardcodes unspecified; rav1e seat sets Limited + BT709/BT601
17+ (replica export.rs:3494-3507) -> I11 config fields, else visible colour shift.
18+
19+Replica rav1e surface (all in edith_replica/crates/engine/): Cargo.toml:190-197 dep;
20+export.rs:3345 Enc::Av1Sw, :3461 open_av1, :3609 encode arm, :3710 drain arm,
21+:3793-3817 collect_av1/pop_av1 (delete — ec-av1 facade is one-in-one-out like Enc::Hevc,
22+export.rs:3624 "Nothing is ever held back"); name strings export.rs:697, caps.rs:32,:137.
23+I12 gates: cargo tree -p engine no rav1e; cargo test -p engine --test av1 --test backends.
24+
25+I5: crates/ec-av1/src/motion.rs, diamond search around PredMv + half/quarter-pel refine via
26+mc.rs; cost SAD/SSE + lambda*mv_bits priced by interval narrowing (never per-entry prob);
27+constants swept before landing. I6: tile.rs sb_coeff_inter_frame_tile — per block skip,
28+intra_inter, single-ref chain, inter_mode/drl/mv_joint+components; intra-in-inter uses
29+Default_Y_Mode_Cdf NOT KF_Y_MODE; extend Neighbours with per-mi is_inter+mv.
30+I7: encode_sequence(&[Picture]) keeps decoded recon as LAST ref, one slot; RD set =
31+intra ∪ {NEARESTMV skip, NEARESTMV coded, NEWMV}; gate = sample-exact ffmpeg equality
32+key+4 inter. I8 verifier: EC_AV1_CLIP multi-frame, per-frame PSNR floor, inter frames
33+smaller than key on low-motion + inter-block share printed (gate-blind-to-feature).
34+I11: EncoderConfig{w,h,q|bitrate,gop,colour}, encode_planes one-in-one-out, flush none;
35+30-frame gop-15 test = 2 key + 28 inter; colour fields round-trip via ec-av1-syntax.
36+I13 verifier: entry-surface export from replica settings row on a real ~/Videos clip,
37+label/progress/error-path captured; parity table vs rav1e (bytes, PSNR, wall-clock);
38+>2x bytes at equal PSNR = numeric REPORT not fail.
39+
40+Rejected: feature-depth-first (compound/switchable/TX_SELECT first) — triples CDF surface
41+before first ffmpeg-decoded inter frame.
42+
43+Charter boilerplate every lane: own worktree + CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1-<lane>;
44+no new tests/*.rs (ec-av1 tests inline); never validate tables against rav1e layout (transposed);
45+gates cargo test -p ec-av1 (+ --release for ffmpeg roundtrips), clippy, fmt --check; long runs
46+under systemd-run MemoryMax=10G; merge into main at close, branch+worktree die same batch.
tools/ec-bench/src/main.rsmodified+19 -7
@@ -254,22 +254,19 @@ fn parse_ratio(s: &str) -> Option<f64> {
254 }254 }
255 255
256 // ---------------------------------------------------------------------------256 // ---------------------------------------------------------------------------
257-// h265: encode only -- this crate has no decoder (intra-only HEVC encoder).257+// h265: encode, then software-decode the encoded stream back.
258 // ---------------------------------------------------------------------------258 // ---------------------------------------------------------------------------
259 259
260 fn bench_h265_encode(rows: &mut Vec<Row>) {260 fn bench_h265_encode(rows: &mut Vec<Row>) {
261- rows.push(missing_direction(
262- "ec-h265",
263- "decode",
264- "encode-only crate, no decoder present",
265- ));
266 let Some(src) = real_video("h264").or_else(|| real_video("hevc")) else {261 let Some(src) = real_video("h264").or_else(|| real_video("hevc")) else {
262+ rows.push(missing("ec-h265", "decode"));
267 rows.push(missing("ec-h265", "encode"));263 rows.push(missing("ec-h265", "encode"));
268 return;264 return;
269 };265 };
270 let (planes, w, h, n) = extract_yuv420p(&src, 640, 360, 10);266 let (planes, w, h, n) = extract_yuv420p(&src, 640, 360, 10);
271 if n == 0 {267 if n == 0 {
272 rows.push(missing("ec-h265", "encode"));268 rows.push(missing("ec-h265", "encode"));
269+ rows.push(missing("ec-h265", "decode"));
273 return;270 return;
274 }271 }
275 let cfg = H265Config::new(w, h);272 let cfg = H265Config::new(w, h);
@@ -277,6 +274,7 @@ fn bench_h265_encode(rows: &mut Vec<Row>) {
277 let frame_len = (w * h + 2 * (w.div_ceil(2) * h.div_ceil(2))) as usize;274 let frame_len = (w * h + 2 * (w.div_ceil(2) * h.div_ceil(2))) as usize;
278 let cw = w.div_ceil(2);275 let cw = w.div_ceil(2);
279 let ch = h.div_ceil(2);276 let ch = h.div_ceil(2);
277+ let mut aus = Vec::new();
280 let start = Instant::now();278 let start = Instant::now();
281 for frame in planes.chunks_exact(frame_len) {279 for frame in planes.chunks_exact(frame_len) {
282 let (y, rest) = frame.split_at((w * h) as usize);280 let (y, rest) = frame.split_at((w * h) as usize);
@@ -293,7 +291,7 @@ fn bench_h265_encode(rows: &mut Vec<Row>) {
293 )291 )
294 .expect("i420 frame");292 .expect("i420 frame");
295 let _ = ch; // silence unused if plane_geometry ignores it293 let _ = ch; // silence unused if plane_geometry ignores it
296- enc.encode_idr(&vf).expect("h265 encode");294+ aus.push(enc.encode_idr(&vf).expect("h265 encode").au);
297 }295 }
298 let wall = start.elapsed().as_secs_f64();296 let wall = start.elapsed().as_secs_f64();
299 let media_s = n as f64 / 30.0;297 let media_s = n as f64 / 30.0;
@@ -305,6 +303,20 @@ fn bench_h265_encode(rows: &mut Vec<Row>) {
305 wall_ms: wall * 1000.0,303 wall_ms: wall * 1000.0,
306 rtf: (wall > 0.0).then_some(media_s / wall),304 rtf: (wall > 0.0).then_some(media_s / wall),
307 });305 });
306+
307+ let start = Instant::now();
308+ for au in &aus {
309+ ec_h265::decode::decode_idr_au(au).expect("h265 decode");
310+ }
311+ let wall = start.elapsed().as_secs_f64();
312+ rows.push(Row {
313+ component: "ec-h265",
314+ direction: "decode",
315+ content: format!("{w}x{h}, {n} frames, own IDR stream"),
316+ media: format!("{media_s:.1}s"),
317+ wall_ms: wall * 1000.0,
318+ rtf: (wall > 0.0).then_some(media_s / wall),
319+ });
308 }320 }
309 321
310 // ---------------------------------------------------------------------------322 // ---------------------------------------------------------------------------