wip(av1): lossless lane snapshot at the turn cap (orchestrator)
Browse files at this commit9a5f8e7285cd1a574166b54c9b0f3267fa47d9a5Parent: f0a5a151 changed file +20 -9
- crates/ec-av1/src/decode.rs +20 -9
crates/ec-av1/src/decode.rsmodified+20 -9
| @@ -9153,7 +9153,18 @@ struct RectStripModes { | |||
| 9153 | /// TX_32X16`) and only the second reaches a square -- the reason | 9153 | /// TX_32X16`) and only the second reaches a square -- the reason |
| 9154 | /// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is | 9154 | /// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is |
| 9155 | /// already square) mis-tiled 1:4 strips. | 9155 | /// already square) mis-tiled 1:4 strips. |
| 9156 | -fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) { | 9156 | +fn depth_to_tx_wh( |
| 9157 | + bw: usize, | ||
| 9158 | + bh: usize, | ||
| 9159 | + depth: usize, | ||
| 9160 | + fctx: &crate::decode::FrameCtx, | ||
| 9161 | +) -> (usize, usize) { | ||
| 9162 | + // lane-lossless: TX_4X4 whatever the strip's own size and depth (libaom | ||
| 9163 | + // `read_tx_size`: the lossless early return comes before | ||
| 9164 | + // `max_txsize_rect_lookup`), and no `tx_depth` symbol was read to get here. | ||
| 9165 | + if lossless(fctx) { | ||
| 9166 | + return (4, 4); | ||
| 9167 | + } | ||
| 9157 | let (mut w, mut h) = (bw.min(64), bh.min(64)); | 9168 | let (mut w, mut h) = (bw.min(64), bh.min(64)); |
| 9158 | for _ in 0..depth { | 9169 | for _ in 0..depth { |
| 9159 | match w.cmp(&h) { | 9170 | match w.cmp(&h) { |
| @@ -10289,7 +10300,7 @@ fn decode_intra_rect_in_inter( | |||
| 10289 | if crate::envflags::env_flag!("EC_SPLITSTRIP") { | 10300 | if crate::envflags::env_flag!("EC_SPLITSTRIP") { |
| 10290 | eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}"); | 10301 | eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}"); |
| 10291 | } | 10302 | } |
| 10292 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 10303 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 10293 | // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h, | 10304 | // lane-inter16ab r8: libaom runs `set_txfm_ctxs(tx_size, n4_w, n4_h, |
| 10294 | // skip && is_inter, xd)` (decodeframe.c `decode_block`) for EVERY block | 10305 | // skip && is_inter, xd)` (decodeframe.c `decode_block`) for EVERY block |
| 10295 | // of an inter frame, intra ones included -- with the skip term 0 it | 10306 | // of an inter frame, intra ones included -- with the skip term 0 it |
| @@ -10489,7 +10500,7 @@ fn decode_block_rect( | |||
| 10489 | // per transform unit, each unit taking its edges from the previous | 10500 | // per transform unit, each unit taking its edges from the previous |
| 10490 | // unit's reconstruction inside this same strip (spec 5.11.36) -- | 10501 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| 10491 | // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. | 10502 | // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. |
| 10492 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 10503 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 10493 | if crate::envflags::env_flag!("EC_SBPART_DUMP64") { | 10504 | if crate::envflags::env_flag!("EC_SBPART_DUMP64") { |
| 10494 | eprintln!( | 10505 | eprintln!( |
| 10495 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | 10506 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
| @@ -10995,7 +11006,7 @@ fn decode_leaf_rect( | |||
| 10995 | // depth 2), addressed at this leaf's own mi position. | 11006 | // depth 2), addressed at this leaf's own mi position. |
| 10996 | hit!(TX_DEPTH_HITS); | 11007 | hit!(TX_DEPTH_HITS); |
| 10997 | hit!(SUB16_SPLIT_HITS); | 11008 | hit!(SUB16_SPLIT_HITS); |
| 10998 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 11009 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 10999 | let modes = RectStripModes { | 11010 | let modes = RectStripModes { |
| 11000 | skip, | 11011 | skip, |
| 11001 | mode, | 11012 | mode, |
| @@ -11328,7 +11339,7 @@ fn decode_block_rect4( | |||
| 11328 | publish_txfm_bands_if_in_inter( | 11339 | publish_txfm_bands_if_in_inter( |
| 11329 | neighbours, | 11340 | neighbours, |
| 11330 | (mi_r, mi_c), | 11341 | (mi_r, mi_c), |
| 11331 | - depth_to_tx_wh(bw, bh, depth), | 11342 | + depth_to_tx_wh(bw, bh, depth, fctx), |
| 11332 | (bw, bh), fctx, | 11343 | (bw, bh), fctx, |
| 11333 | ); | 11344 | ); |
| 11334 | if depth != 0 { | 11345 | if depth != 0 { |
| @@ -11338,7 +11349,7 @@ fn decode_block_rect4( | |||
| 11338 | // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; | 11349 | // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; |
| 11339 | // both interleave in every real stream. | 11350 | // both interleave in every real stream. |
| 11340 | hit!(TX_DEPTH_HITS); | 11351 | hit!(TX_DEPTH_HITS); |
| 11341 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 11352 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 11342 | // lane-rectsplitx r2: both depths ship together, as the r1 handoff | 11353 | // lane-rectsplitx r2: both depths ship together, as the r1 handoff |
| 11343 | // predicted -- depth 1 fires FIRST in every attempt that splits at | 11354 | // predicted -- depth 1 fires FIRST in every attempt that splits at |
| 11344 | // all, so a depth-2-only lift could never be gated. The r1 mismatch | 11355 | // all, so a depth-2-only lift could never be gated. The r1 mismatch |
| @@ -11853,7 +11864,7 @@ fn decode_rect4_16_strip( | |||
| 11853 | hit!(TX_DEPTH_HITS); | 11864 | hit!(TX_DEPTH_HITS); |
| 11854 | hit!(RECT4_16_SPLIT_HITS); | 11865 | hit!(RECT4_16_SPLIT_HITS); |
| 11855 | } | 11866 | } |
| 11856 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 11867 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 11857 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 11868 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 11858 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 11869 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 11859 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); | 11870 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); |
| @@ -12344,7 +12355,7 @@ fn decode_block_rect64( | |||
| 12344 | publish_txfm_bands_if_in_inter( | 12355 | publish_txfm_bands_if_in_inter( |
| 12345 | neighbours, | 12356 | neighbours, |
| 12346 | (mi_r, mi_c), | 12357 | (mi_r, mi_c), |
| 12347 | - depth_to_tx_wh(bw, bh, depth), | 12358 | + depth_to_tx_wh(bw, bh, depth, fctx), |
| 12348 | (bw, bh), fctx, | 12359 | (bw, bh), fctx, |
| 12349 | ); | 12360 | ); |
| 12350 | if depth != 0 { | 12361 | if depth != 0 { |
| @@ -12354,7 +12365,7 @@ fn decode_block_rect64( | |||
| 12354 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 | 12365 | // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| 12355 | // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 | 12366 | // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 |
| 12356 | // measured the old square formula mis-tiling exactly that strip). | 12367 | // measured the old square formula mis-tiling exactly that strip). |
| 12357 | - let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 12368 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth, fctx); |
| 12358 | if bw.max(bh) / bw.min(bh) == 4 { | 12369 | if bw.max(bh) / bw.min(bh) == 4 { |
| 12359 | let which = if depth == 1 { | 12370 | let which = if depth == 1 { |
| 12360 | &RECT4_SPLIT_DEPTH1_HITS | 12371 | &RECT4_SPLIT_DEPTH1_HITS |