wip(sb128): r3 state -- compound tpl extension samples ported, inter refusal lifted
Browse files at this commitd5ca61c8a32a27cffe7ba172a1f7e237d5ac509eParent: 68956144 changed files +57 -16
- crates/ec-av1/src/decode.rs +16 -0
- crates/ec-av1/src/mvstack.rs +41 -0
- crates/ec-av1/src/refusal_inventory.rs +0 -1
- crates/ec-av1/src/stream.rs +0 -15
crates/ec-av1/src/decode.rsmodified+16 -0
| @@ -14616,6 +14616,22 @@ fn decode_inter_block( | ||
| 14616 | 14616 | force_integer_mv, |
| 14617 | 14617 | (gm_table[(ref0 - LAST_FRAME) as usize], gm_table[(ref1 - LAST_FRAME) as usize]), |
| 14618 | 14618 | ); |
| 14619 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 14620 | + eprintln!( | |
| 14621 | + "EC_MODE_VAL mi_row={mi_row} mi_col={mi_col} mode={} ref0={ref0} ref1={ref1} mv0=({},{}) stack={} rng={}", | |
| 14622 | + compound_mode + 17, | |
| 14623 | + mv0.0, | |
| 14624 | + mv0.1, | |
| 14625 | + comp_stack.entries.len(), | |
| 14626 | + dec.debug_state().0 | |
| 14627 | + ); | |
| 14628 | + for (i, e) in comp_stack.entries.iter().enumerate() { | |
| 14629 | + eprintln!( | |
| 14630 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} i={i} this=({},{}) comp=({},{}) w={}", | |
| 14631 | + e.mv0.0, e.mv0.1, e.mv1.0, e.mv1.1, e.weight | |
| 14632 | + ); | |
| 14633 | + } | |
| 14634 | + } | |
| 14619 | 14635 | let is_globalmv = compound_mode == 6; // GLOBAL_GLOBALMV |
| 14620 | 14636 | // spec `is_nontrans_global_motion`: ALL active refs' models must |
| 14621 | 14637 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
crates/ec-av1/src/mvstack.rsmodified+41 -0
| @@ -1660,6 +1660,47 @@ pub fn find_mv_stack_compound( | ||
| 1660 | 1660 | } |
| 1661 | 1661 | blk_row += step_h; |
| 1662 | 1662 | } |
| 1663 | + // lane-sb128 r3: libaom's three `tpl_sample_pos` EXTENSION samples | |
| 1664 | + // (mvref_common.c:591), which the single-ref twin already ports and | |
| 1665 | + // this compound path dropped. `check_sb_border`'s mask is libaom's | |
| 1666 | + // hardcoded `mi_size_wide[BLOCK_64X64]` (16), NOT the sequence's | |
| 1667 | + // superblock size. Missing them cost one weight-2 vote on a | |
| 1668 | + // candidate, which reordered the stack and gave a NEW_NEWMV block a | |
| 1669 | + // different predictor -- 957 wrong pixels on one 32x32 block of one | |
| 1670 | + // frame with the entropy stream in sync. | |
| 1671 | + let allow_extension = (2..16).contains(&bh4) && (2..16).contains(&bw4); | |
| 1672 | + if allow_extension { | |
| 1673 | + let (voffset, hoffset) = (bh4.max(2) as isize, bw4.max(2) as isize); | |
| 1674 | + let sb_mask = 16isize; | |
| 1675 | + for (row_off, col_off) in [ | |
| 1676 | + (voffset, -2isize), | |
| 1677 | + (voffset, hoffset), | |
| 1678 | + (voffset - 2, hoffset), | |
| 1679 | + ] { | |
| 1680 | + let row = (mi_row as isize & (sb_mask - 1)) + row_off; | |
| 1681 | + let col = (mi_col as isize & (sb_mask - 1)) + col_off; | |
| 1682 | + if row < 0 || row >= sb_mask || col < 0 || col >= sb_mask { | |
| 1683 | + continue; | |
| 1684 | + } | |
| 1685 | + let cand0 = crate::motion_field::add_tpl_ref_mv( | |
| 1686 | + field, mi_row, mi_col, row_off, col_off, cur_offset_0, | |
| 1687 | + allow_high_precision_mv, | |
| 1688 | + ); | |
| 1689 | + let cand1 = crate::motion_field::add_tpl_ref_mv( | |
| 1690 | + field, mi_row, mi_col, row_off, col_off, cur_offset_1, | |
| 1691 | + allow_high_precision_mv, | |
| 1692 | + ); | |
| 1693 | + if cand0.is_some() || cand1.is_some() { | |
| 1694 | + any_hit = true; | |
| 1695 | + add_compound_candidate( | |
| 1696 | + &mut candidates, | |
| 1697 | + cand0.map_or((0, 0), |c| c.mv), | |
| 1698 | + cand1.map_or((0, 0), |c| c.mv), | |
| 1699 | + 2, | |
| 1700 | + ); | |
| 1701 | + } | |
| 1702 | + } | |
| 1703 | + } | |
| 1663 | 1704 | if any_hit { |
| 1664 | 1705 | TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1665 | 1706 | } |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
| @@ -45,7 +45,6 @@ const REFUSALS: &[&str] = &[ | ||
| 45 | 45 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 46 | 46 | "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", |
| 47 | 47 | "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", |
| 48 | - "an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 superblock root only)", | |
| 49 | 48 | "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", |
| 50 | 49 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", |
| 51 | 50 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", |
crates/ec-av1/src/stream.rsmodified+0 -15
| @@ -492,19 +492,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 492 | 492 | .is_some_and(|seq| seq.use_128x128_superblock); |
| 493 | 493 | let sb128_active = use_sb128 && (header.mi_cols > 16 || header.mi_rows > 16); |
| 494 | 494 | crate::decode::set_sb128(sb128_active); |
| 495 | - // lane-sb128 r2 RESIDUAL: the inter tile loop now reads the 128 root | |
| 496 | - // and walks libaom's quadrant order, and 8 of the 9 decode-order | |
| 497 | - // frames of the r2 gate stream are pixel-exact -- but frame 6 still | |
| 498 | - // differs (996 luma bytes, entropy in sync), and the SAME content at | |
| 499 | - // `--sb-size=64` is exact (`sb128_r2_control_sb64`), so the residual is | |
| 500 | - // sb128-specific. The refusal stays until that frame is exact: silent | |
| 501 | - // wrong pixels on his films are worse than a named stop. | |
| 502 | - if sb128_active && header.frame_type != FrameType::Key { | |
| 503 | - return Err(Error::unsupported( | |
| 504 | - "AV1 decode_stream", | |
| 505 | - "an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 superblock root only)", | |
| 506 | - )); | |
| 507 | - } | |
| 508 | 495 | // lane-hbd r5: `BIT_DEPTH` (decode.rs) drives `crate::decode::sample_max`, |
| 509 | 496 | // which every dequant/inverse-transform clamp reads -- set per frame, |
| 510 | 497 | // not once per process, for the same cross-sequence-on-one-thread |
| @@ -16224,8 +16211,6 @@ mod tests { | ||
| 16224 | 16211 | /// superblock), and temporal MV candidates (the inter-only path). Both bit |
| 16225 | 16212 | /// depths -- his films are `yuv420p10le`. Only a missing tool SKIPs. |
| 16226 | 16213 | #[test] |
| 16227 | - #[ignore = "lane-sb128 r2: reproducer for the residual frame-6 mismatch; the \ | |
| 16228 | - product path still refuses inter frames at sb128 (see decode_stream)"] | |
| 16229 | 16214 | fn a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact() { |
| 16230 | 16215 | const NAME: &str = |
| 16231 | 16216 | "a_real_aomenc_inter_sequence_with_128x128_superblocks_decodes_pixel_exact"; |