Pin the hidden-ARF witness and gate it
Browse files at this commit620173e3c9562dfc4551b91f2db10668ab7126aaParent: 79abd1e- test
- pin the hidden-ARF witness and gate it
- sweep the same missing TXFM_CONTEXT publication in the 32-level 1:4 strip reader
3 changed files +100 -0
- crates/ec-av1/fixtures/reelb_arf_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +34 -0
- crates/ec-av1/src/stream.rs +66 -0
crates/ec-av1/fixtures/reelb_arf_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+34 -0
| @@ -2638,6 +2638,18 @@ pub(crate) fn sub16_split_hits() -> usize { | |||
| 2638 | SUB16_SPLIT_HITS.with(|c| c.get()) | 2638 | SUB16_SPLIT_HITS.with(|c| c.get()) |
| 2639 | } | 2639 | } |
| 2640 | 2640 | ||
| 2641 | +// lane-frame36 r2: superblock-level strips ([`decode_block_rect64`]) whose | ||
| 2642 | +// luma transform is SPLIT and which therefore leave through that fn's early | ||
| 2643 | +// return -- the arm that published no `TXFM_CONTEXT` band until this round. | ||
| 2644 | +thread_local! { | ||
| 2645 | + static RECT64_SPLIT_TXFM_PUBLISH_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2646 | +} | ||
| 2647 | + | ||
| 2648 | +/// Current value of `RECT64_SPLIT_TXFM_PUBLISH_HITS`. | ||
| 2649 | +pub(crate) fn rect64_split_txfm_publish_hits() -> usize { | ||
| 2650 | + RECT64_SPLIT_TXFM_PUBLISH_HITS.with(|c| c.get()) | ||
| 2651 | +} | ||
| 2652 | + | ||
| 2641 | /// Current value of `RECT4_COEFF_HITS`. | 2653 | /// Current value of `RECT4_COEFF_HITS`. |
| 2642 | pub(crate) fn rect4_coeff_hits() -> usize { | 2654 | pub(crate) fn rect4_coeff_hits() -> usize { |
| 2643 | RECT4_COEFF_HITS.with(|c| c.get()) | 2655 | RECT4_COEFF_HITS.with(|c| c.get()) |
| @@ -8610,6 +8622,13 @@ fn decode_block_rect4( | |||
| 8610 | if !skip { | 8622 | if !skip { |
| 8611 | RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 8623 | RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); |
| 8612 | } | 8624 | } |
| 8625 | + // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | ||
| 8626 | + // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | ||
| 8627 | + // frame, so this 1:4 strip -- which is also the INTER frame's reader | ||
| 8628 | + // for 32x8/8x32 ([`decode_intra_rect4_in_inter`]) -- publishes its | ||
| 8629 | + // transform size in both TXFM_CONTEXT bands. Without it the next block | ||
| 8630 | + // reads the row's stale value. | ||
| 8631 | + txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | ||
| 8613 | return Ok((mode, uv_predict_mode)); | 8632 | return Ok((mode, uv_predict_mode)); |
| 8614 | } | 8633 | } |
| 8615 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip | 8634 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip |
| @@ -8760,6 +8779,13 @@ fn decode_block_rect4( | |||
| 8760 | } else { | 8779 | } else { |
| 8761 | RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | 8780 | RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); |
| 8762 | } | 8781 | } |
| 8782 | + // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | ||
| 8783 | + // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | ||
| 8784 | + // frame, so this 1:4 strip -- which is also the INTER frame's reader | ||
| 8785 | + // for 32x8/8x32 ([`decode_intra_rect4_in_inter`]) -- publishes its | ||
| 8786 | + // transform size in both TXFM_CONTEXT bands. Without it the next block | ||
| 8787 | + // reads the row's stale value. | ||
| 8788 | + txfm_partition_update_rect(neighbours, (mi_r, mi_c), (bw, bh), (bw, bh)); | ||
| 8763 | return Ok((mode, uv_predict_mode)); | 8789 | return Ok((mode, uv_predict_mode)); |
| 8764 | }; | 8790 | }; |
| 8765 | if let Some(b) = &palette_y_buf { | 8791 | if let Some(b) = &palette_y_buf { |
| @@ -8822,6 +8848,13 @@ fn decode_block_rect4( | |||
| 8822 | } else { | 8848 | } else { |
| 8823 | RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | 8849 | RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); |
| 8824 | } | 8850 | } |
| 8851 | + // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm, | ||
| 8852 | + // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter | ||
| 8853 | + // frame, so this 1:4 strip -- which is also the INTER frame's reader | ||
| 8854 | + // for 32x8/8x32 ([`decode_intra_rect4_in_inter`]) -- publishes its | ||
| 8855 | + // transform size in both TXFM_CONTEXT bands. Without it the next block | ||
| 8856 | + // reads the row's stale value. | ||
| 8857 | + txfm_partition_update_rect(neighbours, (mi_r, mi_c), (bw, bh), (bw, bh)); | ||
| 8825 | Ok((mode, uv_predict_mode)) | 8858 | Ok((mode, uv_predict_mode)) |
| 8826 | } | 8859 | } |
| 8827 | 8860 | ||
| @@ -9600,6 +9633,7 @@ fn decode_block_rect64( | |||
| 9600 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The | 9633 | // mi(192,144) took `tx_size_cat3` row 2 where libaom takes row 1. The |
| 9601 | // bands carry the SPLIT unit's size, not the block's. | 9634 | // bands carry the SPLIT unit's size, not the block's. |
| 9602 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | 9635 | txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); |
| 9636 | + RECT64_SPLIT_TXFM_PUBLISH_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9603 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 9637 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| 9604 | return Ok(()); | 9638 | return Ok(()); |
| 9605 | } | 9639 | } |
crates/ec-av1/src/stream.rsmodified+66 -0
| @@ -30065,6 +30065,72 @@ mod tests { | |||
| 30065 | ); | 30065 | ); |
| 30066 | } | 30066 | } |
| 30067 | 30067 | ||
| 30068 | + /// lane-frame36 r2: the hidden-ARF witness. `crates/ec-av1/fixtures/ | ||
| 30069 | + /// reelb_arf_witness.obu`, 32126 bytes, sha256 | ||
| 30070 | + /// `7f3b060da5aa9c537633e760c4af71316237db7692f6ae0d459bd2c2dd867d37`: | ||
| 30071 | + /// the first 58 frame-carrying OBUs of a 2 s head cut of the 10-bit | ||
| 30072 | + /// 3840x1608 AV1 HDR10 stream, 40 decode-order frames, 37 shown. | ||
| 30073 | + /// | ||
| 30074 | + /// What it covers that no earlier fixture did: decode-order frame 33 is a | ||
| 30075 | + /// HIDDEN alt-ref (`show_frame=0`, order_hint 64, `cdef_bits=1`, loop | ||
| 30076 | + /// restoration `[Switchable, Sgrproj, Switchable]`, `skip_mode_frame` | ||
| 30077 | + /// [1,6]) -- the first frame of the stream carrying a SPLIT | ||
| 30078 | + /// superblock-level intra strip in an inter frame. Its 16x64 strip at | ||
| 30079 | + /// mi(192,140) reads `tx_depth=1` (TX_16X32), and until this round | ||
| 30080 | + /// [`decode_block_rect64`]'s split arm returned past the tail that | ||
| 30081 | + /// publishes the `TXFM_CONTEXT` bands, so the 32x64 block at mi(192,144) | ||
| 30082 | + /// read the row's init value 64 as its left transform height and took | ||
| 30083 | + /// `tx_size_cat3` row 2 where aomdec takes row 1 -- a desync no shown | ||
| 30084 | + /// frame exposed until the ARF was displayed (class | ||
| 30085 | + /// `gate-blind-to-hidden-frames`). | ||
| 30086 | + /// | ||
| 30087 | + /// The counter assert is on `rect64_split_txfm_publish_hits`, the split | ||
| 30088 | + /// arm that was silent, so a stream that stopped carrying the shape fails | ||
| 30089 | + /// the gate instead of passing it vacuously. | ||
| 30090 | + #[test] | ||
| 30091 | + fn a_10bit_film_hidden_arf_with_split_superblock_strips_decodes_pixel_exact() { | ||
| 30092 | + const NAME: &str = | ||
| 30093 | + "a_10bit_film_hidden_arf_with_split_superblock_strips_decodes_pixel_exact"; | ||
| 30094 | + if !have_ffmpeg() { | ||
| 30095 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 30096 | + return; | ||
| 30097 | + } | ||
| 30098 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 30099 | + .join("fixtures/reelb_arf_witness.obu"); | ||
| 30100 | + let stream = std::fs::read(&path) | ||
| 30101 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 30102 | + let (width, height) = (3840usize, 1608usize); | ||
| 30103 | + let before = crate::decode::rect64_split_txfm_publish_hits(); | ||
| 30104 | + let frames = match decode_stream(&stream) { | ||
| 30105 | + Ok(frames) => frames, | ||
| 30106 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 30107 | + }; | ||
| 30108 | + let fired = crate::decode::rect64_split_txfm_publish_hits() - before; | ||
| 30109 | + assert!( | ||
| 30110 | + fired > 0, | ||
| 30111 | + "{NAME}: no split superblock-level strip in the stream -- the gate would be vacuous" | ||
| 30112 | + ); | ||
| 30113 | + assert_eq!(frames.len(), 37, "{NAME}: 37 shown frames"); | ||
| 30114 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 30115 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | ||
| 30116 | + assert_eq!( | ||
| 30117 | + ffmpeg_frames.len(), | ||
| 30118 | + frames.len(), | ||
| 30119 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | ||
| 30120 | + ffmpeg_frames.len(), | ||
| 30121 | + frames.len() | ||
| 30122 | + ); | ||
| 30123 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 30124 | + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | ||
| 30125 | + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | ||
| 30126 | + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | ||
| 30127 | + } | ||
| 30128 | + eprintln!( | ||
| 30129 | + "{NAME}: 37 shown frames pixel-exact on every plane, \ | ||
| 30130 | + rect64_split_txfm_publish={fired}" | ||
| 30131 | + ); | ||
| 30132 | + } | ||
| 30133 | + | ||
| 30068 | 30134 | ||
| 30069 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an | 30135 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an |
| 30070 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra | 30136 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra |