Horizontal MC taps multiply at 16 bits
Browse files at this commitdcac6b36b2f4cfdd5a02a0814381359ba031cda2Parent: 8c7cbe4- perf
- horizontal MC taps multiply at 16 bits
1 changed file +8 -1
- crates/ec-av1/src/mc.rs +8 -1
crates/ec-av1/src/mc.rsmodified+8 -1
| @@ -257,10 +257,17 @@ fn hpass_row(reference: &[u16], row_base: usize, true_width: usize, x0: i32, tap | |||
| 257 | if start >= 0 && start as usize + block_w + 7 <= true_width { | 257 | if start >= 0 && start as usize + block_w + 7 <= true_width { |
| 258 | let s = row_base + start as usize; | 258 | let s = row_base + start as usize; |
| 259 | if let Some(src) = reference.get(s..s + block_w + 7) { | 259 | if let Some(src) = reference.get(s..s + block_w + 7) { |
| 260 | + // Both factors are 16-bit (a tap is |x| <= 128, a sample fits the | ||
| 261 | + // bit depth), so the products are exactly the i32 ones above but | ||
| 262 | + // the widening multiply is one instruction per pair. | ||
| 263 | + let t16 = [ | ||
| 264 | + taps[0] as i16, taps[1] as i16, taps[2] as i16, taps[3] as i16, | ||
| 265 | + taps[4] as i16, taps[5] as i16, taps[6] as i16, taps[7] as i16, | ||
| 266 | + ]; | ||
| 260 | for (o, w) in out.iter_mut().zip(src.windows(8)) { | 267 | for (o, w) in out.iter_mut().zip(src.windows(8)) { |
| 261 | let mut sum = 0i32; | 268 | let mut sum = 0i32; |
| 262 | for t in 0..8 { | 269 | for t in 0..8 { |
| 263 | - sum += taps[t] * i32::from(w[t]); | 270 | + sum += i32::from(t16[t]) * i32::from(w[t] as i16); |
| 264 | } | 271 | } |
| 265 | *o = round2(sum, INTER_ROUND_0); | 272 | *o = round2(sum, INTER_ROUND_0); |
| 266 | } | 273 | } |