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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
|
/*
* Copyright (c) 2023, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AOM_AV1_COMMON_ARM_COMPOUND_CONVOLVE_NEON_H_
#define AOM_AV1_COMMON_ARM_COMPOUND_CONVOLVE_NEON_H_
#include <arm_neon.h>
#include "av1/common/convolve.h"
#include "av1/common/enums.h"
#include "av1/common/filter.h"
static INLINE void compute_dist_wtd_avg_4x1(uint16x4_t dd0, uint16x4_t d0,
const uint16_t fwd_offset,
const uint16_t bck_offset,
const int16x4_t round_offset,
uint8x8_t *d0_u8) {
uint32x4_t blend0 = vmull_n_u16(dd0, fwd_offset);
blend0 = vmlal_n_u16(blend0, d0, bck_offset);
uint16x4_t avg0 = vshrn_n_u32(blend0, DIST_PRECISION_BITS);
int16x4_t dst0 = vsub_s16(vreinterpret_s16_u16(avg0), round_offset);
int16x8_t dst0q = vcombine_s16(dst0, vdup_n_s16(0));
*d0_u8 = vqrshrun_n_s16(dst0q, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_basic_avg_4x1(uint16x4_t dd0, uint16x4_t d0,
const int16x4_t round_offset,
uint8x8_t *d0_u8) {
uint16x4_t avg0 = vhadd_u16(dd0, d0);
int16x4_t dst0 = vsub_s16(vreinterpret_s16_u16(avg0), round_offset);
int16x8_t dst0q = vcombine_s16(dst0, vdup_n_s16(0));
*d0_u8 = vqrshrun_n_s16(dst0q, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_dist_wtd_avg_8x1(uint16x8_t dd0, uint16x8_t d0,
const uint16_t fwd_offset,
const uint16_t bck_offset,
const int16x8_t round_offset,
uint8x8_t *d0_u8) {
uint32x4_t blend0_lo = vmull_n_u16(vget_low_u16(dd0), fwd_offset);
blend0_lo = vmlal_n_u16(blend0_lo, vget_low_u16(d0), bck_offset);
uint32x4_t blend0_hi = vmull_n_u16(vget_high_u16(dd0), fwd_offset);
blend0_hi = vmlal_n_u16(blend0_hi, vget_high_u16(d0), bck_offset);
uint16x8_t avg0 = vcombine_u16(vshrn_n_u32(blend0_lo, DIST_PRECISION_BITS),
vshrn_n_u32(blend0_hi, DIST_PRECISION_BITS));
int16x8_t dst0 = vsubq_s16(vreinterpretq_s16_u16(avg0), round_offset);
*d0_u8 = vqrshrun_n_s16(dst0, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_basic_avg_8x1(uint16x8_t dd0, uint16x8_t d0,
const int16x8_t round_offset,
uint8x8_t *d0_u8) {
uint16x8_t avg0 = vhaddq_u16(dd0, d0);
int16x8_t dst0 = vsubq_s16(vreinterpretq_s16_u16(avg0), round_offset);
*d0_u8 = vqrshrun_n_s16(dst0, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_dist_wtd_avg_4x4(
uint16x4_t dd0, uint16x4_t dd1, uint16x4_t dd2, uint16x4_t dd3,
uint16x4_t d0, uint16x4_t d1, uint16x4_t d2, uint16x4_t d3,
const uint16_t fwd_offset, const uint16_t bck_offset,
const int16x8_t round_offset, uint8x8_t *d01_u8, uint8x8_t *d23_u8) {
uint32x4_t blend0 = vmull_n_u16(dd0, fwd_offset);
blend0 = vmlal_n_u16(blend0, d0, bck_offset);
uint32x4_t blend1 = vmull_n_u16(dd1, fwd_offset);
blend1 = vmlal_n_u16(blend1, d1, bck_offset);
uint32x4_t blend2 = vmull_n_u16(dd2, fwd_offset);
blend2 = vmlal_n_u16(blend2, d2, bck_offset);
uint32x4_t blend3 = vmull_n_u16(dd3, fwd_offset);
blend3 = vmlal_n_u16(blend3, d3, bck_offset);
uint16x4_t avg0 = vshrn_n_u32(blend0, DIST_PRECISION_BITS);
uint16x4_t avg1 = vshrn_n_u32(blend1, DIST_PRECISION_BITS);
uint16x4_t avg2 = vshrn_n_u32(blend2, DIST_PRECISION_BITS);
uint16x4_t avg3 = vshrn_n_u32(blend3, DIST_PRECISION_BITS);
int16x8_t dst_01 = vreinterpretq_s16_u16(vcombine_u16(avg0, avg1));
int16x8_t dst_23 = vreinterpretq_s16_u16(vcombine_u16(avg2, avg3));
dst_01 = vsubq_s16(dst_01, round_offset);
dst_23 = vsubq_s16(dst_23, round_offset);
*d01_u8 = vqrshrun_n_s16(dst_01, FILTER_BITS - ROUND0_BITS);
*d23_u8 = vqrshrun_n_s16(dst_23, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_basic_avg_4x4(uint16x4_t dd0, uint16x4_t dd1,
uint16x4_t dd2, uint16x4_t dd3,
uint16x4_t d0, uint16x4_t d1,
uint16x4_t d2, uint16x4_t d3,
const int16x8_t round_offset,
uint8x8_t *d01_u8, uint8x8_t *d23_u8) {
uint16x4_t avg0 = vhadd_u16(dd0, d0);
uint16x4_t avg1 = vhadd_u16(dd1, d1);
uint16x4_t avg2 = vhadd_u16(dd2, d2);
uint16x4_t avg3 = vhadd_u16(dd3, d3);
int16x8_t dst_01 = vreinterpretq_s16_u16(vcombine_u16(avg0, avg1));
int16x8_t dst_23 = vreinterpretq_s16_u16(vcombine_u16(avg2, avg3));
dst_01 = vsubq_s16(dst_01, round_offset);
dst_23 = vsubq_s16(dst_23, round_offset);
*d01_u8 = vqrshrun_n_s16(dst_01, FILTER_BITS - ROUND0_BITS);
*d23_u8 = vqrshrun_n_s16(dst_23, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_dist_wtd_avg_8x4(
uint16x8_t dd0, uint16x8_t dd1, uint16x8_t dd2, uint16x8_t dd3,
uint16x8_t d0, uint16x8_t d1, uint16x8_t d2, uint16x8_t d3,
const uint16_t fwd_offset, const uint16_t bck_offset,
const int16x8_t round_offset, uint8x8_t *d0_u8, uint8x8_t *d1_u8,
uint8x8_t *d2_u8, uint8x8_t *d3_u8) {
uint32x4_t blend0_lo = vmull_n_u16(vget_low_u16(dd0), fwd_offset);
blend0_lo = vmlal_n_u16(blend0_lo, vget_low_u16(d0), bck_offset);
uint32x4_t blend0_hi = vmull_n_u16(vget_high_u16(dd0), fwd_offset);
blend0_hi = vmlal_n_u16(blend0_hi, vget_high_u16(d0), bck_offset);
uint32x4_t blend1_lo = vmull_n_u16(vget_low_u16(dd1), fwd_offset);
blend1_lo = vmlal_n_u16(blend1_lo, vget_low_u16(d1), bck_offset);
uint32x4_t blend1_hi = vmull_n_u16(vget_high_u16(dd1), fwd_offset);
blend1_hi = vmlal_n_u16(blend1_hi, vget_high_u16(d1), bck_offset);
uint32x4_t blend2_lo = vmull_n_u16(vget_low_u16(dd2), fwd_offset);
blend2_lo = vmlal_n_u16(blend2_lo, vget_low_u16(d2), bck_offset);
uint32x4_t blend2_hi = vmull_n_u16(vget_high_u16(dd2), fwd_offset);
blend2_hi = vmlal_n_u16(blend2_hi, vget_high_u16(d2), bck_offset);
uint32x4_t blend3_lo = vmull_n_u16(vget_low_u16(dd3), fwd_offset);
blend3_lo = vmlal_n_u16(blend3_lo, vget_low_u16(d3), bck_offset);
uint32x4_t blend3_hi = vmull_n_u16(vget_high_u16(dd3), fwd_offset);
blend3_hi = vmlal_n_u16(blend3_hi, vget_high_u16(d3), bck_offset);
uint16x8_t avg0 = vcombine_u16(vshrn_n_u32(blend0_lo, DIST_PRECISION_BITS),
vshrn_n_u32(blend0_hi, DIST_PRECISION_BITS));
uint16x8_t avg1 = vcombine_u16(vshrn_n_u32(blend1_lo, DIST_PRECISION_BITS),
vshrn_n_u32(blend1_hi, DIST_PRECISION_BITS));
uint16x8_t avg2 = vcombine_u16(vshrn_n_u32(blend2_lo, DIST_PRECISION_BITS),
vshrn_n_u32(blend2_hi, DIST_PRECISION_BITS));
uint16x8_t avg3 = vcombine_u16(vshrn_n_u32(blend3_lo, DIST_PRECISION_BITS),
vshrn_n_u32(blend3_hi, DIST_PRECISION_BITS));
int16x8_t dst0 = vsubq_s16(vreinterpretq_s16_u16(avg0), round_offset);
int16x8_t dst1 = vsubq_s16(vreinterpretq_s16_u16(avg1), round_offset);
int16x8_t dst2 = vsubq_s16(vreinterpretq_s16_u16(avg2), round_offset);
int16x8_t dst3 = vsubq_s16(vreinterpretq_s16_u16(avg3), round_offset);
*d0_u8 = vqrshrun_n_s16(dst0, FILTER_BITS - ROUND0_BITS);
*d1_u8 = vqrshrun_n_s16(dst1, FILTER_BITS - ROUND0_BITS);
*d2_u8 = vqrshrun_n_s16(dst2, FILTER_BITS - ROUND0_BITS);
*d3_u8 = vqrshrun_n_s16(dst3, FILTER_BITS - ROUND0_BITS);
}
static INLINE void compute_basic_avg_8x4(uint16x8_t dd0, uint16x8_t dd1,
uint16x8_t dd2, uint16x8_t dd3,
uint16x8_t d0, uint16x8_t d1,
uint16x8_t d2, uint16x8_t d3,
const int16x8_t round_offset,
uint8x8_t *d0_u8, uint8x8_t *d1_u8,
uint8x8_t *d2_u8, uint8x8_t *d3_u8) {
uint16x8_t avg0 = vhaddq_u16(dd0, d0);
uint16x8_t avg1 = vhaddq_u16(dd1, d1);
uint16x8_t avg2 = vhaddq_u16(dd2, d2);
uint16x8_t avg3 = vhaddq_u16(dd3, d3);
int16x8_t dst0 = vsubq_s16(vreinterpretq_s16_u16(avg0), round_offset);
int16x8_t dst1 = vsubq_s16(vreinterpretq_s16_u16(avg1), round_offset);
int16x8_t dst2 = vsubq_s16(vreinterpretq_s16_u16(avg2), round_offset);
int16x8_t dst3 = vsubq_s16(vreinterpretq_s16_u16(avg3), round_offset);
*d0_u8 = vqrshrun_n_s16(dst0, FILTER_BITS - ROUND0_BITS);
*d1_u8 = vqrshrun_n_s16(dst1, FILTER_BITS - ROUND0_BITS);
*d2_u8 = vqrshrun_n_s16(dst2, FILTER_BITS - ROUND0_BITS);
*d3_u8 = vqrshrun_n_s16(dst3, FILTER_BITS - ROUND0_BITS);
}
static INLINE uint16x4_t
convolve6_4_2d_v(const int16x4_t s0, const int16x4_t s1, const int16x4_t s2,
const int16x4_t s3, const int16x4_t s4, const int16x4_t s5,
const int16x8_t y_filter, const int32x4_t offset_const) {
const int16x4_t y_filter_0_3 = vget_low_s16(y_filter);
const int16x4_t y_filter_4_7 = vget_high_s16(y_filter);
int32x4_t sum = offset_const;
// Filter values at indices 0 and 7 are 0.
sum = vmlal_lane_s16(sum, s0, y_filter_0_3, 1);
sum = vmlal_lane_s16(sum, s1, y_filter_0_3, 2);
sum = vmlal_lane_s16(sum, s2, y_filter_0_3, 3);
sum = vmlal_lane_s16(sum, s3, y_filter_4_7, 0);
sum = vmlal_lane_s16(sum, s4, y_filter_4_7, 1);
sum = vmlal_lane_s16(sum, s5, y_filter_4_7, 2);
return vqrshrun_n_s32(sum, COMPOUND_ROUND1_BITS);
}
static INLINE uint16x8_t
convolve6_8_2d_v(const int16x8_t s0, const int16x8_t s1, const int16x8_t s2,
const int16x8_t s3, const int16x8_t s4, const int16x8_t s5,
const int16x8_t y_filter, const int32x4_t offset_const) {
const int16x4_t y_filter_0_3 = vget_low_s16(y_filter);
const int16x4_t y_filter_4_7 = vget_high_s16(y_filter);
int32x4_t sum0 = offset_const;
// Filter values at indices 0 and 7 are 0.
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s0), y_filter_0_3, 1);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s1), y_filter_0_3, 2);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s2), y_filter_0_3, 3);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s3), y_filter_4_7, 0);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s4), y_filter_4_7, 1);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s5), y_filter_4_7, 2);
int32x4_t sum1 = offset_const;
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s0), y_filter_0_3, 1);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s1), y_filter_0_3, 2);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s2), y_filter_0_3, 3);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s3), y_filter_4_7, 0);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s4), y_filter_4_7, 1);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s5), y_filter_4_7, 2);
return vcombine_u16(vqrshrun_n_s32(sum0, COMPOUND_ROUND1_BITS),
vqrshrun_n_s32(sum1, COMPOUND_ROUND1_BITS));
}
static INLINE void dist_wtd_convolve_2d_vert_6tap_dist_wtd_avg_neon(
int16_t *src_ptr, const int src_stride, uint8_t *dst8_ptr, int dst8_stride,
ConvolveParams *conv_params, const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
const int16_t round_offset = (1 << (offset_bits - COMPOUND_ROUND1_BITS)) +
(1 << (offset_bits - COMPOUND_ROUND1_BITS - 1));
const int16x8_t round_offset_vec = vdupq_n_s16(round_offset);
const uint16_t fwd_offset = conv_params->fwd_offset;
const uint16_t bck_offset = conv_params->bck_offset;
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4;
load_s16_4x5(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4);
src_ptr += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s5, s6, s7, s8;
load_s16_4x4(src_ptr, src_stride, &s5, &s6, &s7, &s8);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x4_t d1 =
convolve6_4_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x4_t d2 =
convolve6_4_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x4_t d3 =
convolve6_4_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
uint16x4_t dd0, dd1, dd2, dd3;
load_u16_4x4(dst_ptr, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d01_u8, d23_u8;
compute_dist_wtd_avg_4x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3, fwd_offset,
bck_offset, round_offset_vec, &d01_u8, &d23_u8);
store_u8x4_strided_x2(dst8_ptr + 0 * dst8_stride, dst8_stride, d01_u8);
store_u8x4_strided_x2(dst8_ptr + 2 * dst8_stride, dst8_stride, d23_u8);
dst8_ptr += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s5 = vld1_s16(src_ptr);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x4_t dd0 = vld1_u16(dst_ptr);
uint8x8_t d01_u8;
compute_dist_wtd_avg_4x1(dd0, d0, fwd_offset, bck_offset,
vget_low_s16(round_offset_vec), &d01_u8);
store_u8_4x1(dst8_ptr, d01_u8);
dst8_ptr += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
uint8_t *d_u8 = dst8_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4;
load_s16_8x5(s, src_stride, &s0, &s1, &s2, &s3, &s4);
s += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s5, s6, s7, s8;
load_s16_8x4(s, src_stride, &s5, &s6, &s7, &s8);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x8_t d1 =
convolve6_8_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x8_t d2 =
convolve6_8_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x8_t d3 =
convolve6_8_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
uint16x8_t dd0, dd1, dd2, dd3;
load_u16_8x4(d, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d0_u8, d1_u8, d2_u8, d3_u8;
compute_dist_wtd_avg_8x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3, fwd_offset,
bck_offset, round_offset_vec, &d0_u8, &d1_u8,
&d2_u8, &d3_u8);
store_u8_8x4(d_u8, dst8_stride, d0_u8, d1_u8, d2_u8, d3_u8);
d_u8 += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s5 = vld1q_s16(s);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x8_t dd0 = vld1q_u16(d);
uint8x8_t d0_u8;
compute_dist_wtd_avg_8x1(dd0, d0, fwd_offset, bck_offset,
round_offset_vec, &d0_u8);
vst1_u8(d_u8, d0_u8);
d_u8 += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
dst8_ptr += 8;
w -= 8;
} while (w != 0);
}
}
static INLINE void dist_wtd_convolve_2d_vert_6tap_avg_neon(
int16_t *src_ptr, const int src_stride, uint8_t *dst8_ptr, int dst8_stride,
ConvolveParams *conv_params, const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
const int16_t round_offset = (1 << (offset_bits - COMPOUND_ROUND1_BITS)) +
(1 << (offset_bits - COMPOUND_ROUND1_BITS - 1));
const int16x8_t round_offset_vec = vdupq_n_s16(round_offset);
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4;
load_s16_4x5(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4);
src_ptr += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s5, s6, s7, s8;
load_s16_4x4(src_ptr, src_stride, &s5, &s6, &s7, &s8);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x4_t d1 =
convolve6_4_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x4_t d2 =
convolve6_4_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x4_t d3 =
convolve6_4_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
uint16x4_t dd0, dd1, dd2, dd3;
load_u16_4x4(dst_ptr, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d01_u8, d23_u8;
compute_basic_avg_4x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3,
round_offset_vec, &d01_u8, &d23_u8);
store_u8x4_strided_x2(dst8_ptr + 0 * dst8_stride, dst8_stride, d01_u8);
store_u8x4_strided_x2(dst8_ptr + 2 * dst8_stride, dst8_stride, d23_u8);
dst8_ptr += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s5 = vld1_s16(src_ptr);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x4_t dd0 = vld1_u16(dst_ptr);
uint8x8_t d01_u8;
compute_basic_avg_4x1(dd0, d0, vget_low_s16(round_offset_vec), &d01_u8);
store_u8_4x1(dst8_ptr, d01_u8);
dst8_ptr += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
uint8_t *d_u8 = dst8_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4;
load_s16_8x5(s, src_stride, &s0, &s1, &s2, &s3, &s4);
s += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s5, s6, s7, s8;
load_s16_8x4(s, src_stride, &s5, &s6, &s7, &s8);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x8_t d1 =
convolve6_8_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x8_t d2 =
convolve6_8_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x8_t d3 =
convolve6_8_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
uint16x8_t dd0, dd1, dd2, dd3;
load_u16_8x4(d, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d0_u8, d1_u8, d2_u8, d3_u8;
compute_basic_avg_8x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3,
round_offset_vec, &d0_u8, &d1_u8, &d2_u8, &d3_u8);
store_u8_8x4(d_u8, dst8_stride, d0_u8, d1_u8, d2_u8, d3_u8);
d_u8 += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s5 = vld1q_s16(s);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x8_t dd0 = vld1q_u16(d);
uint8x8_t d0_u8;
compute_basic_avg_8x1(dd0, d0, round_offset_vec, &d0_u8);
vst1_u8(d_u8, d0_u8);
d_u8 += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
dst8_ptr += 8;
w -= 8;
} while (w != 0);
}
}
static INLINE void dist_wtd_convolve_2d_vert_6tap_neon(
int16_t *src_ptr, const int src_stride, ConvolveParams *conv_params,
const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4;
load_s16_4x5(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4);
src_ptr += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s5, s6, s7, s8;
load_s16_4x4(src_ptr, src_stride, &s5, &s6, &s7, &s8);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x4_t d1 =
convolve6_4_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x4_t d2 =
convolve6_4_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x4_t d3 =
convolve6_4_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
store_u16_4x4(dst_ptr, dst_stride, d0, d1, d2, d3);
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s5 = vld1_s16(src_ptr);
uint16x4_t d0 =
convolve6_4_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
vst1_u16(dst_ptr, d0);
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4;
load_s16_8x5(s, src_stride, &s0, &s1, &s2, &s3, &s4);
s += 5 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s5, s6, s7, s8;
load_s16_8x4(s, src_stride, &s5, &s6, &s7, &s8);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
uint16x8_t d1 =
convolve6_8_2d_v(s1, s2, s3, s4, s5, s6, y_filter, offset_const);
uint16x8_t d2 =
convolve6_8_2d_v(s2, s3, s4, s5, s6, s7, y_filter, offset_const);
uint16x8_t d3 =
convolve6_8_2d_v(s3, s4, s5, s6, s7, s8, y_filter, offset_const);
store_u16_8x4(d, dst_stride, d0, d1, d2, d3);
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s5 = vld1q_s16(s);
uint16x8_t d0 =
convolve6_8_2d_v(s0, s1, s2, s3, s4, s5, y_filter, offset_const);
vst1q_u16(d, d0);
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
w -= 8;
} while (w != 0);
}
}
static INLINE uint16x4_t
convolve8_4_2d_v(const int16x4_t s0, const int16x4_t s1, const int16x4_t s2,
const int16x4_t s3, const int16x4_t s4, const int16x4_t s5,
const int16x4_t s6, const int16x4_t s7,
const int16x8_t y_filter, const int32x4_t offset_const) {
const int16x4_t y_filter_0_3 = vget_low_s16(y_filter);
const int16x4_t y_filter_4_7 = vget_high_s16(y_filter);
int32x4_t sum = offset_const;
sum = vmlal_lane_s16(sum, s0, y_filter_0_3, 0);
sum = vmlal_lane_s16(sum, s1, y_filter_0_3, 1);
sum = vmlal_lane_s16(sum, s2, y_filter_0_3, 2);
sum = vmlal_lane_s16(sum, s3, y_filter_0_3, 3);
sum = vmlal_lane_s16(sum, s4, y_filter_4_7, 0);
sum = vmlal_lane_s16(sum, s5, y_filter_4_7, 1);
sum = vmlal_lane_s16(sum, s6, y_filter_4_7, 2);
sum = vmlal_lane_s16(sum, s7, y_filter_4_7, 3);
return vqrshrun_n_s32(sum, COMPOUND_ROUND1_BITS);
}
static INLINE uint16x8_t
convolve8_8_2d_v(const int16x8_t s0, const int16x8_t s1, const int16x8_t s2,
const int16x8_t s3, const int16x8_t s4, const int16x8_t s5,
const int16x8_t s6, const int16x8_t s7,
const int16x8_t y_filter, const int32x4_t offset_const) {
const int16x4_t y_filter_0_3 = vget_low_s16(y_filter);
const int16x4_t y_filter_4_7 = vget_high_s16(y_filter);
int32x4_t sum0 = offset_const;
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s0), y_filter_0_3, 0);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s1), y_filter_0_3, 1);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s2), y_filter_0_3, 2);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s3), y_filter_0_3, 3);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s4), y_filter_4_7, 0);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s5), y_filter_4_7, 1);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s6), y_filter_4_7, 2);
sum0 = vmlal_lane_s16(sum0, vget_low_s16(s7), y_filter_4_7, 3);
int32x4_t sum1 = offset_const;
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s0), y_filter_0_3, 0);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s1), y_filter_0_3, 1);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s2), y_filter_0_3, 2);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s3), y_filter_0_3, 3);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s4), y_filter_4_7, 0);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s5), y_filter_4_7, 1);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s6), y_filter_4_7, 2);
sum1 = vmlal_lane_s16(sum1, vget_high_s16(s7), y_filter_4_7, 3);
return vcombine_u16(vqrshrun_n_s32(sum0, COMPOUND_ROUND1_BITS),
vqrshrun_n_s32(sum1, COMPOUND_ROUND1_BITS));
}
static INLINE void dist_wtd_convolve_2d_vert_8tap_dist_wtd_avg_neon(
int16_t *src_ptr, const int src_stride, uint8_t *dst8_ptr, int dst8_stride,
ConvolveParams *conv_params, const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
const int16_t round_offset = (1 << (offset_bits - COMPOUND_ROUND1_BITS)) +
(1 << (offset_bits - COMPOUND_ROUND1_BITS - 1));
const int16x8_t round_offset_vec = vdupq_n_s16(round_offset);
const uint16_t fwd_offset = conv_params->fwd_offset;
const uint16_t bck_offset = conv_params->bck_offset;
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4, s5, s6;
load_s16_4x7(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
src_ptr += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s7, s8, s9, s10;
load_s16_4x4(src_ptr, src_stride, &s7, &s8, &s9, &s10);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
uint16x4_t d1 = convolve8_4_2d_v(s1, s2, s3, s4, s5, s6, s7, s8, y_filter,
offset_const);
uint16x4_t d2 = convolve8_4_2d_v(s2, s3, s4, s5, s6, s7, s8, s9, y_filter,
offset_const);
uint16x4_t d3 = convolve8_4_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
uint16x4_t dd0, dd1, dd2, dd3;
load_u16_4x4(dst_ptr, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d01_u8, d23_u8;
compute_dist_wtd_avg_4x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3, fwd_offset,
bck_offset, round_offset_vec, &d01_u8, &d23_u8);
store_u8x4_strided_x2(dst8_ptr + 0 * dst8_stride, dst8_stride, d01_u8);
store_u8x4_strided_x2(dst8_ptr + 2 * dst8_stride, dst8_stride, d23_u8);
dst8_ptr += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s7 = vld1_s16(src_ptr);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
uint16x4_t dd0 = vld1_u16(dst_ptr);
uint8x8_t d01_u8;
compute_dist_wtd_avg_4x1(dd0, d0, fwd_offset, bck_offset,
vget_low_s16(round_offset_vec), &d01_u8);
store_u8_4x1(dst8_ptr, d01_u8);
dst8_ptr += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
uint8_t *d_u8 = dst8_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4, s5, s6;
load_s16_8x7(s, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
s += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s7, s8, s9, s10;
load_s16_8x4(s, src_stride, &s7, &s8, &s9, &s10);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
uint16x8_t d1 = convolve8_8_2d_v(s1, s2, s3, s4, s5, s6, s7, s8,
y_filter, offset_const);
uint16x8_t d2 = convolve8_8_2d_v(s2, s3, s4, s5, s6, s7, s8, s9,
y_filter, offset_const);
uint16x8_t d3 = convolve8_8_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
uint16x8_t dd0, dd1, dd2, dd3;
load_u16_8x4(d, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d0_u8, d1_u8, d2_u8, d3_u8;
compute_dist_wtd_avg_8x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3, fwd_offset,
bck_offset, round_offset_vec, &d0_u8, &d1_u8,
&d2_u8, &d3_u8);
store_u8_8x4(d_u8, dst8_stride, d0_u8, d1_u8, d2_u8, d3_u8);
d_u8 += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s7 = vld1q_s16(s);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
uint16x8_t dd0 = vld1q_u16(d);
uint8x8_t d0_u8;
compute_dist_wtd_avg_8x1(dd0, d0, fwd_offset, bck_offset,
round_offset_vec, &d0_u8);
vst1_u8(d_u8, d0_u8);
d_u8 += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
dst8_ptr += 8;
w -= 8;
} while (w != 0);
}
}
static INLINE void dist_wtd_convolve_2d_vert_8tap_avg_neon(
int16_t *src_ptr, const int src_stride, uint8_t *dst8_ptr, int dst8_stride,
ConvolveParams *conv_params, const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
const int16_t round_offset = (1 << (offset_bits - COMPOUND_ROUND1_BITS)) +
(1 << (offset_bits - COMPOUND_ROUND1_BITS - 1));
const int16x8_t round_offset_vec = vdupq_n_s16(round_offset);
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4, s5, s6;
load_s16_4x7(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
src_ptr += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s7, s8, s9, s10;
load_s16_4x4(src_ptr, src_stride, &s7, &s8, &s9, &s10);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
uint16x4_t d1 = convolve8_4_2d_v(s1, s2, s3, s4, s5, s6, s7, s8, y_filter,
offset_const);
uint16x4_t d2 = convolve8_4_2d_v(s2, s3, s4, s5, s6, s7, s8, s9, y_filter,
offset_const);
uint16x4_t d3 = convolve8_4_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
uint16x4_t dd0, dd1, dd2, dd3;
load_u16_4x4(dst_ptr, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d01_u8, d23_u8;
compute_basic_avg_4x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3,
round_offset_vec, &d01_u8, &d23_u8);
store_u8x4_strided_x2(dst8_ptr + 0 * dst8_stride, dst8_stride, d01_u8);
store_u8x4_strided_x2(dst8_ptr + 2 * dst8_stride, dst8_stride, d23_u8);
dst8_ptr += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s7 = vld1_s16(src_ptr);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
uint16x4_t dd0 = vld1_u16(dst_ptr);
uint8x8_t d01_u8;
compute_basic_avg_4x1(dd0, d0, vget_low_s16(round_offset_vec), &d01_u8);
store_u8_4x1(dst8_ptr, d01_u8);
dst8_ptr += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
uint8_t *d_u8 = dst8_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4, s5, s6;
load_s16_8x7(s, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
s += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s7, s8, s9, s10;
load_s16_8x4(s, src_stride, &s7, &s8, &s9, &s10);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
uint16x8_t d1 = convolve8_8_2d_v(s1, s2, s3, s4, s5, s6, s7, s8,
y_filter, offset_const);
uint16x8_t d2 = convolve8_8_2d_v(s2, s3, s4, s5, s6, s7, s8, s9,
y_filter, offset_const);
uint16x8_t d3 = convolve8_8_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
uint16x8_t dd0, dd1, dd2, dd3;
load_u16_8x4(d, dst_stride, &dd0, &dd1, &dd2, &dd3);
uint8x8_t d0_u8, d1_u8, d2_u8, d3_u8;
compute_basic_avg_8x4(dd0, dd1, dd2, dd3, d0, d1, d2, d3,
round_offset_vec, &d0_u8, &d1_u8, &d2_u8, &d3_u8);
store_u8_8x4(d_u8, dst8_stride, d0_u8, d1_u8, d2_u8, d3_u8);
d_u8 += 4 * dst8_stride;
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s7 = vld1q_s16(s);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
uint16x8_t dd0 = vld1q_u16(d);
uint8x8_t d0_u8;
compute_basic_avg_8x1(dd0, d0, round_offset_vec, &d0_u8);
vst1_u8(d_u8, d0_u8);
d_u8 += dst8_stride;
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
dst8_ptr += 8;
w -= 8;
} while (w != 0);
}
}
static INLINE void dist_wtd_convolve_2d_vert_8tap_neon(
int16_t *src_ptr, const int src_stride, ConvolveParams *conv_params,
const int16x8_t y_filter, int h, int w) {
const int bd = 8;
const int offset_bits = bd + 2 * FILTER_BITS - ROUND0_BITS;
const int32x4_t offset_const = vdupq_n_s32(1 << offset_bits);
CONV_BUF_TYPE *dst_ptr = conv_params->dst;
const int dst_stride = conv_params->dst_stride;
if (w == 4) {
int16x4_t s0, s1, s2, s3, s4, s5, s6;
load_s16_4x7(src_ptr, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
src_ptr += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x4_t s7, s8, s9, s10;
load_s16_4x4(src_ptr, src_stride, &s7, &s8, &s9, &s10);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
uint16x4_t d1 = convolve8_4_2d_v(s1, s2, s3, s4, s5, s6, s7, s8, y_filter,
offset_const);
uint16x4_t d2 = convolve8_4_2d_v(s2, s3, s4, s5, s6, s7, s8, s9, y_filter,
offset_const);
uint16x4_t d3 = convolve8_4_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
store_u16_4x4(dst_ptr, dst_stride, d0, d1, d2, d3);
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
src_ptr += 4 * src_stride;
dst_ptr += 4 * dst_stride;
h -= 4;
#else // !AOM_ARCH_AARCH64
int16x4_t s7 = vld1_s16(src_ptr);
uint16x4_t d0 = convolve8_4_2d_v(s0, s1, s2, s3, s4, s5, s6, s7, y_filter,
offset_const);
vst1_u16(dst_ptr, d0);
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
src_ptr += src_stride;
dst_ptr += dst_stride;
h--;
#endif // AOM_ARCH_AARCH64
} while (h != 0);
} else {
do {
int16_t *s = src_ptr;
CONV_BUF_TYPE *d = dst_ptr;
int height = h;
int16x8_t s0, s1, s2, s3, s4, s5, s6;
load_s16_8x7(s, src_stride, &s0, &s1, &s2, &s3, &s4, &s5, &s6);
s += 7 * src_stride;
do {
#if AOM_ARCH_AARCH64
int16x8_t s7, s8, s9, s10;
load_s16_8x4(s, src_stride, &s7, &s8, &s9, &s10);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
uint16x8_t d1 = convolve8_8_2d_v(s1, s2, s3, s4, s5, s6, s7, s8,
y_filter, offset_const);
uint16x8_t d2 = convolve8_8_2d_v(s2, s3, s4, s5, s6, s7, s8, s9,
y_filter, offset_const);
uint16x8_t d3 = convolve8_8_2d_v(s3, s4, s5, s6, s7, s8, s9, s10,
y_filter, offset_const);
store_u16_8x4(d, dst_stride, d0, d1, d2, d3);
s0 = s4;
s1 = s5;
s2 = s6;
s3 = s7;
s4 = s8;
s5 = s9;
s6 = s10;
s += 4 * src_stride;
d += 4 * dst_stride;
height -= 4;
#else // !AOM_ARCH_AARCH64
int16x8_t s7 = vld1q_s16(s);
uint16x8_t d0 = convolve8_8_2d_v(s0, s1, s2, s3, s4, s5, s6, s7,
y_filter, offset_const);
vst1q_u16(d, d0);
s0 = s1;
s1 = s2;
s2 = s3;
s3 = s4;
s4 = s5;
s5 = s6;
s6 = s7;
s += src_stride;
d += dst_stride;
height--;
#endif // AOM_ARCH_AARCH64
} while (height != 0);
src_ptr += 8;
dst_ptr += 8;
w -= 8;
} while (w != 0);
}
}
#endif // AOM_AV1_COMMON_ARM_COMPOUND_CONVOLVE_NEON_H_
|