forge
Explore
Log in

Don't you dare go Hollow

A BLOCK_4X4 intra leaf never read its own segment_id

Browse files at this commit

96c590fbe7d4beb08237602c3dd6c8537804f317Ahmet Kaan GümüşParent: 5113966
  • fix
    • a BLOCK_4X4 intra leaf never read its own segment_id
Show full message
fix(av1): a BLOCK_4X4 intra leaf never read its own segment_id

read_intra_mode_sub8 skipped spec 5.11.6's intra_segment_id entirely, so on
a segmented key frame the first sub-8x8 split ate the segment_id symbol's
place in the tile (msac desync from that block on) and every 4x4 leaf
dequantized with the previous block's SEG_LVL_ALT_Q.
crates/ec-av1/src/decode.rsmodified+12 -0
@@ -15709,10 +15709,22 @@ fn read_intra_mode_sub8(
15709 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {15709 if crate::envflags::env_flag!("EC_TRACE_MODE_STEP") {
15710 eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);15710 eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0);
15711 }15711 }
15712+ // lane-seg2: same `intra_segment_id` placement as the square and rect
15713+ // readers (spec 5.11.6) -- a `BLOCK_4X4` leaf codes its own `segment_id`
15714+ // like any other block, over its own 1x1 mi footprint. Dropping it here
15715+ // both ate a symbol (the tile desynced at the frame's first sub-8x8
15716+ // split) and left `cur_segment_id` on the previous block, so the leaf
15717+ // dequantized with a neighbour's `SEG_LVL_ALT_Q`.
15718+ if seg_id_pre_skip(fctx) {
15719+ intra_segment_id(dec, cdfs, mi_r, mi_c, 1, 1, false, fctx);
15720+ }
15712 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;15721 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;
15713 if trace {15722 if trace {
15714 eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0);15723 eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0);
15715 }15724 }
15725+ if !seg_id_pre_skip(fctx) {
15726+ intra_segment_id(dec, cdfs, mi_r, mi_c, 1, 1, skip, fctx);
15727+ }
15716 maybe_read_cdef_idx(dec, mi_r, mi_c, skip, fctx);15728 maybe_read_cdef_idx(dec, mi_r, mi_c, skip, fctx);
15717 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip, fctx);15729 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip, fctx);
15718 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip, fctx);15730 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip, fctx);