Two lossless INTER defects on screen content -- a skip 8x8 leaf restored the previous block's luma band, and a rect sub-8x8 intra leaf read one TX_4X8
Browse files at this commit025c25471a60dbed9d268c77b50e257cacadd827Parent: afd4958- fix
- two lossless INTER defects on screen content -- a skip 8x8 leaf restored the previous block's luma band, and a rect sub-8x8 intra leaf read one TX_4X8
2 changed files +31 -8
crates/ec-av1/src/decode.rsmodified+23 -5
| @@ -11944,7 +11944,7 @@ fn decode_rect4_16_strip( | |||
| 11944 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 11944 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 11945 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 11945 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 11946 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); | 11946 | neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); |
| 11947 | - if depth != 0 { | 11947 | + if depth != 0 || lossless(fctx) { |
| 11948 | // [`decode_rect_split`]'s per-unit walk, inlined because the | 11948 | // [`decode_rect_split`]'s per-unit walk, inlined because the |
| 11949 | // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to | 11949 | // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to |
| 11950 | // the strip (that function codes one chroma transform per block). | 11950 | // the strip (that function codes one chroma transform per block). |
| @@ -16049,7 +16049,7 @@ fn decode_leaf_rect8( | |||
| 16049 | // context -- `decode_leaf8`'s own depth-1 loop, two units instead of | 16049 | // context -- `decode_leaf8`'s own depth-1 loop, two units instead of |
| 16050 | // four. The per-TU path writes its own neighbour state, so the | 16050 | // four. The per-TU path writes its own neighbour state, so the |
| 16051 | // block-level write below is skipped for it. | 16051 | // block-level write below is skipped for it. |
| 16052 | - let split = depth != 0; | 16052 | + let split = depth != 0 || lossless(fctx); |
| 16053 | if split { | 16053 | if split { |
| 16054 | let mut done = 0usize; | 16054 | let mut done = 0usize; |
| 16055 | for tu in 0..2usize { | 16055 | for tu in 0..2usize { |
| @@ -30934,7 +30934,7 @@ fn decode_intra_sub8_leaf( | |||
| 30934 | hit!(TX_DEPTH_HITS); | 30934 | hit!(TX_DEPTH_HITS); |
| 30935 | hit!(RECT8_SPLIT_TX_HITS); | 30935 | hit!(RECT8_SPLIT_TX_HITS); |
| 30936 | } | 30936 | } |
| 30937 | - let split = depth != 0; | 30937 | + let split = depth != 0 || (lossless(fctx) && bw != bh); |
| 30938 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); | 30938 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 30939 | let reach = if bw == bh { | 30939 | let reach = if bw == bh { |
| 30940 | Reach::of(bw, px, py, y.width, y.height, fctx) | 30940 | Reach::of(bw, px, py, y.width, y.height, fctx) |
| @@ -32787,7 +32787,16 @@ fn decode_inter_block8( | |||
| 32787 | // leaf published level 0 to its right/below neighbours: the next | 32787 | // leaf published level 0 to its right/below neighbours: the next |
| 32788 | // block's first TU read `skip_contexts[4][0] = 3` where aomdec | 32788 | // block's first TU read `skip_contexts[4][0] = 3` where aomdec |
| 32789 | // reads `[4][4] = 6` (class early-return-skips-tail). | 32789 | // reads `[4][4] = 6` (class early-return-skips-tail). |
| 32790 | - let saved_luma_ctx = split8.then(|| { | 32790 | + // lane-lossless3: `!skip` too. A SKIP block codes no coefficients and so |
| 32791 | + // publishes nothing per transform unit, and on a LOSSLESS frame | ||
| 32792 | + // `read_block_tx_size` hands back 4x4 leaves for a skip block as well | ||
| 32793 | + // (libaom's `read_tx_size` returns TX_4X4 before it reads anything), so | ||
| 32794 | + // `split8` is true over an UNTOUCHED band -- the restore then put the | ||
| 32795 | + // previous block's levels back over the zeros `record_mi` had just | ||
| 32796 | + // written, where libaom runs `av1_reset_entropy_context`. Class | ||
| 32797 | + // [[override-slot-on-one-arm]]: a save/restore is only valid on the arm | ||
| 32798 | + // that actually wrote the per-TU state. | ||
| 32799 | + let saved_luma_ctx = (split8 && !skip).then(|| { | ||
| 32791 | ( | 32800 | ( |
| 32792 | [ | 32801 | [ |
| 32793 | neighbours.left[leaf_mi.0][0], | 32802 | neighbours.left[leaf_mi.0][0], |
| @@ -33969,7 +33978,16 @@ fn decode_inter_block8( | |||
| 33969 | // but `record_mi` rewrites all three planes of these cells at once -- so | 33978 | // but `record_mi` rewrites all three planes of these cells at once -- so |
| 33970 | // save plane 0 across it, exactly as `record_split_luma` leaves plane 0 | 33979 | // save plane 0 across it, exactly as `record_split_luma` leaves plane 0 |
| 33971 | // alone at the bigger block sizes. | 33980 | // alone at the bigger block sizes. |
| 33972 | - let saved_luma_ctx = split8.then(|| { | 33981 | +// lane-lossless3: `!skip` too. A SKIP block codes no coefficients and so |
| 33982 | + // publishes nothing per transform unit, and on a LOSSLESS frame | ||
| 33983 | + // `read_block_tx_size` hands back 4x4 leaves for a skip block as well | ||
| 33984 | + // (libaom's `read_tx_size` returns TX_4X4 before it reads anything), so | ||
| 33985 | + // `split8` is true over an UNTOUCHED band -- the restore then put the | ||
| 33986 | + // previous block's levels back over the zeros `record_mi` had just | ||
| 33987 | + // written, where libaom runs `av1_reset_entropy_context`. Class | ||
| 33988 | + // [[override-slot-on-one-arm]]: a save/restore is only valid on the arm | ||
| 33989 | + // that actually wrote the per-TU state. | ||
| 33990 | + let saved_luma_ctx = (split8 && !skip).then(|| { | ||
| 33973 | ( | 33991 | ( |
| 33974 | [ | 33992 | [ |
| 33975 | neighbours.left[leaf_mi.0][0], | 33993 | neighbours.left[leaf_mi.0][0], |
crates/ec-av1/src/stream.rsmodified+8 -3
| @@ -4117,15 +4117,20 @@ pub(crate) mod tests { | |||
| 4117 | // (w, h, frames, gop, bit depth, 128-superblock, screen content) | 4117 | // (w, h, frames, gop, bit depth, 128-superblock, screen content) |
| 4118 | // lane-lossless2: the SCREEN rows carry palette blocks, which is what | 4118 | // lane-lossless2: the SCREEN rows carry palette blocks, which is what |
| 4119 | // caught the whole-block palette prediction being handed to a 4x4 | 4119 | // caught the whole-block palette prediction being handed to a 4x4 |
| 4120 | - // chroma unit; they are KEY-only, see the lane report's deferred | 4120 | + // chroma unit. |
| 4121 | - // screen-inter desync. | 4121 | + // lane-lossless3: the last row is a screen source with INTER frames -- |
| 4122 | - let cases: [(usize, usize, usize, &str, u32, bool, bool); 6] = [ | 4122 | + // the row that caught both of this lane's defects (a skip 8x8 leaf |
| 4123 | + // restoring the previous block's luma level band over the zeros | ||
| 4124 | + // `av1_reset_entropy_context` writes, and a rect sub-8x8 INTRA leaf | ||
| 4125 | + // reading one TX_4X8 unit where a lossless frame codes two TX_4X4). | ||
| 4126 | + let cases: [(usize, usize, usize, &str, u32, bool, bool); 7] = [ | ||
| 4123 | (256, 128, 8, "4", 8, false, false), | 4127 | (256, 128, 8, "4", 8, false, false), |
| 4124 | (192, 96, 6, "3", 10, false, false), | 4128 | (192, 96, 6, "3", 10, false, false), |
| 4125 | (320, 192, 6, "3", 8, false, false), | 4129 | (320, 192, 6, "3", 8, false, false), |
| 4126 | (256, 256, 4, "2", 8, true, false), | 4130 | (256, 256, 4, "2", 8, true, false), |
| 4127 | (320, 192, 2, "1", 8, false, true), | 4131 | (320, 192, 2, "1", 8, false, true), |
| 4128 | (640, 384, 2, "1", 8, false, true), | 4132 | (640, 384, 2, "1", 8, false, true), |
| 4133 | + (640, 384, 6, "3", 8, false, true), | ||
| 4129 | ]; | 4134 | ]; |
| 4130 | for &(w, h, frames, gop, depth, sb128, screen) in &cases { | 4135 | for &(w, h, frames, gop, depth, sb128, screen) in &cases { |
| 4131 | let tag = format!( | 4136 | let tag = format!( |