• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3  * Copyright (c) 2023, Alliance for Open Media. All rights reserved
4  *
5  * This source code is subject to the terms of the BSD 2 Clause License and
6  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
7  * was not distributed with this source code in the LICENSE file, you can
8  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
9  * Media Patent License 1.0 was not distributed with this source code in the
10  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
11  */
12 
13 #include <arm_neon.h>
14 #include <assert.h>
15 #include <string.h>
16 
17 #include "config/aom_config.h"
18 #include "config/aom_dsp_rtcd.h"
19 
20 #include "aom/aom_integer.h"
21 #include "aom_dsp/aom_dsp_common.h"
22 #include "aom_dsp/aom_filter.h"
23 #include "aom_dsp/arm/mem_neon.h"
24 #include "aom_dsp/arm/transpose_neon.h"
25 #include "aom_ports/mem.h"
26 
27 DECLARE_ALIGNED(16, static const uint8_t, dot_prod_permute_tbl[48]) = {
28   0, 1, 2,  3,  1, 2,  3,  4,  2,  3,  4,  5,  3,  4,  5,  6,
29   4, 5, 6,  7,  5, 6,  7,  8,  6,  7,  8,  9,  7,  8,  9,  10,
30   8, 9, 10, 11, 9, 10, 11, 12, 10, 11, 12, 13, 11, 12, 13, 14
31 };
32 
33 DECLARE_ALIGNED(16, static const uint8_t, dot_prod_tran_concat_tbl[32]) = {
34   0, 8,  16, 24, 1, 9,  17, 25, 2, 10, 18, 26, 3, 11, 19, 27,
35   4, 12, 20, 28, 5, 13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31
36 };
37 
38 DECLARE_ALIGNED(16, static const uint8_t, dot_prod_merge_block_tbl[48]) = {
39   /* Shift left and insert new last column in transposed 4x4 block. */
40   1, 2, 3, 16, 5, 6, 7, 20, 9, 10, 11, 24, 13, 14, 15, 28,
41   /* Shift left and insert two new columns in transposed 4x4 block. */
42   2, 3, 16, 17, 6, 7, 20, 21, 10, 11, 24, 25, 14, 15, 28, 29,
43   /* Shift left and insert three new columns in transposed 4x4 block. */
44   3, 16, 17, 18, 7, 20, 21, 22, 11, 24, 25, 26, 15, 28, 29, 30
45 };
46 
convolve8_4_sdot(uint8x16_t samples,const int8x8_t filter,const int32x4_t correction,const uint8x16_t range_limit,const uint8x16x2_t permute_tbl)47 static INLINE int16x4_t convolve8_4_sdot(uint8x16_t samples,
48                                          const int8x8_t filter,
49                                          const int32x4_t correction,
50                                          const uint8x16_t range_limit,
51                                          const uint8x16x2_t permute_tbl) {
52   int8x16_t clamped_samples, permuted_samples[2];
53   int32x4_t sum;
54 
55   /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */
56   clamped_samples = vreinterpretq_s8_u8(vsubq_u8(samples, range_limit));
57 
58   /* Permute samples ready for dot product. */
59   /* { 0,  1,  2,  3,  1,  2,  3,  4,  2,  3,  4,  5,  3,  4,  5,  6 } */
60   permuted_samples[0] = vqtbl1q_s8(clamped_samples, permute_tbl.val[0]);
61   /* { 4,  5,  6,  7,  5,  6,  7,  8,  6,  7,  8,  9,  7,  8,  9, 10 } */
62   permuted_samples[1] = vqtbl1q_s8(clamped_samples, permute_tbl.val[1]);
63 
64   /* Accumulate dot product into 'correction' to account for range clamp. */
65   sum = vdotq_lane_s32(correction, permuted_samples[0], filter, 0);
66   sum = vdotq_lane_s32(sum, permuted_samples[1], filter, 1);
67 
68   /* Further narrowing and packing is performed by the caller. */
69   return vqmovn_s32(sum);
70 }
71 
convolve8_8_sdot(uint8x16_t samples,const int8x8_t filter,const int32x4_t correction,const uint8x16_t range_limit,const uint8x16x3_t permute_tbl)72 static INLINE uint8x8_t convolve8_8_sdot(uint8x16_t samples,
73                                          const int8x8_t filter,
74                                          const int32x4_t correction,
75                                          const uint8x16_t range_limit,
76                                          const uint8x16x3_t permute_tbl) {
77   int8x16_t clamped_samples, permuted_samples[3];
78   int32x4_t sum0, sum1;
79   int16x8_t sum;
80 
81   /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */
82   clamped_samples = vreinterpretq_s8_u8(vsubq_u8(samples, range_limit));
83 
84   /* Permute samples ready for dot product. */
85   /* { 0,  1,  2,  3,  1,  2,  3,  4,  2,  3,  4,  5,  3,  4,  5,  6 } */
86   permuted_samples[0] = vqtbl1q_s8(clamped_samples, permute_tbl.val[0]);
87   /* { 4,  5,  6,  7,  5,  6,  7,  8,  6,  7,  8,  9,  7,  8,  9, 10 } */
88   permuted_samples[1] = vqtbl1q_s8(clamped_samples, permute_tbl.val[1]);
89   /* { 8,  9, 10, 11,  9, 10, 11, 12, 10, 11, 12, 13, 11, 12, 13, 14 } */
90   permuted_samples[2] = vqtbl1q_s8(clamped_samples, permute_tbl.val[2]);
91 
92   /* Accumulate dot product into 'correction' to account for range clamp. */
93   /* First 4 output values. */
94   sum0 = vdotq_lane_s32(correction, permuted_samples[0], filter, 0);
95   sum0 = vdotq_lane_s32(sum0, permuted_samples[1], filter, 1);
96   /* Second 4 output values. */
97   sum1 = vdotq_lane_s32(correction, permuted_samples[1], filter, 0);
98   sum1 = vdotq_lane_s32(sum1, permuted_samples[2], filter, 1);
99 
100   /* Narrow and re-pack. */
101   sum = vcombine_s16(vqmovn_s32(sum0), vqmovn_s32(sum1));
102   return vqrshrun_n_s16(sum, FILTER_BITS);
103 }
104 
aom_convolve8_horiz_neon_dotprod(const uint8_t * src,ptrdiff_t src_stride,uint8_t * dst,ptrdiff_t dst_stride,const int16_t * filter_x,int x_step_q4,const int16_t * filter_y,int y_step_q4,int w,int h)105 void aom_convolve8_horiz_neon_dotprod(const uint8_t *src, ptrdiff_t src_stride,
106                                       uint8_t *dst, ptrdiff_t dst_stride,
107                                       const int16_t *filter_x, int x_step_q4,
108                                       const int16_t *filter_y, int y_step_q4,
109                                       int w, int h) {
110   const int8x8_t filter = vmovn_s16(vld1q_s16(filter_x));
111   const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter_x), 128);
112   const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp));
113   const uint8x16_t range_limit = vdupq_n_u8(128);
114   uint8x16_t s0, s1, s2, s3;
115 
116   assert((intptr_t)dst % 4 == 0);
117   assert(dst_stride % 4 == 0);
118 
119   (void)x_step_q4;
120   (void)filter_y;
121   (void)y_step_q4;
122 
123   src -= ((SUBPEL_TAPS / 2) - 1);
124 
125   if (w == 4) {
126     const uint8x16x2_t perm_tbl = vld1q_u8_x2(dot_prod_permute_tbl);
127     do {
128       int16x4_t t0, t1, t2, t3;
129       uint8x8_t d01, d23;
130 
131       load_u8_16x4(src, src_stride, &s0, &s1, &s2, &s3);
132 
133       t0 = convolve8_4_sdot(s0, filter, correction, range_limit, perm_tbl);
134       t1 = convolve8_4_sdot(s1, filter, correction, range_limit, perm_tbl);
135       t2 = convolve8_4_sdot(s2, filter, correction, range_limit, perm_tbl);
136       t3 = convolve8_4_sdot(s3, filter, correction, range_limit, perm_tbl);
137       d01 = vqrshrun_n_s16(vcombine_s16(t0, t1), FILTER_BITS);
138       d23 = vqrshrun_n_s16(vcombine_s16(t2, t3), FILTER_BITS);
139 
140       store_u8x4_strided_x2(dst + 0 * dst_stride, dst_stride, d01);
141       store_u8x4_strided_x2(dst + 2 * dst_stride, dst_stride, d23);
142 
143       src += 4 * src_stride;
144       dst += 4 * dst_stride;
145       h -= 4;
146     } while (h > 0);
147   } else {
148     const uint8x16x3_t perm_tbl = vld1q_u8_x3(dot_prod_permute_tbl);
149     const uint8_t *s;
150     uint8_t *d;
151     int width;
152     uint8x8_t d0, d1, d2, d3;
153 
154     do {
155       width = w;
156       s = src;
157       d = dst;
158       do {
159         load_u8_16x4(s, src_stride, &s0, &s1, &s2, &s3);
160 
161         d0 = convolve8_8_sdot(s0, filter, correction, range_limit, perm_tbl);
162         d1 = convolve8_8_sdot(s1, filter, correction, range_limit, perm_tbl);
163         d2 = convolve8_8_sdot(s2, filter, correction, range_limit, perm_tbl);
164         d3 = convolve8_8_sdot(s3, filter, correction, range_limit, perm_tbl);
165 
166         store_u8_8x4(d, dst_stride, d0, d1, d2, d3);
167 
168         s += 8;
169         d += 8;
170         width -= 8;
171       } while (width != 0);
172       src += 4 * src_stride;
173       dst += 4 * dst_stride;
174       h -= 4;
175     } while (h > 0);
176   }
177 }
178 
transpose_concat_4x4(int8x8_t a0,int8x8_t a1,int8x8_t a2,int8x8_t a3,int8x16_t * b,const uint8x16_t permute_tbl)179 static INLINE void transpose_concat_4x4(int8x8_t a0, int8x8_t a1, int8x8_t a2,
180                                         int8x8_t a3, int8x16_t *b,
181                                         const uint8x16_t permute_tbl) {
182   /* Transpose 8-bit elements and concatenate result rows as follows:
183    * a0: 00, 01, 02, 03, XX, XX, XX, XX
184    * a1: 10, 11, 12, 13, XX, XX, XX, XX
185    * a2: 20, 21, 22, 23, XX, XX, XX, XX
186    * a3: 30, 31, 32, 33, XX, XX, XX, XX
187    *
188    * b: 00, 10, 20, 30, 01, 11, 21, 31, 02, 12, 22, 32, 03, 13, 23, 33
189    *
190    * The 'permute_tbl' is always 'dot_prod_tran_concat_tbl' above. Passing it
191    * as an argument is preferable to loading it directly from memory as this
192    * inline helper is called many times from the same parent function.
193    */
194 
195   int8x16x2_t samples = { { vcombine_s8(a0, a1), vcombine_s8(a2, a3) } };
196   *b = vqtbl2q_s8(samples, permute_tbl);
197 }
198 
transpose_concat_8x4(int8x8_t a0,int8x8_t a1,int8x8_t a2,int8x8_t a3,int8x16_t * b0,int8x16_t * b1,const uint8x16x2_t permute_tbl)199 static INLINE void transpose_concat_8x4(int8x8_t a0, int8x8_t a1, int8x8_t a2,
200                                         int8x8_t a3, int8x16_t *b0,
201                                         int8x16_t *b1,
202                                         const uint8x16x2_t permute_tbl) {
203   /* Transpose 8-bit elements and concatenate result rows as follows:
204    * a0: 00, 01, 02, 03, 04, 05, 06, 07
205    * a1: 10, 11, 12, 13, 14, 15, 16, 17
206    * a2: 20, 21, 22, 23, 24, 25, 26, 27
207    * a3: 30, 31, 32, 33, 34, 35, 36, 37
208    *
209    * b0: 00, 10, 20, 30, 01, 11, 21, 31, 02, 12, 22, 32, 03, 13, 23, 33
210    * b1: 04, 14, 24, 34, 05, 15, 25, 35, 06, 16, 26, 36, 07, 17, 27, 37
211    *
212    * The 'permute_tbl' is always 'dot_prod_tran_concat_tbl' above. Passing it
213    * as an argument is preferable to loading it directly from memory as this
214    * inline helper is called many times from the same parent function.
215    */
216 
217   int8x16x2_t samples = { { vcombine_s8(a0, a1), vcombine_s8(a2, a3) } };
218   *b0 = vqtbl2q_s8(samples, permute_tbl.val[0]);
219   *b1 = vqtbl2q_s8(samples, permute_tbl.val[1]);
220 }
221 
convolve8_4_sdot_partial(const int8x16_t samples_lo,const int8x16_t samples_hi,const int32x4_t correction,const int8x8_t filter)222 static INLINE int16x4_t convolve8_4_sdot_partial(const int8x16_t samples_lo,
223                                                  const int8x16_t samples_hi,
224                                                  const int32x4_t correction,
225                                                  const int8x8_t filter) {
226   /* Sample range-clamping and permutation are performed by the caller. */
227   int32x4_t sum;
228 
229   /* Accumulate dot product into 'correction' to account for range clamp. */
230   sum = vdotq_lane_s32(correction, samples_lo, filter, 0);
231   sum = vdotq_lane_s32(sum, samples_hi, filter, 1);
232 
233   /* Further narrowing and packing is performed by the caller. */
234   return vqmovn_s32(sum);
235 }
236 
convolve8_8_sdot_partial(const int8x16_t samples0_lo,const int8x16_t samples0_hi,const int8x16_t samples1_lo,const int8x16_t samples1_hi,const int32x4_t correction,const int8x8_t filter)237 static INLINE uint8x8_t convolve8_8_sdot_partial(const int8x16_t samples0_lo,
238                                                  const int8x16_t samples0_hi,
239                                                  const int8x16_t samples1_lo,
240                                                  const int8x16_t samples1_hi,
241                                                  const int32x4_t correction,
242                                                  const int8x8_t filter) {
243   /* Sample range-clamping and permutation are performed by the caller. */
244   int32x4_t sum0, sum1;
245   int16x8_t sum;
246 
247   /* Accumulate dot product into 'correction' to account for range clamp. */
248   /* First 4 output values. */
249   sum0 = vdotq_lane_s32(correction, samples0_lo, filter, 0);
250   sum0 = vdotq_lane_s32(sum0, samples0_hi, filter, 1);
251   /* Second 4 output values. */
252   sum1 = vdotq_lane_s32(correction, samples1_lo, filter, 0);
253   sum1 = vdotq_lane_s32(sum1, samples1_hi, filter, 1);
254 
255   /* Narrow and re-pack. */
256   sum = vcombine_s16(vqmovn_s32(sum0), vqmovn_s32(sum1));
257   return vqrshrun_n_s16(sum, FILTER_BITS);
258 }
259 
aom_convolve8_vert_neon_dotprod(const uint8_t * src,ptrdiff_t src_stride,uint8_t * dst,ptrdiff_t dst_stride,const int16_t * filter_x,int x_step_q4,const int16_t * filter_y,int y_step_q4,int w,int h)260 void aom_convolve8_vert_neon_dotprod(const uint8_t *src, ptrdiff_t src_stride,
261                                      uint8_t *dst, ptrdiff_t dst_stride,
262                                      const int16_t *filter_x, int x_step_q4,
263                                      const int16_t *filter_y, int y_step_q4,
264                                      int w, int h) {
265   const int8x8_t filter = vmovn_s16(vld1q_s16(filter_y));
266   const int16x8_t correct_tmp = vmulq_n_s16(vld1q_s16(filter_y), 128);
267   const int32x4_t correction = vdupq_n_s32((int32_t)vaddvq_s16(correct_tmp));
268   const uint8x8_t range_limit = vdup_n_u8(128);
269   const uint8x16x3_t merge_block_tbl = vld1q_u8_x3(dot_prod_merge_block_tbl);
270   int8x16x2_t samples_LUT;
271 
272   assert((intptr_t)dst % 4 == 0);
273   assert(dst_stride % 4 == 0);
274 
275   (void)filter_x;
276   (void)x_step_q4;
277   (void)y_step_q4;
278 
279   src -= ((SUBPEL_TAPS / 2) - 1) * src_stride;
280 
281   if (w == 4) {
282     const uint8x16_t tran_concat_tbl = vld1q_u8(dot_prod_tran_concat_tbl);
283 
284     uint8x8_t t0, t1, t2, t3, t4, t5, t6;
285     load_u8_8x7(src, src_stride, &t0, &t1, &t2, &t3, &t4, &t5, &t6);
286     src += 7 * src_stride;
287 
288     /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */
289     int8x8_t s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit));
290     int8x8_t s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit));
291     int8x8_t s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit));
292     int8x8_t s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit));
293     int8x8_t s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit));
294     int8x8_t s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit));
295     int8x8_t s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit));
296 
297     /* This operation combines a conventional transpose and the sample permute
298      * (see horizontal case) required before computing the dot product.
299      */
300     int8x16_t s0123, s1234, s2345, s3456;
301     transpose_concat_4x4(s0, s1, s2, s3, &s0123, tran_concat_tbl);
302     transpose_concat_4x4(s1, s2, s3, s4, &s1234, tran_concat_tbl);
303     transpose_concat_4x4(s2, s3, s4, s5, &s2345, tran_concat_tbl);
304     transpose_concat_4x4(s3, s4, s5, s6, &s3456, tran_concat_tbl);
305 
306     do {
307       uint8x8_t t7, t8, t9, t10;
308       load_u8_8x4(src, src_stride, &t7, &t8, &t9, &t10);
309 
310       int8x8_t s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit));
311       int8x8_t s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit));
312       int8x8_t s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit));
313       int8x8_t s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit));
314 
315       int8x16_t s4567, s5678, s6789, s78910;
316       transpose_concat_4x4(s7, s8, s9, s10, &s78910, tran_concat_tbl);
317 
318       /* Merge new data into block from previous iteration. */
319       samples_LUT.val[0] = s3456;
320       samples_LUT.val[1] = s78910;
321       s4567 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]);
322       s5678 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]);
323       s6789 = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]);
324 
325       int16x4_t d0 = convolve8_4_sdot_partial(s0123, s4567, correction, filter);
326       int16x4_t d1 = convolve8_4_sdot_partial(s1234, s5678, correction, filter);
327       int16x4_t d2 = convolve8_4_sdot_partial(s2345, s6789, correction, filter);
328       int16x4_t d3 =
329           convolve8_4_sdot_partial(s3456, s78910, correction, filter);
330       uint8x8_t d01 = vqrshrun_n_s16(vcombine_s16(d0, d1), FILTER_BITS);
331       uint8x8_t d23 = vqrshrun_n_s16(vcombine_s16(d2, d3), FILTER_BITS);
332 
333       store_u8x4_strided_x2(dst + 0 * dst_stride, dst_stride, d01);
334       store_u8x4_strided_x2(dst + 2 * dst_stride, dst_stride, d23);
335 
336       /* Prepare block for next iteration - re-using as much as possible. */
337       /* Shuffle everything up four rows. */
338       s0123 = s4567;
339       s1234 = s5678;
340       s2345 = s6789;
341       s3456 = s78910;
342 
343       src += 4 * src_stride;
344       dst += 4 * dst_stride;
345       h -= 4;
346     } while (h != 0);
347   } else {
348     const uint8x16x2_t tran_concat_tbl = vld1q_u8_x2(dot_prod_tran_concat_tbl);
349 
350     do {
351       int height = h;
352       const uint8_t *s = src;
353       uint8_t *d = dst;
354 
355       uint8x8_t t0, t1, t2, t3, t4, t5, t6;
356       load_u8_8x7(s, src_stride, &t0, &t1, &t2, &t3, &t4, &t5, &t6);
357       s += 7 * src_stride;
358 
359       /* Clamp sample range to [-128, 127] for 8-bit signed dot product. */
360       int8x8_t s0 = vreinterpret_s8_u8(vsub_u8(t0, range_limit));
361       int8x8_t s1 = vreinterpret_s8_u8(vsub_u8(t1, range_limit));
362       int8x8_t s2 = vreinterpret_s8_u8(vsub_u8(t2, range_limit));
363       int8x8_t s3 = vreinterpret_s8_u8(vsub_u8(t3, range_limit));
364       int8x8_t s4 = vreinterpret_s8_u8(vsub_u8(t4, range_limit));
365       int8x8_t s5 = vreinterpret_s8_u8(vsub_u8(t5, range_limit));
366       int8x8_t s6 = vreinterpret_s8_u8(vsub_u8(t6, range_limit));
367 
368       /* This operation combines a conventional transpose and the sample permute
369        * (see horizontal case) required before computing the dot product.
370        */
371       int8x16_t s0123_lo, s0123_hi, s1234_lo, s1234_hi, s2345_lo, s2345_hi,
372           s3456_lo, s3456_hi;
373       transpose_concat_8x4(s0, s1, s2, s3, &s0123_lo, &s0123_hi,
374                            tran_concat_tbl);
375       transpose_concat_8x4(s1, s2, s3, s4, &s1234_lo, &s1234_hi,
376                            tran_concat_tbl);
377       transpose_concat_8x4(s2, s3, s4, s5, &s2345_lo, &s2345_hi,
378                            tran_concat_tbl);
379       transpose_concat_8x4(s3, s4, s5, s6, &s3456_lo, &s3456_hi,
380                            tran_concat_tbl);
381 
382       do {
383         uint8x8_t t7, t8, t9, t10;
384         load_u8_8x4(s, src_stride, &t7, &t8, &t9, &t10);
385 
386         int8x8_t s7 = vreinterpret_s8_u8(vsub_u8(t7, range_limit));
387         int8x8_t s8 = vreinterpret_s8_u8(vsub_u8(t8, range_limit));
388         int8x8_t s9 = vreinterpret_s8_u8(vsub_u8(t9, range_limit));
389         int8x8_t s10 = vreinterpret_s8_u8(vsub_u8(t10, range_limit));
390 
391         int8x16_t s4567_lo, s4567_hi, s5678_lo, s5678_hi, s6789_lo, s6789_hi,
392             s78910_lo, s78910_hi;
393         transpose_concat_8x4(s7, s8, s9, s10, &s78910_lo, &s78910_hi,
394                              tran_concat_tbl);
395 
396         /* Merge new data into block from previous iteration. */
397         samples_LUT.val[0] = s3456_lo;
398         samples_LUT.val[1] = s78910_lo;
399         s4567_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]);
400         s5678_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]);
401         s6789_lo = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]);
402 
403         samples_LUT.val[0] = s3456_hi;
404         samples_LUT.val[1] = s78910_hi;
405         s4567_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[0]);
406         s5678_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[1]);
407         s6789_hi = vqtbl2q_s8(samples_LUT, merge_block_tbl.val[2]);
408 
409         uint8x8_t d0 = convolve8_8_sdot_partial(s0123_lo, s4567_lo, s0123_hi,
410                                                 s4567_hi, correction, filter);
411         uint8x8_t d1 = convolve8_8_sdot_partial(s1234_lo, s5678_lo, s1234_hi,
412                                                 s5678_hi, correction, filter);
413         uint8x8_t d2 = convolve8_8_sdot_partial(s2345_lo, s6789_lo, s2345_hi,
414                                                 s6789_hi, correction, filter);
415         uint8x8_t d3 = convolve8_8_sdot_partial(s3456_lo, s78910_lo, s3456_hi,
416                                                 s78910_hi, correction, filter);
417 
418         store_u8_8x4(d, dst_stride, d0, d1, d2, d3);
419 
420         /* Prepare block for next iteration - re-using as much as possible. */
421         /* Shuffle everything up four rows. */
422         s0123_lo = s4567_lo;
423         s0123_hi = s4567_hi;
424         s1234_lo = s5678_lo;
425         s1234_hi = s5678_hi;
426         s2345_lo = s6789_lo;
427         s2345_hi = s6789_hi;
428         s3456_lo = s78910_lo;
429         s3456_hi = s78910_hi;
430 
431         s += 4 * src_stride;
432         d += 4 * dst_stride;
433         height -= 4;
434       } while (height != 0);
435       src += 8;
436       dst += 8;
437       w -= 8;
438     } while (w != 0);
439   }
440 }
441