Transform-unit top-right/bottom-left inside a block wider than 64
Browse files at this commitd1400b2b64eb60f8651410ec2d00be6cc4d2c046Parent: 606ff15- fix
- transform-unit top-right/bottom-left inside a block wider than 64
2 changed files +39 -4
- crates/ec-av1/src/encode.rs +22 -3
- crates/ec-av1/src/stream.rs +17 -1
crates/ec-av1/src/encode.rsmodified+22 -3
| @@ -1261,13 +1261,32 @@ impl Reach { | ||
| 1261 | 1261 | tx_h: usize, |
| 1262 | 1262 | block: Self, |
| 1263 | 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 | 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 | 1280 | true |
| 1267 | 1281 | } else { |
| 1268 | - row_off == 0 && block.above_right | |
| 1282 | + 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 | 1290 | false |
| 1272 | 1291 | } else if row_off + tx_h < bh { |
| 1273 | 1292 | true |
crates/ec-av1/src/stream.rsmodified+17 -1
| @@ -19173,6 +19173,12 @@ mod tests { | ||
| 19173 | 19173 | (44, "--cq-level=8", 256, 192, false, false, true), |
| 19174 | 19174 | (46, "--cq-level=55", 192, 256, false, true, false), |
| 19175 | 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 | 19183 | let (mut matched, mut named_refusals, mut out_of_scope) = (0u32, 0u32, 0u32); |
| 19178 | 19184 | let (mut horz_arms, mut vert_arms) = (0u32, 0u32); |
| @@ -19189,7 +19195,17 @@ mod tests { | ||
| 19189 | 19195 | // through `geq` instead -- same effect on the encoder's |
| 19190 | 19196 | // partition choice, byte-identical across runs. |
| 19191 | 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 | 19210 | "-pix_fmt", pix, "-strict", "-1", "-t", "0.2", |
| 19195 | 19211 | "-f", "yuv4mpegpipe", "-", |