-
Notifications
You must be signed in to change notification settings - Fork 225
/
pixel-a.S
1414 lines (1235 loc) · 40.2 KB
/
pixel-a.S
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
/*****************************************************************************
* pixel.S: aarch64 pixel metrics
*****************************************************************************
* Copyright (C) 2009-2020 x264 project
*
* Authors: David Conrad <lessen42@gmail.com>
* Janne Grunau <janne-x264@jannau.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at licensing@x264.com.
*****************************************************************************/
#include "asm.S"
const mask
.rept 16
.byte 0xff
.endr
.rept 16
.byte 0x00
.endr
endconst
const mask_ac_4_8
.short 0, -1, -1, -1, 0, -1, -1, -1
.short 0, -1, -1, -1, -1, -1, -1, -1
endconst
.macro SAD_START_4
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
uabdl v16.8h, v0.8b, v1.8b
.endm
.macro SAD_4
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
uabal v16.8h, v0.8b, v1.8b
.endm
.macro SAD_START_8
ld1 {v1.8b}, [x2], x3
ld1 {v0.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
uabdl v16.8h, v0.8b, v1.8b
uabdl v17.8h, v2.8b, v3.8b
.endm
.macro SAD_8
ld1 {v1.8b}, [x2], x3
ld1 {v0.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
uabal v16.8h, v0.8b, v1.8b
uabal v17.8h, v2.8b, v3.8b
.endm
.macro SAD_START_16
ld1 {v1.16b}, [x2], x3
ld1 {v0.16b}, [x0], x1
ld1 {v3.16b}, [x2], x3
ld1 {v2.16b}, [x0], x1
uabdl v16.8h, v0.8b, v1.8b
uabdl2 v17.8h, v0.16b, v1.16b
uabal v16.8h, v2.8b, v3.8b
uabal2 v17.8h, v2.16b, v3.16b
.endm
.macro SAD_16
ld1 {v1.16b}, [x2], x3
ld1 {v0.16b}, [x0], x1
ld1 {v3.16b}, [x2], x3
ld1 {v2.16b}, [x0], x1
uabal v16.8h, v0.8b, v1.8b
uabal2 v17.8h, v0.16b, v1.16b
uabal v16.8h, v2.8b, v3.8b
uabal2 v17.8h, v2.16b, v3.16b
.endm
.macro SAD_FUNC w, h, name
function pixel_sad\name\()_\w\()x\h\()_neon, export=1
SAD_START_\w
.rept \h / 2 - 1
SAD_\w
.endr
.if \w > 4
add v16.8h, v16.8h, v17.8h
.endif
uaddlv s0, v16.8h
fmov w0, s0
ret
endfunc
.endm
SAD_FUNC 4, 4
SAD_FUNC 4, 8
SAD_FUNC 4, 16
SAD_FUNC 8, 4
SAD_FUNC 8, 8
SAD_FUNC 8, 16
SAD_FUNC 16, 8
SAD_FUNC 16, 16
.macro SAD_X_4 x, first=uabal
ld1 {v0.s}[0], [x0], x7
ld1 {v1.s}[0], [x1], x5
ld1 {v0.s}[1], [x0], x7
ld1 {v1.s}[1], [x1], x5
\first v16.8h, v1.8b, v0.8b
ld1 {v2.s}[0], [x2], x5
ld1 {v2.s}[1], [x2], x5
\first v17.8h, v2.8b, v0.8b
ld1 {v3.s}[0], [x3], x5
ld1 {v3.s}[1], [x3], x5
\first v18.8h, v3.8b, v0.8b
.if \x == 4
ld1 {v4.s}[0], [x4], x5
ld1 {v4.s}[1], [x4], x5
\first v19.8h, v4.8b, v0.8b
.endif
.endm
.macro SAD_X_8 x, first=uabal
ld1 {v0.8b}, [x0], x7
ld1 {v1.8b}, [x1], x5
\first v16.8h, v1.8b, v0.8b
ld1 {v2.8b}, [x2], x5
ld1 {v5.8b}, [x0], x7
\first v17.8h, v2.8b, v0.8b
ld1 {v3.8b}, [x3], x5
ld1 {v1.8b}, [x1], x5
\first v18.8h, v3.8b, v0.8b
uabal v16.8h, v1.8b, v5.8b
ld1 {v2.8b}, [x2], x5
ld1 {v3.8b}, [x3], x5
uabal v17.8h, v2.8b, v5.8b
uabal v18.8h, v3.8b, v5.8b
.if \x == 4
ld1 {v4.8b}, [x4], x5
\first v19.8h, v4.8b, v0.8b
ld1 {v4.8b}, [x4], x5
uabal v19.8h, v4.8b, v5.8b
.endif
.endm
.macro SAD_X_16 x, first=uabal
ld1 {v0.16b}, [x0], x7
ld1 {v1.16b}, [x1], x5
\first v16.8h, v1.8b, v0.8b
\first\()2 v20.8h, v1.16b, v0.16b
ld1 {v2.16b}, [x2], x5
ld1 {v5.16b}, [x0], x7
\first v17.8h, v2.8b, v0.8b
\first\()2 v21.8h, v2.16b, v0.16b
ld1 {v3.16b}, [x3], x5
ld1 {v1.16b}, [x1], x5
\first v18.8h, v3.8b, v0.8b
\first\()2 v22.8h, v3.16b, v0.16b
uabal v16.8h, v1.8b, v5.8b
uabal2 v20.8h, v1.16b, v5.16b
ld1 {v2.16b}, [x2], x5
ld1 {v3.16b}, [x3], x5
uabal v17.8h, v2.8b, v5.8b
uabal2 v21.8h, v2.16b, v5.16b
uabal v18.8h, v3.8b, v5.8b
uabal2 v22.8h, v3.16b, v5.16b
.if \x == 4
ld1 {v4.16b}, [x4], x5
\first v19.8h, v4.8b, v0.8b
\first\()2 v23.8h, v4.16b, v0.16b
ld1 {v4.16b}, [x4], x5
uabal v19.8h, v4.8b, v5.8b
uabal2 v23.8h, v4.16b, v5.16b
.endif
.endm
.macro SAD_X_FUNC x, w, h
function pixel_sad_x\x\()_\w\()x\h\()_neon, export=1
.if \x == 3
mov x6, x5
mov x5, x4
.endif
mov x7, #FENC_STRIDE
SAD_X_\w \x, uabdl
.rept \h / 2 - 1
SAD_X_\w \x
.endr
.if \w > 8
add v16.8h, v16.8h, v20.8h
add v17.8h, v17.8h, v21.8h
add v18.8h, v18.8h, v22.8h
.if \x == 4
add v19.8h, v19.8h, v23.8h
.endif
.endif
// add up the sads
uaddlv s0, v16.8h
uaddlv s1, v17.8h
uaddlv s2, v18.8h
stp s0, s1, [x6], #8
.if \x == 3
str s2, [x6]
.else
uaddlv s3, v19.8h
stp s2, s3, [x6]
.endif
ret
endfunc
.endm
SAD_X_FUNC 3, 4, 4
SAD_X_FUNC 3, 4, 8
SAD_X_FUNC 3, 8, 4
SAD_X_FUNC 3, 8, 8
SAD_X_FUNC 3, 8, 16
SAD_X_FUNC 3, 16, 8
SAD_X_FUNC 3, 16, 16
SAD_X_FUNC 4, 4, 4
SAD_X_FUNC 4, 4, 8
SAD_X_FUNC 4, 8, 4
SAD_X_FUNC 4, 8, 8
SAD_X_FUNC 4, 8, 16
SAD_X_FUNC 4, 16, 8
SAD_X_FUNC 4, 16, 16
function pixel_vsad_neon, export=1
subs w2, w2, #2
ld1 {v0.16b}, [x0], x1
ld1 {v1.16b}, [x0], x1
uabdl v6.8h, v0.8b, v1.8b
uabdl2 v7.8h, v0.16b, v1.16b
b.le 2f
1:
subs w2, w2, #2
ld1 {v0.16b}, [x0], x1
uabal v6.8h, v1.8b, v0.8b
uabal2 v7.8h, v1.16b, v0.16b
ld1 {v1.16b}, [x0], x1
b.lt 2f
uabal v6.8h, v0.8b, v1.8b
uabal2 v7.8h, v0.16b, v1.16b
b.gt 1b
2:
add v5.8h, v6.8h, v7.8h
uaddlv s0, v5.8h
fmov w0, s0
ret
endfunc
function pixel_asd8_neon, export=1
sub w4, w4, #2
ld1 {v0.8b}, [x0], x1
ld1 {v1.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
usubl v16.8h, v0.8b, v1.8b
1:
subs w4, w4, #2
ld1 {v4.8b}, [x0], x1
ld1 {v5.8b}, [x2], x3
usubl v17.8h, v2.8b, v3.8b
usubl v18.8h, v4.8b, v5.8b
add v16.8h, v16.8h, v17.8h
ld1 {v2.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
add v16.8h, v16.8h, v18.8h
b.gt 1b
usubl v17.8h, v2.8b, v3.8b
add v16.8h, v16.8h, v17.8h
saddlv s0, v16.8h
abs v0.2s, v0.2s
fmov w0, s0
ret
endfunc
.macro SSD_START_4
ld1 {v16.s}[0], [x0], x1
ld1 {v17.s}[0], [x2], x3
usubl v2.8h, v16.8b, v17.8b
ld1 {v16.s}[0], [x0], x1
ld1 {v17.s}[0], [x2], x3
smull v0.4s, v2.4h, v2.4h
.endm
.macro SSD_4
usubl v2.8h, v16.8b, v17.8b
ld1 {v16.s}[0], [x0], x1
ld1 {v17.s}[0], [x2], x3
smlal v0.4s, v2.4h, v2.4h
.endm
.macro SSD_END_4
usubl v2.8h, v16.8b, v17.8b
smlal v0.4s, v2.4h, v2.4h
.endm
.macro SSD_START_8
ld1 {v16.8b}, [x0], x1
ld1 {v17.8b}, [x2], x3
usubl v2.8h, v16.8b, v17.8b
ld1 {v16.8b}, [x0], x1
smull v0.4s, v2.4h, v2.4h
ld1 {v17.8b}, [x2], x3
smlal2 v0.4s, v2.8h, v2.8h
.endm
.macro SSD_8
usubl v2.8h, v16.8b, v17.8b
ld1 {v16.8b}, [x0], x1
smlal v0.4s, v2.4h, v2.4h
ld1 {v17.8b}, [x2], x3
smlal2 v0.4s, v2.8h, v2.8h
.endm
.macro SSD_END_8
usubl v2.8h, v16.8b, v17.8b
smlal v0.4s, v2.4h, v2.4h
smlal2 v0.4s, v2.8h, v2.8h
.endm
.macro SSD_START_16
ld1 {v16.16b}, [x0], x1
ld1 {v17.16b}, [x2], x3
usubl v2.8h, v16.8b, v17.8b
usubl2 v3.8h, v16.16b, v17.16b
ld1 {v16.16b}, [x0], x1
smull v0.4s, v2.4h, v2.4h
smull2 v1.4s, v2.8h, v2.8h
ld1 {v17.16b}, [x2], x3
smlal v0.4s, v3.4h, v3.4h
smlal2 v1.4s, v3.8h, v3.8h
.endm
.macro SSD_16
usubl v2.8h, v16.8b, v17.8b
usubl2 v3.8h, v16.16b, v17.16b
ld1 {v16.16b}, [x0], x1
smlal v0.4s, v2.4h, v2.4h
smlal2 v1.4s, v2.8h, v2.8h
ld1 {v17.16b}, [x2], x3
smlal v0.4s, v3.4h, v3.4h
smlal2 v1.4s, v3.8h, v3.8h
.endm
.macro SSD_END_16
usubl v2.8h, v16.8b, v17.8b
usubl2 v3.8h, v16.16b, v17.16b
smlal v0.4s, v2.4h, v2.4h
smlal2 v1.4s, v2.8h, v2.8h
smlal v0.4s, v3.4h, v3.4h
smlal2 v1.4s, v3.8h, v3.8h
add v0.4s, v0.4s, v1.4s
.endm
.macro SSD_FUNC w h
function pixel_ssd_\w\()x\h\()_neon, export=1
SSD_START_\w
.rept \h-2
SSD_\w
.endr
SSD_END_\w
addv s0, v0.4s
mov w0, v0.s[0]
ret
endfunc
.endm
SSD_FUNC 4, 4
SSD_FUNC 4, 8
SSD_FUNC 4, 16
SSD_FUNC 8, 4
SSD_FUNC 8, 8
SSD_FUNC 8, 16
SSD_FUNC 16, 8
SSD_FUNC 16, 16
function pixel_ssd_nv12_core_neon, export=1
sxtw x8, w4
add x8, x8, #8
and x8, x8, #~15
movi v6.2d, #0
movi v7.2d, #0
sub x1, x1, x8, lsl #1
sub x3, x3, x8, lsl #1
1:
subs w8, w4, #16
ld2 {v0.8b,v1.8b}, [x0], #16
ld2 {v2.8b,v3.8b}, [x2], #16
ld2 {v24.8b,v25.8b}, [x0], #16
ld2 {v26.8b,v27.8b}, [x2], #16
usubl v16.8h, v0.8b, v2.8b
usubl v17.8h, v1.8b, v3.8b
smull v20.4s, v16.4h, v16.4h
smull v21.4s, v17.4h, v17.4h
usubl v18.8h, v24.8b, v26.8b
usubl v19.8h, v25.8b, v27.8b
smlal2 v20.4s, v16.8h, v16.8h
smlal2 v21.4s, v17.8h, v17.8h
b.lt 4f
b.eq 3f
2:
smlal v20.4s, v18.4h, v18.4h
smlal v21.4s, v19.4h, v19.4h
ld2 {v0.8b,v1.8b}, [x0], #16
ld2 {v2.8b,v3.8b}, [x2], #16
smlal2 v20.4s, v18.8h, v18.8h
smlal2 v21.4s, v19.8h, v19.8h
subs w8, w8, #16
usubl v16.8h, v0.8b, v2.8b
usubl v17.8h, v1.8b, v3.8b
smlal v20.4s, v16.4h, v16.4h
smlal v21.4s, v17.4h, v17.4h
ld2 {v24.8b,v25.8b}, [x0], #16
ld2 {v26.8b,v27.8b}, [x2], #16
smlal2 v20.4s, v16.8h, v16.8h
smlal2 v21.4s, v17.8h, v17.8h
b.lt 4f
usubl v18.8h, v24.8b, v26.8b
usubl v19.8h, v25.8b, v27.8b
b.gt 2b
3:
smlal v20.4s, v18.4h, v18.4h
smlal v21.4s, v19.4h, v19.4h
smlal2 v20.4s, v18.8h, v18.8h
smlal2 v21.4s, v19.8h, v19.8h
4:
subs w5, w5, #1
uaddw v6.2d, v6.2d, v20.2s
uaddw v7.2d, v7.2d, v21.2s
add x0, x0, x1
add x2, x2, x3
uaddw2 v6.2d, v6.2d, v20.4s
uaddw2 v7.2d, v7.2d, v21.4s
b.gt 1b
addp v6.2d, v6.2d, v7.2d
st1 {v6.d}[0], [x6]
st1 {v6.d}[1], [x7]
ret
endfunc
.macro pixel_var_8 h
function pixel_var_8x\h\()_neon, export=1
ld1 {v16.8b}, [x0], x1
ld1 {v17.8b}, [x0], x1
mov x2, \h - 4
umull v1.8h, v16.8b, v16.8b
uxtl v0.8h, v16.8b
umull v2.8h, v17.8b, v17.8b
uaddw v0.8h, v0.8h, v17.8b
ld1 {v18.8b}, [x0], x1
uaddlp v1.4s, v1.8h
uaddlp v2.4s, v2.8h
ld1 {v19.8b}, [x0], x1
1: subs x2, x2, #4
uaddw v0.8h, v0.8h, v18.8b
umull v24.8h, v18.8b, v18.8b
ld1 {v20.8b}, [x0], x1
uaddw v0.8h, v0.8h, v19.8b
umull v25.8h, v19.8b, v19.8b
uadalp v1.4s, v24.8h
ld1 {v21.8b}, [x0], x1
uaddw v0.8h, v0.8h, v20.8b
umull v26.8h, v20.8b, v20.8b
uadalp v2.4s, v25.8h
ld1 {v18.8b}, [x0], x1
uaddw v0.8h, v0.8h, v21.8b
umull v27.8h, v21.8b, v21.8b
uadalp v1.4s, v26.8h
ld1 {v19.8b}, [x0], x1
uadalp v2.4s, v27.8h
b.gt 1b
uaddw v0.8h, v0.8h, v18.8b
umull v28.8h, v18.8b, v18.8b
uaddw v0.8h, v0.8h, v19.8b
umull v29.8h, v19.8b, v19.8b
uadalp v1.4s, v28.8h
uadalp v2.4s, v29.8h
b var_end
endfunc
.endm
pixel_var_8 8
pixel_var_8 16
function pixel_var_16x16_neon, export=1
ld1 {v16.16b}, [x0], x1
ld1 {v17.16b}, [x0], x1
mov x2, #14
umull v1.8h, v16.8b, v16.8b
umull2 v2.8h, v16.16b, v16.16b
uxtl v0.8h, v16.8b
uaddlp v1.4s, v1.8h
uaddlp v2.4s, v2.8h
uaddw2 v0.8h, v0.8h, v16.16b
1: subs x2, x2, #2
ld1 {v18.16b}, [x0], x1
uaddw v0.8h, v0.8h, v17.8b
umull v3.8h, v17.8b, v17.8b
uaddw2 v0.8h, v0.8h, v17.16b
umull2 v4.8h, v17.16b, v17.16b
uadalp v1.4s, v3.8h
uadalp v2.4s, v4.8h
ld1 {v17.16b}, [x0], x1
uaddw v0.8h, v0.8h, v18.8b
umull v5.8h, v18.8b, v18.8b
uaddw2 v0.8h, v0.8h, v18.16b
umull2 v6.8h, v18.16b, v18.16b
uadalp v1.4s, v5.8h
uadalp v2.4s, v6.8h
b.gt 1b
uaddw v0.8h, v0.8h, v17.8b
umull v3.8h, v17.8b, v17.8b
uaddw2 v0.8h, v0.8h, v17.16b
umull2 v4.8h, v17.16b, v17.16b
uadalp v1.4s, v3.8h
uadalp v2.4s, v4.8h
endfunc
function var_end
add v1.4s, v1.4s, v2.4s
uaddlv s0, v0.8h
uaddlv d1, v1.4s
mov w0, v0.s[0]
mov x1, v1.d[0]
orr x0, x0, x1, lsl #32
ret
endfunc
.macro pixel_var2_8 h
function pixel_var2_8x\h\()_neon, export=1
mov x3, #16
ld1 {v16.8b}, [x0], #8
ld1 {v18.8b}, [x1], x3
ld1 {v17.8b}, [x0], #8
ld1 {v19.8b}, [x1], x3
mov x5, \h - 2
usubl v0.8h, v16.8b, v18.8b
usubl v1.8h, v17.8b, v19.8b
ld1 {v16.8b}, [x0], #8
ld1 {v18.8b}, [x1], x3
smull v2.4s, v0.4h, v0.4h
smull2 v3.4s, v0.8h, v0.8h
smull v4.4s, v1.4h, v1.4h
smull2 v5.4s, v1.8h, v1.8h
usubl v6.8h, v16.8b, v18.8b
1: subs x5, x5, #1
ld1 {v17.8b}, [x0], #8
ld1 {v19.8b}, [x1], x3
smlal v2.4s, v6.4h, v6.4h
smlal2 v3.4s, v6.8h, v6.8h
usubl v7.8h, v17.8b, v19.8b
add v0.8h, v0.8h, v6.8h
ld1 {v16.8b}, [x0], #8
ld1 {v18.8b}, [x1], x3
smlal v4.4s, v7.4h, v7.4h
smlal2 v5.4s, v7.8h, v7.8h
usubl v6.8h, v16.8b, v18.8b
add v1.8h, v1.8h, v7.8h
b.gt 1b
ld1 {v17.8b}, [x0], #8
ld1 {v19.8b}, [x1], x3
smlal v2.4s, v6.4h, v6.4h
smlal2 v3.4s, v6.8h, v6.8h
usubl v7.8h, v17.8b, v19.8b
add v0.8h, v0.8h, v6.8h
smlal v4.4s, v7.4h, v7.4h
add v1.8h, v1.8h, v7.8h
smlal2 v5.4s, v7.8h, v7.8h
saddlv s0, v0.8h
saddlv s1, v1.8h
add v2.4s, v2.4s, v3.4s
add v4.4s, v4.4s, v5.4s
mov w0, v0.s[0]
mov w1, v1.s[0]
addv s2, v2.4s
addv s4, v4.4s
mul w0, w0, w0
mul w1, w1, w1
mov w3, v2.s[0]
mov w4, v4.s[0]
sub w0, w3, w0, lsr # 6 + (\h >> 4)
sub w1, w4, w1, lsr # 6 + (\h >> 4)
str w3, [x2]
add w0, w0, w1
str w4, [x2, #4]
ret
endfunc
.endm
pixel_var2_8 8
pixel_var2_8 16
function pixel_satd_4x4_neon, export=1
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v3.s}[0], [x2], x3
ld1 {v2.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
ld1 {v3.s}[1], [x2], x3
ld1 {v2.s}[1], [x0], x1
usubl v0.8h, v0.8b, v1.8b
usubl v1.8h, v2.8b, v3.8b
SUMSUB_AB v2.8h, v3.8h, v0.8h, v1.8h
zip1 v0.2d, v2.2d, v3.2d
zip2 v1.2d, v2.2d, v3.2d
SUMSUB_AB v2.8h, v3.8h, v0.8h, v1.8h
trn1 v0.8h, v2.8h, v3.8h
trn2 v1.8h, v2.8h, v3.8h
SUMSUB_AB v2.8h, v3.8h, v0.8h, v1.8h
trn1 v0.4s, v2.4s, v3.4s
trn2 v1.4s, v2.4s, v3.4s
abs v0.8h, v0.8h
abs v1.8h, v1.8h
umax v0.8h, v0.8h, v1.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret
endfunc
function pixel_satd_4x8_neon, export=1
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v3.s}[0], [x2], x3
ld1 {v2.s}[0], [x0], x1
ld1 {v5.s}[0], [x2], x3
ld1 {v4.s}[0], [x0], x1
ld1 {v7.s}[0], [x2], x3
ld1 {v6.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
ld1 {v3.s}[1], [x2], x3
ld1 {v2.s}[1], [x0], x1
ld1 {v5.s}[1], [x2], x3
ld1 {v4.s}[1], [x0], x1
ld1 {v7.s}[1], [x2], x3
ld1 {v6.s}[1], [x0], x1
b satd_4x8_8x4_end_neon
endfunc
function pixel_satd_8x4_neon, export=1
ld1 {v1.8b}, [x2], x3
ld1 {v0.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
ld1 {v5.8b}, [x2], x3
ld1 {v4.8b}, [x0], x1
ld1 {v7.8b}, [x2], x3
ld1 {v6.8b}, [x0], x1
endfunc
function satd_4x8_8x4_end_neon
usubl v0.8h, v0.8b, v1.8b
usubl v1.8h, v2.8b, v3.8b
usubl v2.8h, v4.8b, v5.8b
usubl v3.8h, v6.8b, v7.8b
SUMSUB_AB v16.8h, v17.8h, v0.8h, v1.8h
SUMSUB_AB v18.8h, v19.8h, v2.8h, v3.8h
SUMSUB_AB v4.8h, v6.8h, v16.8h, v18.8h
SUMSUB_AB v5.8h, v7.8h, v17.8h, v19.8h
trn1 v0.8h, v4.8h, v5.8h
trn2 v1.8h, v4.8h, v5.8h
trn1 v2.8h, v6.8h, v7.8h
trn2 v3.8h, v6.8h, v7.8h
SUMSUB_AB v16.8h, v17.8h, v0.8h, v1.8h
SUMSUB_AB v18.8h, v19.8h, v2.8h, v3.8h
trn1 v0.4s, v16.4s, v18.4s
trn2 v1.4s, v16.4s, v18.4s
trn1 v2.4s, v17.4s, v19.4s
trn2 v3.4s, v17.4s, v19.4s
abs v0.8h, v0.8h
abs v1.8h, v1.8h
abs v2.8h, v2.8h
abs v3.8h, v3.8h
umax v0.8h, v0.8h, v1.8h
umax v1.8h, v2.8h, v3.8h
add v0.8h, v0.8h, v1.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret
endfunc
function pixel_satd_8x8_neon, export=1
mov x4, x30
bl satd_8x8_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v0.8h, v0.8h, v1.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret x4
endfunc
function pixel_satd_8x16_neon, export=1
mov x4, x30
bl satd_8x8_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v30.8h, v0.8h, v1.8h
bl satd_8x8_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v31.8h, v0.8h, v1.8h
add v0.8h, v30.8h, v31.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret x4
endfunc
.macro SUMSUBL_AB sum, sub, a, b
uaddl \sum, \a, \b
usubl \sub, \a, \b
.endm
.macro load_diff_fly_8x8
ld1 {v1.8b}, [x2], x3
ld1 {v0.8b}, [x0], x1
ld1 {v3.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
usubl v16.8h, v0.8b, v1.8b
ld1 {v5.8b}, [x2], x3
ld1 {v4.8b}, [x0], x1
usubl v17.8h, v2.8b, v3.8b
ld1 {v7.8b}, [x2], x3
ld1 {v6.8b}, [x0], x1
usubl v18.8h, v4.8b, v5.8b
ld1 {v1.8b}, [x2], x3
ld1 {v0.8b}, [x0], x1
usubl v19.8h, v6.8b, v7.8b
ld1 {v3.8b}, [x2], x3
ld1 {v2.8b}, [x0], x1
usubl v20.8h, v0.8b, v1.8b
ld1 {v5.8b}, [x2], x3
ld1 {v4.8b}, [x0], x1
usubl v21.8h, v2.8b, v3.8b
ld1 {v7.8b}, [x2], x3
ld1 {v6.8b}, [x0], x1
SUMSUB_AB v0.8h, v1.8h, v16.8h, v17.8h
SUMSUB_AB v2.8h, v3.8h, v18.8h, v19.8h
usubl v22.8h, v4.8b, v5.8b
usubl v23.8h, v6.8b, v7.8b
.endm
.macro SUMSUB_ABCD s1, d1, s2, d2, a, b, c, d
SUMSUB_AB \s1, \d1, \a, \b
SUMSUB_AB \s2, \d2, \c, \d
.endm
.macro HADAMARD4_V r1, r2, r3, r4, t1, t2, t3, t4
SUMSUB_ABCD \t1, \t2, \t3, \t4, \r1, \r2, \r3, \r4
SUMSUB_ABCD \r1, \r3, \r2, \r4, \t1, \t3, \t2, \t4
.endm
function satd_8x8_neon
load_diff_fly_8x8
endfunc
// one vertical hadamard pass and two horizontal
function satd_8x4v_8x8h_neon
SUMSUB_AB v16.8h, v18.8h, v0.8h, v2.8h
SUMSUB_AB v17.8h, v19.8h, v1.8h, v3.8h
HADAMARD4_V v20.8h, v21.8h, v22.8h, v23.8h, v0.8h, v1.8h, v2.8h, v3.8h
transpose v0.8h, v1.8h, v16.8h, v17.8h
transpose v2.8h, v3.8h, v18.8h, v19.8h
transpose v4.8h, v5.8h, v20.8h, v21.8h
transpose v6.8h, v7.8h, v22.8h, v23.8h
SUMSUB_AB v16.8h, v17.8h, v0.8h, v1.8h
SUMSUB_AB v18.8h, v19.8h, v2.8h, v3.8h
SUMSUB_AB v20.8h, v21.8h, v4.8h, v5.8h
SUMSUB_AB v22.8h, v23.8h, v6.8h, v7.8h
transpose v0.4s, v2.4s, v16.4s, v18.4s
transpose v1.4s, v3.4s, v17.4s, v19.4s
transpose v4.4s, v6.4s, v20.4s, v22.4s
transpose v5.4s, v7.4s, v21.4s, v23.4s
abs v0.8h, v0.8h
abs v1.8h, v1.8h
abs v2.8h, v2.8h
abs v3.8h, v3.8h
abs v4.8h, v4.8h
abs v5.8h, v5.8h
abs v6.8h, v6.8h
abs v7.8h, v7.8h
umax v0.8h, v0.8h, v2.8h
umax v1.8h, v1.8h, v3.8h
umax v2.8h, v4.8h, v6.8h
umax v3.8h, v5.8h, v7.8h
ret
endfunc
function pixel_satd_16x8_neon, export=1
mov x4, x30
bl satd_16x4_neon
add v30.8h, v0.8h, v1.8h
add v31.8h, v2.8h, v3.8h
bl satd_16x4_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v30.8h, v30.8h, v0.8h
add v31.8h, v31.8h, v1.8h
add v0.8h, v30.8h, v31.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret x4
endfunc
function pixel_satd_16x16_neon, export=1
mov x4, x30
bl satd_16x4_neon
add v30.8h, v0.8h, v1.8h
add v31.8h, v2.8h, v3.8h
bl satd_16x4_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v30.8h, v30.8h, v0.8h
add v31.8h, v31.8h, v1.8h
bl satd_16x4_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v30.8h, v30.8h, v0.8h
add v31.8h, v31.8h, v1.8h
bl satd_16x4_neon
add v0.8h, v0.8h, v1.8h
add v1.8h, v2.8h, v3.8h
add v30.8h, v30.8h, v0.8h
add v31.8h, v31.8h, v1.8h
add v0.8h, v30.8h, v31.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret x4
endfunc
function satd_16x4_neon
ld1 {v1.16b}, [x2], x3
ld1 {v0.16b}, [x0], x1
ld1 {v3.16b}, [x2], x3
ld1 {v2.16b}, [x0], x1
usubl v16.8h, v0.8b, v1.8b
usubl2 v20.8h, v0.16b, v1.16b
ld1 {v5.16b}, [x2], x3
ld1 {v4.16b}, [x0], x1
usubl v17.8h, v2.8b, v3.8b
usubl2 v21.8h, v2.16b, v3.16b
ld1 {v7.16b}, [x2], x3
ld1 {v6.16b}, [x0], x1
usubl v18.8h, v4.8b, v5.8b
usubl2 v22.8h, v4.16b, v5.16b
usubl v19.8h, v6.8b, v7.8b
usubl2 v23.8h, v6.16b, v7.16b
SUMSUB_AB v0.8h, v1.8h, v16.8h, v17.8h
SUMSUB_AB v2.8h, v3.8h, v18.8h, v19.8h
b satd_8x4v_8x8h_neon
endfunc
function pixel_satd_4x16_neon, export=1
mov x4, x30
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v3.s}[0], [x2], x3
ld1 {v2.s}[0], [x0], x1
ld1 {v5.s}[0], [x2], x3
ld1 {v4.s}[0], [x0], x1
ld1 {v7.s}[0], [x2], x3
ld1 {v6.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
ld1 {v3.s}[1], [x2], x3
ld1 {v2.s}[1], [x0], x1
ld1 {v5.s}[1], [x2], x3
ld1 {v4.s}[1], [x0], x1
ld1 {v7.s}[1], [x2], x3
ld1 {v6.s}[1], [x0], x1
usubl v16.8h, v0.8b, v1.8b
usubl v17.8h, v2.8b, v3.8b
usubl v18.8h, v4.8b, v5.8b
usubl v19.8h, v6.8b, v7.8b
ld1 {v1.s}[0], [x2], x3
ld1 {v0.s}[0], [x0], x1
ld1 {v3.s}[0], [x2], x3
ld1 {v2.s}[0], [x0], x1
ld1 {v5.s}[0], [x2], x3
ld1 {v4.s}[0], [x0], x1
ld1 {v7.s}[0], [x2], x3
ld1 {v6.s}[0], [x0], x1
ld1 {v1.s}[1], [x2], x3
ld1 {v0.s}[1], [x0], x1
ld1 {v3.s}[1], [x2], x3
ld1 {v2.s}[1], [x0], x1
ld1 {v5.s}[1], [x2], x3
ld1 {v4.s}[1], [x0], x1
ld1 {v7.s}[1], [x2], x3
ld1 {v6.s}[1], [x0], x1
usubl v20.8h, v0.8b, v1.8b
usubl v21.8h, v2.8b, v3.8b
usubl v22.8h, v4.8b, v5.8b
usubl v23.8h, v6.8b, v7.8b
SUMSUB_AB v0.8h, v1.8h, v16.8h, v17.8h
SUMSUB_AB v2.8h, v3.8h, v18.8h, v19.8h
bl satd_8x4v_8x8h_neon
add v30.8h, v0.8h, v1.8h
add v31.8h, v2.8h, v3.8h
add v0.8h, v30.8h, v31.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
ret x4
endfunc
function pixel_sa8d_8x8_neon, export=1
mov x4, x30
bl pixel_sa8d_8x8_neon
add v0.8h, v0.8h, v1.8h
uaddlv s0, v0.8h
mov w0, v0.s[0]
add w0, w0, #1
lsr w0, w0, #1
ret x4
endfunc