wip(sb128c): r7 partial from the interrupted round
Browse files at this commit386c0a8ed99c46c7d5ab9513d9008408206d5a5eParent: 33555291 changed file +212 -23
- crates/ec-av1/src/decode.rs +212 -23
crates/ec-av1/src/decode.rsmodified+212 -23
| @@ -1922,6 +1922,19 @@ thread_local! { | |||
| 1922 | /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile | 1922 | /// lane-sb128c r1: how many 128x128 `PARTITION_NONE` roots this INTER tile |
| 1923 | /// path decoded as one whole block (its gate's own witness). | 1923 | /// path decoded as one whole block (its gate's own witness). |
| 1924 | pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1924 | pub(crate) static INTER_SB128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1925 | + /// 128x64 / 64x128 INTER blocks decoded at the 128 root (lane-sb128c r7). | ||
| 1926 | + pub(crate) static INTER_SB128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1927 | + pub(crate) static INTER_SB128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1928 | +} | ||
| 1929 | + | ||
| 1930 | +/// Current value of [`INTER_SB128_HORZ_HITS`], for a gate's before/after delta. | ||
| 1931 | +pub(crate) fn inter_sb128_horz_hits() -> usize { | ||
| 1932 | + INTER_SB128_HORZ_HITS.with(std::cell::Cell::get) | ||
| 1933 | +} | ||
| 1934 | + | ||
| 1935 | +/// Current value of [`INTER_SB128_VERT_HITS`], for a gate's before/after delta. | ||
| 1936 | +pub(crate) fn inter_sb128_vert_hits() -> usize { | ||
| 1937 | + INTER_SB128_VERT_HITS.with(std::cell::Cell::get) | ||
| 1925 | } | 1938 | } |
| 1926 | 1939 | ||
| 1927 | /// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta. | 1940 | /// Current value of [`INTER_SB128_NONE_HITS`], for a gate's before/after delta. |
| @@ -11881,6 +11894,12 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 11881 | // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no | 11894 | // `TX_64X64`, so `av1_get_ext_tx_set_type` is `DCT_ONLY` and no |
| 11882 | // `tx_type` symbol is coded at all. | 11895 | // `tx_type` symbol is coded at all. |
| 11883 | | (64, 32) | (32, 64) | (64, 16) | (16, 64) | 11896 | | (64, 32) | (32, 64) | (64, 16) | (16, 64) |
| 11897 | + // lane-sb128c r7: the 128 root's HORZ/VERT halves. These are NOT | ||
| 11898 | + // one rectangular transform -- `max_txsize_rect_lookup | ||
| 11899 | + // [BLOCK_128X64]` is TX_64X64, so the block tiles into two square | ||
| 11900 | + // TX_64X64 units read through the mu-chunk loop, same as the | ||
| 11901 | + // 128x128 NONE block's four. | ||
| 11902 | + | (128, 64) | (64, 128) | ||
| 11884 | ) | 11903 | ) |
| 11885 | } | 11904 | } |
| 11886 | 11905 | ||
| @@ -12007,6 +12026,55 @@ fn read_block_tx_size_rect( | |||
| 12007 | } | 12026 | } |
| 12008 | // `max_txsize_rect_lookup` is the block's own size, capped at 64 -- and | 12027 | // `max_txsize_rect_lookup` is the block's own size, capped at 64 -- and |
| 12009 | // `rect_inter_residual_supported` has already excluded everything above 32. | 12028 | // `rect_inter_residual_supported` has already excluded everything above 32. |
| 12029 | + // lane-sb128c r7: except at the 128 root. `max_txsize_rect_lookup | ||
| 12030 | + // [BLOCK_128X64] == TX_64X64` (libaom `common_data.h`), so a 128x64 block | ||
| 12031 | + // is TWO square top-level transform units side by side and a 64x128 one is | ||
| 12032 | + // two stacked -- exactly what libaom `read_block_tx_size` | ||
| 12033 | + // (decodeframe.c:1140) codes with its `idy/idx` loop over | ||
| 12034 | + // `tx_size_high_unit/tx_size_wide_unit[max_tx_size]`. Each unit reads its | ||
| 12035 | + // own `txfm_partition` symbol at depth 0. | ||
| 12036 | + if bw.max(bh) > 64 { | ||
| 12037 | + let tx = 64usize; | ||
| 12038 | + let (max_w_mi, max_h_mi) = ( | ||
| 12039 | + (bw / MI).min(mi_cols.saturating_sub(at_mi.1)), | ||
| 12040 | + (bh / MI).min(mi_rows.saturating_sub(at_mi.0)), | ||
| 12041 | + ); | ||
| 12042 | + let mut leaves = Vec::new(); | ||
| 12043 | + if !TX_SELECT_INTER.with(std::cell::Cell::get) { | ||
| 12044 | + for row in (0..bh / MI).step_by(tx / MI) { | ||
| 12045 | + for col in (0..bw / MI).step_by(tx / MI) { | ||
| 12046 | + leaves.push((row, col, tx, tx)); | ||
| 12047 | + } | ||
| 12048 | + } | ||
| 12049 | + for &(row, col, tw, th) in &leaves { | ||
| 12050 | + txfm_partition_update_rect(n, (at_mi.0 + row, at_mi.1 + col), (tw, th), (tw, th)); | ||
| 12051 | + } | ||
| 12052 | + return Ok(Some(leaves)); | ||
| 12053 | + } | ||
| 12054 | + for row in (0..bh / MI).step_by(tx / MI) { | ||
| 12055 | + for col in (0..bw / MI).step_by(tx / MI) { | ||
| 12056 | + read_var_tx_size( | ||
| 12057 | + dec, | ||
| 12058 | + cdfs, | ||
| 12059 | + n, | ||
| 12060 | + at_mi, | ||
| 12061 | + bw.max(bh), | ||
| 12062 | + (max_w_mi, max_h_mi), | ||
| 12063 | + (tx, tx), | ||
| 12064 | + 0, | ||
| 12065 | + row, | ||
| 12066 | + col, | ||
| 12067 | + &mut leaves, | ||
| 12068 | + ); | ||
| 12069 | + } | ||
| 12070 | + } | ||
| 12071 | + if leaves.iter().any(|l| l.2.max(l.3) > 64) { | ||
| 12072 | + return Err(unsupported( | ||
| 12073 | + "an inter var-tx tree with a leaf transform larger than 64x64", | ||
| 12074 | + )); | ||
| 12075 | + } | ||
| 12076 | + return Ok(Some(leaves)); | ||
| 12077 | + } | ||
| 12010 | let (tx_w, tx_h) = (bw, bh); | 12078 | let (tx_w, tx_h) = (bw, bh); |
| 12011 | if !TX_SELECT_INTER.with(std::cell::Cell::get) { | 12079 | if !TX_SELECT_INTER.with(std::cell::Cell::get) { |
| 12012 | // `TX_MODE_LARGEST`: no symbol at all, the whole block is one | 12080 | // `TX_MODE_LARGEST`: no symbol at all, the whole block is one |
| @@ -13260,6 +13328,15 @@ thread_local! { | |||
| 13260 | /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one | 13328 | /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one |
| 13261 | /// whole 128x128 block (lane-sb128b r1's gate counter). | 13329 | /// whole 128x128 block (lane-sb128b r1's gate counter). |
| 13262 | pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 13330 | pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 13331 | + /// 128 roots that resolved to PARTITION_HORZ (two 128x64 pieces, or one | ||
| 13332 | + /// when the bottom half is out of frame) -- lane-sb128c r7. | ||
| 13333 | + pub(crate) static PART128_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13334 | + /// 128 roots that resolved to PARTITION_VERT (two 64x128 pieces). | ||
| 13335 | + pub(crate) static PART128_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13336 | + /// Of those, the ones decided by the GATHERED bit at a frame edge -- the | ||
| 13337 | + /// only shape a 1080p (mi_rows = 270) stream reaches. | ||
| 13338 | + pub(crate) static PART128_EDGE_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13339 | + pub(crate) static PART128_EDGE_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13263 | } | 13340 | } |
| 13264 | 13341 | ||
| 13265 | /// [`PART128_NONE_HITS`], for a gate's own before/after delta. | 13342 | /// [`PART128_NONE_HITS`], for a gate's own before/after delta. |
| @@ -13267,6 +13344,26 @@ pub(crate) fn part128_none_hits() -> usize { | |||
| 13267 | PART128_NONE_HITS.with(std::cell::Cell::get) | 13344 | PART128_NONE_HITS.with(std::cell::Cell::get) |
| 13268 | } | 13345 | } |
| 13269 | 13346 | ||
| 13347 | +/// [`PART128_HORZ_HITS`], for a gate's own before/after delta. | ||
| 13348 | +pub(crate) fn part128_horz_hits() -> usize { | ||
| 13349 | + PART128_HORZ_HITS.with(std::cell::Cell::get) | ||
| 13350 | +} | ||
| 13351 | + | ||
| 13352 | +/// [`PART128_VERT_HITS`], for a gate's own before/after delta. | ||
| 13353 | +pub(crate) fn part128_vert_hits() -> usize { | ||
| 13354 | + PART128_VERT_HITS.with(std::cell::Cell::get) | ||
| 13355 | +} | ||
| 13356 | + | ||
| 13357 | +/// [`PART128_EDGE_HORZ_HITS`] -- gathered-bit HORZ at the bottom frame edge. | ||
| 13358 | +pub(crate) fn part128_edge_horz_hits() -> usize { | ||
| 13359 | + PART128_EDGE_HORZ_HITS.with(std::cell::Cell::get) | ||
| 13360 | +} | ||
| 13361 | + | ||
| 13362 | +/// [`PART128_EDGE_VERT_HITS`] -- gathered-bit VERT at the right frame edge. | ||
| 13363 | +pub(crate) fn part128_edge_vert_hits() -> usize { | ||
| 13364 | + PART128_EDGE_VERT_HITS.with(std::cell::Cell::get) | ||
| 13365 | +} | ||
| 13366 | + | ||
| 13270 | thread_local! { | 13367 | thread_local! { |
| 13271 | /// How many CHROMA transform units were coded inside a block whose uv | 13368 | /// How many CHROMA transform units were coded inside a block whose uv |
| 13272 | /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128 | 13369 | /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128 |
| @@ -13328,6 +13425,7 @@ fn read_sb128_root( | |||
| 13328 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { | 13425 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 { |
| 13329 | PARTITION_SPLIT | 13426 | PARTITION_SPLIT |
| 13330 | } else { | 13427 | } else { |
| 13428 | + PART128_EDGE_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13331 | PARTITION_HORZ | 13429 | PARTITION_HORZ |
| 13332 | } | 13430 | } |
| 13333 | } | 13431 | } |
| @@ -13335,6 +13433,7 @@ fn read_sb128_root( | |||
| 13335 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { | 13433 | if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 { |
| 13336 | PARTITION_SPLIT | 13434 | PARTITION_SPLIT |
| 13337 | } else { | 13435 | } else { |
| 13436 | + PART128_EDGE_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13338 | PARTITION_VERT | 13437 | PARTITION_VERT |
| 13339 | } | 13438 | } |
| 13340 | } | 13439 | } |
| @@ -13347,15 +13446,23 @@ fn read_sb128_root( | |||
| 13347 | // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by | 13446 | // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by |
| 13348 | // the key-frame caller below. The six remaining arms (HORZ/VERT and the | 13447 | // the key-frame caller below. The six remaining arms (HORZ/VERT and the |
| 13349 | // four AB shapes) still need the rect/AB machinery at this size. | 13448 | // four AB shapes) still need the rect/AB machinery at this size. |
| 13350 | - if part128 != PARTITION_SPLIT && part128 != PARTITION_NONE { | 13449 | + // lane-sb128c r7: HORZ (two 128x64) and VERT (two 64x128) now decode on |
| 13351 | - return Err(unsupported( | 13450 | + // both tile paths. The four AB shapes (libaom `decode_partition`'s |
| 13352 | - "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", | 13451 | + // PARTITION_HORZ_A..VERT_B, decodeframe.c) still need the mixed |
| 13353 | - )); | 13452 | + // 128x64 + 64x64 + 64x64 visit order and stay refused by name; a 128 |
| 13354 | - } | 13453 | + // root has no 1:4 arm at all (`PARTITION_HORZ_4`/`VERT_4` are excluded |
| 13355 | - if part128 == PARTITION_SPLIT { | 13454 | + // for BLOCK_128X128 by `av1_get_partition_cdf`'s 8-symbol alphabet, |
| 13356 | - PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 13455 | + // which stops at VERT_B). |
| 13357 | - } else { | 13456 | + match part128 { |
| 13358 | - PART128_NONE_HITS.with(|c| c.set(c.get() + 1)); | 13457 | + PARTITION_SPLIT => PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)), |
| 13458 | + PARTITION_NONE => PART128_NONE_HITS.with(|c| c.set(c.get() + 1)), | ||
| 13459 | + PARTITION_HORZ => PART128_HORZ_HITS.with(|c| c.set(c.get() + 1)), | ||
| 13460 | + PARTITION_VERT => PART128_VERT_HITS.with(|c| c.set(c.get() + 1)), | ||
| 13461 | + _ => { | ||
| 13462 | + return Err(unsupported( | ||
| 13463 | + "a 128x128 superblock AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B at the 128 root)", | ||
| 13464 | + )); | ||
| 13465 | + } | ||
| 13359 | } | 13466 | } |
| 13360 | Ok(part128) | 13467 | Ok(part128) |
| 13361 | } | 13468 | } |
| @@ -15475,6 +15582,12 @@ impl PlaneBuf { | |||
| 15475 | prediction: &[u16], | 15582 | prediction: &[u16], |
| 15476 | residual: &[i32], | 15583 | residual: &[i32], |
| 15477 | ) { | 15584 | ) { |
| 15585 | + // lane-sb128c r7: a 128x64 half of a 128 root at the BOTTOM frame edge | ||
| 15586 | + // is the first block shape whose true footprint overhangs the padded | ||
| 15587 | + // coding surface (mi_rows = 198 -> a plane 800 rows tall, block rows | ||
| 15588 | + // 768..832). libaom reconstructs those rows into the frame buffer's | ||
| 15589 | + // border; nothing reads them back, so they are simply dropped here. | ||
| 15590 | + let (h, w) = (h.min(self.height.saturating_sub(y)), w.min(self.width.saturating_sub(x))); | ||
| 15478 | for row in 0..h { | 15591 | for row in 0..h { |
| 15479 | for col in 0..w { | 15592 | for col in 0..w { |
| 15480 | let sample = (i32::from(prediction[row * side + col]) + residual[row * side + col]) | 15593 | let sample = (i32::from(prediction[row * side + col]) + residual[row * side + col]) |
| @@ -16774,7 +16887,10 @@ fn decode_inter_block( | |||
| 16774 | maybe_read_cdef_idx(dec, rmi, cmi, skip); | 16887 | maybe_read_cdef_idx(dec, rmi, cmi, skip); |
| 16775 | // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip | 16888 | // lane-inter4 r1: spec 5.11.6's `bSize == sbSize` -- a 64x32/64x16 strip |
| 16776 | // is NOT the whole superblock, so its `skip` never suppresses the read. | 16889 | // is NOT the whole superblock, so its `skip` never suppresses the read. |
| 16777 | - let whole_sb = side == 64 && write_w == 64 && write_h == 64; | 16890 | + // lane-sb128c r7: `sbSize` is 128 under `--sb-size=128`, so the whole-block |
| 16891 | + // test is against the sequence's own superblock side, not a hardcoded 64. | ||
| 16892 | + let sb_px = sb_mi_cur() as usize * 4; | ||
| 16893 | + let whole_sb = side == sb_px && write_w == sb_px && write_h == sb_px; | ||
| 16778 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); | 16894 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 16779 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); | 16895 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 16780 | let (has_above, has_left) = ( | 16896 | let (has_above, has_left) = ( |
| @@ -17885,7 +18001,13 @@ fn decode_inter_block( | |||
| 17885 | None, | 18001 | None, |
| 17886 | )?; | 18002 | )?; |
| 17887 | } | 18003 | } |
| 17888 | - if rect_tu { | 18004 | + if side > 64 { |
| 18005 | + // Already read inside the mu-chunk loop above -- at the 128 | ||
| 18006 | + // root a rect (128x64/64x128) block's chroma is per mu | ||
| 18007 | + // chunk too, so this test comes BEFORE the `rect_tu` one. | ||
| 18008 | + u_grid = std::mem::take(&mut u_units); | ||
| 18009 | + v_grid = std::mem::take(&mut v_units); | ||
| 18010 | + } else if rect_tu { | ||
| 17889 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a | 18011 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a |
| 17890 | // 2:1 strip is the strip's own rect chroma size (16x8 / | 18012 | // 2:1 strip is the strip's own rect chroma size (16x8 / |
| 17891 | // 8x16), one unit for the whole block, and it codes no | 18013 | // 8x16), one unit for the whole block, and it codes no |
| @@ -17935,10 +18057,6 @@ fn decode_inter_block( | |||
| 17935 | uh, | 18057 | uh, |
| 17936 | chroma_side, | 18058 | chroma_side, |
| 17937 | ); | 18059 | ); |
| 17938 | - } else if side > 64 { | ||
| 17939 | - // Already read inside the mu-chunk loop above. | ||
| 17940 | - u_grid = std::mem::take(&mut u_units); | ||
| 17941 | - v_grid = std::mem::take(&mut v_units); | ||
| 17942 | } else { | 18060 | } else { |
| 17943 | u_grid = read_inter_plane( | 18061 | u_grid = read_inter_plane( |
| 17944 | dec, | 18062 | dec, |
| @@ -18984,7 +19102,13 @@ fn decode_inter_block( | |||
| 18984 | None, | 19102 | None, |
| 18985 | )?; | 19103 | )?; |
| 18986 | } | 19104 | } |
| 18987 | - if rect_tu { | 19105 | + if side > 64 { |
| 19106 | + // Already read inside the mu-chunk loop above -- at the 128 | ||
| 19107 | + // root a rect (128x64/64x128) block's chroma is per mu | ||
| 19108 | + // chunk too, so this test comes BEFORE the `rect_tu` one. | ||
| 19109 | + u_grid = std::mem::take(&mut u_units); | ||
| 19110 | + v_grid = std::mem::take(&mut v_units); | ||
| 19111 | + } else if rect_tu { | ||
| 18988 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a | 19112 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a |
| 18989 | // 2:1 strip is the strip's own rect chroma size (16x8 / | 19113 | // 2:1 strip is the strip's own rect chroma size (16x8 / |
| 18990 | // 8x16), one unit for the whole block, and it codes no | 19114 | // 8x16), one unit for the whole block, and it codes no |
| @@ -19034,10 +19158,6 @@ fn decode_inter_block( | |||
| 19034 | uh, | 19158 | uh, |
| 19035 | chroma_side, | 19159 | chroma_side, |
| 19036 | ); | 19160 | ); |
| 19037 | - } else if side > 64 { | ||
| 19038 | - // Already read inside the mu-chunk loop above. | ||
| 19039 | - u_grid = std::mem::take(&mut u_units); | ||
| 19040 | - v_grid = std::mem::take(&mut v_units); | ||
| 19041 | } else { | 19161 | } else { |
| 19042 | u_grid = read_inter_plane( | 19162 | u_grid = read_inter_plane( |
| 19043 | dec, | 19163 | dec, |
| @@ -21647,8 +21767,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21647 | continue; | 21767 | continue; |
| 21648 | } | 21768 | } |
| 21649 | { | 21769 | { |
| 21770 | + let mut sb128_rect = None; | ||
| 21650 | if sb128 && sb_start { | 21771 | if sb128 && sb_start { |
| 21651 | - if read_sb128_root( | 21772 | + let part128 = read_sb128_root( |
| 21652 | &mut dec, | 21773 | &mut dec, |
| 21653 | &mut cdfs, | 21774 | &mut cdfs, |
| 21654 | &neighbours, | 21775 | &neighbours, |
| @@ -21659,8 +21780,17 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21659 | sb_c, | 21780 | sb_c, |
| 21660 | mi_cols, | 21781 | mi_cols, |
| 21661 | mi_rows, | 21782 | mi_rows, |
| 21662 | - )? == PARTITION_NONE | 21783 | + )?; |
| 21663 | - { | 21784 | + if matches!(part128, PARTITION_HORZ | PARTITION_VERT) { |
| 21785 | + // Two 128x64 (HORZ) or two 64x128 (VERT) inter blocks; the | ||
| 21786 | + // whole 128x128 root is consumed here, so the remaining | ||
| 21787 | + // three 64-quadrant visits of this superblock carry no | ||
| 21788 | + // syntax (same skip the NONE arm runs). | ||
| 21789 | + sb128_none = true; | ||
| 21790 | + sb128_rect = Some(part128); | ||
| 21791 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 21792 | + } | ||
| 21793 | + if part128 == PARTITION_NONE { | ||
| 21664 | // One 128x128 inter block. Its luma transform is | 21794 | // One 128x128 inter block. Its luma transform is |
| 21665 | // `max_txsize_rect_lookup[BLOCK_128X128]` = TX_64X64 (four | 21795 | // `max_txsize_rect_lookup[BLOCK_128X128]` = TX_64X64 (four |
| 21666 | // units, read as var-tx leaves), its uv plane block is | 21796 | // units, read as var-tx leaves), its uv plane block is |
| @@ -21747,6 +21877,65 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21747 | )? | 21877 | )? |
| 21748 | }; | 21878 | }; |
| 21749 | } | 21879 | } |
| 21880 | + if let Some(part128) = sb128_rect { | ||
| 21881 | + // lane-sb128c r7: libaom `decode_partition` (decodeframe.c:1554) | ||
| 21882 | + // codes PARTITION_HORZ at the 128 root as `subsize = | ||
| 21883 | + // BLOCK_128X64` at (mi_row, mi_col) and a second one at | ||
| 21884 | + // (mi_row + hbs, mi_col) only `if (mi_row + hbs < mi_rows)`; | ||
| 21885 | + // PARTITION_VERT mirrors it on the column. `hbs` here is | ||
| 21886 | + // `mi_size_high[BLOCK_128X128] / 2` = 16 mi. | ||
| 21887 | + let horz = part128 == PARTITION_HORZ; | ||
| 21888 | + let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | ||
| 21889 | + let base_mi = sub16_to_mi(at128); | ||
| 21890 | + let (bw, bh) = if horz { (128usize, 64usize) } else { (64, 128) }; | ||
| 21891 | + for i in 0..2 { | ||
| 21892 | + let at_mi = if horz { | ||
| 21893 | + (base_mi.0 + i * 16, base_mi.1) | ||
| 21894 | + } else { | ||
| 21895 | + (base_mi.0, base_mi.1 + i * 16) | ||
| 21896 | + }; | ||
| 21897 | + if i > 0 && (at_mi.0 >= mi_rows as usize || at_mi.1 >= mi_cols as usize) { | ||
| 21898 | + break; | ||
| 21899 | + } | ||
| 21900 | + inter_piece!( | ||
| 21901 | + at_mi, SB * 2, | ||
| 21902 | + TxbSet::Luma64, TxbSet::Luma64, TxbSet::Chroma32, TX32, TX32, | ||
| 21903 | + &scan32, &scan32, 3, bw, bh | ||
| 21904 | + ); | ||
| 21905 | + if horz { | ||
| 21906 | + INTER_SB128_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 21907 | + } else { | ||
| 21908 | + INTER_SB128_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 21909 | + } | ||
| 21910 | + } | ||
| 21911 | + // One `cdef_idx` per BLOCK, copied to every 64x64 CDEF unit it | ||
| 21912 | + // covers -- both halves of the root read their own, and the | ||
| 21913 | + // first one's read lands in the top-left unit while the | ||
| 21914 | + // second's lands in the bottom-left (HORZ) / top-right (VERT). | ||
| 21915 | + let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize); | ||
| 21916 | + CDEF_IDX_GRID.with(|g| { | ||
| 21917 | + let mut g = g.borrow_mut(); | ||
| 21918 | + let cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 21919 | + if cols == 0 { | ||
| 21920 | + return; | ||
| 21921 | + } | ||
| 21922 | + for (src, dst) in if horz { | ||
| 21923 | + [((0, 0), (0, 1)), ((1, 0), (1, 1))] | ||
| 21924 | + } else { | ||
| 21925 | + [((0, 0), (1, 0)), ((0, 1), (1, 1))] | ||
| 21926 | + } { | ||
| 21927 | + let (si, di) = ( | ||
| 21928 | + (q_r + src.0) * cols + q_c + src.1, | ||
| 21929 | + (q_r + dst.0) * cols + q_c + dst.1, | ||
| 21930 | + ); | ||
| 21931 | + if q_c + src.1 < cols && q_c + dst.1 < cols && si < g.len() && di < g.len() | ||
| 21932 | + { | ||
| 21933 | + g[di] = g[si]; | ||
| 21934 | + } | ||
| 21935 | + } | ||
| 21936 | + }); | ||
| 21937 | + continue; | ||
| 21938 | + } | ||
| 21750 | if sb128_none { | 21939 | if sb128_none { |
| 21751 | INTER_SB128_NONE_HITS.with(|c| c.set(c.get() + 1)); | 21940 | INTER_SB128_NONE_HITS.with(|c| c.set(c.get() + 1)); |
| 21752 | let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | 21941 | let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); |