From ad3e7b0591384eb0d785e8296b947c5c1930b54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 5 Sep 2026 22:11:28 +0300 Subject: [PATCH] perf(av1): an intra transform unit no longer clones its coefficient grid read_plane returned residual_grid_placeholder(&levels, side) -- a to_vec of the whole coded grid -- on the tx_side == side arm, and the levels Vec itself on the other; both arms are the same value, so the copy was pure waste per intra transform unit. Byte-exact: 12/12 gate hashes at 1/4/16 threads. instructions:u on the 4K segment: 396.613 G -> 396.536 G at 1 thread, 401.464 G -> 401.371 G at (16,4,2) (the copy itself is memmove traffic instructions:u barely sees). --- crates/ec-av1/src/decode.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 7d9cdbf7..1eeb9da7 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -13416,19 +13416,12 @@ fn read_plane( filter_intra, smooth_neighbor, fctx, ); - Ok(if tx_side == side { - residual_grid_placeholder(&levels, side) - } else { - levels - }) -} - -/// `record`'s neighbour state only reads whether *the coded grid* (not the -/// residual) has nonzero entries, so the levels this function already built -/// are what it wants back; this helper exists only to name that clearly at -/// the one call site where `tx_side == side`. -fn residual_grid_placeholder(levels: &[i32], _tx_side: usize) -> Vec { - levels.to_vec() + // `record`'s neighbour state only reads whether *the coded grid* (not the + // residual) has nonzero entries, so the levels this function already + // built are what it wants back -- both arms of the old `tx_side == side` + // branch returned exactly that, one of them through a full `to_vec` copy + // of the grid per intra transform unit (lane-coefbuf). + Ok(levels) } /// Decodes one whole-block coded superblock/quadrant/leaf: its mode, then its