summaryrefslogtreecommitdiffstats
path: root/media/libvpx/libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c
blob: ebc004a04871953aa321c23d728383d49297ff0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/*
 *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <arm_neon.h>

#include "./vpx_config.h"
#include "vp8/common/arm/loopfilter_arm.h"
#include "vpx_ports/arm.h"

static INLINE void vp8_loop_filter_neon(uint8x16_t qblimit,  // flimit
                                        uint8x16_t qlimit,   // limit
                                        uint8x16_t qthresh,  // thresh
                                        uint8x16_t q3,       // p3
                                        uint8x16_t q4,       // p2
                                        uint8x16_t q5,       // p1
                                        uint8x16_t q6,       // p0
                                        uint8x16_t q7,       // q0
                                        uint8x16_t q8,       // q1
                                        uint8x16_t q9,       // q2
                                        uint8x16_t q10,      // q3
                                        uint8x16_t *q5r,     // p1
                                        uint8x16_t *q6r,     // p0
                                        uint8x16_t *q7r,     // q0
                                        uint8x16_t *q8r) {   // q1
  uint8x16_t q0u8, q1u8, q2u8, q11u8, q12u8, q13u8, q14u8, q15u8;
  int16x8_t q2s16, q11s16;
  uint16x8_t q4u16;
  int8x16_t q1s8, q2s8, q10s8, q11s8, q12s8, q13s8;
  int8x8_t d2s8, d3s8;

  q11u8 = vabdq_u8(q3, q4);
  q12u8 = vabdq_u8(q4, q5);
  q13u8 = vabdq_u8(q5, q6);
  q14u8 = vabdq_u8(q8, q7);
  q3 = vabdq_u8(q9, q8);
  q4 = vabdq_u8(q10, q9);

  q11u8 = vmaxq_u8(q11u8, q12u8);
  q12u8 = vmaxq_u8(q13u8, q14u8);
  q3 = vmaxq_u8(q3, q4);
  q15u8 = vmaxq_u8(q11u8, q12u8);

  q9 = vabdq_u8(q6, q7);

  // vp8_hevmask
  q13u8 = vcgtq_u8(q13u8, qthresh);
  q14u8 = vcgtq_u8(q14u8, qthresh);
  q15u8 = vmaxq_u8(q15u8, q3);

  q2u8 = vabdq_u8(q5, q8);
  q9 = vqaddq_u8(q9, q9);

  q15u8 = vcgeq_u8(qlimit, q15u8);

  // vp8_filter() function
  // convert to signed
  q10 = vdupq_n_u8(0x80);
  q8 = veorq_u8(q8, q10);
  q7 = veorq_u8(q7, q10);
  q6 = veorq_u8(q6, q10);
  q5 = veorq_u8(q5, q10);

  q2u8 = vshrq_n_u8(q2u8, 1);
  q9 = vqaddq_u8(q9, q2u8);

  q10 = vdupq_n_u8(3);

  q2s16 = vsubl_s8(vget_low_s8(vreinterpretq_s8_u8(q7)),
                   vget_low_s8(vreinterpretq_s8_u8(q6)));
  q11s16 = vsubl_s8(vget_high_s8(vreinterpretq_s8_u8(q7)),
                    vget_high_s8(vreinterpretq_s8_u8(q6)));

  q9 = vcgeq_u8(qblimit, q9);

  q1s8 = vqsubq_s8(vreinterpretq_s8_u8(q5), vreinterpretq_s8_u8(q8));

  q14u8 = vorrq_u8(q13u8, q14u8);

  q4u16 = vmovl_u8(vget_low_u8(q10));
  q2s16 = vmulq_s16(q2s16, vreinterpretq_s16_u16(q4u16));
  q11s16 = vmulq_s16(q11s16, vreinterpretq_s16_u16(q4u16));

  q1u8 = vandq_u8(vreinterpretq_u8_s8(q1s8), q14u8);
  q15u8 = vandq_u8(q15u8, q9);

  q1s8 = vreinterpretq_s8_u8(q1u8);
  q2s16 = vaddw_s8(q2s16, vget_low_s8(q1s8));
  q11s16 = vaddw_s8(q11s16, vget_high_s8(q1s8));

  q9 = vdupq_n_u8(4);
  // vp8_filter = clamp(vp8_filter + 3 * ( qs0 - ps0))
  d2s8 = vqmovn_s16(q2s16);
  d3s8 = vqmovn_s16(q11s16);
  q1s8 = vcombine_s8(d2s8, d3s8);
  q1u8 = vandq_u8(vreinterpretq_u8_s8(q1s8), q15u8);
  q1s8 = vreinterpretq_s8_u8(q1u8);

  q2s8 = vqaddq_s8(q1s8, vreinterpretq_s8_u8(q10));
  q1s8 = vqaddq_s8(q1s8, vreinterpretq_s8_u8(q9));
  q2s8 = vshrq_n_s8(q2s8, 3);
  q1s8 = vshrq_n_s8(q1s8, 3);

  q11s8 = vqaddq_s8(vreinterpretq_s8_u8(q6), q2s8);
  q10s8 = vqsubq_s8(vreinterpretq_s8_u8(q7), q1s8);

  q1s8 = vrshrq_n_s8(q1s8, 1);
  q1s8 = vbicq_s8(q1s8, vreinterpretq_s8_u8(q14u8));

  q13s8 = vqaddq_s8(vreinterpretq_s8_u8(q5), q1s8);
  q12s8 = vqsubq_s8(vreinterpretq_s8_u8(q8), q1s8);

  q0u8 = vdupq_n_u8(0x80);
  *q8r = veorq_u8(vreinterpretq_u8_s8(q12s8), q0u8);
  *q7r = veorq_u8(vreinterpretq_u8_s8(q10s8), q0u8);
  *q6r = veorq_u8(vreinterpretq_u8_s8(q11s8), q0u8);
  *q5r = veorq_u8(vreinterpretq_u8_s8(q13s8), q0u8);
  return;
}

void vp8_loop_filter_horizontal_edge_y_neon(unsigned char *src, int pitch,
                                            unsigned char blimit,
                                            unsigned char limit,
                                            unsigned char thresh) {
  uint8x16_t qblimit, qlimit, qthresh, q3, q4;
  uint8x16_t q5, q6, q7, q8, q9, q10;

  qblimit = vdupq_n_u8(blimit);
  qlimit = vdupq_n_u8(limit);
  qthresh = vdupq_n_u8(thresh);
  src -= (pitch << 2);

  q3 = vld1q_u8(src);
  src += pitch;
  q4 = vld1q_u8(src);
  src += pitch;
  q5 = vld1q_u8(src);
  src += pitch;
  q6 = vld1q_u8(src);
  src += pitch;
  q7 = vld1q_u8(src);
  src += pitch;
  q8 = vld1q_u8(src);
  src += pitch;
  q9 = vld1q_u8(src);
  src += pitch;
  q10 = vld1q_u8(src);

  vp8_loop_filter_neon(qblimit, qlimit, qthresh, q3, q4, q5, q6, q7, q8, q9,
                       q10, &q5, &q6, &q7, &q8);

  src -= (pitch * 5);
  vst1q_u8(src, q5);
  src += pitch;
  vst1q_u8(src, q6);
  src += pitch;
  vst1q_u8(src, q7);
  src += pitch;
  vst1q_u8(src, q8);
  return;
}

void vp8_loop_filter_horizontal_edge_uv_neon(unsigned char *u, int pitch,
                                             unsigned char blimit,
                                             unsigned char limit,
                                             unsigned char thresh,
                                             unsigned char *v) {
  uint8x16_t qblimit, qlimit, qthresh, q3, q4;
  uint8x16_t q5, q6, q7, q8, q9, q10;
  uint8x8_t d6, d7, d8, d9, d10, d11, d12, d13, d14;
  uint8x8_t d15, d16, d17, d18, d19, d20, d21;

  qblimit = vdupq_n_u8(blimit);
  qlimit = vdupq_n_u8(limit);
  qthresh = vdupq_n_u8(thresh);

  u -= (pitch << 2);
  v -= (pitch << 2);

  d6 = vld1_u8(u);
  u += pitch;
  d7 = vld1_u8(v);
  v += pitch;
  d8 = vld1_u8(u);
  u += pitch;
  d9 = vld1_u8(v);
  v += pitch;
  d10 = vld1_u8(u);
  u += pitch;
  d11 = vld1_u8(v);
  v += pitch;
  d12 = vld1_u8(u);
  u += pitch;
  d13 = vld1_u8(v);
  v += pitch;
  d14 = vld1_u8(u);
  u += pitch;
  d15 = vld1_u8(v);
  v += pitch;
  d16 = vld1_u8(u);
  u += pitch;
  d17 = vld1_u8(v);
  v += pitch;
  d18 = vld1_u8(u);
  u += pitch;
  d19 = vld1_u8(v);
  v += pitch;
  d20 = vld1_u8(u);
  d21 = vld1_u8(v);

  q3 = vcombine_u8(d6, d7);
  q4 = vcombine_u8(d8, d9);
  q5 = vcombine_u8(d10, d11);
  q6 = vcombine_u8(d12, d13);
  q7 = vcombine_u8(d14, d15);
  q8 = vcombine_u8(d16, d17);
  q9 = vcombine_u8(d18, d19);
  q10 = vcombine_u8(d20, d21);

  vp8_loop_filter_neon(qblimit, qlimit, qthresh, q3, q4, q5, q6, q7, q8, q9,
                       q10, &q5, &q6, &q7, &q8);

  u -= (pitch * 5);
  vst1_u8(u, vget_low_u8(q5));
  u += pitch;
  vst1_u8(u, vget_low_u8(q6));
  u += pitch;
  vst1_u8(u, vget_low_u8(q7));
  u += pitch;
  vst1_u8(u, vget_low_u8(q8));

  v -= (pitch * 5);
  vst1_u8(v, vget_high_u8(q5));
  v += pitch;
  vst1_u8(v, vget_high_u8(q6));
  v += pitch;
  vst1_u8(v, vget_high_u8(q7));
  v += pitch;
  vst1_u8(v, vget_high_u8(q8));
  return;
}

static INLINE void write_4x8(unsigned char *dst, int pitch,
                             const uint8x8x4_t result) {
#ifdef VPX_INCOMPATIBLE_GCC
  /*
   * uint8x8x4_t result
  00 01 02 03 | 04 05 06 07
  10 11 12 13 | 14 15 16 17
  20 21 22 23 | 24 25 26 27
  30 31 32 33 | 34 35 36 37
  ---
  * after vtrn_u16
  00 01 20 21 | 04 05 24 25
  02 03 22 23 | 06 07 26 27
  10 11 30 31 | 14 15 34 35
  12 13 32 33 | 16 17 36 37
  ---
  * after vtrn_u8
  00 10 20 30 | 04 14 24 34
  01 11 21 31 | 05 15 25 35
  02 12 22 32 | 06 16 26 36
  03 13 23 33 | 07 17 27 37
  */
  const uint16x4x2_t r02_u16 = vtrn_u16(vreinterpret_u16_u8(result.val[0]),
                                        vreinterpret_u16_u8(result.val[2]));
  const uint16x4x2_t r13_u16 = vtrn_u16(vreinterpret_u16_u8(result.val[1]),
                                        vreinterpret_u16_u8(result.val[3]));
  const uint8x8x2_t r01_u8 = vtrn_u8(vreinterpret_u8_u16(r02_u16.val[0]),
                                     vreinterpret_u8_u16(r13_u16.val[0]));
  const uint8x8x2_t r23_u8 = vtrn_u8(vreinterpret_u8_u16(r02_u16.val[1]),
                                     vreinterpret_u8_u16(r13_u16.val[1]));
  const uint32x2_t x_0_4 = vreinterpret_u32_u8(r01_u8.val[0]);
  const uint32x2_t x_1_5 = vreinterpret_u32_u8(r01_u8.val[1]);
  const uint32x2_t x_2_6 = vreinterpret_u32_u8(r23_u8.val[0]);
  const uint32x2_t x_3_7 = vreinterpret_u32_u8(r23_u8.val[1]);
  vst1_lane_u32((uint32_t *)dst, x_0_4, 0);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_1_5, 0);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_2_6, 0);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_3_7, 0);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_0_4, 1);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_1_5, 1);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_2_6, 1);
  dst += pitch;
  vst1_lane_u32((uint32_t *)dst, x_3_7, 1);
