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
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
|
/*
* Copyright (c) 2023 Loongson Technology Corporation Limited
* Contributed by jinbo <jinbo@loongson.cn>
*
* 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 "loongson_asm.S"
.extern ff_hevc_qpel_filters
.extern ff_hevc_epel_filters
.macro LOAD_VAR bit
addi.w t1, a5, 6 //shift
addi.w t3, zero, 1 //one
sub.w t4, t1, t3
sll.w t3, t3, t4 //offset
.if \bit == 128
vreplgr2vr.w vr1, a6 //wx
vreplgr2vr.w vr2, t3 //offset
vreplgr2vr.w vr3, t1 //shift
vreplgr2vr.w vr4, a7 //ox
.else
xvreplgr2vr.w xr1, a6
xvreplgr2vr.w xr2, t3
xvreplgr2vr.w xr3, t1
xvreplgr2vr.w xr4, a7
.endif
.endm
.macro HEVC_PEL_UNI_W_PIXELS8_LSX src0, dst0, w
vldrepl.d vr0, \src0, 0
vsllwil.hu.bu vr0, vr0, 0
vexth.wu.hu vr5, vr0
vsllwil.wu.hu vr0, vr0, 0
vslli.w vr0, vr0, 6
vslli.w vr5, vr5, 6
vmul.w vr0, vr0, vr1
vmul.w vr5, vr5, vr1
vadd.w vr0, vr0, vr2
vadd.w vr5, vr5, vr2
vsra.w vr0, vr0, vr3
vsra.w vr5, vr5, vr3
vadd.w vr0, vr0, vr4
vadd.w vr5, vr5, vr4
vssrani.h.w vr5, vr0, 0
vssrani.bu.h vr5, vr5, 0
.if \w == 6
fst.s f5, \dst0, 0
vstelm.h vr5, \dst0, 4, 2
.else
fst.d f5, \dst0, 0
.endif
.endm
.macro HEVC_PEL_UNI_W_PIXELS8x2_LASX src0, dst0, w
vldrepl.d vr0, \src0, 0
add.d t2, \src0, a3
vldrepl.d vr5, t2, 0
xvpermi.q xr0, xr5, 0x02
xvsllwil.hu.bu xr0, xr0, 0
xvexth.wu.hu xr5, xr0
xvsllwil.wu.hu xr0, xr0, 0
xvslli.w xr0, xr0, 6
xvslli.w xr5, xr5, 6
xvmul.w xr0, xr0, xr1
xvmul.w xr5, xr5, xr1
xvadd.w xr0, xr0, xr2
xvadd.w xr5, xr5, xr2
xvsra.w xr0, xr0, xr3
xvsra.w xr5, xr5, xr3
xvadd.w xr0, xr0, xr4
xvadd.w xr5, xr5, xr4
xvssrani.h.w xr5, xr0, 0
xvpermi.q xr0, xr5, 0x01
xvssrani.bu.h xr0, xr5, 0
add.d t3, \dst0, a1
.if \w == 6
vstelm.w vr0, \dst0, 0, 0
vstelm.h vr0, \dst0, 4, 2
vstelm.w vr0, t3, 0, 2
vstelm.h vr0, t3, 4, 6
.else
vstelm.d vr0, \dst0, 0, 0
vstelm.d vr0, t3, 0, 1
.endif
.endm
.macro HEVC_PEL_UNI_W_PIXELS16_LSX src0, dst0
vld vr0, \src0, 0
vexth.hu.bu vr7, vr0
vexth.wu.hu vr8, vr7
vsllwil.wu.hu vr7, vr7, 0
vsllwil.hu.bu vr5, vr0, 0
vexth.wu.hu vr6, vr5
vsllwil.wu.hu vr5, vr5, 0
vslli.w vr5, vr5, 6
vslli.w vr6, vr6, 6
vslli.w vr7, vr7, 6
vslli.w vr8, vr8, 6
vmul.w vr5, vr5, vr1
vmul.w vr6, vr6, vr1
vmul.w vr7, vr7, vr1
vmul.w vr8, vr8, vr1
vadd.w vr5, vr5, vr2
vadd.w vr6, vr6, vr2
vadd.w vr7, vr7, vr2
vadd.w vr8, vr8, vr2
vsra.w vr5, vr5, vr3
vsra.w vr6, vr6, vr3
vsra.w vr7, vr7, vr3
vsra.w vr8, vr8, vr3
vadd.w vr5, vr5, vr4
vadd.w vr6, vr6, vr4
vadd.w vr7, vr7, vr4
vadd.w vr8, vr8, vr4
vssrani.h.w vr6, vr5, 0
vssrani.h.w vr8, vr7, 0
vssrani.bu.h vr8, vr6, 0
vst vr8, \dst0, 0
.endm
.macro HEVC_PEL_UNI_W_PIXELS16_LASX src0, dst0
vld vr0, \src0, 0
xvpermi.d xr0, xr0, 0xd8
xvsllwil.hu.bu xr0, xr0, 0
xvexth.wu.hu xr6, xr0
xvsllwil.wu.hu xr5, xr0, 0
xvslli.w xr5, xr5, 6
xvslli.w xr6, xr6, 6
xvmul.w xr5, xr5, xr1
xvmul.w xr6, xr6, xr1
xvadd.w xr5, xr5, xr2
xvadd.w xr6, xr6, xr2
xvsra.w xr5, xr5, xr3
xvsra.w xr6, xr6, xr3
xvadd.w xr5, xr5, xr4
xvadd.w xr6, xr6, xr4
xvssrani.h.w xr6, xr5, 0
xvpermi.q xr7, xr6, 0x01
xvssrani.bu.h xr7, xr6, 0
vst vr7, \dst0, 0
.endm
.macro HEVC_PEL_UNI_W_PIXELS32_LASX src0, dst0, w
.if \w == 16
vld vr0, \src0, 0
add.d t2, \src0, a3
vld vr5, t2, 0
xvpermi.q xr0, xr5, 0x02
.else //w=24/32
xvld xr0, \src0, 0
.endif
xvexth.hu.bu xr7, xr0
xvexth.wu.hu xr8, xr7
xvsllwil.wu.hu xr7, xr7, 0
xvsllwil.hu.bu xr5, xr0, 0
xvexth.wu.hu xr6, xr5
xvsllwil.wu.hu xr5, xr5, 0
xvslli.w xr5, xr5, 6
xvslli.w xr6, xr6, 6
xvslli.w xr7, xr7, 6
xvslli.w xr8, xr8, 6
xvmul.w xr5, xr5, xr1
xvmul.w xr6, xr6, xr1
xvmul.w xr7, xr7, xr1
xvmul.w xr8, xr8, xr1
xvadd.w xr5, xr5, xr2
xvadd.w xr6, xr6, xr2
xvadd.w xr7, xr7, xr2
xvadd.w xr8, xr8, xr2
xvsra.w xr5, xr5, xr3
xvsra.w xr6, xr6, xr3
xvsra.w xr7, xr7, xr3
xvsra.w xr8, xr8, xr3
xvadd.w xr5, xr5, xr4
xvadd.w xr6, xr6, xr4
xvadd.w xr7, xr7, xr4
xvadd.w xr8, xr8, xr4
xvssrani.h.w xr6, xr5, 0
xvssrani.h.w xr8, xr7, 0
xvssrani.bu.h xr8, xr6, 0
.if \w == 16
vst vr8, \dst0, 0
add.d t2, \dst0, a1
xvpermi.q xr8, xr8, 0x01
vst vr8, t2, 0
.elseif \w == 24
vst vr8, \dst0, 0
xvstelm.d xr8, \dst0, 16, 2
.else
xvst xr8, \dst0, 0
.endif
.endm
/*
* void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_pel_uni_w_pixels4_8_lsx
LOAD_VAR 128
srli.w t0, a4, 1
.LOOP_PIXELS4:
vldrepl.w vr0, a2, 0
add.d t1, a2, a3
vldrepl.w vr5, t1, 0
vsllwil.hu.bu vr0, vr0, 0
vsllwil.wu.hu vr0, vr0, 0
vsllwil.hu.bu vr5, vr5, 0
vsllwil.wu.hu vr5, vr5, 0
vslli.w vr0, vr0, 6
vslli.w vr5, vr5, 6
vmul.w vr0, vr0, vr1
vmul.w vr5, vr5, vr1
vadd.w vr0, vr0, vr2
vadd.w vr5, vr5, vr2
vsra.w vr0, vr0, vr3
vsra.w vr5, vr5, vr3
vadd.w vr0, vr0, vr4
vadd.w vr5, vr5, vr4
vssrani.h.w vr5, vr0, 0
vssrani.bu.h vr5, vr5, 0
fst.s f5, a0, 0
add.d t2, a0, a1
vstelm.w vr5, t2, 0, 1
alsl.d a2, a3, a2, 1
alsl.d a0, a1, a0, 1
addi.w t0, t0, -1
bnez t0, .LOOP_PIXELS4
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels6_8_lsx
LOAD_VAR 128
.LOOP_PIXELS6:
HEVC_PEL_UNI_W_PIXELS8_LSX a2, a0, 6
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS6
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels6_8_lasx
LOAD_VAR 256
srli.w t0, a4, 1
.LOOP_PIXELS6_LASX:
HEVC_PEL_UNI_W_PIXELS8x2_LASX a2, a0, 6
alsl.d a2, a3, a2, 1
alsl.d a0, a1, a0, 1
addi.w t0, t0, -1
bnez t0, .LOOP_PIXELS6_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels8_8_lsx
LOAD_VAR 128
.LOOP_PIXELS8:
HEVC_PEL_UNI_W_PIXELS8_LSX a2, a0, 8
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS8
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels8_8_lasx
LOAD_VAR 256
srli.w t0, a4, 1
.LOOP_PIXELS8_LASX:
HEVC_PEL_UNI_W_PIXELS8x2_LASX a2, a0, 8
alsl.d a2, a3, a2, 1
alsl.d a0, a1, a0, 1
addi.w t0, t0, -1
bnez t0, .LOOP_PIXELS8_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels12_8_lsx
LOAD_VAR 128
.LOOP_PIXELS12:
vld vr0, a2, 0
vexth.hu.bu vr7, vr0
vsllwil.wu.hu vr7, vr7, 0
vsllwil.hu.bu vr5, vr0, 0
vexth.wu.hu vr6, vr5
vsllwil.wu.hu vr5, vr5, 0
vslli.w vr5, vr5, 6
vslli.w vr6, vr6, 6
vslli.w vr7, vr7, 6
vmul.w vr5, vr5, vr1
vmul.w vr6, vr6, vr1
vmul.w vr7, vr7, vr1
vadd.w vr5, vr5, vr2
vadd.w vr6, vr6, vr2
vadd.w vr7, vr7, vr2
vsra.w vr5, vr5, vr3
vsra.w vr6, vr6, vr3
vsra.w vr7, vr7, vr3
vadd.w vr5, vr5, vr4
vadd.w vr6, vr6, vr4
vadd.w vr7, vr7, vr4
vssrani.h.w vr6, vr5, 0
vssrani.h.w vr7, vr7, 0
vssrani.bu.h vr7, vr6, 0
fst.d f7, a0, 0
vstelm.w vr7, a0, 8, 2
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS12
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels12_8_lasx
LOAD_VAR 256
.LOOP_PIXELS12_LASX:
vld vr0, a2, 0
xvpermi.d xr0, xr0, 0xd8
xvsllwil.hu.bu xr0, xr0, 0
xvexth.wu.hu xr6, xr0
xvsllwil.wu.hu xr5, xr0, 0
xvslli.w xr5, xr5, 6
xvslli.w xr6, xr6, 6
xvmul.w xr5, xr5, xr1
xvmul.w xr6, xr6, xr1
xvadd.w xr5, xr5, xr2
xvadd.w xr6, xr6, xr2
xvsra.w xr5, xr5, xr3
xvsra.w xr6, xr6, xr3
xvadd.w xr5, xr5, xr4
xvadd.w xr6, xr6, xr4
xvssrani.h.w xr6, xr5, 0
xvpermi.q xr7, xr6, 0x01
xvssrani.bu.h xr7, xr6, 0
fst.d f7, a0, 0
vstelm.w vr7, a0, 8, 2
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS12_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels16_8_lsx
LOAD_VAR 128
.LOOP_PIXELS16:
HEVC_PEL_UNI_W_PIXELS16_LSX a2, a0
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS16
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels16_8_lasx
LOAD_VAR 256
srli.w t0, a4, 1
.LOOP_PIXELS16_LASX:
HEVC_PEL_UNI_W_PIXELS32_LASX a2, a0, 16
alsl.d a2, a3, a2, 1
alsl.d a0, a1, a0, 1
addi.w t0, t0, -1
bnez t0, .LOOP_PIXELS16_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels24_8_lsx
LOAD_VAR 128
.LOOP_PIXELS24:
HEVC_PEL_UNI_W_PIXELS16_LSX a2, a0
addi.d t0, a2, 16
addi.d t1, a0, 16
HEVC_PEL_UNI_W_PIXELS8_LSX t0, t1, 8
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS24
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels24_8_lasx
LOAD_VAR 256
.LOOP_PIXELS24_LASX:
HEVC_PEL_UNI_W_PIXELS32_LASX a2, a0, 24
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS24_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels32_8_lsx
LOAD_VAR 128
.LOOP_PIXELS32:
HEVC_PEL_UNI_W_PIXELS16_LSX a2, a0
addi.d t0, a2, 16
addi.d t1, a0, 16
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS32
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels32_8_lasx
LOAD_VAR 256
.LOOP_PIXELS32_LASX:
HEVC_PEL_UNI_W_PIXELS32_LASX a2, a0, 32
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS32_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels48_8_lsx
LOAD_VAR 128
.LOOP_PIXELS48:
HEVC_PEL_UNI_W_PIXELS16_LSX a2, a0
addi.d t0, a2, 16
addi.d t1, a0, 16
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
addi.d t0, a2, 32
addi.d t1, a0, 32
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS48
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels48_8_lasx
LOAD_VAR 256
.LOOP_PIXELS48_LASX:
HEVC_PEL_UNI_W_PIXELS32_LASX a2, a0, 32
addi.d t0, a2, 32
addi.d t1, a0, 32
HEVC_PEL_UNI_W_PIXELS16_LASX t0, t1
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS48_LASX
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels64_8_lsx
LOAD_VAR 128
.LOOP_PIXELS64:
HEVC_PEL_UNI_W_PIXELS16_LSX a2, a0
addi.d t0, a2, 16
addi.d t1, a0, 16
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
addi.d t0, a2, 32
addi.d t1, a0, 32
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
addi.d t0, a2, 48
addi.d t1, a0, 48
HEVC_PEL_UNI_W_PIXELS16_LSX t0, t1
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS64
endfunc
function ff_hevc_put_hevc_pel_uni_w_pixels64_8_lasx
LOAD_VAR 256
.LOOP_PIXELS64_LASX:
HEVC_PEL_UNI_W_PIXELS32_LASX a2, a0, 32
addi.d t0, a2, 32
addi.d t1, a0, 32
HEVC_PEL_UNI_W_PIXELS32_LASX t0, t1, 32
add.d a2, a2, a3
add.d a0, a0, a1
addi.w a4, a4, -1
bnez a4, .LOOP_PIXELS64_LASX
endfunc
.macro vhaddw.d.h in0
vhaddw.w.h \in0, \in0, \in0
vhaddw.d.w \in0, \in0, \in0
.endm
.macro xvhaddw.d.h in0
xvhaddw.w.h \in0, \in0, \in0
xvhaddw.d.w \in0, \in0, \in0
.endm
/*
* void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_qpel_uni_w_v4_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
fld.s f6, a2, 0 //0
fldx.s f7, a2, a3 //1
fldx.s f8, a2, t0 //2
add.d a2, a2, t1
fld.s f9, a2, 0 //3
fldx.s f10, a2, a3 //4
fldx.s f11, a2, t0 //5
fldx.s f12, a2, t1 //6
add.d a2, a2, t2
vilvl.b vr6, vr7, vr6
vilvl.b vr7, vr9, vr8
vilvl.b vr8, vr11, vr10
vilvl.b vr9, vr13, vr12
vilvl.h vr6, vr7, vr6
vilvl.h vr7, vr9, vr8
vilvl.w vr8, vr7, vr6
vilvh.w vr9, vr7, vr6
.LOOP_V4:
fld.s f13, a2, 0 //7
fldx.s f14, a2, a3 //8 next loop
add.d a2, a2, t0
vextrins.b vr8, vr13, 0x70
vextrins.b vr8, vr13, 0xf1
vextrins.b vr9, vr13, 0x72
vextrins.b vr9, vr13, 0xf3
vbsrl.v vr10, vr8, 1
vbsrl.v vr11, vr9, 1
vextrins.b vr10, vr14, 0x70
vextrins.b vr10, vr14, 0xf1
vextrins.b vr11, vr14, 0x72
vextrins.b vr11, vr14, 0xf3
vdp2.h.bu.b vr6, vr8, vr5 //QPEL_FILTER(src, stride)
vdp2.h.bu.b vr7, vr9, vr5
vdp2.h.bu.b vr12, vr10, vr5
vdp2.h.bu.b vr13, vr11, vr5
vbsrl.v vr8, vr10, 1
vbsrl.v vr9, vr11, 1
vhaddw.d.h vr6
vhaddw.d.h vr7
vhaddw.d.h vr12
vhaddw.d.h vr13
vpickev.w vr6, vr7, vr6
vpickev.w vr12, vr13, vr12
vmulwev.w.h vr6, vr6, vr1 //QPEL_FILTER(src, stride) * wx
vmulwev.w.h vr12, vr12, vr1
vadd.w vr6, vr6, vr2
vsra.w vr6, vr6, vr3
vadd.w vr6, vr6, vr4
vadd.w vr12, vr12, vr2
vsra.w vr12, vr12, vr3
vadd.w vr12, vr12, vr4
vssrani.h.w vr12, vr6, 0
vssrani.bu.h vr12, vr12, 0
fst.s f12, a0, 0
add.d a0, a0, a1
vstelm.w vr12, a0, 0, 1
add.d a0, a0, a1
addi.d a4, a4, -2
bnez a4, .LOOP_V4
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v6_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
fld.d f6, a2, 0
fldx.d f7, a2, a3
fldx.d f8, a2, t0
add.d a2, a2, t1
fld.d f9, a2, 0
fldx.d f10, a2, a3
fldx.d f11, a2, t0
fldx.d f12, a2, t1
add.d a2, a2, t2
vilvl.b vr6, vr7, vr6 //transpose 8x6 to 3x16
vilvl.b vr7, vr9, vr8
vilvl.b vr8, vr11, vr10
vilvl.b vr9, vr13, vr12
vilvl.h vr10, vr7, vr6
vilvh.h vr11, vr7, vr6
vilvl.h vr12, vr9, vr8
vilvh.h vr13, vr9, vr8
vilvl.w vr6, vr12, vr10
vilvh.w vr7, vr12, vr10
vilvl.w vr8, vr13, vr11
.LOOP_V6:
fld.d f13, a2, 0
add.d a2, a2, a3
vextrins.b vr6, vr13, 0x70
vextrins.b vr6, vr13, 0xf1
vextrins.b vr7, vr13, 0x72
vextrins.b vr7, vr13, 0xf3
vextrins.b vr8, vr13, 0x74
vextrins.b vr8, vr13, 0xf5
vdp2.h.bu.b vr10, vr6, vr5 //QPEL_FILTER(src, stride)
vdp2.h.bu.b vr11, vr7, vr5
vdp2.h.bu.b vr12, vr8, vr5
vbsrl.v vr6, vr6, 1
vbsrl.v vr7, vr7, 1
vbsrl.v vr8, vr8, 1
vhaddw.d.h vr10
vhaddw.d.h vr11
vhaddw.d.h vr12
vpickev.w vr10, vr11, vr10
vpickev.w vr11, vr13, vr12
vmulwev.w.h vr10, vr10, vr1 //QPEL_FILTER(src, stride) * wx
vmulwev.w.h vr11, vr11, vr1
vadd.w vr10, vr10, vr2
vadd.w vr11, vr11, vr2
vsra.w vr10, vr10, vr3
vsra.w vr11, vr11, vr3
vadd.w vr10, vr10, vr4
vadd.w vr11, vr11, vr4
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.s f11, a0, 0
vstelm.h vr11, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_V6
endfunc
// transpose 8x8b to 4x16b
.macro TRANSPOSE8X8B_LSX in0, in1, in2, in3, in4, in5, in6, in7, \
out0, out1, out2, out3
vilvl.b \in0, \in1, \in0
vilvl.b \in1, \in3, \in2
vilvl.b \in2, \in5, \in4
vilvl.b \in3, \in7, \in6
vilvl.h \in4, \in1, \in0
vilvh.h \in5, \in1, \in0
vilvl.h \in6, \in3, \in2
vilvh.h \in7, \in3, \in2
vilvl.w \out0, \in6, \in4
vilvh.w \out1, \in6, \in4
vilvl.w \out2, \in7, \in5
vilvh.w \out3, \in7, \in5
.endm
.macro PUT_HEVC_QPEL_UNI_W_V8_LSX in0, in1, in2, in3, out0, out1, pos
.if \pos == 0
vextrins.b \in0, vr13, 0x70 //insert the 8th load
vextrins.b \in0, vr13, 0xf1
vextrins.b \in1, vr13, 0x72
vextrins.b \in1, vr13, 0xf3
vextrins.b \in2, vr13, 0x74
vextrins.b \in2, vr13, 0xf5
vextrins.b \in3, vr13, 0x76
vextrins.b \in3, vr13, 0xf7
.else// \pos == 8
vextrins.b \in0, vr13, 0x78
vextrins.b \in0, vr13, 0xf9
vextrins.b \in1, vr13, 0x7a
vextrins.b \in1, vr13, 0xfb
vextrins.b \in2, vr13, 0x7c
vextrins.b \in2, vr13, 0xfd
vextrins.b \in3, vr13, 0x7e
vextrins.b \in3, vr13, 0xff
.endif
vdp2.h.bu.b \out0, \in0, vr5 //QPEL_FILTER(src, stride)
vdp2.h.bu.b \out1, \in1, vr5
vdp2.h.bu.b vr12, \in2, vr5
vdp2.h.bu.b vr20, \in3, vr5
vbsrl.v \in0, \in0, 1 //Back up previous 7 loaded datas,
vbsrl.v \in1, \in1, 1 //so just need to insert the 8th
vbsrl.v \in2, \in2, 1 //load in the next loop.
vbsrl.v \in3, \in3, 1
vhaddw.d.h \out0
vhaddw.d.h \out1
vhaddw.d.h vr12
vhaddw.d.h vr20
vpickev.w \out0, \out1, \out0
vpickev.w \out1, vr20, vr12
vmulwev.w.h \out0, \out0, vr1 //QPEL_FILTER(src, stride) * wx
vmulwev.w.h \out1, \out1, vr1
vadd.w \out0, \out0, vr2
vadd.w \out1, \out1, vr2
vsra.w \out0, \out0, vr3
vsra.w \out1, \out1, vr3
vadd.w \out0, \out0, vr4
vadd.w \out1, \out1, vr4
.endm
function ff_hevc_put_hevc_qpel_uni_w_v8_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
fld.d f6, a2, 0
fldx.d f7, a2, a3
fldx.d f8, a2, t0
add.d a2, a2, t1
fld.d f9, a2, 0
fldx.d f10, a2, a3
fldx.d f11, a2, t0
fldx.d f12, a2, t1
add.d a2, a2, t2
TRANSPOSE8X8B_LSX vr6, vr7, vr8, vr9, vr10, vr11, vr12, vr13, \
vr6, vr7, vr8, vr9
.LOOP_V8:
fld.d f13, a2, 0 //the 8th load
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_V8_LSX vr6, vr7, vr8, vr9, vr10, vr11, 0
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.d f11, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_V8
endfunc
.macro PUT_HEVC_UNI_W_V8_LASX w
fld.d f6, a2, 0
fldx.d f7, a2, a3
fldx.d f8, a2, t0
add.d a2, a2, t1
fld.d f9, a2, 0
fldx.d f10, a2, a3
fldx.d f11, a2, t0
fldx.d f12, a2, t1
add.d a2, a2, t2
TRANSPOSE8X8B_LSX vr6, vr7, vr8, vr9, vr10, vr11, vr12, vr13, \
vr6, vr7, vr8, vr9
xvpermi.q xr6, xr7, 0x02
xvpermi.q xr8, xr9, 0x02
.LOOP_V8_LASX_\w:
fld.d f13, a2, 0 // 0 1 2 3 4 5 6 7 the 8th load
add.d a2, a2, a3
vshuf4i.h vr13, vr13, 0xd8
vbsrl.v vr14, vr13, 4
xvpermi.q xr13, xr14, 0x02 //0 1 4 5 * * * * 2 3 6 7 * * * *
xvextrins.b xr6, xr13, 0x70 //begin to insert the 8th load
xvextrins.b xr6, xr13, 0xf1
xvextrins.b xr8, xr13, 0x72
xvextrins.b xr8, xr13, 0xf3
xvdp2.h.bu.b xr20, xr6, xr5 //QPEL_FILTER(src, stride)
xvdp2.h.bu.b xr21, xr8, xr5
xvbsrl.v xr6, xr6, 1
xvbsrl.v xr8, xr8, 1
xvhaddw.d.h xr20
xvhaddw.d.h xr21
xvpickev.w xr20, xr21, xr20
xvpermi.d xr20, xr20, 0xd8
xvmulwev.w.h xr20, xr20, xr1 //QPEL_FILTER(src, stride) * wx
xvadd.w xr20, xr20, xr2
xvsra.w xr20, xr20, xr3
xvadd.w xr10, xr20, xr4
xvpermi.q xr11, xr10, 0x01
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.d f11, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_V8_LASX_\w
.endm
function ff_hevc_put_hevc_qpel_uni_w_v8_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
PUT_HEVC_UNI_W_V8_LASX 8
endfunc
.macro PUT_HEVC_QPEL_UNI_W_V16_LSX w
vld vr6, a2, 0
vldx vr7, a2, a3
vldx vr8, a2, t0
add.d a2, a2, t1
vld vr9, a2, 0
vldx vr10, a2, a3
vldx vr11, a2, t0
vldx vr12, a2, t1
add.d a2, a2, t2
.if \w > 8
vilvh.d vr14, vr14, vr6
vilvh.d vr15, vr15, vr7
vilvh.d vr16, vr16, vr8
vilvh.d vr17, vr17, vr9
vilvh.d vr18, vr18, vr10
vilvh.d vr19, vr19, vr11
vilvh.d vr20, vr20, vr12
.endif
TRANSPOSE8X8B_LSX vr6, vr7, vr8, vr9, vr10, vr11, vr12, vr13, \
vr6, vr7, vr8, vr9
.if \w > 8
TRANSPOSE8X8B_LSX vr14, vr15, vr16, vr17, vr18, vr19, vr20, vr21, \
vr14, vr15, vr16, vr17
.endif
.LOOP_HORI_16_\w:
vld vr13, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_V8_LSX vr6, vr7, vr8, vr9, vr10, vr11, 0
.if \w > 8
PUT_HEVC_QPEL_UNI_W_V8_LSX vr14, vr15, vr16, vr17, vr18, vr19, 8
.endif
vssrani.h.w vr11, vr10, 0
.if \w > 8
vssrani.h.w vr19, vr18, 0
vssrani.bu.h vr19, vr11, 0
.else
vssrani.bu.h vr11, vr11, 0
.endif
.if \w == 8
fst.d f11, a0, 0
.elseif \w == 12
fst.d f19, a0, 0
vstelm.w vr19, a0, 8, 2
.else
vst vr19, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HORI_16_\w
.endm
function ff_hevc_put_hevc_qpel_uni_w_v16_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
PUT_HEVC_QPEL_UNI_W_V16_LSX 16
endfunc
.macro PUT_HEVC_QPEL_UNI_W_V16_LASX w
vld vr6, a2, 0
vldx vr7, a2, a3
vldx vr8, a2, t0
add.d a2, a2, t1
vld vr9, a2, 0
vldx vr10, a2, a3
vldx vr11, a2, t0
vldx vr12, a2, t1
add.d a2, a2, t2
xvpermi.q xr6, xr10, 0x02 //pack and transpose the 8x16 to 4x32 begin
xvpermi.q xr7, xr11, 0x02
xvpermi.q xr8, xr12, 0x02
xvpermi.q xr9, xr13, 0x02
xvilvl.b xr14, xr7, xr6 //0 2
xvilvh.b xr15, xr7, xr6 //1 3
xvilvl.b xr16, xr9, xr8 //0 2
xvilvh.b xr17, xr9, xr8 //1 3
xvpermi.d xr14, xr14, 0xd8
xvpermi.d xr15, xr15, 0xd8
xvpermi.d xr16, xr16, 0xd8
xvpermi.d xr17, xr17, 0xd8
xvilvl.h xr6, xr16, xr14
xvilvh.h xr7, xr16, xr14
xvilvl.h xr8, xr17, xr15
xvilvh.h xr9, xr17, xr15
xvilvl.w xr14, xr7, xr6 //0 1 4 5
xvilvh.w xr15, xr7, xr6 //2 3 6 7
xvilvl.w xr16, xr9, xr8 //8 9 12 13
xvilvh.w xr17, xr9, xr8 //10 11 14 15 end
.LOOP_HORI_16_LASX_\w:
vld vr13, a2, 0 //the 8th load
add.d a2, a2, a3
vshuf4i.w vr13, vr13, 0xd8
vbsrl.v vr12, vr13, 8
xvpermi.q xr13, xr12, 0x02
xvextrins.b xr14, xr13, 0x70 //inset the 8th load
xvextrins.b xr14, xr13, 0xf1
xvextrins.b xr15, xr13, 0x72
xvextrins.b xr15, xr13, 0xf3
xvextrins.b xr16, xr13, 0x74
xvextrins.b xr16, xr13, 0xf5
xvextrins.b xr17, xr13, 0x76
xvextrins.b xr17, xr13, 0xf7
xvdp2.h.bu.b xr6, xr14, xr5 //QPEL_FILTER(src, stride)
xvdp2.h.bu.b xr7, xr15, xr5
xvdp2.h.bu.b xr8, xr16, xr5
xvdp2.h.bu.b xr9, xr17, xr5
xvhaddw.d.h xr6
xvhaddw.d.h xr7
xvhaddw.d.h xr8
xvhaddw.d.h xr9
xvbsrl.v xr14, xr14, 1 //Back up previous 7 loaded datas,
xvbsrl.v xr15, xr15, 1 //so just need to insert the 8th
xvbsrl.v xr16, xr16, 1 //load in next loop.
xvbsrl.v xr17, xr17, 1
xvpickev.w xr6, xr7, xr6 //0 1 2 3 4 5 6 7
xvpickev.w xr7, xr9, xr8 //8 9 10 11 12 13 14 15
xvmulwev.w.h xr6, xr6, xr1 //QPEL_FILTER(src, stride) * wx
xvmulwev.w.h xr7, xr7, xr1
xvadd.w xr6, xr6, xr2
xvadd.w xr7, xr7, xr2
xvsra.w xr6, xr6, xr3
xvsra.w xr7, xr7, xr3
xvadd.w xr6, xr6, xr4
xvadd.w xr7, xr7, xr4
xvssrani.h.w xr7, xr6, 0 //0 1 2 3 8 9 10 11 4 5 6 7 12 13 14 15
xvpermi.q xr6, xr7, 0x01
vssrani.bu.h vr6, vr7, 0
vshuf4i.w vr6, vr6, 0xd8
.if \w == 12
fst.d f6, a0, 0
vstelm.w vr6, a0, 8, 2
.else
vst vr6, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HORI_16_LASX_\w
.endm
function ff_hevc_put_hevc_qpel_uni_w_v16_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
PUT_HEVC_QPEL_UNI_W_V16_LASX 16
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v12_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
PUT_HEVC_QPEL_UNI_W_V16_LSX 12
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v12_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
PUT_HEVC_QPEL_UNI_W_V16_LASX 12
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v24_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
PUT_HEVC_QPEL_UNI_W_V16_LSX 24
addi.d a0, t4, 16
addi.d a2, t5, 16
addi.d a4, t6, 0
PUT_HEVC_QPEL_UNI_W_V16_LSX 8
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v24_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
PUT_HEVC_QPEL_UNI_W_V16_LASX 24
addi.d a0, t4, 16
addi.d a2, t5, 16
addi.d a4, t6, 0
PUT_HEVC_UNI_W_V8_LASX 24
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v32_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 2
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V32:
PUT_HEVC_QPEL_UNI_W_V16_LSX 32
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d a2, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V32
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v32_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 2
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V32_LASX:
PUT_HEVC_QPEL_UNI_W_V16_LASX 32
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d a2, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V32_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v48_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 3
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V48:
PUT_HEVC_QPEL_UNI_W_V16_LSX 48
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d t4, t4, 16
addi.d a2, t5, 16
addi.d t5, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V48
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v48_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 3
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V48_LASX:
PUT_HEVC_QPEL_UNI_W_V16_LASX 48
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d t4, t4, 16
addi.d a2, t5, 16
addi.d t5, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V48_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v64_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 4
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V64:
PUT_HEVC_QPEL_UNI_W_V16_LSX 64
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d t4, t4, 16
addi.d a2, t5, 16
addi.d t5, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V64
endfunc
function ff_hevc_put_hevc_qpel_uni_w_v64_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
add.d t2, t1, a3 //stride * 4
sub.d a2, a2, t1 //src -= stride*3
addi.d t3, zero, 4
addi.d t4, a0, 0 //save dst
addi.d t5, a2, 0 //save src
addi.d t6, a4, 0
.LOOP_V64_LASX:
PUT_HEVC_QPEL_UNI_W_V16_LASX 64
addi.d t3, t3, -1
addi.d a0, t4, 16
addi.d t4, t4, 16
addi.d a2, t5, 16
addi.d t5, t5, 16
addi.d a4, t6, 0
bnez t3, .LOOP_V64_LASX
endfunc
.macro PUT_HEVC_QPEL_UNI_W_H8_LSX in0, out0, out1
vbsrl.v vr7, \in0, 1
vbsrl.v vr8, \in0, 2
vbsrl.v vr9, \in0, 3
vbsrl.v vr10, \in0, 4
vbsrl.v vr11, \in0, 5
vbsrl.v vr12, \in0, 6
vbsrl.v vr13, \in0, 7
vilvl.d vr6, vr7, \in0
vilvl.d vr7, vr9, vr8
vilvl.d vr8, vr11, vr10
vilvl.d vr9, vr13, vr12
vdp2.h.bu.b vr10, vr6, vr5
vdp2.h.bu.b vr11, vr7, vr5
vdp2.h.bu.b vr12, vr8, vr5
vdp2.h.bu.b vr13, vr9, vr5
vhaddw.d.h vr10
vhaddw.d.h vr11
vhaddw.d.h vr12
vhaddw.d.h vr13
vpickev.w vr10, vr11, vr10
vpickev.w vr11, vr13, vr12
vmulwev.w.h vr10, vr10, vr1
vmulwev.w.h vr11, vr11, vr1
vadd.w vr10, vr10, vr2
vadd.w vr11, vr11, vr2
vsra.w vr10, vr10, vr3
vsra.w vr11, vr11, vr3
vadd.w \out0, vr10, vr4
vadd.w \out1, vr11, vr4
.endm
.macro PUT_HEVC_QPEL_UNI_W_H8_LASX in0, out0
xvbsrl.v xr7, \in0, 4
xvpermi.q xr7, \in0, 0x20
xvbsrl.v xr8, xr7, 1
xvbsrl.v xr9, xr7, 2
xvbsrl.v xr10, xr7, 3
xvpackev.d xr7, xr8, xr7
xvpackev.d xr8, xr10, xr9
xvdp2.h.bu.b xr10, xr7, xr5
xvdp2.h.bu.b xr11, xr8, xr5
xvhaddw.d.h xr10
xvhaddw.d.h xr11
xvpickev.w xr10, xr11, xr10
xvmulwev.w.h xr10, xr10, xr1
xvadd.w xr10, xr10, xr2
xvsra.w xr10, xr10, xr3
xvadd.w \out0, xr10, xr4
.endm
.macro PUT_HEVC_QPEL_UNI_W_H16_LASX in0, out0
xvpermi.d xr6, \in0, 0x94
xvbsrl.v xr7, xr6, 1
xvbsrl.v xr8, xr6, 2
xvbsrl.v xr9, xr6, 3
xvbsrl.v xr10, xr6, 4
xvbsrl.v xr11, xr6, 5
xvbsrl.v xr12, xr6, 6
xvbsrl.v xr13, xr6, 7
xvpackev.d xr6, xr7, xr6
xvpackev.d xr7, xr9, xr8
xvpackev.d xr8, xr11, xr10
xvpackev.d xr9, xr13, xr12
xvdp2.h.bu.b xr10, xr6, xr5
xvdp2.h.bu.b xr11, xr7, xr5
xvdp2.h.bu.b xr12, xr8, xr5
xvdp2.h.bu.b xr13, xr9, xr5
xvhaddw.d.h xr10
xvhaddw.d.h xr11
xvhaddw.d.h xr12
xvhaddw.d.h xr13
xvpickev.w xr10, xr11, xr10
xvpickev.w xr11, xr13, xr12
xvmulwev.w.h xr10, xr10, xr1
xvmulwev.w.h xr11, xr11, xr1
xvadd.w xr10, xr10, xr2
xvadd.w xr11, xr11, xr2
xvsra.w xr10, xr10, xr3
xvsra.w xr11, xr11, xr3
xvadd.w xr10, xr10, xr4
xvadd.w xr11, xr11, xr4
xvssrani.h.w xr11, xr10, 0
xvpermi.q \out0, xr11, 0x01
xvssrani.bu.h \out0, xr11, 0
.endm
/*
* void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_qpel_uni_w_h4_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H4:
vld vr18, a2, 0
vldx vr19, a2, a3
alsl.d a2, a3, a2, 1
vbsrl.v vr6, vr18, 1
vbsrl.v vr7, vr18, 2
vbsrl.v vr8, vr18, 3
vbsrl.v vr9, vr19, 1
vbsrl.v vr10, vr19, 2
vbsrl.v vr11, vr19, 3
vilvl.d vr6, vr6, vr18
vilvl.d vr7, vr8, vr7
vilvl.d vr8, vr9, vr19
vilvl.d vr9, vr11, vr10
vdp2.h.bu.b vr10, vr6, vr5
vdp2.h.bu.b vr11, vr7, vr5
vdp2.h.bu.b vr12, vr8, vr5
vdp2.h.bu.b vr13, vr9, vr5
vhaddw.d.h vr10
vhaddw.d.h vr11
vhaddw.d.h vr12
vhaddw.d.h vr13
vpickev.w vr10, vr11, vr10
vpickev.w vr11, vr13, vr12
vmulwev.w.h vr10, vr10, vr1
vmulwev.w.h vr11, vr11, vr1
vadd.w vr10, vr10, vr2
vadd.w vr11, vr11, vr2
vsra.w vr10, vr10, vr3
vsra.w vr11, vr11, vr3
vadd.w vr10, vr10, vr4
vadd.w vr11, vr11, vr4
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.s f11, a0, 0
vbsrl.v vr11, vr11, 4
fstx.s f11, a0, a1
alsl.d a0, a1, a0, 1
addi.d a4, a4, -2
bnez a4, .LOOP_H4
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h4_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H4_LASX:
vld vr18, a2, 0
vldx vr19, a2, a3
alsl.d a2, a3, a2, 1
xvpermi.q xr18, xr19, 0x02
xvbsrl.v xr6, xr18, 1
xvbsrl.v xr7, xr18, 2
xvbsrl.v xr8, xr18, 3
xvpackev.d xr6, xr6, xr18
xvpackev.d xr7, xr8, xr7
xvdp2.h.bu.b xr10, xr6, xr5
xvdp2.h.bu.b xr11, xr7, xr5
xvhaddw.d.h xr10
xvhaddw.d.h xr11
xvpickev.w xr10, xr11, xr10
xvmulwev.w.h xr10, xr10, xr1
xvadd.w xr10, xr10, xr2
xvsra.w xr10, xr10, xr3
xvadd.w xr10, xr10, xr4
xvpermi.q xr11, xr10, 0x01
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.s f11, a0, 0
vbsrl.v vr11, vr11, 4
fstx.s f11, a0, a1
alsl.d a0, a1, a0, 1
addi.d a4, a4, -2
bnez a4, .LOOP_H4_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h6_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H6:
vld vr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr10, vr11
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.s f11, a0, 0
vstelm.h vr11, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H6
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h6_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H6_LASX:
vld vr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LASX xr6, xr10
xvpermi.q xr11, xr10, 0x01
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.s f11, a0, 0
vstelm.h vr11, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H6_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h8_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H8:
vld vr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr10, vr11
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.d f11, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H8
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h8_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H8_LASX:
vld vr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LASX xr6, xr10
xvpermi.q xr11, xr10, 0x01
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr11, vr11, 0
fst.d f11, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H8_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h12_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H12:
vld vr6, a2, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr14, vr15
vld vr6, a2, 8
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr16, vr17
add.d a2, a2, a3
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
fst.d f17, a0, 0
vbsrl.v vr17, vr17, 8
fst.s f17, a0, 8
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H12
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h12_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H12_LASX:
xvld xr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr6, xr14
fst.d f14, a0, 0
vstelm.w vr14, a0, 8, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H12_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h16_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H16:
vld vr6, a2, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr14, vr15
vld vr6, a2, 8
PUT_HEVC_QPEL_UNI_W_H8_LSX vr6, vr16, vr17
add.d a2, a2, a3
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H16
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h16_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H16_LASX:
xvld xr6, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr6, xr10
vst vr10, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H16_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h24_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H24:
vld vr18, a2, 0
vld vr19, a2, 16
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr14, vr15
vshuf4i.d vr18, vr19, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr14, vr15
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.d f15, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H24
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h24_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H24_LASX:
xvld xr18, a2, 0
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr20
xvpermi.q xr19, xr18, 0x01
vst vr20, a0, 0
PUT_HEVC_QPEL_UNI_W_H8_LASX xr19, xr20
xvpermi.q xr21, xr20, 0x01
vssrani.h.w vr21, vr20, 0
vssrani.bu.h vr21, vr21, 0
fst.d f21, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H24_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h32_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H32:
vld vr18, a2, 0
vld vr19, a2, 16
vld vr20, a2, 32
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr14, vr15
vshuf4i.d vr18, vr19, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr14, vr15
vshuf4i.d vr19, vr20, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H32
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h32_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H32_LASX:
xvld xr18, a2, 0
xvld xr19, a2, 16
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr20
PUT_HEVC_QPEL_UNI_W_H16_LASX xr19, xr21
xvpermi.q xr20, xr21, 0x02
xvst xr20, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H32_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h48_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H48:
vld vr18, a2, 0
vld vr19, a2, 16
vld vr20, a2, 32
vld vr21, a2, 48
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr14, vr15
vshuf4i.d vr18, vr19, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr14, vr15
vshuf4i.d vr19, vr20, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 16
PUT_HEVC_QPEL_UNI_W_H8_LSX vr20, vr14, vr15
vshuf4i.d vr20, vr21, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr20, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H48
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h48_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H48_LASX:
xvld xr18, a2, 0
xvld xr19, a2, 32
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr20
xvpermi.q xr18, xr19, 0x03
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr21
xvpermi.q xr20, xr21, 0x02
xvst xr20, a0, 0
PUT_HEVC_QPEL_UNI_W_H16_LASX xr19, xr20
vst vr20, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H48_LASX
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h64_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
.LOOP_H64:
vld vr18, a2, 0
vld vr19, a2, 16
vld vr20, a2, 32
vld vr21, a2, 48
vld vr22, a2, 64
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr14, vr15
vshuf4i.d vr18, vr19, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr18, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 0
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr14, vr15
vshuf4i.d vr19, vr20, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr19, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 16
PUT_HEVC_QPEL_UNI_W_H8_LSX vr20, vr14, vr15
vshuf4i.d vr20, vr21, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr20, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 32
PUT_HEVC_QPEL_UNI_W_H8_LSX vr21, vr14, vr15
vshuf4i.d vr21, vr22, 0x09
PUT_HEVC_QPEL_UNI_W_H8_LSX vr21, vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, 48
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H64
endfunc
function ff_hevc_put_hevc_qpel_uni_w_h64_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
xvreplve0.q xr5, xr5
addi.d a2, a2, -3 //src -= 3
.LOOP_H64_LASX:
xvld xr18, a2, 0
xvld xr19, a2, 32
xvld xr20, a2, 64
add.d a2, a2, a3
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr21
xvpermi.q xr18, xr19, 0x03
PUT_HEVC_QPEL_UNI_W_H16_LASX xr18, xr22
xvpermi.q xr21, xr22, 0x02
xvst xr21, a0, 0
PUT_HEVC_QPEL_UNI_W_H16_LASX xr19, xr21
xvpermi.q xr19, xr20, 0x03
PUT_HEVC_QPEL_UNI_W_H16_LASX xr19, xr22
xvpermi.q xr21, xr22, 0x02
xvst xr21, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_H64_LASX
endfunc
const shufb
.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6 //mask for epel_uni_w(128-bit)
.byte 4,5,6,7, 5,6,7,8 ,6,7,8,9, 7,8,9,10 //mask for epel_uni_w(256-bit)
.byte 0,1,2,3, 4,5,6,7 ,1,2,3,4, 5,6,7,8 //mask for qpel_uni_h4
.byte 0,1,1,2, 2,3,3,4 ,4,5,5,6, 6,7,7,8 //mask for qpel_uni_h/v6/8...
.byte 0,1,2,3, 1,2,3,4 ,2,3,4,5, 3,4,5,6, 4,5,6,7, 5,6,7,8, 6,7,8,9, 7,8,9,10 //epel_uni_w_h16/24/32/48/64
.byte 0,1,1,2, 2,3,3,4 ,4,5,5,6, 6,7,7,8, 0,1,1,2, 2,3,3,4 ,4,5,5,6, 6,7,7,8 //mask for bi_epel_h16/24/32/48/64
endconst
.macro PUT_HEVC_EPEL_UNI_W_HV4_LSX w
fld.d f7, a2, 0 // start to load src
fldx.d f8, a2, a3
alsl.d a2, a3, a2, 1
fld.d f9, a2, 0
vshuf.b vr7, vr7, vr7, vr0 // 0123 1234 2345 3456
vshuf.b vr8, vr8, vr8, vr0
vshuf.b vr9, vr9, vr9, vr0
vdp2.h.bu.b vr10, vr7, vr5 // EPEL_FILTER(src, 1)
vdp2.h.bu.b vr11, vr8, vr5
vdp2.h.bu.b vr12, vr9, vr5
vhaddw.w.h vr10, vr10, vr10 // tmp[0/1/2/3]
vhaddw.w.h vr11, vr11, vr11 // vr10,vr11,vr12 corresponding to EPEL_EXTRA
vhaddw.w.h vr12, vr12, vr12
.LOOP_HV4_\w:
add.d a2, a2, a3
fld.d f14, a2, 0 // height loop begin
vshuf.b vr14, vr14, vr14, vr0
vdp2.h.bu.b vr13, vr14, vr5
vhaddw.w.h vr13, vr13, vr13
vmul.w vr14, vr10, vr16 // EPEL_FILTER(tmp, MAX_PB_SIZE)
vmadd.w vr14, vr11, vr17
vmadd.w vr14, vr12, vr18
vmadd.w vr14, vr13, vr19
vaddi.wu vr10, vr11, 0 //back up previous value
vaddi.wu vr11, vr12, 0
vaddi.wu vr12, vr13, 0
vsrai.w vr14, vr14, 6 // >> 6
vmul.w vr14, vr14, vr1 // * wx
vadd.w vr14, vr14, vr2 // + offset
vsra.w vr14, vr14, vr3 // >> shift
vadd.w vr14, vr14, vr4 // + ox
vssrani.h.w vr14, vr14, 0
vssrani.bu.h vr14, vr14, 0 // clip
fst.s f14, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HV4_\w
.endm
/*
* void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_epel_uni_w_hv4_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV4_LSX 4
endfunc
.macro PUT_HEVC_EPEL_UNI_W_HV8_LSX w
vld vr7, a2, 0 // start to load src
vldx vr8, a2, a3
alsl.d a2, a3, a2, 1
vld vr9, a2, 0
vshuf.b vr10, vr7, vr7, vr0 // 0123 1234 2345 3456
vshuf.b vr11, vr8, vr8, vr0
vshuf.b vr12, vr9, vr9, vr0
vshuf.b vr7, vr7, vr7, vr22// 4567 5678 6789 78910
vshuf.b vr8, vr8, vr8, vr22
vshuf.b vr9, vr9, vr9, vr22
vdp2.h.bu.b vr13, vr10, vr5 // EPEL_FILTER(src, 1)
vdp2.h.bu.b vr14, vr11, vr5
vdp2.h.bu.b vr15, vr12, vr5
vdp2.h.bu.b vr23, vr7, vr5
vdp2.h.bu.b vr20, vr8, vr5
vdp2.h.bu.b vr21, vr9, vr5
vhaddw.w.h vr7, vr13, vr13
vhaddw.w.h vr8, vr14, vr14
vhaddw.w.h vr9, vr15, vr15
vhaddw.w.h vr10, vr23, vr23
vhaddw.w.h vr11, vr20, vr20
vhaddw.w.h vr12, vr21, vr21
.LOOP_HV8_HORI_\w:
add.d a2, a2, a3
vld vr15, a2, 0
vshuf.b vr23, vr15, vr15, vr0
vshuf.b vr15, vr15, vr15, vr22
vdp2.h.bu.b vr13, vr23, vr5
vdp2.h.bu.b vr14, vr15, vr5
vhaddw.w.h vr13, vr13, vr13 //789--13
vhaddw.w.h vr14, vr14, vr14 //101112--14
vmul.w vr15, vr7, vr16 //EPEL_FILTER(tmp, MAX_PB_SIZE)
vmadd.w vr15, vr8, vr17
vmadd.w vr15, vr9, vr18
vmadd.w vr15, vr13, vr19
vmul.w vr20, vr10, vr16
vmadd.w vr20, vr11, vr17
vmadd.w vr20, vr12, vr18
vmadd.w vr20, vr14, vr19
vaddi.wu vr7, vr8, 0 //back up previous value
vaddi.wu vr8, vr9, 0
vaddi.wu vr9, vr13, 0
vaddi.wu vr10, vr11, 0
vaddi.wu vr11, vr12, 0
vaddi.wu vr12, vr14, 0
vsrai.w vr15, vr15, 6 // >> 6
vsrai.w vr20, vr20, 6
vmul.w vr15, vr15, vr1 // * wx
vmul.w vr20, vr20, vr1
vadd.w vr15, vr15, vr2 // + offset
vadd.w vr20, vr20, vr2
vsra.w vr15, vr15, vr3 // >> shift
vsra.w vr20, vr20, vr3
vadd.w vr15, vr15, vr4 // + ox
vadd.w vr20, vr20, vr4
vssrani.h.w vr20, vr15, 0
vssrani.bu.h vr20, vr20, 0
.if \w > 6
fst.d f20, a0, 0
.else
fst.s f20, a0, 0
vstelm.h vr20, a0, 4, 2
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HV8_HORI_\w
.endm
.macro PUT_HEVC_EPEL_UNI_W_HV8_LASX w
vld vr7, a2, 0 // start to load src
vldx vr8, a2, a3
alsl.d a2, a3, a2, 1
vld vr9, a2, 0
xvreplve0.q xr7, xr7
xvreplve0.q xr8, xr8
xvreplve0.q xr9, xr9
xvshuf.b xr10, xr7, xr7, xr0 // 0123 1234 2345 3456
xvshuf.b xr11, xr8, xr8, xr0
xvshuf.b xr12, xr9, xr9, xr0
xvdp2.h.bu.b xr13, xr10, xr5 // EPEL_FILTER(src, 1)
xvdp2.h.bu.b xr14, xr11, xr5
xvdp2.h.bu.b xr15, xr12, xr5
xvhaddw.w.h xr7, xr13, xr13
xvhaddw.w.h xr8, xr14, xr14
xvhaddw.w.h xr9, xr15, xr15
.LOOP_HV8_HORI_LASX_\w:
add.d a2, a2, a3
vld vr15, a2, 0
xvreplve0.q xr15, xr15
xvshuf.b xr23, xr15, xr15, xr0
xvdp2.h.bu.b xr10, xr23, xr5
xvhaddw.w.h xr10, xr10, xr10
xvmul.w xr15, xr7, xr16 //EPEL_FILTER(tmp, MAX_PB_SIZE)
xvmadd.w xr15, xr8, xr17
xvmadd.w xr15, xr9, xr18
xvmadd.w xr15, xr10, xr19
xvaddi.wu xr7, xr8, 0 //back up previous value
xvaddi.wu xr8, xr9, 0
xvaddi.wu xr9, xr10, 0
xvsrai.w xr15, xr15, 6 // >> 6
xvmul.w xr15, xr15, xr1 // * wx
xvadd.w xr15, xr15, xr2 // + offset
xvsra.w xr15, xr15, xr3 // >> shift
xvadd.w xr15, xr15, xr4 // + ox
xvpermi.q xr20, xr15, 0x01
vssrani.h.w vr20, vr15, 0
vssrani.bu.h vr20, vr20, 0
.if \w > 6
fst.d f20, a0, 0
.else
fst.s f20, a0, 0
vstelm.h vr20, a0, 4, 2
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HV8_HORI_LASX_\w
.endm
.macro PUT_HEVC_EPEL_UNI_W_HV16_LASX w
xvld xr7, a2, 0 // start to load src
xvldx xr8, a2, a3
alsl.d a2, a3, a2, 1
xvld xr9, a2, 0
xvpermi.d xr10, xr7, 0x09 //8..18
xvpermi.d xr11, xr8, 0x09
xvpermi.d xr12, xr9, 0x09
xvreplve0.q xr7, xr7
xvreplve0.q xr8, xr8
xvreplve0.q xr9, xr9
xvshuf.b xr13, xr7, xr7, xr0 // 0123 1234 2345 3456
xvshuf.b xr14, xr8, xr8, xr0
xvshuf.b xr15, xr9, xr9, xr0
xvdp2.h.bu.b xr20, xr13, xr5 // EPEL_FILTER(src, 1)
xvdp2.h.bu.b xr21, xr14, xr5
xvdp2.h.bu.b xr22, xr15, xr5
xvhaddw.w.h xr7, xr20, xr20
xvhaddw.w.h xr8, xr21, xr21
xvhaddw.w.h xr9, xr22, xr22
xvreplve0.q xr10, xr10
xvreplve0.q xr11, xr11
xvreplve0.q xr12, xr12
xvshuf.b xr13, xr10, xr10, xr0
xvshuf.b xr14, xr11, xr11, xr0
xvshuf.b xr15, xr12, xr12, xr0
xvdp2.h.bu.b xr20, xr13, xr5
xvdp2.h.bu.b xr21, xr14, xr5
xvdp2.h.bu.b xr22, xr15, xr5
xvhaddw.w.h xr10, xr20, xr20
xvhaddw.w.h xr11, xr21, xr21
xvhaddw.w.h xr12, xr22, xr22
.LOOP_HV16_HORI_LASX_\w:
add.d a2, a2, a3
xvld xr15, a2, 0
xvpermi.d xr20, xr15, 0x09 //8...18
xvreplve0.q xr15, xr15
xvreplve0.q xr20, xr20
xvshuf.b xr21, xr15, xr15, xr0
xvshuf.b xr22, xr20, xr20, xr0
xvdp2.h.bu.b xr13, xr21, xr5
xvdp2.h.bu.b xr14, xr22, xr5
xvhaddw.w.h xr13, xr13, xr13
xvhaddw.w.h xr14, xr14, xr14
xvmul.w xr15, xr7, xr16 //EPEL_FILTER(tmp, MAX_PB_SIZE)
xvmadd.w xr15, xr8, xr17
xvmadd.w xr15, xr9, xr18
xvmadd.w xr15, xr13, xr19
xvmul.w xr20, xr10, xr16
xvmadd.w xr20, xr11, xr17
xvmadd.w xr20, xr12, xr18
xvmadd.w xr20, xr14, xr19
xvaddi.wu xr7, xr8, 0 //back up previous value
xvaddi.wu xr8, xr9, 0
xvaddi.wu xr9, xr13, 0
xvaddi.wu xr10, xr11, 0
xvaddi.wu xr11, xr12, 0
xvaddi.wu xr12, xr14, 0
xvsrai.w xr15, xr15, 6 // >> 6
xvsrai.w xr20, xr20, 6 // >> 6
xvmul.w xr15, xr15, xr1 // * wx
xvmul.w xr20, xr20, xr1 // * wx
xvadd.w xr15, xr15, xr2 // + offset
xvadd.w xr20, xr20, xr2 // + offset
xvsra.w xr15, xr15, xr3 // >> shift
xvsra.w xr20, xr20, xr3 // >> shift
xvadd.w xr15, xr15, xr4 // + ox
xvadd.w xr20, xr20, xr4 // + ox
xvssrani.h.w xr20, xr15, 0
xvpermi.q xr21, xr20, 0x01
vssrani.bu.h vr21, vr20, 0
vpermi.w vr21, vr21, 0xd8
.if \w < 16
fst.d f21, a0, 0
vstelm.w vr21, a0, 8, 2
.else
vst vr21, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_HV16_HORI_LASX_\w
.endm
function ff_hevc_put_hevc_epel_uni_w_hv6_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV8_LSX 6
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv6_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV8_LASX 6
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv8_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV8_LSX 8
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv8_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV8_LASX 8
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv12_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_HV8_LSX 12
addi.d a0, t2, 8
addi.d a2, t3, 8
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_HV4_LSX 12
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv12_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV16_LASX 12
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv16_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 2
.LOOP_HV16:
PUT_HEVC_EPEL_UNI_W_HV8_LSX 16
addi.d a0, t2, 8
addi.d a2, t3, 8
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV16
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv16_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
PUT_HEVC_EPEL_UNI_W_HV16_LASX 16
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv24_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 3
.LOOP_HV24:
PUT_HEVC_EPEL_UNI_W_HV8_LSX 24
addi.d a0, t2, 8
addi.d t2, t2, 8
addi.d a2, t3, 8
addi.d t3, t3, 8
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV24
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv24_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_HV16_LASX 24
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_HV8_LASX 24
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv32_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 4
.LOOP_HV32:
PUT_HEVC_EPEL_UNI_W_HV8_LSX 32
addi.d a0, t2, 8
addi.d t2, t2, 8
addi.d a2, t3, 8
addi.d t3, t3, 8
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV32
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv32_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 2
.LOOP_HV32_LASX:
PUT_HEVC_EPEL_UNI_W_HV16_LASX 32
addi.d a0, t2, 16
addi.d t2, t2, 16
addi.d a2, t3, 16
addi.d t3, t3, 16
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV32_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv48_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 6
.LOOP_HV48:
PUT_HEVC_EPEL_UNI_W_HV8_LSX 48
addi.d a0, t2, 8
addi.d t2, t2, 8
addi.d a2, t3, 8
addi.d t3, t3, 8
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV48
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv48_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 3
.LOOP_HV48_LASX:
PUT_HEVC_EPEL_UNI_W_HV16_LASX 48
addi.d a0, t2, 16
addi.d t2, t2, 16
addi.d a2, t3, 16
addi.d t3, t3, 16
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV48_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv64_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
vreplvei.w vr5, vr5, 0
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
vreplvei.w vr16, vr6, 0
vreplvei.w vr17, vr6, 1
vreplvei.w vr18, vr6, 2
vreplvei.w vr19, vr6, 3
la.local t1, shufb
vld vr0, t1, 0
vaddi.bu vr22, vr0, 4 // update shufb to get high part
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 8
.LOOP_HV64:
PUT_HEVC_EPEL_UNI_W_HV8_LSX 64
addi.d a0, t2, 8
addi.d t2, t2, 8
addi.d a2, t3, 8
addi.d t3, t3, 8
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV64
endfunc
function ff_hevc_put_hevc_epel_uni_w_hv64_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 // mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr5, t1, t0 // ff_hevc_epel_filters[mx];
xvreplve0.w xr5, xr5
ld.d t0, sp, 8 // my
slli.w t0, t0, 2
vldx vr6, t1, t0 // ff_hevc_epel_filters[my];
vsllwil.h.b vr6, vr6, 0
vsllwil.w.h vr6, vr6, 0
xvreplve0.q xr6, xr6
xvrepl128vei.w xr16, xr6, 0
xvrepl128vei.w xr17, xr6, 1
xvrepl128vei.w xr18, xr6, 2
xvrepl128vei.w xr19, xr6, 3
la.local t1, shufb
xvld xr0, t1, 0
sub.d a2, a2, a3 // src -= srcstride
addi.d a2, a2, -1
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
addi.d t5, zero, 4
.LOOP_HV64_LASX:
PUT_HEVC_EPEL_UNI_W_HV16_LASX 64
addi.d a0, t2, 16
addi.d t2, t2, 16
addi.d a2, t3, 16
addi.d t3, t3, 16
addi.d a4, t4, 0
addi.d t5, t5, -1
bnez t5, .LOOP_HV64_LASX
endfunc
/*
* void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, intptr_t mx, intptr_t my,
* int width)
*/
function ff_hevc_put_hevc_uni_qpel_h4_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr5, t1, t0 //filter
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr1, t1
la.local t1, shufb
vld vr2, t1, 32 //mask0 0 1
vaddi.bu vr3, vr2, 2 //mask1 2 3
.LOOP_UNI_H4:
vld vr18, a2, 0
vldx vr19, a2, a3
alsl.d a2, a3, a2, 1
vshuf.b vr6, vr18, vr18, vr2
vshuf.b vr7, vr18, vr18, vr3
vshuf.b vr8, vr19, vr19, vr2
vshuf.b vr9, vr19, vr19, vr3
vdp2.h.bu.b vr10, vr6, vr5
vdp2.h.bu.b vr11, vr7, vr5
vdp2.h.bu.b vr12, vr8, vr5
vdp2.h.bu.b vr13, vr9, vr5
vhaddw.d.h vr10
vhaddw.d.h vr11
vhaddw.d.h vr12
vhaddw.d.h vr13
vpickev.w vr10, vr11, vr10
vpickev.w vr11, vr13, vr12
vpickev.h vr10, vr11, vr10
vadd.h vr10, vr10, vr1
vsrai.h vr10, vr10, 6
vssrani.bu.h vr10, vr10, 0
fst.s f10, a0, 0
vbsrl.v vr10, vr10, 4
fstx.s f10, a0, a1
alsl.d a0, a1, a0, 1
addi.d a4, a4, -2
bnez a4, .LOOP_UNI_H4
endfunc
.macro HEVC_UNI_QPEL_H8_LSX in0, out0
vshuf.b vr10, \in0, \in0, vr5
vshuf.b vr11, \in0, \in0, vr6
vshuf.b vr12, \in0, \in0, vr7
vshuf.b vr13, \in0, \in0, vr8
vdp2.h.bu.b \out0, vr10, vr0 //(QPEL_FILTER(src, 1)
vdp2add.h.bu.b \out0, vr11, vr1
vdp2add.h.bu.b \out0, vr12, vr2
vdp2add.h.bu.b \out0, vr13, vr3
vadd.h \out0, \out0, vr4
vsrai.h \out0, \out0, 6
.endm
.macro HEVC_UNI_QPEL_H16_LASX in0, out0
xvshuf.b xr10, \in0, \in0, xr5
xvshuf.b xr11, \in0, \in0, xr6
xvshuf.b xr12, \in0, \in0, xr7
xvshuf.b xr13, \in0, \in0, xr8
xvdp2.h.bu.b \out0, xr10, xr0 //(QPEL_FILTER(src, 1)
xvdp2add.h.bu.b \out0, xr11, xr1
xvdp2add.h.bu.b \out0, xr12, xr2
xvdp2add.h.bu.b \out0, xr13, xr3
xvadd.h \out0, \out0, xr4
xvsrai.h \out0, \out0, 6
.endm
function ff_hevc_put_hevc_uni_qpel_h6_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H6:
vld vr9, a2, 0
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vssrani.bu.h vr14, vr14, 0
fst.s f14, a0, 0
vstelm.h vr14, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H6
endfunc
function ff_hevc_put_hevc_uni_qpel_h8_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H8:
vld vr9, a2, 0
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vssrani.bu.h vr14, vr14, 0
fst.d f14, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H8
endfunc
function ff_hevc_put_hevc_uni_qpel_h12_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H12:
vld vr9, a2, 0
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vld vr9, a2, 8
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr15
vssrani.bu.h vr15, vr14, 0
fst.d f15, a0, 0
vstelm.w vr15, a0, 8, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H12
endfunc
function ff_hevc_put_hevc_uni_qpel_h12_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H12_LASX:
xvld xr9, a2, 0
add.d a2, a2, a3
xvpermi.d xr9, xr9, 0x94 //rearrange data
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvpermi.q xr15, xr14, 0x01
vssrani.bu.h vr15, vr14, 0
fst.d f15, a0, 0
vstelm.w vr15, a0, 8, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H12_LASX
endfunc
function ff_hevc_put_hevc_uni_qpel_h16_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H16:
vld vr9, a2, 0
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vld vr9, a2, 8
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr15
vssrani.bu.h vr15, vr14, 0
vst vr15, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H16
endfunc
function ff_hevc_put_hevc_uni_qpel_h16_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H16_LASX:
xvld xr9, a2, 0
add.d a2, a2, a3
xvpermi.d xr9, xr9, 0x94 //rearrange data
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvpermi.q xr15, xr14, 0x01
vssrani.bu.h vr15, vr14, 0
vst vr15, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H16_LASX
endfunc
function ff_hevc_put_hevc_uni_qpel_h24_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H24:
vld vr9, a2, 0
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vld vr9, a2, 8
HEVC_UNI_QPEL_H8_LSX vr9, vr15
vld vr9, a2, 16
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr16
vssrani.bu.h vr15, vr14, 0
vssrani.bu.h vr16, vr16, 0
vst vr15, a0, 0
fst.d f16, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H24
endfunc
function ff_hevc_put_hevc_uni_qpel_h24_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H24_LASX:
xvld xr9, a2, 0
xvpermi.q xr19, xr9, 0x01 //16...23
add.d a2, a2, a3
xvpermi.d xr9, xr9, 0x94 //rearrange data
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvpermi.q xr15, xr14, 0x01
vssrani.bu.h vr15, vr14, 0
vst vr15, a0, 0
HEVC_UNI_QPEL_H8_LSX vr19, vr16
vssrani.bu.h vr16, vr16, 0
fst.d f16, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H24_LASX
endfunc
function ff_hevc_put_hevc_uni_qpel_h32_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H32:
vld vr9, a2, 0
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vld vr9, a2, 8
HEVC_UNI_QPEL_H8_LSX vr9, vr15
vld vr9, a2, 16
HEVC_UNI_QPEL_H8_LSX vr9, vr16
vld vr9, a2, 24
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr17
vssrani.bu.h vr15, vr14, 0
vssrani.bu.h vr17, vr16, 0
vst vr15, a0, 0
vst vr17, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H32
endfunc
function ff_hevc_put_hevc_uni_qpel_h32_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H32_LASX:
xvld xr9, a2, 0
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvld xr9, a2, 16
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr15
add.d a2, a2, a3
xvssrani.bu.h xr15, xr14, 0
xvpermi.d xr15, xr15, 0xd8
xvst xr15, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H32_LASX
endfunc
function ff_hevc_put_hevc_uni_qpel_h48_8_lsx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
vreplvei.h vr1, vr0, 1 //cd...
vreplvei.h vr2, vr0, 2 //ef...
vreplvei.h vr3, vr0, 3 //gh...
vreplvei.h vr0, vr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
vreplgr2vr.h vr4, t1
la.local t1, shufb
vld vr5, t1, 48
vaddi.bu vr6, vr5, 2
vaddi.bu vr7, vr5, 4
vaddi.bu vr8, vr5, 6
.LOOP_UNI_H48:
vld vr9, a2, 0
HEVC_UNI_QPEL_H8_LSX vr9, vr14
vld vr9, a2, 8
HEVC_UNI_QPEL_H8_LSX vr9, vr15
vld vr9, a2, 16
HEVC_UNI_QPEL_H8_LSX vr9, vr16
vld vr9, a2, 24
HEVC_UNI_QPEL_H8_LSX vr9, vr17
vld vr9, a2, 32
HEVC_UNI_QPEL_H8_LSX vr9, vr18
vld vr9, a2, 40
add.d a2, a2, a3
HEVC_UNI_QPEL_H8_LSX vr9, vr19
vssrani.bu.h vr15, vr14, 0
vssrani.bu.h vr17, vr16, 0
vssrani.bu.h vr19, vr18, 0
vst vr15, a0, 0
vst vr17, a0, 16
vst vr19, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H48
endfunc
function ff_hevc_put_hevc_uni_qpel_h48_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H48_LASX:
xvld xr9, a2, 0
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvld xr9, a2, 16
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr15
xvld xr9, a2, 32
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr16
add.d a2, a2, a3
xvssrani.bu.h xr15, xr14, 0
xvpermi.d xr15, xr15, 0xd8
xvst xr15, a0, 0
xvpermi.q xr17, xr16, 0x01
vssrani.bu.h vr17, vr16, 0
vst vr17, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H48_LASX
endfunc
function ff_hevc_put_hevc_uni_qpel_h64_8_lasx
slli.w t0, a5, 4
la.local t1, ff_hevc_qpel_filters
vldx vr0, t1, t0 //filter abcdefgh
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1 //cd...
xvrepl128vei.h xr2, xr0, 2 //ef...
xvrepl128vei.h xr3, xr0, 3 //gh...
xvrepl128vei.h xr0, xr0, 0 //ab...
addi.d a2, a2, -3 //src -= 3
addi.w t1, zero, 32
xvreplgr2vr.h xr4, t1
la.local t1, shufb
vld vr5, t1, 48
xvreplve0.q xr5, xr5
xvaddi.bu xr6, xr5, 2
xvaddi.bu xr7, xr5, 4
xvaddi.bu xr8, xr5, 6
.LOOP_UNI_H64_LASX:
xvld xr9, a2, 0
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr14
xvld xr9, a2, 16
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr15
xvld xr9, a2, 32
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr16
xvld xr9, a2, 48
xvpermi.d xr9, xr9, 0x94
HEVC_UNI_QPEL_H16_LASX xr9, xr17
add.d a2, a2, a3
xvssrani.bu.h xr15, xr14, 0
xvpermi.d xr15, xr15, 0xd8
xvst xr15, a0, 0
xvssrani.bu.h xr17, xr16, 0
xvpermi.d xr17, xr17, 0xd8
xvst xr17, a0, 32
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_H64_LASX
endfunc
/*
* void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_epel_uni_w_v4_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
fld.s f6, a2, 0 //0
fldx.s f7, a2, a3 //1
fldx.s f8, a2, t0 //2
add.d a2, a2, t1
vilvl.b vr6, vr7, vr6
vilvl.b vr7, vr8, vr8
vilvl.h vr6, vr7, vr6
vreplvei.w vr0, vr0, 0
.LOOP_UNI_V4:
fld.s f9, a2, 0 //3
fldx.s f10, a2, a3 //4
add.d a2, a2, t0
vextrins.b vr6, vr9, 0x30 //insert the 3th load
vextrins.b vr6, vr9, 0x71
vextrins.b vr6, vr9, 0xb2
vextrins.b vr6, vr9, 0xf3
vbsrl.v vr7, vr6, 1
vextrins.b vr7, vr10, 0x30 //insert the 4th load
vextrins.b vr7, vr10, 0x71
vextrins.b vr7, vr10, 0xb2
vextrins.b vr7, vr10, 0xf3
vdp2.h.bu.b vr8, vr6, vr0 //EPEL_FILTER(src, stride)
vdp2.h.bu.b vr9, vr7, vr0
vhaddw.w.h vr10, vr8, vr8
vhaddw.w.h vr11, vr9, vr9
vmulwev.w.h vr10, vr10, vr1 //EPEL_FILTER(src, stride) * wx
vmulwev.w.h vr11, vr11, vr1
vadd.w vr10, vr10, vr2 // + offset
vadd.w vr11, vr11, vr2
vsra.w vr10, vr10, vr3 // >> shift
vsra.w vr11, vr11, vr3
vadd.w vr10, vr10, vr4 // + ox
vadd.w vr11, vr11, vr4
vssrani.h.w vr11, vr10, 0
vssrani.bu.h vr10, vr11, 0
vbsrl.v vr6, vr7, 1
fst.s f10, a0, 0
vbsrl.v vr10, vr10, 4
fstx.s f10, a0, a1
alsl.d a0, a1, a0, 1
addi.d a4, a4, -2
bnez a4, .LOOP_UNI_V4
endfunc
.macro CALC_EPEL_FILTER_LSX out0, out1
vdp2.h.bu.b vr12, vr10, vr0 //EPEL_FILTER(src, stride)
vdp2add.h.bu.b vr12, vr11, vr5
vexth.w.h vr13, vr12
vsllwil.w.h vr12, vr12, 0
vmulwev.w.h vr12, vr12, vr1 //EPEL_FILTER(src, stride) * wx
vmulwev.w.h vr13, vr13, vr1 //EPEL_FILTER(src, stride) * wx
vadd.w vr12, vr12, vr2 // + offset
vadd.w vr13, vr13, vr2
vsra.w vr12, vr12, vr3 // >> shift
vsra.w vr13, vr13, vr3
vadd.w \out0, vr12, vr4 // + ox
vadd.w \out1, vr13, vr4
.endm
.macro CALC_EPEL_FILTER_LASX out0
xvdp2.h.bu.b xr11, xr12, xr0 //EPEL_FILTER(src, stride)
xvhaddw.w.h xr12, xr11, xr11
xvmulwev.w.h xr12, xr12, xr1 //EPEL_FILTER(src, stride) * wx
xvadd.w xr12, xr12, xr2 // + offset
xvsra.w xr12, xr12, xr3 // >> shift
xvadd.w \out0, xr12, xr4 // + ox
.endm
//w is a label, also can be used as a condition for ".if" statement.
.macro PUT_HEVC_EPEL_UNI_W_V8_LSX w
fld.d f6, a2, 0 //0
fldx.d f7, a2, a3 //1
fldx.d f8, a2, t0 //2
add.d a2, a2, t1
.LOOP_UNI_V8_\w:
fld.d f9, a2, 0 // 3
add.d a2, a2, a3
vilvl.b vr10, vr7, vr6
vilvl.b vr11, vr9, vr8
vaddi.bu vr6, vr7, 0 //back up previous value
vaddi.bu vr7, vr8, 0
vaddi.bu vr8, vr9, 0
CALC_EPEL_FILTER_LSX vr12, vr13
vssrani.h.w vr13, vr12, 0
vssrani.bu.h vr13, vr13, 0
.if \w < 8
fst.s f13, a0, 0
vstelm.h vr13, a0, 4, 2
.else
fst.d f13, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_V8_\w
.endm
//w is a label, also can be used as a condition for ".if" statement.
.macro PUT_HEVC_EPEL_UNI_W_V8_LASX w
fld.d f6, a2, 0 //0
fldx.d f7, a2, a3 //1
fldx.d f8, a2, t0 //2
add.d a2, a2, t1
.LOOP_UNI_V8_LASX_\w:
fld.d f9, a2, 0 // 3
add.d a2, a2, a3
vilvl.b vr10, vr7, vr6
vilvl.b vr11, vr9, vr8
xvilvl.h xr12, xr11, xr10
xvilvh.h xr13, xr11, xr10
xvpermi.q xr12, xr13, 0x02
vaddi.bu vr6, vr7, 0 //back up previous value
vaddi.bu vr7, vr8, 0
vaddi.bu vr8, vr9, 0
CALC_EPEL_FILTER_LASX xr12
xvpermi.q xr13, xr12, 0x01
vssrani.h.w vr13, vr12, 0
vssrani.bu.h vr13, vr13, 0
.if \w < 8
fst.s f13, a0, 0
vstelm.h vr13, a0, 4, 2
.else
fst.d f13, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_V8_LASX_\w
.endm
function ff_hevc_put_hevc_epel_uni_w_v6_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
PUT_HEVC_EPEL_UNI_W_V8_LSX 6
endfunc
function ff_hevc_put_hevc_epel_uni_w_v6_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
PUT_HEVC_EPEL_UNI_W_V8_LASX 6
endfunc
function ff_hevc_put_hevc_epel_uni_w_v8_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
PUT_HEVC_EPEL_UNI_W_V8_LSX 8
endfunc
function ff_hevc_put_hevc_epel_uni_w_v8_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
PUT_HEVC_EPEL_UNI_W_V8_LASX 8
endfunc
//w is a label, also can be used as a condition for ".if" statement.
.macro PUT_HEVC_EPEL_UNI_W_V16_LSX w
vld vr6, a2, 0 //0
vldx vr7, a2, a3 //1
vldx vr8, a2, t0 //2
add.d a2, a2, t1
.LOOP_UNI_V16_\w:
vld vr9, a2, 0 //3
add.d a2, a2, a3
vilvl.b vr10, vr7, vr6
vilvl.b vr11, vr9, vr8
CALC_EPEL_FILTER_LSX vr14, vr15
vilvh.b vr10, vr7, vr6
vilvh.b vr11, vr9, vr8
CALC_EPEL_FILTER_LSX vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vaddi.bu vr6, vr7, 0 //back up previous value
vaddi.bu vr7, vr8, 0
vaddi.bu vr8, vr9, 0
.if \w < 16
fst.d f17, a0, 0
vstelm.w vr17, a0, 8, 2
.else
vst vr17, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_V16_\w
.endm
//w is a label, also can be used as a condition for ".if" statement.
.macro PUT_HEVC_EPEL_UNI_W_V16_LASX w
vld vr6, a2, 0 //0
vldx vr7, a2, a3 //1
vldx vr8, a2, t0 //2
add.d a2, a2, t1
.LOOP_UNI_V16_LASX_\w:
vld vr9, a2, 0 //3
add.d a2, a2, a3
xvilvl.b xr10, xr7, xr6
xvilvh.b xr11, xr7, xr6
xvpermi.q xr11, xr10, 0x20
xvilvl.b xr12, xr9, xr8
xvilvh.b xr13, xr9, xr8
xvpermi.q xr13, xr12, 0x20
xvdp2.h.bu.b xr10, xr11, xr0 //EPEL_FILTER(src, stride)
xvdp2add.h.bu.b xr10, xr13, xr5
xvexth.w.h xr11, xr10
xvsllwil.w.h xr10, xr10, 0
xvmulwev.w.h xr10, xr10, xr1 //EPEL_FILTER(src, stride) * wx
xvmulwev.w.h xr11, xr11, xr1
xvadd.w xr10, xr10, xr2 // + offset
xvadd.w xr11, xr11, xr2
xvsra.w xr10, xr10, xr3 // >> shift
xvsra.w xr11, xr11, xr3
xvadd.w xr10, xr10, xr4 // + wx
xvadd.w xr11, xr11, xr4
xvssrani.h.w xr11, xr10, 0
xvpermi.q xr10, xr11, 0x01
vssrani.bu.h vr10, vr11, 0
vaddi.bu vr6, vr7, 0 //back up previous value
vaddi.bu vr7, vr8, 0
vaddi.bu vr8, vr9, 0
.if \w < 16
fst.d f10, a0, 0
vstelm.w vr10, a0, 8, 2
.else
vst vr10, a0, 0
.endif
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_V16_LASX_\w
.endm
function ff_hevc_put_hevc_epel_uni_w_v12_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 12
endfunc
function ff_hevc_put_hevc_epel_uni_w_v12_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 12
endfunc
function ff_hevc_put_hevc_epel_uni_w_v16_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 16
endfunc
function ff_hevc_put_hevc_epel_uni_w_v16_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 16
endfunc
function ff_hevc_put_hevc_epel_uni_w_v24_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
addi.d t2, a0, 0 //save init
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 24
addi.d a0, t2, 16 //increase step
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V8_LSX 24
endfunc
function ff_hevc_put_hevc_epel_uni_w_v24_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr20, xr0 //save xr0
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
addi.d t2, a0, 0 //save init
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 24
addi.d a0, t2, 16 //increase step
addi.d a2, t3, 16
addi.d a4, t4, 0
xvaddi.bu xr0, xr20, 0
PUT_HEVC_EPEL_UNI_W_V8_LASX 24
endfunc
function ff_hevc_put_hevc_epel_uni_w_v32_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 32
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 33
endfunc
function ff_hevc_put_hevc_epel_uni_w_v32_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 32
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 33
endfunc
function ff_hevc_put_hevc_epel_uni_w_v48_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 48
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 49
addi.d a0, t2, 32
addi.d a2, t3, 32
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 50
endfunc
function ff_hevc_put_hevc_epel_uni_w_v48_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 48
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 49
addi.d a0, t2, 32
addi.d a2, t3, 32
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 50
endfunc
function ff_hevc_put_hevc_epel_uni_w_v64_8_lsx
LOAD_VAR 128
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 64
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 65
addi.d a0, t2, 32
addi.d a2, t3, 32
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 66
addi.d a0, t2, 48
addi.d a2, t3, 48
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LSX 67
endfunc
function ff_hevc_put_hevc_epel_uni_w_v64_8_lasx
LOAD_VAR 256
ld.d t0, sp, 8 //my
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.q xr0, xr0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
sub.d a2, a2, a3 //src -= stride
xvrepl128vei.h xr5, xr0, 1
xvrepl128vei.h xr0, xr0, 0
addi.d t2, a0, 0
addi.d t3, a2, 0
addi.d t4, a4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 64
addi.d a0, t2, 16
addi.d a2, t3, 16
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 65
addi.d a0, t2, 32
addi.d a2, t3, 32
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 66
addi.d a0, t2, 48
addi.d a2, t3, 48
addi.d a4, t4, 0
PUT_HEVC_EPEL_UNI_W_V16_LASX 67
endfunc
/*
* void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* int height, int denom, int wx, int ox,
* intptr_t mx, intptr_t my, int width)
*/
function ff_hevc_put_hevc_epel_uni_w_h4_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr5, t1, 0
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H4:
fld.d f6, a2, 0
add.d a2, a2, a3
vshuf.b vr6, vr6, vr6, vr5
vdp2.h.bu.b vr7, vr6, vr0
vhaddw.w.h vr7, vr7, vr7
vmulwev.w.h vr7, vr7, vr1
vadd.w vr7, vr7, vr2
vsra.w vr7, vr7, vr3
vadd.w vr7, vr7, vr4
vssrani.h.w vr7, vr7, 0
vssrani.bu.h vr7, vr7, 0
fst.s f7, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H4
endfunc
function ff_hevc_put_hevc_epel_uni_w_h6_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H6:
vld vr8, a2, 0
add.d a2, a2, a3
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr14, vr15
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.s f15, a0, 0
vstelm.h vr15, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H6
endfunc
function ff_hevc_put_hevc_epel_uni_w_h6_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H6_LASX:
vld vr8, a2, 0
xvreplve0.q xr8, xr8
add.d a2, a2, a3
xvshuf.b xr12, xr8, xr8, xr6
CALC_EPEL_FILTER_LASX xr14
xvpermi.q xr15, xr14, 0x01
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.s f15, a0, 0
vstelm.h vr15, a0, 4, 2
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H6_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h8_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H8:
vld vr8, a2, 0
add.d a2, a2, a3
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr14, vr15
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.d f15, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H8
endfunc
function ff_hevc_put_hevc_epel_uni_w_h8_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H8_LASX:
vld vr8, a2, 0
xvreplve0.q xr8, xr8
add.d a2, a2, a3
xvshuf.b xr12, xr8, xr8, xr6
CALC_EPEL_FILTER_LASX xr14
xvpermi.q xr15, xr14, 0x01
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.d f15, a0, 0
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H8_LASX
endfunc
.macro EPEL_UNI_W_H16_LOOP_LSX idx0, idx1, idx2
vld vr8, a2, \idx0
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr14, vr15
vld vr8, a2, \idx1
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
vst vr17, a0, \idx2
.endm
.macro EPEL_UNI_W_H16_LOOP_LASX idx0, idx2, w
xvld xr8, a2, \idx0
xvpermi.d xr9, xr8, 0x09
xvreplve0.q xr8, xr8
xvshuf.b xr12, xr8, xr8, xr6
CALC_EPEL_FILTER_LASX xr14
xvreplve0.q xr8, xr9
xvshuf.b xr12, xr8, xr8, xr6
CALC_EPEL_FILTER_LASX xr16
xvssrani.h.w xr16, xr14, 0
xvpermi.q xr17, xr16, 0x01
vssrani.bu.h vr17, vr16, 0
vpermi.w vr17, vr17, 0xd8
.if \w == 12
fst.d f17, a0, 0
vstelm.w vr17, a0, 8, 2
.else
vst vr17, a0, \idx2
.endif
.endm
function ff_hevc_put_hevc_epel_uni_w_h12_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H12:
vld vr8, a2, 0
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr14, vr15
vld vr8, a2, 8
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr16, vr17
vssrani.h.w vr15, vr14, 0
vssrani.h.w vr17, vr16, 0
vssrani.bu.h vr17, vr15, 0
fst.d f17, a0, 0
vstelm.w vr17, a0, 8, 2
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H12
endfunc
function ff_hevc_put_hevc_epel_uni_w_h12_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H12_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 12
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H12_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h16_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H16:
EPEL_UNI_W_H16_LOOP_LSX 0, 8, 0
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H16
endfunc
function ff_hevc_put_hevc_epel_uni_w_h16_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H16_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 16
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H16_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h24_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H24:
EPEL_UNI_W_H16_LOOP_LSX 0, 8, 0
vld vr8, a2, 16
add.d a2, a2, a3
vshuf.b vr10, vr8, vr8, vr6
vshuf.b vr11, vr8, vr8, vr7
CALC_EPEL_FILTER_LSX vr18, vr19
vssrani.h.w vr19, vr18, 0
vssrani.bu.h vr19, vr19, 0
fst.d f19, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H24
endfunc
function ff_hevc_put_hevc_epel_uni_w_h24_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H24_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 24
vld vr8, a2, 16
add.d a2, a2, a3
xvreplve0.q xr8, xr8
xvshuf.b xr12, xr8, xr8, xr6
CALC_EPEL_FILTER_LASX xr14
xvpermi.q xr15, xr14, 0x01
vssrani.h.w vr15, vr14, 0
vssrani.bu.h vr15, vr15, 0
fst.d f15, a0, 16
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H24_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h32_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H32:
EPEL_UNI_W_H16_LOOP_LSX 0, 8, 0
EPEL_UNI_W_H16_LOOP_LSX 16, 24, 16
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H32
endfunc
function ff_hevc_put_hevc_epel_uni_w_h32_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H32_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 32
EPEL_UNI_W_H16_LOOP_LASX 16, 16, 32
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H32_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h48_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H48:
EPEL_UNI_W_H16_LOOP_LSX 0, 8, 0
EPEL_UNI_W_H16_LOOP_LSX 16, 24, 16
EPEL_UNI_W_H16_LOOP_LSX 32, 40, 32
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H48
endfunc
function ff_hevc_put_hevc_epel_uni_w_h48_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H48_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 48
EPEL_UNI_W_H16_LOOP_LASX 16, 16, 48
EPEL_UNI_W_H16_LOOP_LASX 32, 32, 48
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H48_LASX
endfunc
function ff_hevc_put_hevc_epel_uni_w_h64_8_lsx
LOAD_VAR 128
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
vreplvei.w vr0, vr0, 0
la.local t1, shufb
vld vr6, t1, 48
vaddi.bu vr7, vr6, 2
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
vreplvei.h vr5, vr0, 1
vreplvei.h vr0, vr0, 0
.LOOP_UNI_W_H64:
EPEL_UNI_W_H16_LOOP_LSX 0, 8, 0
EPEL_UNI_W_H16_LOOP_LSX 16, 24, 16
EPEL_UNI_W_H16_LOOP_LSX 32, 40, 32
EPEL_UNI_W_H16_LOOP_LSX 48, 56, 48
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H64
endfunc
function ff_hevc_put_hevc_epel_uni_w_h64_8_lasx
LOAD_VAR 256
ld.d t0, sp, 0 //mx
slli.w t0, t0, 2
la.local t1, ff_hevc_epel_filters
vldx vr0, t1, t0 //filter
xvreplve0.w xr0, xr0
la.local t1, shufb
xvld xr6, t1, 64
slli.d t0, a3, 1 //stride * 2
add.d t1, t0, a3 //stride * 3
addi.d a2, a2, -1 //src -= 1
.LOOP_UNI_W_H64_LASX:
EPEL_UNI_W_H16_LOOP_LASX 0, 0, 64
EPEL_UNI_W_H16_LOOP_LASX 16, 16, 64
EPEL_UNI_W_H16_LOOP_LASX 32, 32, 64
EPEL_UNI_W_H16_LOOP_LASX 48, 48, 64
add.d a2, a2, a3
add.d a0, a0, a1
addi.d a4, a4, -1
bnez a4, .LOOP_UNI_W_H64_LASX
endfunc
/*
* void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride,
* const uint8_t *_src, ptrdiff_t _srcstride,
* const int16_t *src2, int height, intptr_t mx,
* intptr_t my, int width)
*/
function ff_hevc_put_hevc_bi_epel_h4_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
vreplvei.w vr0, vr0, 0
la.local t0, shufb
vld vr1, t0, 0 // mask
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H4:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
add.d a2, a2, a3
addi.d a4, a4, 128
vshuf.b vr5, vr5, vr5, vr1
vdp2.h.bu.b vr6, vr5, vr0 // EPEL_FILTER(src, 1)
vsllwil.w.h vr4, vr4, 0
vhaddw.w.h vr6, vr6, vr6
vadd.w vr6, vr6, vr4 // src2[x]
vssrani.h.w vr6, vr6, 0
vssrarni.bu.h vr6, vr6, 7
fst.s f6, a0, 0
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H4
endfunc
.macro PUT_HEVC_BI_EPEL_H8_LSX in0, in1, in2, in3, out0
vshuf.b vr6, \in1, \in0, \in2
vshuf.b vr7, \in1, \in0, \in3
vdp2.h.bu.b vr8, vr6, vr0 // EPEL_FILTER(src, 1)
vdp2add.h.bu.b vr8, vr7, vr1 // EPEL_FILTER(src, 1)
vsadd.h \out0, vr8, vr4 // src2[x]
.endm
.macro PUT_HEVC_BI_EPEL_H16_LASX in0, in1, in2, in3, out0
xvshuf.b xr6, \in1, \in0, \in2
xvshuf.b xr7, \in1, \in0, \in3
xvdp2.h.bu.b xr8, xr6, xr0 // EPEL_FILTER(src, 1)
xvdp2add.h.bu.b xr8, xr7, xr1 // EPEL_FILTER(src, 1)
xvsadd.h \out0, xr8, xr4 // src2[x]
.endm
function ff_hevc_put_hevc_bi_epel_h6_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H6:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
add.d a2, a2, a3
addi.d a4, a4, 128
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr7
vssrarni.bu.h vr7, vr7, 7
fst.s f7, a0, 0
vstelm.h vr7, a0, 4, 2
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H6
endfunc
function ff_hevc_put_hevc_bi_epel_h8_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H8:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
add.d a2, a2, a3
addi.d a4, a4, 128
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr7
vssrarni.bu.h vr7, vr7, 7
fst.d f7, a0, 0
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H8
endfunc
function ff_hevc_put_hevc_bi_epel_h12_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H12:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr11
vld vr5, a2, 8
vld vr4, a4, 16
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr12
vssrarni.bu.h vr12, vr11, 7
fst.d f12, a0, 0
vstelm.w vr12, a0, 8, 2
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H12
endfunc
function ff_hevc_put_hevc_bi_epel_h12_8_lasx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1
xvrepl128vei.h xr0, xr0, 0
la.local t0, shufb
xvld xr2, t0, 96// mask
xvaddi.bu xr3, xr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H12_LASX:
xvld xr4, a4, 0 // src2
xvld xr5, a2, 0
xvpermi.d xr5, xr5, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr5, xr5, xr2, xr3, xr9
xvpermi.q xr10, xr9, 0x01
vssrarni.bu.h vr10, vr9, 7
fst.d f10, a0, 0
vstelm.w vr10, a0, 8, 2
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H12_LASX
endfunc
function ff_hevc_put_hevc_bi_epel_h16_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H16:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr11
vld vr5, a2, 8
vld vr4, a4, 16
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr12
vssrarni.bu.h vr12, vr11, 7
vst vr12, a0, 0
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H16
endfunc
function ff_hevc_put_hevc_bi_epel_h16_8_lasx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1
xvrepl128vei.h xr0, xr0, 0
la.local t0, shufb
xvld xr2, t0, 96// mask
xvaddi.bu xr3, xr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H16_LASX:
xvld xr4, a4, 0 // src2
xvld xr5, a2, 0
xvpermi.d xr5, xr5, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr5, xr5, xr2, xr3, xr9
xvpermi.q xr10, xr9, 0x01
vssrarni.bu.h vr10, vr9, 7
vst vr10, a0, 0
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H16_LASX
endfunc
function ff_hevc_put_hevc_bi_epel_h32_8_lasx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1
xvrepl128vei.h xr0, xr0, 0
la.local t0, shufb
xvld xr2, t0, 96// mask
xvaddi.bu xr3, xr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H32_LASX:
xvld xr4, a4, 0 // src2
xvld xr5, a2, 0
xvpermi.q xr15, xr5, 0x01
xvpermi.d xr5, xr5, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr5, xr5, xr2, xr3, xr9
xvld xr4, a4, 32
xvld xr15, a2, 16
xvpermi.d xr15, xr15, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr15, xr15, xr2, xr3, xr11
xvssrarni.bu.h xr11, xr9, 7
xvpermi.d xr11, xr11, 0xd8
xvst xr11, a0, 0
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H32_LASX
endfunc
function ff_hevc_put_hevc_bi_epel_h48_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6// filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
vaddi.bu vr21, vr2, 8
vaddi.bu vr22, vr2, 10
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H48:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
vld vr9, a2, 16
vld vr10, a2, 32
vld vr11, a2, 48
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr12
vld vr4, a4, 16
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr9, vr21, vr22, vr13
vld vr4, a4, 32
PUT_HEVC_BI_EPEL_H8_LSX vr9, vr9, vr2, vr3, vr14
vld vr4, a4, 48
PUT_HEVC_BI_EPEL_H8_LSX vr9, vr10, vr21, vr22, vr15
vld vr4, a4, 64
PUT_HEVC_BI_EPEL_H8_LSX vr10, vr10, vr2, vr3, vr16
vld vr4, a4, 80
PUT_HEVC_BI_EPEL_H8_LSX vr10, vr11, vr21, vr22, vr17
vssrarni.bu.h vr13, vr12, 7
vssrarni.bu.h vr15, vr14, 7
vssrarni.bu.h vr17, vr16, 7
vst vr13, a0, 0
vst vr15, a0, 16
vst vr17, a0, 32
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H48
endfunc
function ff_hevc_put_hevc_bi_epel_h48_8_lasx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1
xvrepl128vei.h xr0, xr0, 0
la.local t0, shufb
xvld xr2, t0, 96// mask
xvaddi.bu xr3, xr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H48_LASX:
xvld xr4, a4, 0 // src2
xvld xr5, a2, 0
xvld xr9, a2, 32
xvpermi.d xr10, xr9, 0x94
xvpermi.q xr9, xr5, 0x21
xvpermi.d xr9, xr9, 0x94
xvpermi.d xr5, xr5, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr5, xr5, xr2, xr3, xr11
xvld xr4, a4, 32
PUT_HEVC_BI_EPEL_H16_LASX xr9, xr9, xr2, xr3, xr12
xvld xr4, a4, 64
PUT_HEVC_BI_EPEL_H16_LASX xr10, xr10, xr2, xr3, xr13
xvssrarni.bu.h xr12, xr11, 7
xvpermi.d xr12, xr12, 0xd8
xvpermi.q xr14, xr13, 0x01
vssrarni.bu.h vr14, vr13, 7
xvst xr12, a0, 0
vst vr14, a0, 32
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H48_LASX
endfunc
function ff_hevc_put_hevc_bi_epel_h64_8_lsx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6// filter
vreplvei.h vr1, vr0, 1
vreplvei.h vr0, vr0, 0
la.local t0, shufb
vld vr2, t0, 48// mask
vaddi.bu vr3, vr2, 2
vaddi.bu vr21, vr2, 8
vaddi.bu vr22, vr2, 10
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H64:
vld vr4, a4, 0 // src2
vld vr5, a2, 0
vld vr9, a2, 16
vld vr10, a2, 32
vld vr11, a2, 48
vld vr12, a2, 64
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr5, vr2, vr3, vr13
vld vr4, a4, 16
PUT_HEVC_BI_EPEL_H8_LSX vr5, vr9, vr21, vr22, vr14
vld vr4, a4, 32
PUT_HEVC_BI_EPEL_H8_LSX vr9, vr9, vr2, vr3, vr15
vld vr4, a4, 48
PUT_HEVC_BI_EPEL_H8_LSX vr9, vr10, vr21, vr22, vr16
vld vr4, a4, 64
PUT_HEVC_BI_EPEL_H8_LSX vr10, vr10, vr2, vr3, vr17
vld vr4, a4, 80
PUT_HEVC_BI_EPEL_H8_LSX vr10, vr11, vr21, vr22, vr18
vld vr4, a4, 96
PUT_HEVC_BI_EPEL_H8_LSX vr11, vr11, vr2, vr3, vr19
vld vr4, a4, 112
PUT_HEVC_BI_EPEL_H8_LSX vr11, vr12, vr21, vr22, vr20
vssrarni.bu.h vr14, vr13, 7
vssrarni.bu.h vr16, vr15, 7
vssrarni.bu.h vr18, vr17, 7
vssrarni.bu.h vr20, vr19, 7
vst vr14, a0, 0
vst vr16, a0, 16
vst vr18, a0, 32
vst vr20, a0, 48
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H64
endfunc
function ff_hevc_put_hevc_bi_epel_h64_8_lasx
slli.w a6, a6, 2
la.local t0, ff_hevc_epel_filters
vldx vr0, t0, a6 // filter
xvreplve0.q xr0, xr0
xvrepl128vei.h xr1, xr0, 1
xvrepl128vei.h xr0, xr0, 0
la.local t0, shufb
xvld xr2, t0, 96// mask
xvaddi.bu xr3, xr2, 2
addi.d a2, a2, -1 // src -= 1
.LOOP_BI_EPEL_H64_LASX:
xvld xr4, a4, 0 // src2
xvld xr5, a2, 0
xvld xr9, a2, 32
xvld xr11, a2, 48
xvpermi.d xr11, xr11, 0x94
xvpermi.d xr10, xr9, 0x94
xvpermi.q xr9, xr5, 0x21
xvpermi.d xr9, xr9, 0x94
xvpermi.d xr5, xr5, 0x94
PUT_HEVC_BI_EPEL_H16_LASX xr5, xr5, xr2, xr3, xr12
xvld xr4, a4, 32
PUT_HEVC_BI_EPEL_H16_LASX xr9, xr9, xr2, xr3, xr13
xvld xr4, a4, 64
PUT_HEVC_BI_EPEL_H16_LASX xr10, xr10, xr2, xr3, xr14
xvld xr4, a4, 96
PUT_HEVC_BI_EPEL_H16_LASX xr11, xr11, xr2, xr3, xr15
xvssrarni.bu.h xr13, xr12, 7
xvssrarni.bu.h xr15, xr14, 7
xvpermi.d xr13, xr13, 0xd8
xvpermi.d xr15, xr15, 0xd8
xvst xr13, a0, 0
xvst xr15, a0, 32
add.d a2, a2, a3
addi.d a4, a4, 128
add.d a0, a0, a1
addi.d a5, a5, -1
bnez a5, .LOOP_BI_EPEL_H64_LASX
endfunc
|