Combine_compound folded two shifts libaom keeps separate
Browse files at this commitcc39f29c6bba0e3bbada55fa18f3ae962b0e3382Parent: 4254638- fix
- combine_compound folded two shifts libaom keeps separate
2 changed files +33 -6
- crates/ec-av1/src/mc.rs +9 -1
- lanes/hbdinter-r1.report.md +24 -5
crates/ec-av1/src/mc.rsmodified+9 -1
| @@ -672,8 +672,16 @@ pub fn combine_compound( | |||
| 672 | assert_eq!(pred0.len(), pred1.len(), "both refs predict the same block"); | 672 | assert_eq!(pred0.len(), pred1.len(), "both refs predict the same block"); |
| 673 | assert_eq!(dst.len(), pred0.len(), "the destination is the block"); | 673 | assert_eq!(dst.len(), pred0.len(), "the destination is the block"); |
| 674 | for i in 0..dst.len() { | 674 | for i in 0..dst.len() { |
| 675 | + // libaom (`av1_highbd_dist_wtd_convolve_2d_c`, and its lowbd twin) | ||
| 676 | + // applies the two shifts SEPARATELY: a truncating `>> | ||
| 677 | + // DIST_PRECISION_BITS` on the weighted sum, then `ROUND_POWER_OF_TWO` | ||
| 678 | + // by `round_bits == INTER_POST_ROUND`. Folding them into one | ||
| 679 | + // `Round2(sum, 8)` is NOT the same function -- it rounds up one LSB | ||
| 680 | + // whenever `(sum >> 4) + 8` is one below a multiple of 16 and the | ||
| 681 | + // dropped low 4 bits are non-zero. | ||
| 675 | let sum = pred0[i] * fwd_weight + pred1[i] * bck_weight; | 682 | let sum = pred0[i] * fwd_weight + pred1[i] * bck_weight; |
| 676 | - dst[i] = round2(sum, INTER_POST_ROUND + DIST_PRECISION_BITS).clamp(0, crate::decode::sample_max()) as u16; | 683 | + dst[i] = round2(sum >> DIST_PRECISION_BITS, INTER_POST_ROUND) |
| 684 | + .clamp(0, crate::decode::sample_max()) as u16; | ||
| 677 | } | 685 | } |
| 678 | } | 686 | } |
| 679 | 687 | ||
lanes/hbdinter-r1.report.mdmodified+24 -5
| @@ -117,8 +117,27 @@ after those two lanes land. | |||
| 117 | against `convolve.h:43` but not attributed by a failing-then-passing | 117 | against `convolve.h:43` but not attributed by a failing-then-passing |
| 118 | pixel — unblocked by a fixture whose LR RD picks `RESTORE_WIENER` at | 118 | pixel — unblocked by a fixture whose LR RD picks `RESTORE_WIENER` at |
| 119 | 10-bit (higher-detail content than `gradients`). | 119 | 10-bit (higher-detail content than `gradients`). |
| 120 | -- accepted: `combine_compound` folds libaom's `>> DIST_PRECISION_BITS` | 120 | +- FIXED after the first commit (`mc.rs` `combine_compound`, commit below): |
| 121 | - then `Round2(.., round_bits)` into one `Round2(.., 8)`. Bit-depth | 121 | + it folded libaom's truncating `>> DIST_PRECISION_BITS` and the following |
| 122 | - independent, so out of this lane's scope, but the two are not | 122 | + `Round2(.., INTER_POST_ROUND)` into one `Round2(.., 8)`. Those are not the |
| 123 | - algebraically identical for odd intermediates -- flagged for whoever owns | 123 | + same function -- the folded form rounds one LSB up whenever |
| 124 | - compound. | 124 | + `(sum >> 4) + 8` sits one below a multiple of 16 with non-zero dropped |
| 125 | + low bits. Bit-depth independent (the CONV_BUF `round_offset` cancels | ||
| 126 | + exactly in this crate's unbiased domain, derived from | ||
| 127 | + `av1_highbd_dist_wtd_convolve_2d_c`), so it is a rare off-by-one at ANY | ||
| 128 | + depth. Flagged by lane-cwarp's measurement that 10-bit *compound* still | ||
| 129 | + mismatches frame 1 luma while single-ref is 6/6 exact -- this is my best | ||
| 130 | + candidate for that, but I did not have lane-cwarp's fixture, so it is | ||
| 131 | + UNVERIFIED against their mismatch. All 16 compound tests (incl. the two | ||
| 132 | + real-aomenc 8-bit compound/masked-compound gates) stay green with it: | ||
| 133 | + `cargo test -p ec-av1 --lib -j3 compound` -> 16 passed, 0 failed, 73.58s. | ||
| 134 | + | ||
| 135 | +## Overlap with lane-cwarp | ||
| 136 | + | ||
| 137 | +lane-cwarp commit `04fc3ce` (worktree `edith_codecs-cwarp`) carries the same | ||
| 138 | +two fixes I derived independently here: `mc.rs` `diffwtd_mask`'s missing | ||
| 139 | +`(bd - 8)` and `warp.rs`'s `const BD = 8`. Semantically identical, textually | ||
| 140 | +different (my hunks carry different comments) -- **expect a conflict in | ||
| 141 | +`mc.rs` and `warp.rs` when both branches merge; either side's hunk is | ||
| 142 | +correct, keep one.** The LR (`compute_ab`, Wiener clamp) and | ||
| 143 | +`combine_compound` fixes are unique to this branch. | ||