forge
Explore
Log in

Don't you dare go Hollow

A 1:4 intra strip in an inter frame took its tx-depth CDF row from the key frame's deblock grid, not the TXFM_CONTEXT bands

Browse files at this commit

27250ff85c9359bb14fd81df450e3bc40793a007Ahmet Kaan GümüşParent: c11cb86
  • fix
    • a 1:4 intra strip in an inter frame took its tx-depth CDF row from the key frame's deblock grid, not the TXFM_CONTEXT bands
Show full message
fix(av1): a 1:4 intra strip in an inter frame took its tx-depth CDF row from the key frame's deblock grid, not the TXFM_CONTEXT bands

`get_tx_size_context` reads `above_txfm_context`/`left_txfm_context` on an
inter frame; the 2:1 and 16x4 intra-in-inter arms already switch to
[`tx_size_context_txfm_rect`] for that, `decode_block_rect4` (32x8/8x32),
`decode_block_rect64` (64x16/16x64) and `decode_block_rect`'s own cat-2 read
did not. Measured on the 10-bit 1920x792 128-superblock stream, decode-order
frame 1: the 32x8 HORZ_4 strip at mi(48,176) read `tx_size_cat2` row 1 where
libaom reads row 2 (ours rng after the symbol did not occur anywhere in the
oracle's frame trace), and every symbol after it was off. With the bands the
cross-decoder ladder now runs from mi(0,320) to mi(40,221) inclusive.

Also adds the missing `EC_TRACE_MODE_STEP` tx_depth rung to those three
readers plus the 16x4 strip -- without it a range ladder cannot see the
symbol at all, which is what made the earlier bisection stop one block short.
crates/ec-av1/src/decode.rsmodified+70 -7
@@ -7842,8 +7842,26 @@ fn decode_block_rect(
7842 // pinned HORZ quadrant were wrong from their very first pixel, and why our7842 // pinned HORZ quadrant were wrong from their very first pixel, and why our
7843 // range after the read equalled the oracle's range for the whole block.7843 // range after the read equalled the oracle's range for the whole block.
7844 let depth = if tx_select {7844 let depth = if tx_select {
7845- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);7845+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
7846- dec.symbol(&mut cdfs.tx_size_cat2[ctx])7846+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
7847+ // the 16x4 intra-in-inter strips already do); the key frame's
7848+ // deblock-grid approximation is only right where those bands were never
7849+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
7850+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
7851+ // `tx_size_cat2` row 1 where libaom reads row 2.
7852+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
7853+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
7854+ } else {
7855+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
7856+ };
7857+ let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]);
7858+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
7859+ eprintln!(
7860+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}",
7861+ dec.debug_state().0
7862+ );
7863+ }
7864+ d
7847 } else {7865 } else {
7848 07866 0
7849 };7867 };
@@ -8658,8 +8676,26 @@ fn decode_block_rect4(
8658 uv_mode8676 uv_mode
8659 };8677 };
8660 let depth = if tx_select {8678 let depth = if tx_select {
8661- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);8679+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
8662- dec.symbol(&mut cdfs.tx_size_cat2[ctx])8680+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
8681+ // the 16x4 intra-in-inter strips already do); the key frame's
8682+ // deblock-grid approximation is only right where those bands were never
8683+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
8684+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
8685+ // `tx_size_cat2` row 1 where libaom reads row 2.
8686+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
8687+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
8688+ } else {
8689+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
8690+ };
8691+ let d = dec.symbol(&mut cdfs.tx_size_cat2[ctx]);
8692+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
8693+ eprintln!(
8694+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=2 rng={}",
8695+ dec.debug_state().0
8696+ );
8697+ }
8698+ d
8663 } else {8699 } else {
8664 08700 0
8665 };8701 };
@@ -9176,7 +9212,16 @@ fn decode_rect4_16_strip(
9176 } else {9212 } else {
9177 tx_size_context_rect(neighbours, lmi, bw, bh)9213 tx_size_context_rect(neighbours, lmi, bw, bh)
9178 };9214 };
9179- dec.symbol(&mut cdfs.tx_size_cat1[ctx])9215+ let d = dec.symbol(&mut cdfs.tx_size_cat1[ctx]);
9216+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
9217+ eprintln!(
9218+ "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=1 rng={}",
9219+ lmi.0,
9220+ lmi.1,
9221+ dec.debug_state().0
9222+ );
9223+ }
9224+ d
9180 } else {9225 } else {
9181 09226 0
9182 };9227 };
@@ -9653,7 +9698,18 @@ fn decode_block_rect64(
9653 };9698 };
9654 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));9699 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
9655 let depth = if tx_select {9700 let depth = if tx_select {
9656- let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh);9701+ // lane-t900 r2: on an INTER frame `get_tx_size_context` reads the real
9702+ // `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what the 2:1 and
9703+ // the 16x4 intra-in-inter strips already do); the key frame's
9704+ // deblock-grid approximation is only right where those bands were never
9705+ // written. Measured on the 10-bit 1920x792 128-superblock stream,
9706+ // decode-order frame 1: the 32x8 HORZ_4 strip at mi(48,176) read
9707+ // `tx_size_cat2` row 1 where libaom reads row 2.
9708+ let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() {
9709+ tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw, bh)
9710+ } else {
9711+ tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh)
9712+ };
9657 // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`)9713 // lane-rectsplit r1: `bsize_to_tx_size_cat` (libaom `decodemv.c`)
9658 // counts `sub_tx_size_map` steps from the block's own max rect9714 // counts `sub_tx_size_map` steps from the block's own max rect
9659 // transform down to TX_4X4, minus one -- BLOCK_64X32's chain9715 // transform down to TX_4X4, minus one -- BLOCK_64X32's chain
@@ -9661,7 +9717,14 @@ fn decode_block_rect64(
9661 // steps, so this level's category is 3 (the same one a 64x64 square9717 // steps, so this level's category is 3 (the same one a 64x64 square
9662 // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF9718 // block uses), not the 2 a 32x16 strip uses. Reading the cat-2 CDF
9663 // here was a wrong-table read of a real symbol.9719 // here was a wrong-table read of a real symbol.
9664- dec.symbol(&mut cdfs.tx_size_cat3[ctx])9720+ let d = dec.symbol(&mut cdfs.tx_size_cat3[ctx]);
9721+ if std::env::var_os("EC_TRACE_MODE_STEP").is_some() {
9722+ eprintln!(
9723+ "EC_ISTEP mi_row={mi_r} mi_col={mi_c} name=tx_depth val={d} ctx={ctx} cat=3 rng={}",
9724+ dec.debug_state().0
9725+ );
9726+ }
9727+ d
9665 } else {9728 } else {
9666 09729 0
9667 };9730 };