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
|
/*
* VP8 NEON optimisations
*
* Copyright (c) 2010 Rob Clark <rob@ti.com>
* Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
* Copyright (c) 2018 Magnus Röös <mla2.roos@gmail.com>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/aarch64/asm.S"
#include "neon.S"
function ff_vp8_idct_add_neon, export=1
ld1 {v0.8b - v3.8b}, [x1]
mov w4, #20091
movk w4, #35468/2, lsl #16
dup v4.2s, w4
smull v26.4s, v1.4h, v4.h[0]
smull v27.4s, v3.4h, v4.h[0]
sqdmulh v20.4h, v1.4h, v4.h[1]
sqdmulh v23.4h, v3.4h, v4.h[1]
sqshrn v21.4h, v26.4s, #16
sqshrn v22.4h, v27.4s, #16
add v21.4h, v21.4h, v1.4h
add v22.4h, v22.4h, v3.4h
add v16.4h, v0.4h, v2.4h
sub v17.4h, v0.4h, v2.4h
add v18.4h, v21.4h, v23.4h
sub v19.4h, v20.4h, v22.4h
add v0.4h, v16.4h, v18.4h
add v1.4h, v17.4h, v19.4h
sub v3.4h, v16.4h, v18.4h
sub v2.4h, v17.4h, v19.4h
transpose_4x4H v0, v1, v2, v3, v24, v5, v6, v7
movi v29.8h, #0
smull v26.4s, v1.4h, v4.h[0]
st1 {v29.8h}, [x1], #16
smull v27.4s, v3.4h, v4.h[0]
st1 {v29.16b}, [x1]
sqdmulh v21.4h, v1.4h, v4.h[1]
sqdmulh v23.4h, v3.4h, v4.h[1]
sqshrn v20.4h, v26.4s, #16
sqshrn v22.4h, v27.4s, #16
add v20.4h, v20.4h, v1.4h
add v22.4h, v22.4h, v3.4h
add v16.4h, v0.4h, v2.4h
sub v17.4h, v0.4h, v2.4h
add v18.4h, v20.4h, v23.4h
ld1 {v24.d}[0], [x0], x2
zip1 v16.2d, v16.2d, v17.2d
sub v19.4h, v21.4h, v22.4h
ld1 {v25.d}[0], [x0], x2
zip1 v18.2d, v18.2d, v19.2d
add v0.8h, v16.8h, v18.8h
ld1 {v25.d}[1], [x0], x2
sub v1.8h, v16.8h, v18.8h
ld1 {v24.d}[1], [x0], x2
srshr v0.8h, v0.8h, #3
trn1 v24.4s, v24.4s, v25.4s
srshr v1.8h, v1.8h, #3
sub x0, x0, x2, lsl #2
ext v1.16b, v1.16b, v1.16b, #8
trn1 v3.2d, v0.2d, v1.2d
trn2 v0.2d, v0.2d, v1.2d
trn1 v1.8h, v3.8h, v0.8h
trn2 v3.8h, v3.8h, v0.8h
uzp1 v0.4s, v1.4s, v3.4s
uzp2 v1.4s, v3.4s, v1.4s
uaddw v0.8h, v0.8h, v24.8b
uaddw2 v1.8h, v1.8h, v24.16b
sqxtun v0.8b, v0.8h
sqxtun2 v0.16b, v1.8h
st1 {v0.s}[0], [x0], x2
st1 {v0.s}[1], [x0], x2
st1 {v0.s}[3], [x0], x2
st1 {v0.s}[2], [x0], x2
ret
endfunc
function ff_vp8_idct_dc_add4y_neon, export=1
movi v0.16b, #0
mov x3, #32
ld1r {v16.4h}, [x1]
st1 {v0.h}[0], [x1], x3
ld1r {v17.4h}, [x1]
st1 {v0.h}[0], [x1], x3
zip1 v16.2d, v16.2d, v17.2d
ld1r {v18.4h}, [x1]
st1 {v0.h}[0], [x1], x3
ld1r {v19.4h}, [x1]
st1 {v0.h}[0], [x1], x3
zip1 v18.2d, v18.2d, v19.2d
srshr v16.8h, v16.8h, #3 // dc >>= 3
ld1 {v0.16b}, [x0], x2
srshr v18.8h, v18.8h, #3
ld1 {v1.16b}, [x0], x2
uaddw v20.8h, v16.8h, v0.8b
ld1 {v2.16b}, [x0], x2
uaddw2 v0.8h, v18.8h, v0.16b
ld1 {v3.16b}, [x0], x2
uaddw v21.8h, v16.8h, v1.8b
uaddw2 v1.8h, v18.8h, v1.16b
uaddw v22.8h, v16.8h, v2.8b
uaddw2 v2.8h, v18.8h, v2.16b
uaddw v23.8h, v16.8h, v3.8b
uaddw2 v3.8h, v18.8h, v3.16b
sub x0, x0, x2, lsl #2
sqxtun v20.8b, v20.8h
sqxtun2 v20.16b, v0.8h
sqxtun v21.8b, v21.8h
sqxtun2 v21.16b, v1.8h
sqxtun v22.8b, v22.8h
st1 {v20.16b}, [x0], x2
sqxtun2 v22.16b, v2.8h
st1 {v21.16b}, [x0], x2
sqxtun v23.8b, v23.8h
st1 {v22.16b}, [x0], x2
sqxtun2 v23.16b, v3.8h
st1 {v23.16b}, [x0], x2
ret
endfunc
function ff_vp8_idct_dc_add_neon, export=1
mov w3, #0
ld1r {v2.8h}, [x1]
strh w3, [x1]
srshr v2.8h, v2.8h, #3
ld1 {v0.s}[0], [x0], x2
ld1 {v0.s}[1], [x0], x2
uaddw v3.8h, v2.8h, v0.8b
ld1 {v1.s}[0], [x0], x2
ld1 {v1.s}[1], [x0], x2
uaddw v4.8h, v2.8h, v1.8b
sqxtun v0.8b, v3.8h
sqxtun v1.8b, v4.8h
sub x0, x0, x2, lsl #2
st1 {v0.s}[0], [x0], x2
st1 {v0.s}[1], [x0], x2
st1 {v1.s}[0], [x0], x2
st1 {v1.s}[1], [x0], x2
ret
endfunc
// Register layout:
// P3..Q3 -> v0..v7
// flim_E -> v22
// flim_I -> v23
// hev_thresh -> x5
//
.macro vp8_loop_filter, inner=0, simple=0, hev_thresh
.if \simple
uabd v17.16b, v3.16b, v4.16b // abs(P0-Q0)
uabd v23.16b, v2.16b, v5.16b // abs(P1-Q1)
uqadd v17.16b, v17.16b, v17.16b // abs(P0-Q0) * 2
ushr v18.16b, v23.16b, #1 // abs(P1-Q1) / 2
uqadd v19.16b, v17.16b, v18.16b // (abs(P0-Q0)*2) + (abs(P1-Q1)/2)
movi v21.16b, #0x80
cmhs v16.16b, v22.16b, v19.16b // (abs(P0-Q0)*2) + (abs(P1-Q1)/2) <= flim
.else
// calculate hev and normal_limit:
uabd v20.16b, v2.16b, v3.16b // abs(P1-P0)
uabd v21.16b, v5.16b, v4.16b // abs(Q1-Q0)
uabd v18.16b, v0.16b, v1.16b // abs(P3-P2)
uabd v19.16b, v1.16b, v2.16b // abs(P2-P1)
cmhs v16.16b, v23.16b, v20.16b // abs(P1-P0) <= flim_I
cmhs v17.16b, v23.16b, v21.16b // abs(Q1-Q0) <= flim_I
cmhs v18.16b, v23.16b, v18.16b // abs(P3-P2) <= flim_I
cmhs v19.16b, v23.16b, v19.16b // abs(P2-P1) <= flim_I
and v16.16b, v17.16b, v16.16b
uabd v17.16b, v7.16b, v6.16b // abs(Q3-Q2)
and v16.16b, v16.16b, v19.16b
uabd v19.16b, v6.16b, v5.16b // abs(Q2-Q1)
and v16.16b, v16.16b, v18.16b
cmhs v18.16b, v23.16b, v17.16b // abs(Q3-Q2) <= flim_I
cmhs v19.16b, v23.16b, v19.16b // abs(Q2-Q1) <= flim_I
uabd v17.16b, v3.16b, v4.16b // abs(P0-Q0)
uabd v23.16b, v2.16b, v5.16b // abs(P1-Q1)
and v16.16b, v16.16b, v18.16b
uqadd v17.16b, v17.16b, v17.16b // abs(P0-Q0) * 2
and v16.16b, v16.16b, v19.16b
ushr v18.16b, v23.16b, #1 // abs(P1-Q1) / 2
dup v23.16b, \hev_thresh // hev_thresh
uqadd v19.16b, v17.16b, v18.16b // (abs(P0-Q0)*2) + (abs(P1-Q1)/2)
cmhi v20.16b, v20.16b, v23.16b // abs(P1-P0) > hev_thresh
cmhs v19.16b, v22.16b, v19.16b // (abs(P0-Q0)*2) + (abs(P1-Q1)/2) <= flim_E
cmhi v22.16b, v21.16b, v23.16b // abs(Q1-Q0) > hev_thresh
and v16.16b, v16.16b, v19.16b
movi v21.16b, #0x80
orr v17.16b, v20.16b, v22.16b
.endif
// at this point:
// v16: normal_limit
// v17: hev
// convert to signed value:
eor v3.16b, v3.16b, v21.16b // PS0 = P0 ^ 0x80
eor v4.16b, v4.16b, v21.16b // QS0 = Q0 ^ 0x80
movi v20.8h, #3
ssubl v18.8h, v4.8b, v3.8b // QS0 - PS0
ssubl2 v19.8h, v4.16b, v3.16b // (widened to 16bit)
eor v2.16b, v2.16b, v21.16b // PS1 = P1 ^ 0x80
eor v5.16b, v5.16b, v21.16b // QS1 = Q1 ^ 0x80
mul v18.8h, v18.8h, v20.8h // w = 3 * (QS0 - PS0)
mul v19.8h, v19.8h, v20.8h
sqsub v20.16b, v2.16b, v5.16b // clamp(PS1-QS1)
movi v22.16b, #4
movi v23.16b, #3
.if \inner
and v20.16b, v20.16b, v17.16b // if(hev) w += clamp(PS1-QS1)
.endif
saddw v18.8h, v18.8h, v20.8b // w += clamp(PS1-QS1)
saddw2 v19.8h, v19.8h, v20.16b
sqxtn v18.8b, v18.8h // narrow result back into v18
sqxtn2 v18.16b, v19.8h
.if !\inner && !\simple
eor v1.16b, v1.16b, v21.16b // PS2 = P2 ^ 0x80
eor v6.16b, v6.16b, v21.16b // QS2 = Q2 ^ 0x80
.endif
and v18.16b, v18.16b, v16.16b // w &= normal_limit
// registers used at this point..
// v0 -> P3 (don't corrupt)
// v1-v6 -> PS2-QS2
// v7 -> Q3 (don't corrupt)
// v17 -> hev
// v18 -> w
// v21 -> #0x80
// v22 -> #4
// v23 -> #3
// v16, v19, v29 -> unused
//
// filter_common: is4tap==1
// c1 = clamp(w + 4) >> 3;
// c2 = clamp(w + 3) >> 3;
// Q0 = s2u(QS0 - c1);
// P0 = s2u(PS0 + c2);
.if \simple
sqadd v19.16b, v18.16b, v22.16b // c1 = clamp((w&hev)+4)
sqadd v20.16b, v18.16b, v23.16b // c2 = clamp((w&hev)+3)
sshr v19.16b, v19.16b, #3 // c1 >>= 3
sshr v20.16b, v20.16b, #3 // c2 >>= 3
sqsub v4.16b, v4.16b, v19.16b // QS0 = clamp(QS0-c1)
sqadd v3.16b, v3.16b, v20.16b // PS0 = clamp(PS0+c2)
eor v4.16b, v4.16b, v21.16b // Q0 = QS0 ^ 0x80
eor v3.16b, v3.16b, v21.16b // P0 = PS0 ^ 0x80
eor v5.16b, v5.16b, v21.16b // Q1 = QS1 ^ 0x80
eor v2.16b, v2.16b, v21.16b // P1 = PS1 ^ 0x80
.elseif \inner
// the !is4tap case of filter_common, only used for inner blocks
// c3 = ((c1&~hev) + 1) >> 1;
// Q1 = s2u(QS1 - c3);
// P1 = s2u(PS1 + c3);
sqadd v19.16b, v18.16b, v22.16b // c1 = clamp((w&hev)+4)
sqadd v20.16b, v18.16b, v23.16b // c2 = clamp((w&hev)+3)
sshr v19.16b, v19.16b, #3 // c1 >>= 3
sshr v20.16b, v20.16b, #3 // c2 >>= 3
sqsub v4.16b, v4.16b, v19.16b // QS0 = clamp(QS0-c1)
sqadd v3.16b, v3.16b, v20.16b // PS0 = clamp(PS0+c2)
bic v19.16b, v19.16b, v17.16b // c1 & ~hev
eor v4.16b, v4.16b, v21.16b // Q0 = QS0 ^ 0x80
srshr v19.16b, v19.16b, #1 // c3 >>= 1
eor v3.16b, v3.16b, v21.16b // P0 = PS0 ^ 0x80
sqsub v5.16b, v5.16b, v19.16b // QS1 = clamp(QS1-c3)
sqadd v2.16b, v2.16b, v19.16b // PS1 = clamp(PS1+c3)
eor v5.16b, v5.16b, v21.16b // Q1 = QS1 ^ 0x80
eor v2.16b, v2.16b, v21.16b // P1 = PS1 ^ 0x80
.else
and v20.16b, v18.16b, v17.16b // w & hev
sqadd v19.16b, v20.16b, v22.16b // c1 = clamp((w&hev)+4)
sqadd v20.16b, v20.16b, v23.16b // c2 = clamp((w&hev)+3)
sshr v19.16b, v19.16b, #3 // c1 >>= 3
sshr v20.16b, v20.16b, #3 // c2 >>= 3
bic v18.16b, v18.16b, v17.16b // w &= ~hev
sqsub v4.16b, v4.16b, v19.16b // QS0 = clamp(QS0-c1)
sqadd v3.16b, v3.16b, v20.16b // PS0 = clamp(PS0+c2)
// filter_mbedge:
// a = clamp((27*w + 63) >> 7);
// Q0 = s2u(QS0 - a);
// P0 = s2u(PS0 + a);
// a = clamp((18*w + 63) >> 7);
// Q1 = s2u(QS1 - a);
// P1 = s2u(PS1 + a);
// a = clamp((9*w + 63) >> 7);
// Q2 = s2u(QS2 - a);
// P2 = s2u(PS2 + a);
movi v17.8h, #63
sshll v22.8h, v18.8b, #3
sshll2 v23.8h, v18.16b, #3
saddw v22.8h, v22.8h, v18.8b
saddw2 v23.8h, v23.8h, v18.16b
add v16.8h, v17.8h, v22.8h
add v17.8h, v17.8h, v23.8h // 9*w + 63
add v19.8h, v16.8h, v22.8h
add v20.8h, v17.8h, v23.8h // 18*w + 63
add v22.8h, v19.8h, v22.8h
add v23.8h, v20.8h, v23.8h // 27*w + 63
sqshrn v16.8b, v16.8h, #7
sqshrn2 v16.16b, v17.8h, #7 // clamp(( 9*w + 63)>>7)
sqshrn v19.8b, v19.8h, #7
sqshrn2 v19.16b, v20.8h, #7 // clamp((18*w + 63)>>7)
sqshrn v22.8b, v22.8h, #7
sqshrn2 v22.16b, v23.8h, #7 // clamp((27*w + 63)>>7)
sqadd v1.16b, v1.16b, v16.16b // PS2 = clamp(PS2+a)
sqsub v6.16b, v6.16b, v16.16b // QS2 = clamp(QS2-a)
sqadd v2.16b, v2.16b, v19.16b // PS1 = clamp(PS1+a)
sqsub v5.16b, v5.16b, v19.16b // QS1 = clamp(QS1-a)
sqadd v3.16b, v3.16b, v22.16b // PS0 = clamp(PS0+a)
sqsub v4.16b, v4.16b, v22.16b // QS0 = clamp(QS0-a)
eor v3.16b, v3.16b, v21.16b // P0 = PS0 ^ 0x80
eor v4.16b, v4.16b, v21.16b // Q0 = QS0 ^ 0x80
eor v2.16b, v2.16b, v21.16b // P1 = PS1 ^ 0x80
eor v5.16b, v5.16b, v21.16b // Q1 = QS1 ^ 0x80
eor v1.16b, v1.16b, v21.16b // P2 = PS2 ^ 0x80
eor v6.16b, v6.16b, v21.16b // Q2 = QS2 ^ 0x80
.endif
.endm
.macro vp8_v_loop_filter16 name, inner=0, simple=0
function ff_vp8_v_loop_filter16\name\()_neon, export=1
sub x0, x0, x1, lsl #1+!\simple
// Load pixels:
.if !\simple
ld1 {v0.16b}, [x0], x1 // P3
ld1 {v1.16b}, [x0], x1 // P2
.endif
ld1 {v2.16b}, [x0], x1 // P1
ld1 {v3.16b}, [x0], x1 // P0
ld1 {v4.16b}, [x0], x1 // Q0
ld1 {v5.16b}, [x0], x1 // Q1
.if !\simple
ld1 {v6.16b}, [x0], x1 // Q2
ld1 {v7.16b}, [x0] // Q3
dup v23.16b, w3 // flim_I
.endif
dup v22.16b, w2 // flim_E
vp8_loop_filter inner=\inner, simple=\simple, hev_thresh=w4
// back up to P2: dst -= stride * 6
sub x0, x0, x1, lsl #2
.if !\simple
sub x0, x0, x1, lsl #1
// Store pixels:
st1 {v1.16b}, [x0], x1 // P2
.endif
st1 {v2.16b}, [x0], x1 // P1
st1 {v3.16b}, [x0], x1 // P0
st1 {v4.16b}, [x0], x1 // Q0
st1 {v5.16b}, [x0], x1 // Q1
.if !\simple
st1 {v6.16b}, [x0] // Q2
.endif
ret
endfunc
.endm
vp8_v_loop_filter16
vp8_v_loop_filter16 _inner, inner=1
vp8_v_loop_filter16 _simple, simple=1
.macro vp8_v_loop_filter8uv name, inner=0
function ff_vp8_v_loop_filter8uv\name\()_neon, export=1
sub x0, x0, x2, lsl #2
sub x1, x1, x2, lsl #2
// Load pixels:
ld1 {v0.d}[0], [x0], x2 // P3
ld1 {v0.d}[1], [x1], x2 // P3
ld1 {v1.d}[0], [x0], x2 // P2
ld1 {v1.d}[1], [x1], x2 // P2
ld1 {v2.d}[0], [x0], x2 // P1
ld1 {v2.d}[1], [x1], x2 // P1
ld1 {v3.d}[0], [x0], x2 // P0
ld1 {v3.d}[1], [x1], x2 // P0
ld1 {v4.d}[0], [x0], x2 // Q0
ld1 {v4.d}[1], [x1], x2 // Q0
ld1 {v5.d}[0], [x0], x2 // Q1
ld1 {v5.d}[1], [x1], x2 // Q1
ld1 {v6.d}[0], [x0], x2 // Q2
ld1 {v6.d}[1], [x1], x2 // Q2
ld1 {v7.d}[0], [x0] // Q3
ld1 {v7.d}[1], [x1] // Q3
dup v22.16b, w3 // flim_E
dup v23.16b, w4 // flim_I
vp8_loop_filter inner=\inner, hev_thresh=w5
// back up to P2: u,v -= stride * 6
sub x0, x0, x2, lsl #2
sub x1, x1, x2, lsl #2
sub x0, x0, x2, lsl #1
sub x1, x1, x2, lsl #1
// Store pixels:
st1 {v1.d}[0], [x0], x2 // P2
st1 {v1.d}[1], [x1], x2 // P2
st1 {v2.d}[0], [x0], x2 // P1
st1 {v2.d}[1], [x1], x2 // P1
st1 {v3.d}[0], [x0], x2 // P0
st1 {v3.d}[1], [x1], x2 // P0
st1 {v4.d}[0], [x0], x2 // Q0
st1 {v4.d}[1], [x1], x2 // Q0
st1 {v5.d}[0], [x0], x2 // Q1
st1 {v5.d}[1], [x1], x2 // Q1
st1 {v6.d}[0], [x0] // Q2
st1 {v6.d}[1], [x1] // Q2
ret
endfunc
.endm
vp8_v_loop_filter8uv
vp8_v_loop_filter8uv _inner, inner=1
.macro vp8_h_loop_filter16 name, inner=0, simple=0
function ff_vp8_h_loop_filter16\name\()_neon, export=1
sub x0, x0, #4
// Load pixels:
ld1 {v0.d}[0], [x0], x1
ld1 {v1.d}[0], [x0], x1
ld1 {v2.d}[0], [x0], x1
ld1 {v3.d}[0], [x0], x1
ld1 {v4.d}[0], [x0], x1
ld1 {v5.d}[0], [x0], x1
ld1 {v6.d}[0], [x0], x1
ld1 {v7.d}[0], [x0], x1
ld1 {v0.d}[1], [x0], x1
ld1 {v1.d}[1], [x0], x1
ld1 {v2.d}[1], [x0], x1
ld1 {v3.d}[1], [x0], x1
ld1 {v4.d}[1], [x0], x1
ld1 {v5.d}[1], [x0], x1
ld1 {v6.d}[1], [x0], x1
ld1 {v7.d}[1], [x0], x1
transpose_8x16B v0, v1, v2, v3, v4, v5, v6, v7, v30, v31
dup v22.16b, w2 // flim_E
.if !\simple
dup v23.16b, w3 // flim_I
.endif
vp8_loop_filter inner=\inner, simple=\simple, hev_thresh=w4
sub x0, x0, x1, lsl #4 // backup 16 rows
transpose_8x16B v0, v1, v2, v3, v4, v5, v6, v7, v30, v31
// Store pixels:
st1 {v0.d}[0], [x0], x1
st1 {v1.d}[0], [x0], x1
st1 {v2.d}[0], [x0], x1
st1 {v3.d}[0], [x0], x1
st1 {v4.d}[0], [x0], x1
st1 {v5.d}[0], [x0], x1
st1 {v6.d}[0], [x0], x1
st1 {v7.d}[0], [x0], x1
st1 {v0.d}[1], [x0], x1
st1 {v1.d}[1], [x0], x1
st1 {v2.d}[1], [x0], x1
st1 {v3.d}[1], [x0], x1
st1 {v4.d}[1], [x0], x1
st1 {v5.d}[1], [x0], x1
st1 {v6.d}[1], [x0], x1
st1 {v7.d}[1], [x0]
ret
endfunc
.endm
vp8_h_loop_filter16
vp8_h_loop_filter16 _inner, inner=1
vp8_h_loop_filter16 _simple, simple=1
.macro vp8_h_loop_filter8uv name, inner=0
function ff_vp8_h_loop_filter8uv\name\()_neon, export=1
sub x0, x0, #4
sub x1, x1, #4
// Load pixels:
ld1 {v0.d}[0], [x0], x2 // load u
ld1 {v0.d}[1], [x1], x2 // load v
ld1 {v1.d}[0], [x0], x2
ld1 {v1.d}[1], [x1], x2
ld1 {v2.d}[0], [x0], x2
ld1 {v2.d}[1], [x1], x2
ld1 {v3.d}[0], [x0], x2
ld1 {v3.d}[1], [x1], x2
ld1 {v4.d}[0], [x0], x2
ld1 {v4.d}[1], [x1], x2
ld1 {v5.d}[0], [x0], x2
ld1 {v5.d}[1], [x1], x2
ld1 {v6.d}[0], [x0], x2
ld1 {v6.d}[1], [x1], x2
ld1 {v7.d}[0], [x0], x2
ld1 {v7.d}[1], [x1], x2
transpose_8x16B v0, v1, v2, v3, v4, v5, v6, v7, v30, v31
dup v22.16b, w3 // flim_E
dup v23.16b, w4 // flim_I
vp8_loop_filter inner=\inner, hev_thresh=w5
sub x0, x0, x2, lsl #3 // backup u 8 rows
sub x1, x1, x2, lsl #3 // backup v 8 rows
transpose_8x16B v0, v1, v2, v3, v4, v5, v6, v7, v30, v31
// Store pixels:
st1 {v0.d}[0], [x0], x2 // load u
st1 {v0.d}[1], [x1], x2 // load v
st1 {v1.d}[0], [x0], x2
st1 {v1.d}[1], [x1], x2
st1 {v2.d}[0], [x0], x2
st1 {v2.d}[1], [x1], x2
st1 {v3.d}[0], [x0], x2
st1 {v3.d}[1], [x1], x2
st1 {v4.d}[0], [x0], x2
st1 {v4.d}[1], [x1], x2
st1 {v5.d}[0], [x0], x2
st1 {v5.d}[1], [x1], x2
st1 {v6.d}[0], [x0], x2
st1 {v6.d}[1], [x1], x2
st1 {v7.d}[0], [x0]
st1 {v7.d}[1], [x1]
ret
endfunc
.endm
vp8_h_loop_filter8uv
vp8_h_loop_filter8uv _inner, inner=1
function ff_put_vp8_pixels16_neon, export=1
1:
subs w4, w4, #4
ld1 {v0.16b}, [x2], x3
ld1 {v1.16b}, [x2], x3
ld1 {v2.16b}, [x2], x3
ld1 {v3.16b}, [x2], x3
st1 {v0.16b}, [x0], x1
st1 {v1.16b}, [x0], x1
st1 {v2.16b}, [x0], x1
st1 {v3.16b}, [x0], x1
b.gt 1b
ret
endfunc
function ff_put_vp8_pixels8_neon, export=1
1:
subs w4, w4, #4
ld1 {v0.8b}, [x2], x3
ld1 {v0.d}[1], [x2], x3
ld1 {v1.8b}, [x2], x3
ld1 {v1.d}[1], [x2], x3
st1 {v0.8b}, [x0], x1
st1 {v0.d}[1], [x0], x1
st1 {v1.8b}, [x0], x1
st1 {v1.d}[1], [x0], x1
b.gt 1b
ret
endfunc
/* 4/6-tap 8th-pel MC */
.macro vp8_epel8_h6 d, s0, s1
ext v22.8b, \s0\().8b, \s1\().8b, #1
uxtl v18.8h, \s0\().8b
ext v23.8b, \s0\().8b, \s1\().8b, #2
uxtl v19.8h, v22.8b
ext v24.8b, \s0\().8b, \s1\().8b, #3
uxtl v21.8h, v23.8b
ext v25.8b, \s0\().8b, \s1\().8b, #4
uxtl v22.8h, v24.8b
ext v26.8b, \s0\().8b, \s1\().8b, #5
uxtl v25.8h, v25.8b
mul v21.8h, v21.8h, v0.h[2]
uxtl v26.8h, v26.8b
mul v22.8h, v22.8h, v0.h[3]
mls v21.8h, v19.8h, v0.h[1]
mls v22.8h, v25.8h, v0.h[4]
mla v21.8h, v18.8h, v0.h[0]
mla v22.8h, v26.8h, v0.h[5]
sqadd v22.8h, v21.8h, v22.8h
sqrshrun \d\().8b, v22.8h, #7
.endm
.macro vp8_epel16_h6 d0, v0, v1
ext v22.16b, \v0\().16b, \v1\().16b, #3
ext v23.16b, \v0\().16b, \v1\().16b, #4
uxtl v19.8h, v22.8b
uxtl2 v22.8h, v22.16b
ext v3.16b, \v0\().16b, \v1\().16b, #2
uxtl v20.8h, v23.8b
uxtl2 v23.8h, v23.16b
ext v16.16b, \v0\().16b, \v1\().16b, #1
uxtl v18.8h, v3.8b
uxtl2 v3.8h, v3.16b
ext v2.16b, \v0\().16b, \v1\().16b, #5
uxtl v21.8h, v2.8b
uxtl2 v2.8h, v2.16b
uxtl v17.8h, v16.8b
uxtl2 v16.8h, v16.16b
mul v19.8h, v19.8h, v0.h[3]
mul v18.8h, v18.8h, v0.h[2]
mul v3.8h, v3.8h, v0.h[2]
mul v22.8h, v22.8h, v0.h[3]
mls v19.8h, v20.8h, v0.h[4]
uxtl v20.8h, \v0\().8b
uxtl2 v1.8h, \v0\().16b
mls v18.8h, v17.8h, v0.h[1]
mls v3.8h, v16.8h, v0.h[1]
mls v22.8h, v23.8h, v0.h[4]
mla v18.8h, v20.8h, v0.h[0]
mla v19.8h, v21.8h, v0.h[5]
mla v3.8h, v1.8h, v0.h[0]
mla v22.8h, v2.8h, v0.h[5]
sqadd v19.8h, v18.8h, v19.8h
sqadd v22.8h, v3.8h, v22.8h
sqrshrun \d0\().8b, v19.8h, #7
sqrshrun2 \d0\().16b, v22.8h, #7
.endm
.macro vp8_epel8_v6 d0, s0, s1, s2, s3, s4, s5
uxtl \s2\().8h, \s2\().8b
uxtl \s3\().8h, \s3\().8b
uxtl \s1\().8h, \s1\().8b
uxtl \s4\().8h, \s4\().8b
uxtl \s0\().8h, \s0\().8b
uxtl \s5\().8h, \s5\().8b
mul \s2\().8h, \s2\().8h, v0.h[2]
mul \s3\().8h, \s3\().8h, v0.h[3]
mls \s2\().8h, \s1\().8h, v0.h[1]
mls \s3\().8h, \s4\().8h, v0.h[4]
mla \s2\().8h, \s0\().8h, v0.h[0]
mla \s3\().8h, \s5\().8h, v0.h[5]
sqadd \s3\().8h, \s2\().8h, \s3\().8h
sqrshrun \d0\().8b, \s3\().8h, #7
.endm
.macro vp8_epel8_v6_y2 d0, d1, s0, s1, s2, s3, s4, s5, s6
uxtl \s0\().8h, \s0\().8b
uxtl \s3\().8h, \s3\().8b
uxtl \s6\().8h, \s6\().8b
uxtl \s1\().8h, \s1\().8b
uxtl \s4\().8h, \s4\().8b
uxtl \s2\().8h, \s2\().8b
uxtl \s5\().8h, \s5\().8b
mul \s0\().8h, \s0\().8h, v0.h[0]
mul v31.8h , \s3\().8h, v0.h[3]
mul \s3\().8h, \s3\().8h, v0.h[2]
mul \s6\().8h, \s6\().8h, v0.h[5]
mls \s0\().8h, \s1\().8h, v0.h[1]
mls v31.8h , \s4\().8h, v0.h[4]
mls \s3\().8h, \s2\().8h, v0.h[1]
mls \s6\().8h, \s5\().8h, v0.h[4]
mla \s0\().8h, \s2\().8h, v0.h[2]
mla v31.8h , \s5\().8h, v0.h[5]
mla \s3\().8h, \s1\().8h, v0.h[0]
mla \s6\().8h, \s4\().8h, v0.h[3]
sqadd v31.8h , \s0\().8h, v31.8h
sqadd \s6\().8h, \s3\().8h, \s6\().8h
sqrshrun \d0\().8b, v31.8h, #7
sqrshrun \d1\().8b, \s6\().8h, #7
.endm
.macro vp8_epel8_h4 d, v0, v1
ext v22.8b, \v0\().8b, \v1\().8b, #1
uxtl v19.8h, \v0\().8b
ext v23.8b, \v0\().8b, \v1\().8b, #2
uxtl v20.8h, v22.8b
ext v25.8b, \v0\().8b, \v1\().8b, #3
uxtl v22.8h, v23.8b
uxtl v25.8h, v25.8b
mul v20.8h, v20.8h, v0.h[2]
mul v22.8h, v22.8h, v0.h[3]
mls v20.8h, v19.8h, v0.h[1]
mls v22.8h, v25.8h, v0.h[4]
sqadd v22.8h, v20.8h, v22.8h
sqrshrun \d\().8b, v22.8h, #7
.endm
.macro vp8_epel8_v4_y2 d0, s0, s1, s2, s3, s4
uxtl \s0\().8h, \s0\().8b
uxtl \s1\().8h, \s1\().8b
uxtl \s2\().8h, \s2\().8b
uxtl \s3\().8h, \s3\().8b
uxtl \s4\().8h, \s4\().8b
mul v21.8h, \s1\().8h, v0.h[2]
mul v23.8h, \s2\().8h, v0.h[3]
mul \s2\().8h, \s2\().8h, v0.h[2]
mul v22.8h, \s3\().8h, v0.h[3]
mls v21.8h, \s0\().8h, v0.h[1]
mls v23.8h, \s3\().8h, v0.h[4]
mls \s2\().8h, \s1\().8h, v0.h[1]
mls v22.8h, \s4\().8h, v0.h[4]
sqadd v21.8h, v21.8h, v23.8h
sqadd \s2\().8h, \s2\().8h, v22.8h
sqrshrun \d0\().8b, v21.8h, #7
sqrshrun2 \d0\().16b, \s2\().8h, #7
.endm
// note: worst case sum of all 6-tap filter values * 255 is 0x7f80 so 16 bit
// arithmetic can be used to apply filters
const subpel_filters, align=4
.short 0, 6, 123, 12, 1, 0, 0, 0
.short 2, 11, 108, 36, 8, 1, 0, 0
.short 0, 9, 93, 50, 6, 0, 0, 0
.short 3, 16, 77, 77, 16, 3, 0, 0
.short 0, 6, 50, 93, 9, 0, 0, 0
.short 1, 8, 36, 108, 11, 2, 0, 0
.short 0, 1, 12, 123, 6, 0, 0, 0
endconst
function ff_put_vp8_epel16_v6_neon, export=1
sub x2, x2, x3, lsl #1
sxtw x4, w4
sxtw x6, w6
movrel x17, subpel_filters, -16
add x6, x17, x6, lsl #4 // y
ld1 {v0.8h}, [x6]
1:
ld1 {v1.1d - v2.1d}, [x2], x3
ld1 {v3.1d - v4.1d}, [x2], x3
ld1 {v16.1d - v17.1d}, [x2], x3
ld1 {v18.1d - v19.1d}, [x2], x3
ld1 {v20.1d - v21.1d}, [x2], x3
ld1 {v22.1d - v23.1d}, [x2], x3
ld1 {v24.1d - v25.1d}, [x2]
sub x2, x2, x3, lsl #2
vp8_epel8_v6_y2 v1, v3, v1, v3, v16, v18, v20, v22, v24
vp8_epel8_v6_y2 v2, v4, v2, v4, v17, v19, v21, v23, v25
st1 {v1.1d - v2.1d}, [x0], x1
st1 {v3.1d - v4.1d}, [x0], x1
subs x4, x4, #2
b.ne 1b
ret
endfunc
function ff_put_vp8_epel16_h6_neon, export=1
sub x2, x2, #2
sxtw x5, w5 // x
// first pass (horizontal):
movrel x17, subpel_filters, -16
add x5, x17, x5, lsl #4 // x
ld1 {v0.8h}, [x5]
1:
ld1 {v1.16b, v2.16b}, [x2], x3
vp8_epel16_h6 v1, v1, v2
st1 {v1.16b}, [x0], x1
subs w4, w4, #1
b.ne 1b
ret
endfunc
function ff_put_vp8_epel16_h6v6_neon, export=1
sub x2, x2, x3, lsl #1
sub x2, x2, #2
// first pass (horizontal):
movrel x17, subpel_filters, -16
sxtw x5, w5 // x
add x16, x17, x5, lsl #4 // x
sub sp, sp, #336+16
ld1 {v0.8h}, [x16]
add x7, sp, #15
sxtw x4, w4
add x16, x4, #5 // h
bic x7, x7, #15
1:
ld1 {v1.16b, v2.16b}, [x2], x3
vp8_epel16_h6 v1, v1, v2
st1 {v1.16b}, [x7], #16
subs x16, x16, #1
b.ne 1b
// second pass (vertical):
sxtw x6, w6
add x6, x17, x6, lsl #4 // y
add x7, sp, #15
ld1 {v0.8h}, [x6]
bic x7, x7, #15
2:
ld1 {v1.8b - v4.8b}, [x7], #32
ld1 {v16.8b - v19.8b}, [x7], #32
ld1 {v20.8b - v23.8b}, [x7]
sub x7, x7, #48
vp8_epel8_v6 v5, v1, v3, v16, v18, v20, v22
vp8_epel8_v6 v2, v2, v4, v17, v19, v21, v23
trn1 v2.2d, v5.2d, v2.2d
st1 {v2.16b}, [x0], x1
subs x4, x4, #1
b.ne 2b
add sp, sp, #336+16
ret
endfunc
function ff_put_vp8_epel8_h6v6_neon, export=1
sub x2, x2, x3, lsl #1
sub x2, x2, #2
sxtw x4, w4
// first pass (horizontal):
movrel x17, subpel_filters, -16
sxtw x5, w5
add x5, x17, x5, lsl #4 // x
sub sp, sp, #168+16
ld1 {v0.8h}, [x5]
add x7, sp, #15
add x16, x4, #5 // h
bic x7, x7, #15
1:
ld1 {v1.8b, v2.8b}, [x2], x3
vp8_epel8_h6 v1, v1, v2
st1 {v1.8b}, [x7], #8
subs x16, x16, #1
b.ne 1b
// second pass (vertical):
sxtw x6, w6
add x6, x17, x6, lsl #4 // y
add x7, sp, #15
ld1 {v0.8h}, [x6]
bic x7, x7, #15
2:
ld1 {v1.8b - v4.8b}, [x7], #32
ld1 {v5.8b - v7.8b}, [x7]
sub x7, x7, #16
vp8_epel8_v6_y2 v1, v2, v1, v2, v3, v4, v5, v6, v7
st1 {v1.8b}, [x0], x1
st1 {v2.8b}, [x0], x1
subs x4, x4, #2
b.ne 2b
add sp, sp, #168+16
ret
endfunc
function ff_put_vp8_epel8_h4v6_neon, export=1
sub x2, x2, x3, lsl #1
sub x2, x2, #1
sxtw x4, w4
// first pass (horizontal):
movrel x17, subpel_filters, -16
sxtw x5, w5
add x5, x17, x5, lsl #4 // x
sub sp, sp, #168+16
ld1 {v0.8h}, [x5]
add x7, sp, #15
add x16, x4, #5 // h
bic x7, x7, #15
1:
ld1 {v1.8b, v2.8b}, [x2], x3
vp8_epel8_h4 v1, v1, v2
st1 {v1.8b}, [x7], #8
subs x16, x16, #1
b.ne 1b
// second pass (vertical):
sxtw x6, w6
add x6, x17, x6, lsl #4 // y
add x7, sp, #15
ld1 {v0.8h}, [x6]
bic x7, x7, #15
2:
ld1 {v1.8b - v4.8b}, [x7], #32
ld1 {v5.8b - v7.8b}, [x7]
sub x7, x7, #16
vp8_epel8_v6_y2 v1, v2, v1, v2, v3, v4, v5, v6, v7
st1 {v1.8b}, [x0], x1
st1 {v2.8b}, [x0], x1
subs x4, x4, #2
b.ne 2b
add sp, sp, #168+16
ret
endfunc
function ff_put_vp8_epel8_h4v4_neon, export=1
sub x2, x2, x3
sub x2, x2, #1
sxtw x4, w4
// first pass (horizontal):
movrel x17, subpel_filters, -16
sxtw x5, w5
add x5, x17, x5, lsl #4 // x
sub sp, sp, #168+16
ld1 {v0.8h}, [x5]
add x7, sp, #15
add x16, x4, #3 // h
bic x7, x7, #15
1:
ld1 {v1.8b, v2.8b}, [x2], x3
vp8_epel8_h4 v1, v1, v2
st1 {v1.8b}, [x7], #8
subs x16, x16, #1
b.ne 1b
// second pass (vertical):
sxtw x6, w6
add x6, x17, x6, lsl #4 // y
add x7, sp, #15
ld1 {v0.8h}, [x6]
bic x7, x7, #15
2:
ld1 {v1.8b - v2.8b}, [x7], #16
ld1 {v3.8b - v5.8b}, [x7]
vp8_epel8_v4_y2 v1, v1, v2, v3, v4, v5
st1 {v1.d}[0], [x0], x1
st1 {v1.d}[1], [x0], x1
subs x4, x4, #2
b.ne 2b
add sp, sp, #168+16
ret
endfunc
function ff_put_vp8_epel8_h6v4_neon, export=1
sub x2, x2, x3
sub x2, x2, #2
sxtw x4, w4
// first pass (horizontal):
movrel x17, subpel_filters, -16
sxtw x5, w5
add x5, x17, x5, lsl #4 // x
sub sp, sp, #168+16
ld1 {v0.8h}, [x5]
add x7, sp, #15
add x16, x4, #3 // h
bic x7, x7, #15
1:
ld1 {v1.8b, v2.8b}, [x2], x3
vp8_epel8_h6 v1, v1, v2
st1 {v1.8b}, [x7], #8
subs x16, x16, #1
b.ne 1b
// second pass (vertical):
sxtw x6, w6
add x6, x17, x6, lsl #4 // y
add x7, sp, #15
ld1 {v0.8h}, [x6]
bic x7, x7, #15
2:
ld1 {v1.8b - v2.8b}, [x7], #16
ld1 {v3.8b - v5.8b}, [x7]
vp8_epel8_v4_y2 v1, v1, v2, v3, v4, v5
st1 {v1.d}[0], [x0], x1
st1 {v1.d}[1], [x0], x1
subs x4, x4, #2
b.ne 2b
add sp, sp, #168+16
ret
endfunc
|