diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 6a52d579..1e6b15f6 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -11944,7 +11944,7 @@ fn decode_rect4_16_strip( let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); neighbours.record_mode_mi(lmi.0, lmi.1, mi_w, mi_h, mode); - if depth != 0 { + if depth != 0 || lossless(fctx) { // [`decode_rect_split`]'s per-unit walk, inlined because the // CHROMA of this shape belongs to the strip's 4:2:0 pair, not to // the strip (that function codes one chroma transform per block). @@ -16049,7 +16049,7 @@ fn decode_leaf_rect8( // context -- `decode_leaf8`'s own depth-1 loop, two units instead of // four. The per-TU path writes its own neighbour state, so the // block-level write below is skipped for it. - let split = depth != 0; + let split = depth != 0 || lossless(fctx); if split { let mut done = 0usize; for tu in 0..2usize { @@ -30934,7 +30934,7 @@ fn decode_intra_sub8_leaf( hit!(TX_DEPTH_HITS); hit!(RECT8_SPLIT_TX_HITS); } - let split = depth != 0; + let split = depth != 0 || (lossless(fctx) && bw != bh); let (px, py) = (lmi.1 * MI, lmi.0 * MI); let reach = if bw == bh { Reach::of(bw, px, py, y.width, y.height, fctx) @@ -32787,7 +32787,16 @@ fn decode_inter_block8( // leaf published level 0 to its right/below neighbours: the next // block's first TU read `skip_contexts[4][0] = 3` where aomdec // reads `[4][4] = 6` (class early-return-skips-tail). - let saved_luma_ctx = split8.then(|| { + // lane-lossless3: `!skip` too. A SKIP block codes no coefficients and so + // publishes nothing per transform unit, and on a LOSSLESS frame + // `read_block_tx_size` hands back 4x4 leaves for a skip block as well + // (libaom's `read_tx_size` returns TX_4X4 before it reads anything), so + // `split8` is true over an UNTOUCHED band -- the restore then put the + // previous block's levels back over the zeros `record_mi` had just + // written, where libaom runs `av1_reset_entropy_context`. Class + // [[override-slot-on-one-arm]]: a save/restore is only valid on the arm + // that actually wrote the per-TU state. + let saved_luma_ctx = (split8 && !skip).then(|| { ( [ neighbours.left[leaf_mi.0][0], @@ -33969,7 +33978,16 @@ fn decode_inter_block8( // but `record_mi` rewrites all three planes of these cells at once -- so // save plane 0 across it, exactly as `record_split_luma` leaves plane 0 // alone at the bigger block sizes. - let saved_luma_ctx = split8.then(|| { +// lane-lossless3: `!skip` too. A SKIP block codes no coefficients and so + // publishes nothing per transform unit, and on a LOSSLESS frame + // `read_block_tx_size` hands back 4x4 leaves for a skip block as well + // (libaom's `read_tx_size` returns TX_4X4 before it reads anything), so + // `split8` is true over an UNTOUCHED band -- the restore then put the + // previous block's levels back over the zeros `record_mi` had just + // written, where libaom runs `av1_reset_entropy_context`. Class + // [[override-slot-on-one-arm]]: a save/restore is only valid on the arm + // that actually wrote the per-TU state. + let saved_luma_ctx = (split8 && !skip).then(|| { ( [ neighbours.left[leaf_mi.0][0], diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 63f4d801..58a1a072 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -4117,15 +4117,20 @@ pub(crate) mod tests { // (w, h, frames, gop, bit depth, 128-superblock, screen content) // lane-lossless2: the SCREEN rows carry palette blocks, which is what // caught the whole-block palette prediction being handed to a 4x4 - // chroma unit; they are KEY-only, see the lane report's deferred - // screen-inter desync. - let cases: [(usize, usize, usize, &str, u32, bool, bool); 6] = [ + // chroma unit. + // lane-lossless3: the last row is a screen source with INTER frames -- + // the row that caught both of this lane's defects (a skip 8x8 leaf + // restoring the previous block's luma level band over the zeros + // `av1_reset_entropy_context` writes, and a rect sub-8x8 INTRA leaf + // reading one TX_4X8 unit where a lossless frame codes two TX_4X4). + let cases: [(usize, usize, usize, &str, u32, bool, bool); 7] = [ (256, 128, 8, "4", 8, false, false), (192, 96, 6, "3", 10, false, false), (320, 192, 6, "3", 8, false, false), (256, 256, 4, "2", 8, true, false), (320, 192, 2, "1", 8, false, true), (640, 384, 2, "1", 8, false, true), + (640, 384, 6, "3", 8, false, true), ]; for &(w, h, frames, gop, depth, sb128, screen) in &cases { let tag = format!(