forge
Explore
Log in

Don't you dare go Hollow

Transform-unit top-right/bottom-left inside a block wider than 64

Browse files at this commit

d1400b2b64eb60f8651410ec2d00be6cc4d2c046Ahmet Kaan GümüşParent: 606ff15
  • fix
    • transform-unit top-right/bottom-left inside a block wider than 64
Show full message
fix(av1): transform-unit top-right/bottom-left inside a block wider than 64

A block wider than 64 is coded in 64x64 "mu" chunks in raster order, so
libaom's has_top_right takes the column offset MODULO the chunk (plus the one
centre unit of a 128x128) and has_bottom_left grants the left edge of a
right-hand chunk what the already-coded left chunk holds. Reach::of_tu applied
the plain block-wide rule, so the last unit column of every chunk of a 128x64
intra block predicted from a chunk not yet reconstructed -- 375 wrong samples
per 128x64 block on a 512x512 key frame with the transform split.

Gate: a 512x512 arm (second 128 superblock column, high-frequency source,
--enable-tx-size-search=1) joins the sb128 intra_rect_block gate: 164 128x64 +
156 64x128 blocks, 294 of them at TX_16X16, 5 frames pixel-exact.
crates/ec-av1/src/encode.rsmodified+22 -3
@@ -1261,13 +1261,32 @@ impl Reach {
1261 tx_h: usize,1261 tx_h: usize,
1262 block: Self,1262 block: Self,
1263 ) -> Self {1263 ) -> Self {
1264+ // A block wider than 64 is coded in 64x64 "mu" chunks in raster
1265+ // order, so both libaom predicates special-case it (lane-sb128c r10);
1266+ // without this the last unit column of every chunk of a 128x64 block
1267+ // predicts from a chunk libaom has not decoded yet.
1268+ let wide = bw > 64;
1264 Self {1269 Self {
1265- above_right: if col_off + tx_w < bw {1270+ above_right: if row_off > 0 {
1271+ // `has_top_right`'s `row_off > 0` branch: the offset is taken
1272+ // modulo the 64-wide chunk, except for the one unit whose
1273+ // top-right corner is the centre of a 128x128 block.
1274+ if wide {
1275+ (row_off == 64 && col_off + tx_w == 64) || (col_off % 64) + tx_w < 64
1276+ } else {
1277+ col_off + tx_w < bw
1278+ }
1279+ } else if col_off + tx_w < bw {
1266 true1280 true
1267 } else {1281 } else {
1268- row_off == 0 && block.above_right1282+ block.above_right
1269 },1283 },
1270- below_left: if col_off > 0 {1284+ below_left: if wide && col_off > 0 && col_off % 64 == 0 {
1285+ // `has_bottom_left`: at the left edge of a right-hand chunk
1286+ // the bottom-left pixels are in the already-coded left chunk,
1287+ // provided they stay inside it.
1288+ (row_off % 64) + tx_h < bh.min(64)
1289+ } else if col_off > 0 {
1271 false1290 false
1272 } else if row_off + tx_h < bh {1291 } else if row_off + tx_h < bh {
1273 true1292 true
crates/ec-av1/src/stream.rsmodified+17 -1
@@ -19173,6 +19173,12 @@ mod tests {
19173 (44, "--cq-level=8", 256, 192, false, false, true),19173 (44, "--cq-level=8", 256, 192, false, false, true),
19174 (46, "--cq-level=55", 192, 256, false, true, false),19174 (46, "--cq-level=55", 192, 256, false, true, false),
19175 (45, "--cq-level=45", 192, 256, true, true, true),19175 (45, "--cq-level=45", 192, 256, true, true, true),
19176+ // lane-sb128c r10: a SECOND 128 superblock column is what the
19177+ // arms above never had -- the right 64x128 half of a 128-root
19178+ // VERT at mi_col 80 read its tx-depth symbol off the wrong CDF
19179+ // row and every unit column of a 128x64 chunk predicted from the
19180+ // not-yet-decoded chunk to its right.
19181+ (47, "--cq-level=45", 512, 512, false, false, true),
19176 ];19182 ];
19177 let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32);19183 let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32);
19178 let (mut horz_arms, mut vert_arms) = (0u32, 0u32);19184 let (mut horz_arms, mut vert_arms) = (0u32, 0u32);
@@ -19189,7 +19195,17 @@ mod tests {
19189 // through `geq` instead -- same effect on the encoder's19195 // through `geq` instead -- same effect on the encoder's
19190 // partition choice, byte-identical across runs.19196 // partition choice, byte-identical across runs.
19191 &format!(19197 &format!(
19192- "nullsrc=size={width}x{height}:rate=25,format=yuv420p, geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)': cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'"19198+ "nullsrc=size={width}x{height}:rate=25,format=yuv420p, geq=lum='{lum}': cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'",
19199+ // The 512x512 arm carries the r9 witness's own
19200+ // higher-frequency luma: the smooth two-term source
19201+ // gives every 128-rect block a whole-block TX_64X64
19202+ // and no VERT root at all, which is exactly the
19203+ // combination that hid the tx-depth CDF row defect.
19204+ lum = if width == 512 {
19205+ "128+80*sin((X+3*N)/17)+50*sin(Y/29)+30*sin((X+Y)/13)"
19206+ } else {
19207+ "128+90*sin((X+2*N)/37)+30*sin(Y/29)"
19208+ }
19193 ),19209 ),
19194 "-pix_fmt", pix, "-strict", "-1", "-t", "0.2",19210 "-pix_fmt", pix, "-strict", "-1", "-t", "0.2",
19195 "-f", "yuv4mpegpipe", "-",19211 "-f", "yuv4mpegpipe", "-",