Compound MV stack was missing libaom's three tpl_sample_pos extension samples
Browse files at this commit123515aacdd89bc83fbe577f7d19015b2189da56Parent: 6f3b424- fix
- compound MV stack was missing libaom's three tpl_sample_pos extension samples
1 changed file +41 -0
- crates/ec-av1/src/mvstack.rs +41 -0
crates/ec-av1/src/mvstack.rsmodified+41 -0
| @@ -1623,6 +1623,47 @@ pub fn find_mv_stack_compound( | |||
| 1623 | } | 1623 | } |
| 1624 | blk_row += step_h; | 1624 | blk_row += step_h; |
| 1625 | } | 1625 | } |
| 1626 | + // lane-sb128 r3: libaom's three `tpl_sample_pos` EXTENSION samples | ||
| 1627 | + // (mvref_common.c:591), which the single-ref twin already ports and | ||
| 1628 | + // this compound path dropped. `check_sb_border`'s mask is libaom's | ||
| 1629 | + // hardcoded `mi_size_wide[BLOCK_64X64]` (16), NOT the sequence's | ||
| 1630 | + // superblock size. Missing them cost one weight-2 vote on a | ||
| 1631 | + // candidate, which reordered the stack and gave a NEW_NEWMV block a | ||
| 1632 | + // different predictor -- 957 wrong pixels on one 32x32 block of one | ||
| 1633 | + // frame with the entropy stream in sync. | ||
| 1634 | + let allow_extension = (2..16).contains(&bh4) && (2..16).contains(&bw4); | ||
| 1635 | + if allow_extension { | ||
| 1636 | + let (voffset, hoffset) = (bh4.max(2) as isize, bw4.max(2) as isize); | ||
| 1637 | + let sb_mask = 16isize; | ||
| 1638 | + for (row_off, col_off) in [ | ||
| 1639 | + (voffset, -2isize), | ||
| 1640 | + (voffset, hoffset), | ||
| 1641 | + (voffset - 2, hoffset), | ||
| 1642 | + ] { | ||
| 1643 | + let row = (mi_row as isize & (sb_mask - 1)) + row_off; | ||
| 1644 | + let col = (mi_col as isize & (sb_mask - 1)) + col_off; | ||
| 1645 | + if row < 0 || row >= sb_mask || col < 0 || col >= sb_mask { | ||
| 1646 | + continue; | ||
| 1647 | + } | ||
| 1648 | + let cand0 = crate::motion_field::add_tpl_ref_mv( | ||
| 1649 | + field, mi_row, mi_col, row_off, col_off, cur_offset_0, | ||
| 1650 | + allow_high_precision_mv, | ||
| 1651 | + ); | ||
| 1652 | + let cand1 = crate::motion_field::add_tpl_ref_mv( | ||
| 1653 | + field, mi_row, mi_col, row_off, col_off, cur_offset_1, | ||
| 1654 | + allow_high_precision_mv, | ||
| 1655 | + ); | ||
| 1656 | + if cand0.is_some() || cand1.is_some() { | ||
| 1657 | + any_hit = true; | ||
| 1658 | + add_compound_candidate( | ||
| 1659 | + &mut candidates, | ||
| 1660 | + cand0.map_or((0, 0), |c| c.mv), | ||
| 1661 | + cand1.map_or((0, 0), |c| c.mv), | ||
| 1662 | + 2, | ||
| 1663 | + ); | ||
| 1664 | + } | ||
| 1665 | + } | ||
| 1666 | + } | ||
| 1626 | if any_hit { | 1667 | if any_hit { |
| 1627 | TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 1668 | TMV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1628 | } | 1669 | } |