#else
  vst4_lane_u8(dst, result, 0);
  dst += pitch;
  vst4_lane_u8(dst, result, 1);
  dst += pitch;
  vst4_lane_u8(dst, result, 2);
  dst += pitch;
  vst4_lane_u8(dst, result, 3);
  dst += pitch;
  vst4_lane_u8(dst, result, 4);
  dst += pitch;
  vst4_lane_u8(dst, result, 5);
  dst += pitch;
  vst4_lane_u8(dst, result, 6);
  dst += pitch;
  vst4_lane_u8(dst, result, 7);
#endif  // VPX_INCOMPATIBLE_GCC
}

void vp8_loop_filter_vertical_edge_y_neon(unsigned char *src, int pitch,
                                          unsigned char blimit,
                                          unsigned char limit,
                                          unsigned char thresh) {
  unsigned char *s, *d;
  uint8x16_t qblimit, qlimit, qthresh, q3, q4;
  uint8x16_t q5, q6, q7, q8, q9, q10;
  uint8x8_t d6, d7, d8, d9, d10, d11, d12, d13, d14;
  uint8x8_t d15, d16, d17, d18, d19, d20, d21;
  uint32x4x2_t q2tmp0, q2tmp1, q2tmp2, q2tmp3;
  uint16x8x2_t q2tmp4, q2tmp5, q2tmp6, q2tmp7;
  uint8x16x2_t q2tmp8, q2tmp9, q2tmp10, q2tmp11;
  uint8x8x4_t q4ResultH, q4ResultL;

  qblimit = vdupq_n_u8(blimit);
  qlimit = vdupq_n_u8(limit);
  qthresh = vdupq_n_u8(thresh);

  s = src - 4;
  d6 = vld1_u8(s);
  s += pitch;
  d8 = vld1_u8(s);
  s += pitch;
  d10 = vld1_u8(s);
  s += pitch;
  d12 = vld1_u8(s);
  s += pitch;
  d14 = vld1_u8(s);
  s += pitch;
  d16 = vld1_u8(s);
  s += pitch;
  d18 = vld1_u8(s);
  s += pitch;
  d20 = vld1_u8(s);
  s += pitch;
  d7 = vld1_u8(s);
  s += pitch;
  d9 = vld1_u8(s);
  s += pitch;
  d11 = vld1_u8(s);
  s += pitch;
  d13 = vld1_u8(s);
  s += pitch;
  d15 = vld1_u8(s);
  s += pitch;
  d17 = vld1_u8(s);
  s += pitch;
  d19 = vld1_u8(s);
  s += pitch;
  d21 = vld1_u8(s);

  q3 = vcombine_u8(d6, d7);
  q4 = vcombine_u8(d8, d9);
  q5 = vcombine_u8(d10, d11);
  q6 = vcombine_u8(d12, d13);
  q7 = vcombine_u8(d14, d15);
  q8 = vcombine_u8(d16, d17);
  q9 = vcombine_u8(d18, d19);
  q10 = vcombine_u8(d20, d21);

  q2tmp0 = vtrnq_u32(vreinterpretq_u32_u8(q3), vreinterpretq_u32_u8(q7));
  q2tmp1 = vtrnq_u32(vreinterpretq_u32_u8(q4), vreinterpretq_u32_u8(q8));
  q2tmp2 = vtrnq_u32(vreinterpretq_u32_u8(q5), vreinterpretq_u32_u8(q9));
  q2tmp3 = vtrnq_u32(vreinterpretq_u32_u8(q6), vreinterpretq_u32_u8(q10));

  q2tmp4 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp0.val[0]),
                     vreinterpretq_u16_u32(q2tmp2.val[0]));
  q2tmp5 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp1.val[0]),
                     vreinterpretq_u16_u32(q2tmp3.val[0]));
  q2tmp6 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp0.val[1]),
                     vreinterpretq_u16_u32(q2tmp2.val[1]));
  q2tmp7 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp1.val[1]),
                     vreinterpretq_u16_u32(q2tmp3.val[1]));

  q2tmp8 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp4.val[0]),
                    vreinterpretq_u8_u16(q2tmp5.val[0]));
  q2tmp9 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp4.val[1]),
                    vreinterpretq_u8_u16(q2tmp5.val[1]));
  q2tmp10 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp6.val[0]),
                     vreinterpretq_u8_u16(q2tmp7.val[0]));
  q2tmp11 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp6.val[1]),
                     vreinterpretq_u8_u16(q2tmp7.val[1]));

  q3 = q2tmp8.val[0];
  q4 = q2tmp8.val[1];
  q5 = q2tmp9.val[0];
  q6 = q2tmp9.val[1];
  q7 = q2tmp10.val[0];
  q8 = q2tmp10.val[1];
  q9 = q2tmp11.val[0];
  q10 = q2tmp11.val[1];

  vp8_loop_filter_neon(qblimit, qlimit, qthresh, q3, q4, q5, q6, q7, q8, q9,
                       q10, &q5, &q6, &q7, &q8);

  q4ResultL.val[0] = vget_low_u8(q5);   // d10
  q4ResultL.val[1] = vget_low_u8(q6);   // d12
  q4ResultL.val[2] = vget_low_u8(q7);   // d14
  q4ResultL.val[3] = vget_low_u8(q8);   // d16
  q4ResultH.val[0] = vget_high_u8(q5);  // d11
  q4ResultH.val[1] = vget_high_u8(q6);  // d13
  q4ResultH.val[2] = vget_high_u8(q7);  // d15
  q4ResultH.val[3] = vget_high_u8(q8);  // d17

  d = src - 2;
  write_4x8(d, pitch, q4ResultL);
  d += pitch * 8;
  write_4x8(d, pitch, q4ResultH);
}

