Decode the 128-root HORZ/VERT half coded INTRA in an inter frame (opt-in, ungated)
Browse files at this commit37c9fd74686fa567a68f022844daf33cad7b9190Parent: 749b2fb- feat
- decode the 128-root HORZ/VERT half coded INTRA in an inter frame (opt-in, ungated)
3 changed files +98 -2
- crates/ec-av1/examples/decode_probe.rs +4 -0
- crates/ec-av1/src/decode.rs +88 -2
- crates/ec-av1/src/stream.rs +6 -0
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
| @@ -78,6 +78,10 @@ fn main() { | |||
| 78 | println!( | 78 | println!( |
| 79 | "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}" | 79 | "rect_wedge(8x16,16x8,16x32,32x16,8x32,32x8): compound={rw:?} interintra={rwi:?}" |
| 80 | ); | 80 | ); |
| 81 | + // lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA in | ||
| 82 | + // an INTER frame -- the arm this round implemented. | ||
| 83 | + let i128 = ec_av1::stream::intra128_in_inter_counters(); | ||
| 84 | + println!("intra128_in_inter: 128x64={} 64x128={}", i128[0], i128[1]); | ||
| 81 | let sb = ec_av1::stream::sb128_rect_counters(); | 85 | let sb = ec_av1::stream::sb128_rect_counters(); |
| 82 | println!( | 86 | println!( |
| 83 | "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", | 87 | "sb128_rect: edge_horz={} edge_vert={} inter_128x64={} inter_64x128={}", |
crates/ec-av1/src/decode.rsmodified+88 -2
| @@ -7386,6 +7386,56 @@ fn decode_intra_rect_in_inter( | |||
| 7386 | }); | 7386 | }); |
| 7387 | return Ok(()); | 7387 | return Ok(()); |
| 7388 | } | 7388 | } |
| 7389 | + // lane-inter128intra r1: the 128 superblock's PARTITION_HORZ/VERT half | ||
| 7390 | + // coded INTRA inside an inter frame. `size_group_lookup` (common_data.h:61) | ||
| 7391 | + // puts BLOCK_128X64/64X128/128X128 in group 3 and | ||
| 7392 | + // `max_txsize_rect_lookup` caps them at TX_64X64, i.e. the same | ||
| 7393 | + // `tx_size_cat3` row [`decode_block_128rect`] already reads -- so the whole | ||
| 7394 | + // block decodes through the very body the KEY FRAME path proves for this | ||
| 7395 | + // shape (square 64x64 luma units, one TX_32X32 chroma unit per 64x64 mu | ||
| 7396 | + // chunk on the offset-10 txb_skip rows, per-TU prediction, the mu-chunk | ||
| 7397 | + // `Reach` rule and the frame-edge write clip). The only inter-frame | ||
| 7398 | + // differences live inside that body: the mode-info read | ||
| 7399 | + // ([`INTRA_IN_INTER_MODE`] -> `y_mode[3]` plus the `skip` this caller | ||
| 7400 | + // already read), the `tx_depth` context (the real TXFM_CONTEXT bands) and | ||
| 7401 | + // the `set_txfm_ctxs` publication. CfL (>32), filter intra (>32) and | ||
| 7402 | + // palette (>64) do not exist at this size and are refused by name there. | ||
| 7403 | + // lane-inter128intra r1: OPT-IN ONLY (`EC_INTRA128_IN_INTER=1`) until a | ||
| 7404 | + // gate exists. The body below is believed right (it is the key frame's own | ||
| 7405 | + // proven body plus the three inter-frame differences), but the three 1080p | ||
| 7406 | + // cuts that reach this shape reach it AFTER a pre-existing desync (see the | ||
| 7407 | + // lane report: their frame 2 diverges from aomdec inside the superblock at | ||
| 7408 | + // mi(0,320), long before mi(128,416)), and no aomenc recipe found so far | ||
| 7409 | + // emits a 128-root HORZ/VERT half coded intra in an inter frame -- so | ||
| 7410 | + // nothing can currently prove this arm. A refusal is lifted only with a | ||
| 7411 | + // gate (COMMON), so the default path still refuses by name below. | ||
| 7412 | + if bw.max(bh) == 128 && std::env::var_os("EC_INTRA128_IN_INTER").is_some() { | ||
| 7413 | + if allow_screen_content_tools { | ||
| 7414 | + return Err(unsupported( | ||
| 7415 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ | ||
| 7416 | + is consumed for square blocks only)", | ||
| 7417 | + )); | ||
| 7418 | + } | ||
| 7419 | + INTRA_IN_INTER_MODE.with(|c| c.set(Some((3, skip)))); | ||
| 7420 | + let res = decode_block_128rect( | ||
| 7421 | + dec, | ||
| 7422 | + cdfs, | ||
| 7423 | + neighbours, | ||
| 7424 | + (r, c), | ||
| 7425 | + bw, | ||
| 7426 | + bh, | ||
| 7427 | + y, | ||
| 7428 | + u, | ||
| 7429 | + v, | ||
| 7430 | + base_q_idx, | ||
| 7431 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | ||
| 7432 | + allow_screen_content_tools, | ||
| 7433 | + TX_SELECT_INTER.with(std::cell::Cell::get), | ||
| 7434 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | ||
| 7435 | + ); | ||
| 7436 | + INTRA_IN_INTER_MODE.with(|c| c.set(None)); | ||
| 7437 | + return res; | ||
| 7438 | + } | ||
| 7389 | let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { | 7439 | let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { |
| 7390 | (8, 16) => (1usize, 1usize), | 7440 | (8, 16) => (1usize, 1usize), |
| 7391 | (16, 32) => (2, 2), | 7441 | (16, 32) => (2, 2), |
| @@ -11517,6 +11567,15 @@ thread_local! { | |||
| 11517 | /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units, | 11567 | /// Those blocks by resolved intra `tx_depth` (0 = TX_64X64 units, |
| 11518 | /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read. | 11568 | /// 1 = TX_32X32, 2 = TX_16X16) -- proof the depth symbol is really read. |
| 11519 | pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; | 11569 | pub(crate) static INTRA_SB128_DEPTH_HITS: std::cell::Cell<[usize; 3]> = const { std::cell::Cell::new([0; 3]) }; |
| 11570 | + /// lane-inter128intra r1: the same shapes decoded on the INTER block path | ||
| 11571 | + /// (an intra-coded PARTITION_HORZ/VERT half of a 128 superblock inside an | ||
| 11572 | + /// inter frame) -- (128x64, 64x128). | ||
| 11573 | + pub(crate) static INTRA128_IN_INTER_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | ||
| 11574 | +} | ||
| 11575 | + | ||
| 11576 | +/// [`INTRA128_IN_INTER_HITS`], for a gate's own before/after delta. | ||
| 11577 | +pub(crate) fn intra128_in_inter_hits() -> [usize; 2] { | ||
| 11578 | + INTRA128_IN_INTER_HITS.with(std::cell::Cell::get) | ||
| 11520 | } | 11579 | } |
| 11521 | 11580 | ||
| 11522 | /// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] / | 11581 | /// [`INTRA_SB128_HORZ_HITS`] / [`INTRA_SB128_VERT_HITS`] / |
| @@ -11608,8 +11667,17 @@ fn decode_block_128rect( | |||
| 11608 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | 11667 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 11609 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or | 11668 | // spec 5.11.16 `read_tx_size`: read for every intra block, skipped or |
| 11610 | // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc). | 11669 | // not. `bsize_to_tx_size_cat(BLOCK_128X64)` is 3 (see this fn's doc). |
| 11670 | + let in_inter = INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some(); | ||
| 11611 | let depth = if tx_select { | 11671 | let depth = if tx_select { |
| 11612 | - let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); | 11672 | + // lane-inter128intra r1: on an INTER frame `get_tx_size_context` reads |
| 11673 | + // the real `TXFM_CONTEXT` bands, and compares them against | ||
| 11674 | + // `tx_size_wide/high[max_txsize_rect_lookup[bsize]]` -- TX_64X64 for | ||
| 11675 | + // every 128-axis block, hence the `min(64)`. | ||
| 11676 | + let ctx = if in_inter { | ||
| 11677 | + tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)) | ||
| 11678 | + } else { | ||
| 11679 | + tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh) | ||
| 11680 | + }; | ||
| 11613 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) | 11681 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) |
| 11614 | } else { | 11682 | } else { |
| 11615 | 0 | 11683 | 0 |
| @@ -11801,7 +11869,25 @@ fn decode_block_128rect( | |||
| 11801 | logical_tx as u8, | 11869 | logical_tx as u8, |
| 11802 | 0, | 11870 | 0, |
| 11803 | ); | 11871 | ); |
| 11804 | - if bw > bh { | 11872 | + if in_inter { |
| 11873 | + // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter, xd)` | ||
| 11874 | + // (libaom `decodeframe.c` `decode_block`) runs for EVERY block of an | ||
| 11875 | + // inter frame, intra ones included: an intra block stamps its | ||
| 11876 | + // TRANSFORM size over its own footprint in both TXFM_CONTEXT bands. | ||
| 11877 | + // A key frame has no var-tx tree and its readers use the deblock grid, | ||
| 11878 | + // so this is the inter path's alone. | ||
| 11879 | + txfm_partition_update_rect( | ||
| 11880 | + neighbours, | ||
| 11881 | + (mi_r, mi_c), | ||
| 11882 | + (logical_tx, logical_tx), | ||
| 11883 | + (bw, bh), | ||
| 11884 | + ); | ||
| 11885 | + INTRA128_IN_INTER_HITS.with(|c| { | ||
| 11886 | + let mut h = c.get(); | ||
| 11887 | + h[usize::from(bw < bh)] += 1; | ||
| 11888 | + c.set(h); | ||
| 11889 | + }); | ||
| 11890 | + } else if bw > bh { | ||
| 11805 | INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 11891 | INTRA_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| 11806 | } else { | 11892 | } else { |
| 11807 | INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1)); | 11893 | INTRA_SB128_VERT_HITS.with(|c| c.set(c.get() + 1)); |
crates/ec-av1/src/stream.rsmodified+6 -0
| @@ -153,6 +153,12 @@ pub fn intra_sb128_counters() -> (usize, usize, [usize; 3]) { | |||
| 153 | crate::decode::intra_sb128_hits() | 153 | crate::decode::intra_sb128_hits() |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | +/// lane-inter128intra r1: the 128 root's HORZ/VERT half coded INTRA inside an | ||
| 157 | +/// INTER frame -- (128x64 blocks, 64x128 blocks). | ||
| 158 | +pub fn intra128_in_inter_counters() -> [usize; 2] { | ||
| 159 | + crate::decode::intra128_in_inter_hits() | ||
| 160 | +} | ||
| 161 | + | ||
| 156 | /// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`, | 162 | /// lane-sb128c r9: the four AB shapes at the 128 root, in `PARTITION_HORZ_A`, |
| 157 | /// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the | 163 | /// `_HORZ_B`, `_VERT_A`, `_VERT_B` order (key and inter tile paths share the |
| 158 | /// counter -- it is bumped where the root symbol resolves). | 164 | /// counter -- it is bumped where the root symbol resolves). |