void vp8_loop_filter_vertical_edge_uv_neon(unsigned char *u, int pitch,
                                           unsigned char blimit,
                                           unsigned char limit,
                                           unsigned char thresh,
                                           unsigned char *v) {
  unsigned char *us, *ud;
  unsigned char *vs, *vd;
  uint8x16_t qblimit, qlimit, qthresh, q3, q4;
  uint8x16_t q5, q6, q7, q8, q9, q10;
  uint8x8_t d6, d7, d8, d9, d10, d11, d12, d13, d14;
  uint8x8_t d15, d16, d17, d18, d19, d20, d21;
  uint32x4x2_t q2tmp0, q2tmp1, q2tmp2, q2tmp3;
  uint16x8x2_t q2tmp4, q2tmp5, q2tmp6, q2tmp7;
  uint8x16x2_t q2tmp8, q2tmp9, q2tmp10, q2tmp11;
  uint8x8x4_t q4ResultH, q4ResultL;

  qblimit = vdupq_n_u8(blimit);
  qlimit = vdupq_n_u8(limit);
  qthresh = vdupq_n_u8(thresh);

  us = u - 4;
  d6 = vld1_u8(us);
  us += pitch;
  d8 = vld1_u8(us);
  us += pitch;
  d10 = vld1_u8(us);
  us += pitch;
  d12 = vld1_u8(us);
  us += pitch;
  d14 = vld1_u8(us);
  us += pitch;
  d16 = vld1_u8(us);
  us += pitch;
  d18 = vld1_u8(us);
  us += pitch;
  d20 = vld1_u8(us);

  vs = v - 4;
  d7 = vld1_u8(vs);
  vs += pitch;
  d9 = vld1_u8(vs);
  vs += pitch;
  d11 = vld1_u8(vs);
  vs += pitch;
  d13 = vld1_u8(vs);
  vs += pitch;
  d15 = vld1_u8(vs);
  vs += pitch;
  d17 = vld1_u8(vs);
  vs += pitch;
  d19 = vld1_u8(vs);
  vs += pitch;
  d21 = vld1_u8(vs);

  q3 = vcombine_u8(d6, d7);
  q4 = vcombine_u8(d8, d9);
  q5 = vcombine_u8(d10, d11);
  q6 = vcombine_u8(d12, d13);
  q7 = vcombine_u8(d14, d15);
  q8 = vcombine_u8(d16, d17);
  q9 = vcombine_u8(d18, d19);
  q10 = vcombine_u8(d20, d21);

  q2tmp0 = vtrnq_u32(vreinterpretq_u32_u8(q3), vreinterpretq_u32_u8(q7));
  q2tmp1 = vtrnq_u32(vreinterpretq_u32_u8(q4), vreinterpretq_u32_u8(q8));
  q2tmp2 = vtrnq_u32(vreinterpretq_u32_u8(q5), vreinterpretq_u32_u8(q9));
  q2tmp3 = vtrnq_u32(vreinterpretq_u32_u8(q6), vreinterpretq_u32_u8(q10));

  q2tmp4 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp0.val[0]),
                     vreinterpretq_u16_u32(q2tmp2.val[0]));
  q2tmp5 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp1.val[0]),
                     vreinterpretq_u16_u32(q2tmp3.val[0]));
  q2tmp6 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp0.val[1]),
                     vreinterpretq_u16_u32(q2tmp2.val[1]));
  q2tmp7 = vtrnq_u16(vreinterpretq_u16_u32(q2tmp1.val[1]),
                     vreinterpretq_u16_u32(q2tmp3.val[1]));

  q2tmp8 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp4.val[0]),
                    vreinterpretq_u8_u16(q2tmp5.val[0]));
  q2tmp9 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp4.val[1]),
                    vreinterpretq_u8_u16(q2tmp5.val[1]));
  q2tmp10 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp6.val[0]),
                     vreinterpretq_u8_u16(q2tmp7.val[0]));
  q2tmp11 = vtrnq_u8(vreinterpretq_u8_u16(q2tmp6.val[1]),
                     vreinterpretq_u8_u16(q2tmp7.val[1]));

  q3 = q2tmp8.val[0];
  q4 = q2tmp8.val[1];
  q5 = q2tmp9.val[0];
  q6 = q2tmp9.val[1];
  q7 = q2tmp10.val[0];
  q8 = q2tmp10.val[1];
  q9 = q2tmp11.val[0];
  q10 = q2tmp11.val[1];

  vp8_loop_filter_neon(qblimit, qlimit, qthresh, q3, q4, q5, q6, q7, q8, q9,
                       q10, &q5, &q6, &q7, &q8);

  q4ResultL.val[0] = vget_low_u8(q5);  // d10
  q4ResultL.val[1] = vget_low_u8(q6);  // d12
  q4ResultL.val[2] = vget_low_u8(q7);  // d14
  q4ResultL.val[3] = vget_low_u8(q8);  // d16
  ud = u - 2;
  write_4x8(ud, pitch, q4ResultL);

  q4ResultH.val[0] = vget_high_u8(q5);  // d11
  q4ResultH.val[1] = vget_high_u8(q6);  // d13
  q4ResultH.val[2] = vget_high_u8(q7);  // d15
  q4ResultH.val[3] = vget_high_u8(q8);  // d17
  vd = v - 2;
  write_4x8(vd, pitch, q4ResultH);
}