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
|
/*
* Copyright (c) 2017-2020, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file media_libva_caps.cpp
//! \brief This file implements the base C++ class/interface for media capbilities.
//!
#include "hwinfo_linux.h"
#include "linux_system_info.h"
#include "media_libva_util.h"
#include "media_libva_vp.h"
#include "media_libva_common.h"
#include "media_libva_caps.h"
#include "media_libva_caps_cp_interface.h"
#include "media_ddi_decode_const.h"
#include "media_ddi_encode_const.h"
#include "media_libva_caps_factory.h"
typedef MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT> CapsFactory;
#ifdef ANDROID
#include <va/va_android.h>
#endif
#include "set"
#ifndef VA_ENCRYPTION_TYPE_NONE
#define VA_ENCRYPTION_TYPE_NONE 0x00000000
#endif
const uint32_t MediaLibvaCaps::m_decSliceMode[2] =
{
VA_DEC_SLICE_MODE_NORMAL,
VA_DEC_SLICE_MODE_BASE
};
const uint32_t MediaLibvaCaps::m_decProcessMode[2] =
{
VA_DEC_PROCESSING_NONE,
VA_DEC_PROCESSING
};
const uint32_t MediaLibvaCaps::m_encRcMode[9] =
{
VA_RC_CQP, VA_RC_CBR, VA_RC_VBR,
VA_RC_CBR | VA_RC_MB, VA_RC_VBR | VA_RC_MB,
VA_RC_ICQ, VA_RC_VCM, VA_RC_QVBR, VA_RC_AVBR
};
const uint32_t MediaLibvaCaps::m_vpSurfaceAttr[m_numVpSurfaceAttr] =
{
VA_FOURCC('I', '4', '2', '0'),
VA_FOURCC('Y', 'V', '1', '2'),
VA_FOURCC('Y', 'U', 'Y', '2'),
VA_FOURCC('4', '2', '2', 'H'),
VA_FOURCC('4', '2', '2', 'V'),
VA_FOURCC('R', 'G', 'B', 'A'),
VA_FOURCC('B', 'G', 'R', 'A'),
VA_FOURCC('R', 'G', 'B', 'P'),
VA_FOURCC('R', 'G', 'B', 'X'),
VA_FOURCC('P', '0', '1', '0'),
VA_FOURCC('R','G','2', '4'),
VA_FOURCC_ARGB,
VA_FOURCC_ABGR,
VA_FOURCC_A2R10G10B10,
VA_FOURCC_A2B10G10R10,
VA_FOURCC_X2R10G10B10,
VA_FOURCC_X2B10G10R10,
VA_FOURCC_AYUV
};
const uint32_t MediaLibvaCaps::m_jpegSurfaceAttr[m_numJpegSurfaceAttr] =
{
VA_FOURCC_NV12,
VA_FOURCC_IMC3,
VA_FOURCC_Y800,
VA_FOURCC_411P,
VA_FOURCC_422H,
VA_FOURCC_422V,
VA_FOURCC_444P
};
const uint32_t MediaLibvaCaps::m_jpegEncSurfaceAttr[m_numJpegEncSurfaceAttr] =
{
VA_FOURCC_NV12,
VA_FOURCC_YUY2,
VA_FOURCC_UYVY,
VA_FOURCC_Y800
};
MediaLibvaCaps::MediaLibvaCaps(DDI_MEDIA_CONTEXT *mediaCtx)
{
m_mediaCtx = mediaCtx;
m_CapsCp = Create_MediaLibvaCapsCpInterface(mediaCtx, this);
if (m_CapsCp)
{
m_isEntryptSupported = m_CapsCp->IsDecEncryptionSupported(m_mediaCtx);
}
}
MediaLibvaCaps::~MediaLibvaCaps()
{
FreeAttributeList();
Delete_MediaLibvaCapsCpInterface(m_CapsCp);
m_CapsCp = nullptr;
}
bool MediaLibvaCaps::CheckEntrypointCodecType(VAEntrypoint entrypoint, CodecType codecType)
{
switch (codecType)
{
case videoEncode:
if((entrypoint == VAEntrypointEncSlice)
|| (entrypoint == VAEntrypointEncSliceLP)
|| (entrypoint == VAEntrypointEncPicture)
|| (entrypoint == VAEntrypointFEI)
|| (entrypoint == VAEntrypointStats))
{
return true;
}
else
{
return false;
}
break;
case videoDecode:
return (entrypoint == VAEntrypointVLD);
case videoProcess:
if(entrypoint == VAEntrypointVideoProc)
{
return true;
}
else
{
return false;
}
break;
default:
DDI_ASSERTMESSAGE("DDI: Unsupported codecType");
return false;
}
}
VAStatus MediaLibvaCaps::AddDecConfig(uint32_t slicemode, uint32_t encryptType, uint32_t processType)
{
m_decConfigs.emplace_back(slicemode, encryptType, processType);
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::AddEncConfig(uint32_t rcMode, uint32_t feiFunction)
{
m_encConfigs.emplace_back(rcMode, feiFunction);
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::AddVpConfig(uint32_t attrib)
{
m_vpConfigs.emplace_back(attrib);
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetProfileEntrypointFromConfigId(
VAConfigID configId,
VAProfile *profile,
VAEntrypoint *entrypoint,
int32_t *profileTableIdx)
{
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(profileTableIdx, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
CodecType codecType;
int32_t configOffset = 0;
if((configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size())) )
{
configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE;
codecType = videoDecode;
}
else if( (configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE) && (configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE + m_encConfigs.size())) )
{
configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE;
codecType = videoEncode;
}
else if( (configId >= DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE) && (configId < (DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE + m_vpConfigs.size())))
{
configOffset = configId - DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE;
codecType = videoProcess;
}
else
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
int32_t i;
for (i = 0; i < m_profileEntryCount; i++)
{
if (CheckEntrypointCodecType(m_profileEntryTbl[i].m_entrypoint, codecType))
{
int32_t configStart = m_profileEntryTbl[i].m_configStartIdx;
int32_t configEnd = m_profileEntryTbl[i].m_configStartIdx + m_profileEntryTbl[i].m_configNum;
if (configOffset >= configStart && configOffset < configEnd)
{
break;
}
}
}
if (i == m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
else
{
*entrypoint = m_profileEntryTbl[i].m_entrypoint;
*profile = m_profileEntryTbl[i].m_profile;
*profileTableIdx = i;
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::AddProfileEntry(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap *attributeList,
int32_t configStartIdx,
int32_t configNum)
{
if (m_profileEntryCount >= m_maxProfileEntries)
{
DDI_ASSERTMESSAGE("Invalid profile entrypoint number");
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
m_profileEntryTbl[m_profileEntryCount].m_profile = profile;
m_profileEntryTbl[m_profileEntryCount].m_entrypoint = entrypoint;
m_profileEntryTbl[m_profileEntryCount].m_attributes = attributeList;
m_profileEntryTbl[m_profileEntryCount].m_configStartIdx = configStartIdx;
m_profileEntryTbl[m_profileEntryCount].m_configNum = configNum;
m_profileEntryCount++;
return VA_STATUS_SUCCESS;
}
int32_t MediaLibvaCaps::GetProfileTableIdx(VAProfile profile, VAEntrypoint entrypoint)
{
// initialize ret value to "invalid profile"
int32_t ret = -1;
for (int32_t i = 0; i < m_profileEntryCount; i++)
{
if (m_profileEntryTbl[i].m_profile == profile)
{
//there are such profile , but no such entrypoint
ret = -2;
if(m_profileEntryTbl[i].m_entrypoint == entrypoint)
{
return i;
}
}
}
return ret;
}
VAStatus MediaLibvaCaps::CreateAttributeList(AttribMap **attributeList)
{
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
*attributeList = MOS_New(AttribMap);
DDI_CHK_NULL(*attributeList, "Null pointer", VA_STATUS_ERROR_ALLOCATION_FAILED);
m_attributeLists.push_back(*attributeList);
return VA_STATUS_SUCCESS;
}
int32_t MediaLibvaCaps::GetAttributeIndex(std::vector<VAConfigAttrib> *attribList, VAConfigAttribType type)
{
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t attribSize = attribList->size();
for (uint32_t i = 0; i < attribSize; i++)
{
if ((*attribList)[i].type == type)
{
return i;
}
}
return -1;
}
VAStatus MediaLibvaCaps::SetAttribute(
std::vector<VAConfigAttrib> *attributeList,
VAConfigAttribType type,
uint32_t value)
{
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t index = GetAttributeIndex(attributeList, type);
if (index >= 0)
{
(*attributeList)[index].value = value;
return VA_STATUS_SUCCESS;
}
else
{
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
}
VAStatus MediaLibvaCaps::SetAttribute(
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttribType type,
uint32_t value)
{
int32_t idx = GetProfileTableIdx(profile, entrypoint);
DDI_CHK_LARGER(idx, -1, "Didn't find the profile table", VA_STATUS_ERROR_INVALID_PARAMETER);
auto attribList = m_profileEntryTbl[idx].m_attributes;
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
(*attribList)[type] = value;
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::FreeAttributeList()
{
uint32_t attribListCount = m_attributeLists.size();
for (uint32_t i = 0; i < attribListCount; i++)
{
m_attributeLists[i]->clear();
MOS_Delete(m_attributeLists[i]);
m_attributeLists[i] = nullptr;
}
m_attributeLists.clear();
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CheckEncRTFormat(
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib* attrib)
{
DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
attrib->type = VAConfigAttribRTFormat;
if (profile == VAProfileJPEGBaseline)
{
attrib->value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_RGB16 | VA_RT_FORMAT_RGB32;
}
else if(profile == VAProfileHEVCMain10 || profile == VAProfileHEVCSccMain10)
{
attrib->value = VA_RT_FORMAT_YUV420_10;
}
else if(profile == VAProfileHEVCMain12)
{
attrib->value = VA_RT_FORMAT_YUV420_12;
}
else if(profile == VAProfileHEVCMain422_10)
{
attrib->value = VA_RT_FORMAT_YUV422_10;
}
else if(profile == VAProfileHEVCMain422_12)
{
attrib->value = VA_RT_FORMAT_YUV422_12;
}
else if(profile == VAProfileHEVCMain444 || profile == VAProfileHEVCSccMain444)
{
attrib->value = VA_RT_FORMAT_YUV444;
}
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileHEVCSccMain444_10)
{
attrib->value = VA_RT_FORMAT_YUV444_10;
}
else
{
attrib->value = VA_RT_FORMAT_YUV420;
}
EncodeFormat format = Others;
EncodeType type = entrypoint == VAEntrypointEncSliceLP ? Vdenc : DualPipe;
struct EncodeFormatTable* encodeFormatTable = m_encodeFormatTable;
if(IsAvcProfile(profile))
{
format = AVC;
}
else if(IsHevcProfile(profile))
{
format = HEVC;
}
else if(IsVp9Profile(profile))
{
format = VP9;
}
for(uint32_t i = 0; i < m_encodeFormatCount && encodeFormatTable != nullptr; encodeFormatTable++, i++)
{
if(encodeFormatTable->encodeFormat == format
&& encodeFormatTable->encodeType == type)
{
attrib->value = encodeFormatTable->colorFormat;
break;
}
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CheckAttribList(
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib* attrib,
int32_t numAttribs)
{
int32_t idx = GetProfileTableIdx(profile, entrypoint);
if(idx < 0)
{
return VA_STATUS_ERROR_INVALID_VALUE;
}
for(int32_t j = 0; j < numAttribs; j ++)
{
bool isValidAttrib = false;
//temp solution for MV tools, after tool change, it should be removed
if(attrib[j].type == VAConfigAttribEncDynamicScaling
||attrib[j].type == VAConfigAttribEncRateControlExt
||attrib[j].type == VAConfigAttribEncTileSupport)
{
if(attrib[j].value == VA_ATTRIB_NOT_SUPPORTED)
{
isValidAttrib = true;
continue;
}
}
if (m_profileEntryTbl[idx].m_attributes->find(attrib[j].type) !=
m_profileEntryTbl[idx].m_attributes->end())
{
isValidAttrib = false;
if(attrib[j].value == m_configAttribNone)
{
isValidAttrib = true;
continue;
}
if(attrib[j].type == VAConfigAttribRTFormat
||attrib[j].type == VAConfigAttribDecSliceMode
||attrib[j].type == VAConfigAttribDecJPEG
||attrib[j].type == VAConfigAttribRateControl
||attrib[j].type == VAConfigAttribEncPackedHeaders
||attrib[j].type == VAConfigAttribEncIntraRefresh
||attrib[j].type == VAConfigAttribFEIFunctionType
||attrib[j].type == VAConfigAttribEncryption)
{
if(((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & attrib[j].value) == attrib[j].value)
{
isValidAttrib = true;
continue;
}
else if(attrib[j].type == VAConfigAttribRTFormat)
{
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
}
}
else if((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] == attrib[j].value)
{
isValidAttrib = true;
continue;
}
else if(attrib[j].type == VAConfigAttribEncSliceStructure)
{
if(((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & attrib[j].value) == attrib[j].value)
{
isValidAttrib = true;
continue;
}
if((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS)
{
if((attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS)
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS)
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS)
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS))
{
isValidAttrib = true;
continue;
}
}
else if ((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] &
(VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE))
{
if((attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS)
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS)
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS))
{
isValidAttrib = true;
continue;
}
}
}
else if((attrib[j].type == VAConfigAttribMaxPictureWidth)
|| (attrib[j].type == VAConfigAttribMaxPictureHeight)
|| (attrib[j].type == VAConfigAttribEncROI)
|| (attrib[j].type == VAConfigAttribEncDirtyRect))
{
if(attrib[j].value <= (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type])
{
isValidAttrib = true;
continue;
}
}
else if(attrib[j].type == VAConfigAttribEncMaxRefFrames)
{
if(((attrib[j].value & 0xffff) <= ((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & 0xffff))
&&(attrib[j].value <= (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type])) //high16 bit can compare with this way
{
isValidAttrib = true;
continue;
}
}
else if(attrib[j].type == VAConfigAttribEncJPEG)
{
VAConfigAttribValEncJPEG jpegValue, jpegSetValue;
jpegValue.value = attrib[j].value;
jpegSetValue.value = (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type];
if((jpegValue.bits.max_num_quantization_tables <= jpegSetValue.bits.max_num_quantization_tables)
&&(jpegValue.bits.max_num_huffman_tables <= jpegSetValue.bits.max_num_huffman_tables)
&&(jpegValue.bits.max_num_scans <= jpegSetValue.bits.max_num_scans)
&&(jpegValue.bits.max_num_components <= jpegSetValue.bits.max_num_components))
{
isValidAttrib = true;
continue;
}
}
}
//should be removed after msdk remove VAConfigAttribSpatialResidual attributes for VPP
else if((profile == VAProfileNone)
&& (entrypoint == VAEntrypointVideoProc)
&& (attrib[j].type == VAConfigAttribSpatialClipping))
{
isValidAttrib = true;
continue;
}
else if((profile == VAProfileNone)
&& (attrib[j].type == VAConfigAttribStats))
{
isValidAttrib = true;
continue;
}
if(!isValidAttrib)
{
return VA_STATUS_ERROR_INVALID_VALUE;
}
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetGeneralConfigAttrib(VAConfigAttrib* attrib)
{
DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAStatus status = VA_STATUS_SUCCESS;
#if VA_CHECK_VERSION(1, 10, 0)
if (attrib->type == VAConfigAttribContextPriority)
{
attrib->value = CONTEXT_PRIORITY_MAX;
}
else
#endif
{
status = VA_ATTRIB_NOT_SUPPORTED;
}
return status;
}
VAStatus MediaLibvaCaps::CreateEncAttributes(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap **attributeList)
{
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAStatus status = CreateAttributeList(attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
auto attribList = *attributeList;
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
status = CheckEncRTFormat(profile, entrypoint, &attrib);
DDI_CHK_RET(status, "Failed to Check Encode RT Format!");
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribMaxPictureWidth;
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribMaxPictureWidth, &attrib.value);
if(IsMpeg2Profile(profile))
{
attrib.value = CODEC_2K_MAX_PIC_WIDTH;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribMaxPictureHeight;
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribMaxPictureHeight, &attrib.value);
if(IsMpeg2Profile(profile))
{
attrib.value = CODEC_2K_MAX_PIC_HEIGHT;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncJPEG;
VAConfigAttribValEncJPEG jpegAttribVal;
jpegAttribVal.bits.arithmatic_coding_mode = 0;
jpegAttribVal.bits.progressive_dct_mode = 0;
jpegAttribVal.bits.non_interleaved_mode = 0;
jpegAttribVal.bits.differential_mode = 0;
jpegAttribVal.bits.max_num_components = jpegNumComponent;
jpegAttribVal.bits.max_num_scans = 1;
jpegAttribVal.bits.max_num_huffman_tables = JPEG_MAX_NUM_HUFF_TABLE_INDEX;
jpegAttribVal.bits.max_num_quantization_tables = JPEG_MAX_QUANT_TABLE;
attrib.value = jpegAttribVal.value;
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncQualityRange;
if (profile == VAProfileJPEGBaseline)
{
// JPEG has no target usage.
attrib.value = 1;
}
else
{
attrib.value = NUM_TARGET_USAGE_MODES - 1;// Indicates TUs from 1 upto the value reported are supported
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncPackedHeaders;
attrib.value = VA_ATTRIB_NOT_SUPPORTED;
if ((IsAvcProfile(profile))||(IsHevcProfile(profile)))
{
attrib.value = VA_ENC_PACKED_HEADER_PICTURE |
VA_ENC_PACKED_HEADER_SEQUENCE |
VA_ENC_PACKED_HEADER_SLICE |
VA_ENC_PACKED_HEADER_RAW_DATA |
VA_ENC_PACKED_HEADER_MISC;
}
else if (IsMpeg2Profile(profile))
{
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA;
}
else if(IsJpegProfile(profile))
{
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA;
}
else if(IsVp9Profile(profile))
{
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA;
}
else if(IsVp8Profile(profile))
{
attrib.value = VA_ENC_PACKED_HEADER_NONE;
}
(*attribList)[attrib.type] = attrib.value;
if(IsJpegProfile(profile))
{
return status;
}
attrib.type = VAConfigAttribRateControl;
attrib.value = VA_RC_CQP;
if (entrypoint != VAEntrypointEncSliceLP ||
(entrypoint == VAEntrypointEncSliceLP && MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)))
{
attrib.value |= VA_RC_CBR | VA_RC_VBR | VA_RC_MB;
if (IsHevcProfile(profile))
{
if (entrypoint != VAEntrypointEncSliceLP)
attrib.value |= VA_RC_ICQ | VA_RC_QVBR;
attrib.value |= VA_RC_VCM;
}
}
if (IsAvcProfile(profile) && (entrypoint != VAEntrypointEncSliceLP))
{
attrib.value |= VA_RC_ICQ | VA_RC_VCM | VA_RC_QVBR | VA_RC_AVBR;
}
if (IsAvcProfile(profile) &&
((entrypoint == VAEntrypointEncSliceLP) && MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)))
{
attrib.value |= VA_RC_QVBR;
}
if(entrypoint == VAEntrypointFEI)
{
attrib.value = VA_RC_CQP;
}
else if(entrypoint == VAEntrypointStats)
{
attrib.value = VA_RC_NONE;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncInterlaced;
attrib.value = VA_ENC_INTERLACED_NONE;
#ifndef ANDROID
if(IsAvcProfile(profile))
{
attrib.value = VA_ENC_INTERLACED_FIELD;
}
if(IsMpeg2Profile(profile))
{
attrib.value = VA_ENC_INTERLACED_FRAME;
}
#endif
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncMaxRefFrames;
if (entrypoint == VAEntrypointEncSliceLP)
{
//VDEnc Low delay P
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1);
if(IsHevcProfile(profile))
{
//VDEnc Low Delay B, for B frame, it should be 3, 1 instead of this value, but libva could distinguish it with different frame type now
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES_LDB | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_LDB << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1);
}
}
else
{
// default value: 1 frame for each reference list
attrib.value = 1 | (1 << 16);
if(IsAvcProfile(profile))
{
attrib.value = CODECHAL_ENCODE_NUM_MAX_VME_L0_REF | (CODECHAL_ENCODE_NUM_MAX_VME_L1_REF << 16);
}
if(IsVp8Profile(profile))
{
attrib.value = ENCODE_VP8_NUM_MAX_L0_REF ;
}
if (IsHevcProfile(profile))
{
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribEncMaxRefFrames, &attrib.value);
}
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncMaxSlices;
if (entrypoint == VAEntrypointEncSliceLP)
{
if (IsAvcProfile(profile))
{
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED;
}
else if (IsHevcProfile(profile))
{
attrib.value = ENCODE_HEVC_VDENC_NUM_MAX_SLICES;
}
}
else
{
attrib.value = 0;
if (IsAvcProfile(profile))
{
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED;
}
else if (IsHevcProfile(profile))
{
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribEncMaxSlices, &attrib.value);
}
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncSliceStructure;
if (entrypoint == VAEntrypointEncSliceLP)
{
attrib.value = VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS
| VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE;
}
else
{
attrib.value = VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncQuantization;
if(IsAvcProfile(profile))
{
attrib.value = VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED;
}
else
{
attrib.value = VA_ENC_QUANTIZATION_NONE;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncIntraRefresh;
attrib.value = VA_ENC_INTRA_REFRESH_NONE;
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribEncIntraRefresh, &attrib.value);
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncSkipFrame;
if (entrypoint == VAEntrypointEncSliceLP)
{
if (IsAvcProfile(profile))
{
attrib.value = 1;
}
else
{
attrib.value = 0;
}
}
else
{
attrib.value = 1;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncryption;
attrib.value = VA_ATTRIB_NOT_SUPPORTED;
if (m_isEntryptSupported)
{
attrib.value = 0;
uint32_t encryptTypes[DDI_CP_ENCRYPT_TYPES_NUM] = {0};
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile,
encryptTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t j = 0; j < numTypes; j++)
{
attrib.value |= encryptTypes[j];
}
}
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncROI;
if (entrypoint == VAEntrypointEncSliceLP)
{
VAConfigAttribValEncROI roi_attrib = {0};
if (IsAvcProfile(profile))
{
roi_attrib.bits.num_roi_regions = ENCODE_VDENC_AVC_MAX_ROI_NUMBER_G9;
}
else if (IsHevcProfile(profile))
{
roi_attrib.bits.num_roi_regions = CODECHAL_ENCODE_HEVC_MAX_NUM_ROI;
}
roi_attrib.bits.roi_rc_priority_support = 0;
roi_attrib.bits.roi_rc_qp_delta_support = 1;
attrib.value = roi_attrib.value;
}
else
{
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribEncROI, &attrib.value);
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribProcessingRate;
attrib.value = VA_PROCESSING_RATE_ENCODE;
(*attribList)[attrib.type] = attrib.value;
attrib.type = (VAConfigAttribType)VAConfigAttribEncDirtyRect;
attrib.value = 4;
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncParallelRateControl;
attrib.value = 1;
(*attribList)[attrib.type] = attrib.value;
if ((entrypoint == VAEntrypointFEI) && (IsAvcProfile(profile) || IsHevcProfile(profile)))
{
attrib.type = (VAConfigAttribType)VAConfigAttribFEIFunctionType;
attrib.value = IsAvcProfile(profile) ?
(VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK | VA_FEI_FUNCTION_ENC_PAK) :
VA_FEI_FUNCTION_ENC_PAK;
(*attribList)[attrib.type] = attrib.value;
}
attrib.type = (VAConfigAttribType)VAConfigAttribFEIMVPredictors;
attrib.value = 0;
if(IsAvcProfile(profile) || IsHevcProfile(profile))
{
attrib.value = DDI_CODEC_FEI_MAX_NUM_MVPREDICTOR;
}
(*attribList)[attrib.type] = attrib.value;
if(profile == VAProfileNone)
{
attrib.type = (VAConfigAttribType)VAConfigAttribStats;
VAConfigAttribValStats attribValStats;
memset(&attribValStats, 0, sizeof(attribValStats));
attribValStats.bits.max_num_past_references = DDI_CODEC_STATS_MAX_NUM_PAST_REFS;
attribValStats.bits.max_num_future_references = DDI_CODEC_STATS_MAX_NUM_FUTURE_REFS;
attribValStats.bits.num_outputs = DDI_CODEC_STATS_MAX_NUM_OUTPUTS;
attribValStats.bits.interlaced = DDI_CODEC_STATS_INTERLACED_SUPPORT;
attrib.value = attribValStats.value;
(*attribList)[attrib.type] = attrib.value;
}
attrib.type = (VAConfigAttribType)VAConfigAttribCustomRoundingControl;
GetPlatformSpecificAttrib(profile, entrypoint,
(VAConfigAttribType)VAConfigAttribCustomRoundingControl, &attrib.value);
(*attribList)[attrib.type] = attrib.value;
if(IsAvcProfile(profile))
{
// Use VAConfigAttribQPBlockSize to report MBQP support:
// >0 means supported, 0 unsupported. Previous versions of driver
// return VA_ATTRIB_NOT_SUPPORTED for that attribute.
attrib.type = VAConfigAttribQPBlockSize;
if(entrypoint == VAEntrypointEncSliceLP)
{
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribQPBlockSize, &attrib.value);
if(attrib.value == VA_ATTRIB_NOT_SUPPORTED)
{
attrib.value = 0;
}
} else
{
// MBQP always supported for VME
attrib.value = CODECHAL_MACROBLOCK_WIDTH;
}
(*attribList)[attrib.type] = attrib.value;
}
if (IsAvcProfile(profile))
{
attrib.type = (VAConfigAttribType)VAConfigAttribMaxFrameSize;
VAConfigAttribValMaxFrameSize attribValMaxFrameSize;
memset(&attribValMaxFrameSize, 0, sizeof(attribValMaxFrameSize));
attribValMaxFrameSize.bits.max_frame_size = 1;
attribValMaxFrameSize.bits.multiple_pass = 1;
attribValMaxFrameSize.bits.reserved = 0;
attrib.value = attribValMaxFrameSize.value;
(*attribList)[attrib.type] = attrib.value;
}
if (IsHevcProfile(profile))
{
attrib.type = (VAConfigAttribType) VAConfigAttribPredictionDirection;
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribPredictionDirection, &attrib.value);
(*attribList)[attrib.type] = attrib.value;
}
return status;
}
VAStatus MediaLibvaCaps::CreateDecAttributes(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap **attributeList)
{
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAStatus status = CreateAttributeList(attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
auto attribList = *attributeList;
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
if ( profile == VAProfileJPEGBaseline )
{
// at present, latest libva have not support RGB24.
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_RGB16 | VA_RT_FORMAT_RGB32;
}
else if(profile == VAProfileHEVCMain10)
{
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10;
}
else if(profile == VAProfileHEVCMain422_10)
{
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV420_10 | VA_RT_FORMAT_YUV422_10;
}
else
{
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_RGB32;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribDecSliceMode;
if (IsAvcProfile(profile))
{
attrib.value = VA_DEC_SLICE_MODE_NORMAL | VA_DEC_SLICE_MODE_BASE;
}
else if (IsHevcProfile(profile))
{
bool hevcmainProfileSupported = false;
attrib.value = 0;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMainDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain10Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit420Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD42210bitDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit422Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD4448bitDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD44410bitDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit444Decoding))
{
attrib.value |= VA_DEC_SLICE_MODE_NORMAL;
hevcmainProfileSupported = true;
}
if ((MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMainShortDecoding) ||
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMain10ShortDecoding))
&& MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))
{
attrib.value |= VA_DEC_SLICE_MODE_BASE;
hevcmainProfileSupported = true;
}
if (!hevcmainProfileSupported)
{
attrib.value = VA_ATTRIB_NOT_SUPPORTED;
}
}
else if (profile == VAProfileVP9Profile0
|| profile == VAProfileVP9Profile2
|| profile == VAProfileVP9Profile1
|| profile == VAProfileVP9Profile3)
{
bool vp9ProfileSupported = false;
attrib.value = 0;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile0Decoding8bit420)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444))
{
attrib.value |= VA_DEC_SLICE_MODE_NORMAL | VA_DEC_SLICE_MODE_BASE;
vp9ProfileSupported = true;
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444))
{
attrib.value |= VA_DEC_SLICE_MODE_NORMAL;
vp9ProfileSupported = true;
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding10bit420))
{
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_10;
attrib.value |= VA_DEC_SLICE_MODE_NORMAL;
vp9ProfileSupported = true;
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444))
{
attrib.value |= VA_DEC_SLICE_MODE_NORMAL;
vp9ProfileSupported = true;
}
if (!vp9ProfileSupported)
{
attrib.value = VA_ATTRIB_NOT_SUPPORTED;
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444))
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding))
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_10;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444))
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444_10;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420))
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_12;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444))
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444_12;
}
else
{
attrib.value = VA_DEC_SLICE_MODE_NORMAL;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribDecProcessing;
attrib.value = VA_DEC_PROCESSING_NONE;
GetPlatformSpecificAttrib(profile, entrypoint,
VAConfigAttribDecProcessing, &attrib.value);
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribMaxPictureWidth;
attrib.value = CODEC_MAX_PIC_WIDTH;
if(profile == VAProfileJPEGBaseline)
{
attrib.value = ENCODE_JPEG_MAX_PIC_WIDTH;
}
if(IsVc1Profile(profile) || IsMpeg2Profile(profile))
{
attrib.value = CODEC_2K_MAX_PIC_WIDTH;
}
if(IsVp8Profile(profile))
{
attrib.value = CODEC_4K_MAX_PIC_WIDTH;
}
if(IsAvcProfile(profile))
{
attrib.value = CODEC_4K_MAX_PIC_WIDTH;
}
if(IsHevcProfile(profile) || IsVp9Profile(profile))
{
attrib.value = CODEC_8K_MAX_PIC_WIDTH;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribMaxPictureHeight;
attrib.value = CODEC_MAX_PIC_HEIGHT;
if(profile == VAProfileJPEGBaseline)
{
attrib.value = ENCODE_JPEG_MAX_PIC_HEIGHT;
}
if(IsVc1Profile(profile) || IsMpeg2Profile(profile))
{
attrib.value = CODEC_2K_MAX_PIC_HEIGHT;
}
if(IsVp8Profile(profile))
{
attrib.value = CODEC_4K_MAX_PIC_HEIGHT;
}
if(IsAvcProfile(profile))
{
attrib.value = CODEC_4K_MAX_PIC_HEIGHT;
}
if(IsHevcProfile(profile) || IsVp9Profile(profile))
{
attrib.value = CODEC_8K_MAX_PIC_HEIGHT;
}
(*attribList)[attrib.type] = attrib.value;
attrib.type = VAConfigAttribEncryption;
attrib.value = VA_ATTRIB_NOT_SUPPORTED;
if (m_isEntryptSupported)
{
attrib.value = 0;
uint32_t encryptTypes[DDI_CP_ENCRYPT_TYPES_NUM] = {0};
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile,
encryptTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t j = 0; j < numTypes; j++)
{
attrib.value |= encryptTypes[j];
}
}
}
(*attribList)[attrib.type] = attrib.value;
if(profile == VAProfileJPEGBaseline)
{
attrib.type = VAConfigAttribDecJPEG;
attrib.value = ((1 << VA_ROTATION_NONE) | (1 << VA_ROTATION_90) | (1 << VA_ROTATION_180) | (1 << VA_ROTATION_270));
(*attribList)[attrib.type] = attrib.value;
}
if(profile == VAProfileNone)
{
attrib.type = (VAConfigAttribType)VAConfigAttribStats;
VAConfigAttribValStats attribValStats;
memset(&attribValStats, 0, sizeof(attribValStats));
attribValStats.bits.max_num_past_references = DDI_CODEC_STATS_MAX_NUM_PAST_REFS;
attribValStats.bits.max_num_future_references = DDI_CODEC_STATS_MAX_NUM_FUTURE_REFS;
attribValStats.bits.num_outputs = DDI_CODEC_STATS_MAX_NUM_OUTPUTS;
attribValStats.bits.interlaced = DDI_CODEC_STATS_INTERLACED_SUPPORT;
attrib.value = attribValStats.value;
(*attribList)[attrib.type] = attrib.value;
}
attrib.type = VAConfigAttribProcessingRate;
attrib.value = VA_PROCESSING_RATE_DECODE;
(*attribList)[attrib.type] = attrib.value;
attrib.type = (VAConfigAttribType)VAConfigAttribCustomRoundingControl;
GetPlatformSpecificAttrib(profile, entrypoint,
(VAConfigAttribType)VAConfigAttribCustomRoundingControl, &attrib.value);
(*attribList)[attrib.type] = attrib.value;
return status;
}
VAStatus MediaLibvaCaps::CreateVpAttributes(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap **attributeList)
{
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAStatus status = CreateAttributeList(attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
auto attribList = *attributeList;
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
attrib.value = VA_RT_FORMAT_YUV420 |
VA_RT_FORMAT_YUV422 |
VA_RT_FORMAT_YUV444 |
VA_RT_FORMAT_YUV400 |
VA_RT_FORMAT_YUV411 |
VA_RT_FORMAT_RGB16 |
VA_RT_FORMAT_RGB32;
if (m_mediaCtx->platform.eRenderCoreFamily == IGFX_GEN9_CORE)
attrib.value |= VA_RT_FORMAT_RGBP;
(*attribList)[attrib.type] = attrib.value;
return status;
}
VAStatus MediaLibvaCaps::LoadAvcDecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _AVC_DECODE_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrAVCVLDLongDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrAVCVLDShortDecoding))
{
status = CreateDecAttributes(VAProfileH264Main, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[3] = {
VAProfileH264Main,
VAProfileH264High,
VAProfileH264ConstrainedBaseline};
uint32_t configStartIdx, configNum;
for (int32_t i = 0; i < 3; i++)
{
configStartIdx = m_decConfigs.size();
for (int32_t j = 0; j < 2; j++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[j], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile[i],
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(m_decSliceMode[j], encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
configNum = m_decConfigs.size() - configStartIdx;
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, configNum);
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadAvcEncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#if defined (_AVC_ENCODE_VME_SUPPORTED) || defined (_AVC_ENCODE_VDENC_SUPPORTED)
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVC))
{
status = CreateEncAttributes(VAProfileH264Main, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[3] = {
VAProfileH264Main,
VAProfileH264High,
VAProfileH264ConstrainedBaseline};
VAEntrypoint entrypoint[2] = {VAEntrypointEncSlice, VAEntrypointFEI};
uint32_t feiFunctions[3] = {
VA_FEI_FUNCTION_ENC,
VA_FEI_FUNCTION_PAK,
VA_FEI_FUNCTION_ENC_PAK};
uint32_t configStartIdx;
for (int32_t e = 0; e < 2; e++)
{
status = CreateEncAttributes(VAProfileH264ConstrainedBaseline, entrypoint[e], &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
for (int32_t i = 0; i < 3; i++)
{
configStartIdx = m_encConfigs.size();
bool isFei = !!(entrypoint[e] == VAEntrypointFEI);
int32_t maxRcMode = (entrypoint[e] == VAEntrypointEncSlice ? 9 : 1);
for (int32_t j = 0; j < maxRcMode; j++)
{
if (isFei)
{
for (int32_t k = 0; k < 3; k++)
{
AddEncConfig(m_encRcMode[j], feiFunctions[k]);
}
}
else
AddEncConfig(m_encRcMode[j]);
}
AddProfileEntry(profile[i], entrypoint[e], attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadAvcEncLpProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#if defined (_AVC_ENCODE_VME_SUPPORTED) || defined (_AVC_ENCODE_VDENC_SUPPORTED)
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVCVdenc))
{
status = CreateEncAttributes(VAProfileH264Main, VAEntrypointEncSliceLP, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[3] = {
VAProfileH264Main,
VAProfileH264High,
VAProfileH264ConstrainedBaseline};
for (int32_t i = 0; i < 3; i++)
{
uint32_t configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_CQP);
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))
{
/* m_encRcMode[0] is VA_RC_CQP and it is already added */
for (int32_t j = 1; j < 5; j++)
{
AddEncConfig(m_encRcMode[j]);
}
AddEncConfig(VA_RC_QVBR);
#if VA_CHECK_VERSION(1, 10, 0)
AddEncConfig(VA_RC_TCBRC);
#endif
}
AddProfileEntry(profile[i], VAEntrypointEncSliceLP, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadMpeg2DecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _MPEG2_DECODE_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrMPEG2VLDDecoding))
{
status = CreateDecAttributes(VAProfileMPEG2Simple, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[2] = {VAProfileMPEG2Simple, VAProfileMPEG2Main};
for (int32_t i = 0; i < 2; i++)
{
uint32_t configStartIdx = m_decConfigs.size();
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE);
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, 1);
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadMpeg2EncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _MPEG2_ENCODE_VME_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeMPEG2))
{
status = CreateEncAttributes(VAProfileMPEG2Simple, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[2] = {VAProfileMPEG2Simple, VAProfileMPEG2Main};
for (int32_t i = 0; i < 2; i++)
{
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < 3; j++)
{
AddEncConfig(m_encRcMode[j]);
}
AddProfileEntry(profile[i], VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadJpegDecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _JPEG_DECODE_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelJPEGDecoding))
{
status = CreateDecAttributes(VAProfileJPEGBaseline, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE);
AddProfileEntry(VAProfileJPEGBaseline, VAEntrypointVLD, attributeList, configStartIdx, 1);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadJpegEncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _JPEG_ENCODE_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeJPEG))
{
status = CreateEncAttributes(VAProfileJPEGBaseline, VAEntrypointEncPicture, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_NONE);
AddProfileEntry(VAProfileJPEGBaseline, VAEntrypointEncPicture, attributeList,
configStartIdx, 1);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadVc1DecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _VC1_DECODE_SUPPORTED
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVC1VLDDecoding))
{
status = CreateDecAttributes(VAProfileVC1Main, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
VAProfile profile[3] = {VAProfileVC1Advanced, VAProfileVC1Main, VAProfileVC1Simple};
for (int32_t i = 0; i < 3; i++)
{
uint32_t configStartIdx = m_decConfigs.size();
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE);
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, 1);
}
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadVp8DecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _VP8_DECODE_SUPPORTED
AttribMap *attributeList;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP8VLDDecoding))
{
status = CreateDecAttributes(VAProfileVP8Version0_3, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE);
AddProfileEntry(VAProfileVP8Version0_3, VAEntrypointVLD, attributeList, configStartIdx, 1);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadVp8EncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _VP8_ENCODE_SUPPORTED
AttribMap *attributeList;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP8))
{
status = CreateEncAttributes(VAProfileVP8Version0_3, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < 3; j++)
{
AddEncConfig(m_encRcMode[j]);
}
AddProfileEntry(VAProfileVP8Version0_3, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadAdvancedDecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
return status;
}
VAStatus MediaLibvaCaps::LoadVp9DecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _VP9_DECODE_SUPPORTED
AttribMap *attributeList;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile0Decoding8bit420))
{
status = CreateDecAttributes(VAProfileVP9Profile0, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
for (int32_t i = 0; i < 2; i++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile0,
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
AddProfileEntry(VAProfileVP9Profile0, VAEntrypointVLD, attributeList,
configStartIdx, m_decConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420))
{
status = CreateDecAttributes(VAProfileVP9Profile2, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
for (int32_t i = 0; i < 2; i++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile2,
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
AddProfileEntry(VAProfileVP9Profile2, VAEntrypointVLD, attributeList,
configStartIdx, m_decConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444))
{
status = CreateDecAttributes(VAProfileVP9Profile1, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
for (int32_t i = 0; i < 2; i++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile1,
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
AddProfileEntry(VAProfileVP9Profile1, VAEntrypointVLD, attributeList,
configStartIdx, m_decConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444))
{
status = CreateDecAttributes(VAProfileVP9Profile3, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
for (int32_t i = 0; i < 2; i++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile3,
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
AddProfileEntry(VAProfileVP9Profile3, VAEntrypointVLD, attributeList,
configStartIdx, m_decConfigs.size() - configStartIdx);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadVp9EncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
return status;
}
VAStatus MediaLibvaCaps::LoadHevcDecProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
#ifdef _HEVC_DECODE_SUPPORTED
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMainDecoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMainShortDecoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain10Decoding)
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMain10ShortDecoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain10);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit420Decoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain12);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD42210bitDecoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain422_10);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit422Decoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain422_12);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD4448bitDecoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain444);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD44410bitDecoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain444_10);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit444Decoding))
{
LoadDecProfileEntrypoints(VAProfileHEVCMain444_12);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadDecProfileEntrypoints(VAProfile profile)
{
AttribMap *attributeList = nullptr;
VAStatus status = CreateDecAttributes(profile, VAEntrypointVLD, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_decConfigs.size();
for (int32_t j = 0; j < 2; j++)
{
for (int32_t k = 0; k < 2; k++)
{
AddDecConfig(m_decSliceMode[j], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]);
if (m_isEntryptSupported)
{
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM];
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile,
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM);
if (numTypes > 0)
{
for (int32_t l = 0; l < numTypes; l++)
{
AddDecConfig(m_decSliceMode[j], encrytTypes[l],
m_decProcessMode[k]);
}
}
}
}
}
AddProfileEntry(profile, VAEntrypointVLD, attributeList,
configStartIdx, m_decConfigs.size() - configStartIdx);
return status;
}
VAStatus MediaLibvaCaps::LoadHevcEncProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
const uint8_t rcModeSize = (sizeof(m_encRcMode))/(sizeof(m_encRcMode[0]));
#if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED)
AttribMap *attributeList = nullptr;
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC))
{
status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < rcModeSize; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointFEI, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_CQP, VA_FEI_FUNCTION_ENC_PAK);
AddProfileEntry(VAProfileHEVCMain, VAEntrypointFEI, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit))
{
status = CreateEncAttributes(VAProfileHEVCMain10, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < rcModeSize; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit))
{
status = CreateEncAttributes(VAProfileHEVCMain12, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < rcModeSize; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain12, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit422))
{
status = CreateEncAttributes(VAProfileHEVCMain422_10, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < rcModeSize; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain422_10, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit422))
{
status = CreateEncAttributes(VAProfileHEVCMain422_12, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t configStartIdx = m_encConfigs.size();
for (int32_t j = 0; j < rcModeSize; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain422_12, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}
#endif
return status;
}
VAStatus MediaLibvaCaps::LoadNoneProfileEntrypoints()
{
VAStatus status = VA_STATUS_SUCCESS;
AttribMap *attributeList = nullptr;
status = CreateVpAttributes(VAProfileNone, VAEntrypointVideoProc, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
uint32_t configStartIdx = m_vpConfigs.size();
AddVpConfig(0);
AddProfileEntry(VAProfileNone, VAEntrypointVideoProc, attributeList, configStartIdx, 1);
configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_NONE);
AddProfileEntry(VAProfileNone, VAEntrypointStats, attributeList,
configStartIdx, 1);
return status;
}
VAStatus MediaLibvaCaps::GetConfigAttributes(VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib *attribList,
int32_t numAttribs)
{
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t i = GetProfileTableIdx(profile, entrypoint);
switch(i)
{
case -2:
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
case -1:
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
default:
break;
}
DDI_CHK_NULL(m_profileEntryTbl[i].m_attributes, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
for (int32_t j = 0; j < numAttribs; j++)
{
if (m_profileEntryTbl[i].m_attributes->find(attribList[j].type) !=
m_profileEntryTbl[i].m_attributes->end())
{
attribList[j].value = (*m_profileEntryTbl[i].m_attributes)[attribList[j].type];
}
else
{
if (GetGeneralConfigAttrib(&attribList[j]) != VA_STATUS_SUCCESS)
{
//For unknown attribute, set to VA_ATTRIB_NOT_SUPPORTED
attribList[j].value = VA_ATTRIB_NOT_SUPPORTED;
}
}
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CreateDecConfig(
int32_t profileTableIdx,
VAConfigAttrib *attribList,
int32_t numAttribs,
VAConfigID *configId)
{
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
if (numAttribs)
{
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
}
VAConfigAttrib decAttributes[3];
decAttributes[0].type = VAConfigAttribDecSliceMode;
decAttributes[0].value = VA_DEC_SLICE_MODE_NORMAL;
decAttributes[1].type = VAConfigAttribEncryption;
decAttributes[1].value = VA_ENCRYPTION_TYPE_NONE;
decAttributes[2].type = VAConfigAttribDecProcessing;
decAttributes[2].value = VA_DEC_PROCESSING_NONE;
int32_t i,j;
for (j = 0; j < numAttribs; j++)
{
for (i = 0; i < 3; i++)
{
if (attribList[j].type == decAttributes[i].type)
{
decAttributes[i].value = attribList[j].value;
break;
}
}
}
int32_t startIdx = m_profileEntryTbl[profileTableIdx].m_configStartIdx;
int32_t configNum = m_profileEntryTbl[profileTableIdx].m_configNum;
for (i = startIdx; i < (startIdx + configNum); i++)
{
if (decAttributes[0].value == m_decConfigs[i].m_sliceMode
&& decAttributes[1].value == m_decConfigs[i].m_encryptType
&& decAttributes[2].value == m_decConfigs[i].m_processType)
{
break;
}
}
if (i < (startIdx + configNum))
{
*configId = DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + i;
return VA_STATUS_SUCCESS;
}
else
{
*configId = 0xFFFFFFFF;
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
}
}
VAStatus MediaLibvaCaps::CreateEncConfig(
int32_t profileTableIdx,
VAEntrypoint entrypoint,
VAConfigAttrib *attribList,
int32_t numAttribs,
VAConfigID *configId)
{
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
if (numAttribs)
{
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
}
uint32_t rcMode = VA_RC_CQP;
if((entrypoint == VAEntrypointStats) || (entrypoint == VAEntrypointEncPicture))
{
rcMode = VA_RC_NONE;
}
bool rc_mb_flag = false;
if (entrypoint == VAEntrypointEncSliceLP)
{
switch(m_profileEntryTbl[profileTableIdx].m_profile)
{
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain444:
case VAProfileHEVCMain444_10:
rc_mb_flag = true;
break;
default:
rc_mb_flag = false;
break;
}
m_vdencActive = true;
}
uint32_t feiFunction = 0;
int32_t j;
for (j = 0; j < numAttribs; j++)
{
if (VAConfigAttribRateControl == attribList[j].type)
{
//do not set VA_RC_MB without other BRC mode
//if it happend, just set it to default RC mode
if(attribList[j].value != VA_RC_MB)
{
if ((attribList[j].value == VA_RC_CBR ||
attribList[j].value == VA_RC_VBR) && rc_mb_flag)
rcMode = attribList[j].value | VA_RC_MB;
else
rcMode = attribList[j].value;
}
}
if(VAConfigAttribFEIFunctionType == attribList[j].type)
{
feiFunction = attribList[j].value;
}
if(VAConfigAttribRTFormat == attribList[j].type)
{
VAConfigAttrib attribRT;
CheckEncRTFormat(m_profileEntryTbl[profileTableIdx].m_profile, entrypoint, &attribRT);
if((attribList[j].value | attribRT.value) == 0)
{
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
}
}
}
// If VAEntrypointFEI but FEI type (ENC/PAK/ENCPAK) wasn't provided via VAConfigAttribFEIFunctionType
// then use ENC_PAK as default
if (VAEntrypointFEI == entrypoint && 0 == feiFunction)
feiFunction = VA_FEI_FUNCTION_ENC_PAK;
int32_t startIdx = m_profileEntryTbl[profileTableIdx].m_configStartIdx;
int32_t configNum = m_profileEntryTbl[profileTableIdx].m_configNum;
for (j = startIdx; j < (startIdx + configNum); j++)
{
if (m_encConfigs[j].m_rcMode == rcMode &&
m_encConfigs[j].m_FeiFunction == feiFunction)
{
break;
}
}
if (j < (configNum + startIdx))
{
*configId = j + DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE;
return VA_STATUS_SUCCESS;
}
else
{
*configId = 0xFFFFFFFF;
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
}
}
VAStatus MediaLibvaCaps::CreateVpConfig(
int32_t profileTableIdx,
VAConfigAttrib *attribList,
int32_t numAttribs,
VAConfigID *configId)
{
// attribList and numAttribs are for future usage.
DDI_UNUSED(attribList);
DDI_UNUSED(numAttribs);
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
*configId = m_profileEntryTbl[profileTableIdx].m_configStartIdx
+ DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE;
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CheckDecodeResolution(
int32_t codecMode,
VAProfile profile,
uint32_t width,
uint32_t height)
{
uint32_t maxWidth = 0;
uint32_t maxHeight = 0;
switch (codecMode)
{
case CODECHAL_DECODE_MODE_MPEG2VLD:
maxWidth = m_decMpeg2MaxWidth;
maxHeight = m_decMpeg2MaxHeight;
break;
case CODECHAL_DECODE_MODE_VC1VLD:
maxWidth = m_decVc1MaxWidth;
maxHeight = m_decVc1MaxHeight;
break;
case CODECHAL_DECODE_MODE_JPEG:
maxWidth = m_decJpegMaxWidth;
maxHeight = m_decJpegMaxHeight;
break;
case CODECHAL_DECODE_MODE_HEVCVLD:
maxWidth = m_decHevcMaxWidth;
maxHeight = m_decHevcMaxHeight;
break;
case CODECHAL_DECODE_MODE_VP9VLD:
maxWidth = m_decVp9MaxWidth;
maxHeight = m_decVp9MaxHeight;
break;
default:
maxWidth = m_decDefaultMaxWidth;
maxHeight = m_decDefaultMaxHeight;
break;
}
uint32_t alignedHeight = 0;
if (profile == VAProfileVC1Advanced)
{
alignedHeight = MOS_ALIGN_CEIL(height,32);
}
else
{
alignedHeight = height;
}
if (width > maxWidth || alignedHeight > maxHeight)
{
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
}
else
{
return VA_STATUS_SUCCESS;
}
}
VAStatus MediaLibvaCaps::CheckEncodeResolution(
VAProfile profile,
uint32_t width,
uint32_t height)
{
switch (profile)
{
case VAProfileJPEGBaseline:
if (width > m_encJpegMaxWidth
|| width < m_encJpegMinWidth
|| height > m_encJpegMaxHeight
|| height < m_encJpegMinHeight)
{
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
}
break;
case VAProfileMPEG2Simple:
case VAProfileMPEG2Main:
if( width > CODEC_MAX_PIC_WIDTH
|| width < m_encMinWidth
|| height > CODEC_MAX_PIC_HEIGHT
|| height < m_encMinHeight)
{
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
}
break;
default:
if (width > m_encMax4kWidth
|| width < m_encMinWidth
|| height > m_encMax4kHeight
|| height < m_encMinHeight)
{
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
}
break;
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CheckProfile(VAProfile profile)
{
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::CreateConfig(
VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttrib *attribList,
int32_t numAttribs,
VAConfigID *configId)
{
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_RET(CheckProfile(profile),"Failed to check config!");
int32_t i = GetProfileTableIdx(profile, entrypoint);
if (i < 0)
{
if(i == -2)
{
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
}
else
{
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
}
}
VAStatus ret = CheckAttribList(profile, entrypoint, attribList, numAttribs);
if(ret != VA_STATUS_SUCCESS)
{
return ret;
}
if (CheckEntrypointCodecType(entrypoint, videoDecode))
{
return CreateDecConfig(i, attribList, numAttribs, configId);
}
else if(CheckEntrypointCodecType(entrypoint, videoProcess))
{
return CreateVpConfig(i, attribList, numAttribs, configId);
}
else if(CheckEntrypointCodecType(entrypoint, videoEncode))
{
return CreateEncConfig(i,entrypoint,attribList, numAttribs, configId);
}
else
{
DDI_ASSERTMESSAGE("DDI: Unsupported EntryPoint");
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
}
}
VAStatus MediaLibvaCaps::QueryConfigProfiles(
VAProfile *profileList,
int32_t *numProfiles)
{
DDI_CHK_NULL(profileList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(numProfiles, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
std::set<int32_t> profiles;
int32_t i;
for (i = 0; i < m_profileEntryCount; i++)
{
profiles.insert((int32_t)m_profileEntryTbl[i].m_profile);
}
std::set<int32_t>::iterator it;
for (it = profiles.begin(), i = 0; it != profiles.end(); ++it, i++)
{
profileList[i] = (VAProfile)*it;
}
*numProfiles = i;
DDI_CHK_CONDITION((i > DDI_CODEC_GEN_MAX_PROFILES),
"Execeed maximum number of profiles!", VA_STATUS_ERROR_MAX_NUM_EXCEEDED);
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::QueryConfigEntrypoints(
VAProfile profile,
VAEntrypoint *entrypointList,
int32_t *numEntrypoints)
{
DDI_CHK_NULL(entrypointList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(numEntrypoints, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t j = 0;
for (int32_t i = 0; i < m_profileEntryCount; i++)
{
if (m_profileEntryTbl[i].m_profile == profile)
{
entrypointList[j] = m_profileEntryTbl[i].m_entrypoint;
j++;
}
}
*numEntrypoints = j;
DDI_CHK_CONDITION((j == 0), "cant find the profile!", VA_STATUS_ERROR_UNSUPPORTED_PROFILE);
/* If the assert fails then GEN_MAX_ENTRYPOINTS needs to be bigger */
DDI_CHK_CONDITION((j > DDI_CODEC_GEN_MAX_ENTRYPOINTS),
"Execeed maximum number of profiles!", VA_STATUS_ERROR_MAX_NUM_EXCEEDED);
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::QueryConfigAttributes(
VAConfigID configId,
VAProfile *profile,
VAEntrypoint *entrypoint,
VAConfigAttrib *attribList,
int32_t *numAttribs)
{
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(numAttribs, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t profileTableIdx = -1;
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalide config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
auto allAttribsList = m_profileEntryTbl[profileTableIdx].m_attributes;
DDI_CHK_NULL(allAttribsList, "Null pointer", VA_STATUS_ERROR_INVALID_CONFIG);
uint32_t j = 0;
for (auto it = allAttribsList->begin(); it != allAttribsList->end(); ++it)
{
if (it->second != VA_ATTRIB_NOT_SUPPORTED)
{
attribList[j].type = it->first;
attribList[j].value = it->second;
j++;
}
}
*numAttribs = j;
// tracing profile/entry/config, compiler will optimize if trace is disabled
uint32_t data[] = {*profile, *entrypoint, j};
MOS_TraceEventExt(EVENT_VA_CONFIG, EVENT_TYPE_INFO, data, sizeof(data), attribList, j*sizeof(VAConfigAttrib));
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetEncConfigAttr(
VAConfigID configId,
VAProfile *profile,
VAEntrypoint *entrypoint,
uint32_t *rcMode,
uint32_t *feiFunction)
{
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(rcMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t profileTableIdx = -1;
int32_t configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE;
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalide config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx;
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx
+ m_profileEntryTbl[profileTableIdx].m_configNum;
if (configOffset < configStart || configOffset > configEnd)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
*rcMode = m_encConfigs[configOffset].m_rcMode;
*feiFunction = m_encConfigs[configOffset].m_FeiFunction;
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetDecConfigAttr(
VAConfigID configId,
VAProfile *profile,
VAEntrypoint *entrypoint,
uint32_t *sliceMode,
uint32_t *encryptType,
uint32_t *processMode)
{
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(sliceMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(encryptType, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(processMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t profileTableIdx = -1;
int32_t configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE;
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalide config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx;
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx
+ m_profileEntryTbl[profileTableIdx].m_configNum;
if (configOffset < configStart || configOffset > configEnd)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
if (sliceMode)
{
*sliceMode = m_decConfigs[configOffset].m_sliceMode;
}
if (encryptType)
{
*encryptType = m_decConfigs[configOffset].m_encryptType;
}
if (processMode)
{
*processMode = m_decConfigs[configOffset].m_processType;
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetVpConfigAttr(
VAConfigID configId,
VAProfile *profile,
VAEntrypoint *entrypoint)
{
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t profileTableIdx = -1;
int32_t configOffset = configId - DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE;
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalide config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx;
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx
+ m_profileEntryTbl[profileTableIdx].m_configNum;
if (configOffset < configStart || configOffset > configEnd)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::QueryProcessingRate(
VAConfigID configId,
VAProcessingRateParameter *procBuf,
uint32_t *processingRate)
{
DDI_CHK_NULL(procBuf, "Null procBuf", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(processingRate, "Null processingRate", VA_STATUS_ERROR_INVALID_PARAMETER);
int32_t profileTableIdx = -1;
VAEntrypoint entrypoint;
VAProfile profile;
VAStatus status = GetProfileEntrypointFromConfigId(configId, &profile, &entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalide config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
PLATFORM platform;
MEDIA_FEATURE_TABLE skuTable;
MEDIA_WA_TABLE waTable;
memset(&platform, 0, sizeof(platform));
if (MOS_STATUS_SUCCESS != HWInfo_GetGfxInfo(m_mediaCtx->fd, m_mediaCtx->pDrmBufMgr, &platform, &skuTable, &waTable, m_mediaCtx->pGtSystemInfo))
{
DDI_ASSERTMESSAGE("Fatal error - Cannot get Sku/Wa Tables/GtSystemInfo and Platform information");
return VA_STATUS_ERROR_OPERATION_FAILED;
}
const int32_t tuIdxTable[] = {7, 6, 5, 4, 3, 2, 1, 0};
VAProcessingRateParameterEnc *processingRateBuffEnc = nullptr;
VAProcessingRateParameterDec *processingRateBuffDec = nullptr;
uint32_t tuIdx = tuIdxTable[TARGETUSAGE_BEST_SPEED];
VAStatus res = VA_STATUS_SUCCESS;
CODECHAL_MODE encodeMode = CODECHAL_UNSUPPORTED_MODE;
if ((entrypoint == VAEntrypointEncSlice) ||
(entrypoint == VAEntrypointEncSliceLP))
{
// Get VAProcessingBufferEnc
processingRateBuffEnc = &procBuf->proc_buf_enc;
if (processingRateBuffEnc &&
processingRateBuffEnc->quality_level < sizeof(tuIdxTable) / sizeof(tuIdxTable[0]))
{
// If app passes the rate input data from DDI and also its TU is valid, then use it
tuIdx = tuIdxTable[processingRateBuffEnc->quality_level];
}
if (IsAvcProfile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_AVC;
}
else if(IsMpeg2Profile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_MPEG2;
}
else if (IsVp8Profile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_VP8;
}
else if (IsJpegProfile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_JPEG;
}
else if(IsHevcProfile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_HEVC;
}
else if (IsVp9Profile(profile))
{
encodeMode = CODECHAL_ENCODE_MODE_VP9;
}
res = GetMbProcessingRateEnc(
&skuTable,
tuIdx,
encodeMode,
(entrypoint == VAEntrypointEncSliceLP),
processingRate);
}
else if (entrypoint == VAEntrypointVLD)
{
// Get VAProcessingBufferEnc
processingRateBuffDec = & procBuf->proc_buf_dec;
res = GetMbProcessingRateDec(
&skuTable,
processingRate);
}
else // VA_PROCESSING_RATE_NONE or else
{
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
return res;
}
VAStatus MediaLibvaCaps::QuerySurfaceAttributes(
VAConfigID configId,
VASurfaceAttrib *attribList,
uint32_t *numAttribs)
{
DDI_CHK_NULL(numAttribs, "Null num_attribs", VA_STATUS_ERROR_INVALID_PARAMETER);
if (attribList == nullptr)
{
*numAttribs = DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES;
return VA_STATUS_SUCCESS;
}
int32_t profileTableIdx = -1;
VAEntrypoint entrypoint;
VAProfile profile;
VAStatus status = GetProfileEntrypointFromConfigId(configId, &profile, &entrypoint, &profileTableIdx);
DDI_CHK_RET(status, "Invalid config_id!");
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount)
{
return VA_STATUS_ERROR_INVALID_CONFIG;
}
VASurfaceAttrib *attribs = (VASurfaceAttrib *)MOS_AllocAndZeroMemory(DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES * sizeof(*attribs));
if (attribs == nullptr)
{
return VA_STATUS_ERROR_ALLOCATION_FAILED;
}
uint32_t i = 0;
if (entrypoint == VAEntrypointVideoProc) /* vpp */
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
i++;
attribs[i].type = VASurfaceAttribMaxWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VP_MAX_PIC_WIDTH;
i++;
attribs[i].type = VASurfaceAttribMaxHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VP_MAX_PIC_HEIGHT;
i++;
attribs[i].type = VASurfaceAttribMinWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VP_MIN_PIC_WIDTH;
i++;
attribs[i].type = VASurfaceAttribMinHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VP_MIN_PIC_HEIGHT;
i++;
for (uint32_t j = 0; j < m_numVpSurfaceAttr; j++)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = m_vpSurfaceAttr[j];
i++;
}
attribs[i].type = VASurfaceAttribMemoryType;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
i++;
attribs[i].type = VASurfaceAttribExternalBufferDescriptor;
attribs[i].value.type = VAGenericValueTypePointer;
attribs[i].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.p = nullptr; /* ignore */
i++;
}
else if (entrypoint == VAEntrypointVLD) /* vld */
{
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P010;
i++;
if(profile == VAProfileVP9Profile2)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P012;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P016;
i++;
}
}
else if(profile == VAProfileHEVCMain12)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P012;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P016;
i++;
}
else if(profile == VAProfileHEVCMain422_10)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_YUY2;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y210;
i++;
}
else if(profile == VAProfileHEVCMain422_12)
{
//hevc rext: Y216 12/16bit 422
#if VA_CHECK_VERSION(1, 9, 0)
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y212;
i++;
#endif
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y216;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P012;
i++;
}
else if(profile == VAProfileHEVCMain444 || profile == VAProfileVP9Profile1)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_AYUV;
i++;
}
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileVP9Profile3)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y410;
i++;
if(profile == VAProfileVP9Profile3)
{
#if VA_CHECK_VERSION(1, 9, 0)
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y412;
i++;
#endif
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;
}
}
else if(profile == VAProfileHEVCMain444_12)
{
#if VA_CHECK_VERSION(1, 9, 0)
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y412;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y212;
i++;
#endif
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y416;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P012;
i++;
}
else if (profile == VAProfileJPEGBaseline)
{
for (uint32_t j = 0; j < m_numJpegSurfaceAttr; j++)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = m_jpegSurfaceAttr[j];
i++;
}
}
else
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
i++;
}
auto maxWidth = m_decDefaultMaxWidth;
auto maxHeight = m_decDefaultMaxHeight;
if(IsMpeg2Profile(profile))
{
maxWidth = m_decMpeg2MaxWidth;
maxHeight = m_decMpeg2MaxHeight;
}
else if(IsHevcProfile(profile))
{
maxWidth = m_decHevcMaxWidth;
maxHeight = m_decHevcMaxHeight;
}
else if(IsVc1Profile(profile))
{
maxWidth = m_decVc1MaxWidth;
maxHeight = m_decVc1MaxHeight;
}
else if(IsJpegProfile(profile))
{
maxWidth = m_decJpegMaxWidth;
maxHeight = m_decJpegMaxHeight;
}
else if(IsVp9Profile(profile))
{
maxWidth = m_decVp9MaxWidth;
maxHeight = m_decVp9MaxHeight;
}
attribs[i].type = VASurfaceAttribMaxWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = maxWidth;
i++;
attribs[i].type = VASurfaceAttribMaxHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = maxHeight;
i++;
attribs[i].type = VASurfaceAttribMemoryType;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
i++;
}
else if(entrypoint == VAEntrypointEncSlice || entrypoint == VAEntrypointEncSliceLP || entrypoint == VAEntrypointEncPicture || entrypoint == VAEntrypointFEI)
{
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('P', '0', '1', '0');
i++;
}
else if(profile == VAProfileHEVCMain12)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P012;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P016;
i++;
}
else if(profile == VAProfileHEVCMain422_10)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_YUY2;
i++;
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y210;
i++;
}
else if(profile == VAProfileHEVCMain422_12)
{
//hevc rext: Y216 12/16bit 422
#if VA_CHECK_VERSION(1, 9, 0)
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y212;
i++;
#endif
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y216;
i++;
}
else if (profile == VAProfileJPEGBaseline)
{
for (uint32_t j = 0; j < m_numJpegEncSurfaceAttr; j++)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = m_jpegEncSurfaceAttr[j];
i++;
}
}
else
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
i++;
}
attribs[i].type = VASurfaceAttribMaxWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = CODEC_MAX_PIC_WIDTH;
if(profile == VAProfileJPEGBaseline)
{
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_WIDTH;
}
if(IsAvcProfile(profile)||IsHevcProfile(profile)||IsVp8Profile(profile))
{
attribs[i].value.value.i = CODEC_4K_MAX_PIC_WIDTH;
}
i++;
attribs[i].type = VASurfaceAttribMaxHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = CODEC_MAX_PIC_HEIGHT;
if(profile == VAProfileJPEGBaseline)
{
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_HEIGHT;
}
if(IsAvcProfile(profile)||IsHevcProfile(profile)||IsVp8Profile(profile))
{
attribs[i].value.value.i = CODEC_4K_MAX_PIC_HEIGHT;
}
i++;
attribs[i].type = VASurfaceAttribMinWidth;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = m_encMinWidth;
if(profile == VAProfileJPEGBaseline)
{
attribs[i].value.value.i = m_encJpegMinWidth;
}
i++;
attribs[i].type = VASurfaceAttribMinHeight;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE;
attribs[i].value.value.i = m_encMinHeight;
if(profile == VAProfileJPEGBaseline)
{
attribs[i].value.value.i = m_encJpegMinHeight;
}
i++;
attribs[i].type = VASurfaceAttribMemoryType;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
i++;
}
else
{
MOS_FreeMemory(attribs);
return VA_STATUS_ERROR_UNIMPLEMENTED;
}
if (i > *numAttribs)
{
*numAttribs = i;
MOS_FreeMemory(attribs);
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
}
*numAttribs = i;
MOS_SecureMemcpy(attribList, i * sizeof(*attribs), attribs, i * sizeof(*attribs));
MOS_FreeMemory(attribs);
return status;
}
bool MediaLibvaCaps::IsVc1Profile(VAProfile profile)
{
return (
(profile == VAProfileVC1Advanced) ||
(profile == VAProfileVC1Main) ||
(profile == VAProfileVC1Simple)
);
}
bool MediaLibvaCaps::IsAvcProfile(VAProfile profile)
{
return (
(profile == VAProfileH264ConstrainedBaseline) ||
(profile == VAProfileH264Main) ||
(profile == VAProfileH264High)
);
}
bool MediaLibvaCaps::IsMpeg2Profile(VAProfile profile)
{
return (
(profile == VAProfileMPEG2Simple) ||
(profile == VAProfileMPEG2Main)
);
}
bool MediaLibvaCaps::IsVp8Profile(VAProfile profile)
{
return (profile == VAProfileVP8Version0_3);
}
bool MediaLibvaCaps::IsVp9Profile(VAProfile profile)
{
return (
(profile == VAProfileVP9Profile0) ||
(profile == VAProfileVP9Profile2) ||
(profile == VAProfileVP9Profile1) ||
(profile == VAProfileVP9Profile3)
);
}
bool MediaLibvaCaps::IsHevcProfile(VAProfile profile)
{
return (
(profile == VAProfileHEVCMain) ||
(profile == VAProfileHEVCMain10) ||
(profile == VAProfileHEVCMain12) ||
(profile == VAProfileHEVCMain422_10) ||
(profile == VAProfileHEVCMain422_12) ||
(profile == VAProfileHEVCMain444) ||
(profile == VAProfileHEVCMain444_10) ||
(profile == VAProfileHEVCMain444_12)
);
}
bool MediaLibvaCaps::IsJpegProfile(VAProfile profile)
{
return (profile == VAProfileJPEGBaseline);
}
bool MediaLibvaCaps::IsEncFei(VAEntrypoint entrypoint, uint32_t feiFunction)
{
if ((feiFunction & VA_FEI_FUNCTION_ENC_PAK) ||
(feiFunction == VA_FEI_FUNCTION_ENC) ||
(feiFunction == VA_FEI_FUNCTION_PAK) ||
(feiFunction == (VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK)) ||
(entrypoint == VAEntrypointStats))
{
return true;
}
return false;
}
CODECHAL_FUNCTION MediaLibvaCaps::GetEncodeCodecFunction(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction)
{
CODECHAL_FUNCTION codecFunction;
if (profile == VAProfileJPEGBaseline)
{
codecFunction = CODECHAL_FUNCTION_PAK;
}
else if (entrypoint == VAEntrypointEncSliceLP)
{
codecFunction = CODECHAL_FUNCTION_ENC_VDENC_PAK;
}
else
{
codecFunction = CODECHAL_FUNCTION_ENC_PAK;
/*
// FeiFunction bit 0: FEI_ENC_INTEL
// 1: FEI_PAK_INTEL
// 2: FEI_ENC_PAK_INTEL
//
// +---+---+---+
// | 2 | 1 | 0 | FeiFunction [2:0]
// +---+---+---+
//
// b000 means ENC_PAK
*/
if (feiFunction & VA_FEI_FUNCTION_ENC_PAK)
{
codecFunction = CODECHAL_FUNCTION_FEI_ENC_PAK;
}
else if (feiFunction == VA_FEI_FUNCTION_ENC)
{
codecFunction = CODECHAL_FUNCTION_FEI_ENC;
}
else if (feiFunction == VA_FEI_FUNCTION_PAK)
{
codecFunction = CODECHAL_FUNCTION_FEI_PAK;
}
else if (feiFunction == (VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK))
{
// codecFunction in context keeps FEI_ENC_PAK if input is ENC|PAK
codecFunction = CODECHAL_FUNCTION_FEI_ENC_PAK;
}
else if (entrypoint == VAEntrypointStats)
{
codecFunction = CODECHAL_FUNCTION_FEI_PRE_ENC;
}
}
return codecFunction;
}
CODECHAL_MODE MediaLibvaCaps::GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint)
{
if (entrypoint == VAEntrypointStats)
{
return CODECHAL_ENCODE_MODE_AVC;
}
switch (profile)
{
case VAProfileH264High:
case VAProfileH264Main:
case VAProfileH264ConstrainedBaseline:
return CODECHAL_ENCODE_MODE_AVC;
case VAProfileMPEG2Main:
case VAProfileMPEG2Simple:
return CODECHAL_ENCODE_MODE_MPEG2;
case VAProfileJPEGBaseline:
return CODECHAL_ENCODE_MODE_JPEG;
case VAProfileVP8Version0_3:
return CODECHAL_ENCODE_MODE_VP8;
case VAProfileVP9Profile0:
return CODECHAL_ENCODE_MODE_VP9;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain12:
case VAProfileHEVCMain422_10:
case VAProfileHEVCMain422_12:
return CODECHAL_ENCODE_MODE_HEVC;
default:
DDI_ASSERTMESSAGE("Invalid Encode Mode");
return CODECHAL_UNSUPPORTED_MODE;
}
}
CODECHAL_MODE MediaLibvaCaps::GetDecodeCodecMode(VAProfile profile)
{
switch (profile)
{
case VAProfileH264High:
case VAProfileH264Main:
case VAProfileH264ConstrainedBaseline:
return CODECHAL_DECODE_MODE_AVCVLD;
case VAProfileMPEG2Main:
case VAProfileMPEG2Simple:
return CODECHAL_DECODE_MODE_MPEG2VLD;
case VAProfileJPEGBaseline:
return CODECHAL_DECODE_MODE_JPEG;
case VAProfileVP8Version0_3:
return CODECHAL_DECODE_MODE_VP8VLD;
case VAProfileVP9Profile0:
case VAProfileVP9Profile1:
case VAProfileVP9Profile2:
case VAProfileVP9Profile3:
return CODECHAL_DECODE_MODE_VP9VLD;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain12:
case VAProfileHEVCMain422_10:
case VAProfileHEVCMain422_12:
case VAProfileHEVCMain444:
case VAProfileHEVCMain444_10:
case VAProfileHEVCMain444_12:
return CODECHAL_DECODE_MODE_HEVCVLD;
case VAProfileVC1Simple:
case VAProfileVC1Main:
case VAProfileVC1Advanced:
return CODECHAL_DECODE_MODE_VC1VLD;
default:
DDI_ASSERTMESSAGE("Invalid Encode Mode");
return CODECHAL_UNSUPPORTED_MODE;
}
}
std::string MediaLibvaCaps::GetDecodeCodecKey(VAProfile profile)
{
switch (profile)
{
case VAProfileH264High:
case VAProfileH264Main:
case VAProfileH264ConstrainedBaseline:
return DECODE_ID_AVC;
case VAProfileMPEG2Main:
case VAProfileMPEG2Simple:
return DECODE_ID_MPEG2;
case VAProfileJPEGBaseline:
return DECODE_ID_JPEG;
case VAProfileVP8Version0_3:
return DECODE_ID_VP8;
case VAProfileVP9Profile0:
case VAProfileVP9Profile1:
case VAProfileVP9Profile2:
case VAProfileVP9Profile3:
return DECODE_ID_VP9;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
return DECODE_ID_HEVC;
case VAProfileVC1Simple:
case VAProfileVC1Main:
case VAProfileVC1Advanced:
return DECODE_ID_VC1;
default:
DDI_ASSERTMESSAGE("Invalid Encode Mode");
return DECODE_ID_NONE;
}
}
std::string MediaLibvaCaps::GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction)
{
switch (profile)
{
case VAProfileH264High:
case VAProfileH264Main:
case VAProfileH264ConstrainedBaseline:
if (IsEncFei(entrypoint, feiFunction))
{
return ENCODE_ID_AVCFEI;
}
else
{
return ENCODE_ID_AVC;
}
case VAProfileMPEG2Main:
case VAProfileMPEG2Simple:
return ENCODE_ID_MPEG2;
case VAProfileJPEGBaseline:
return ENCODE_ID_JPEG;
case VAProfileVP8Version0_3:
return ENCODE_ID_VP8;
case VAProfileVP9Profile0:
return ENCODE_ID_VP9;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain12:
case VAProfileHEVCMain422_10:
case VAProfileHEVCMain422_12:
if (IsEncFei(entrypoint, feiFunction))
{
return ENCODE_ID_HEVCFEI;
}
else
{
return ENCODE_ID_HEVC;
}
case VAProfileNone:
if (IsEncFei(entrypoint, feiFunction))
{
return ENCODE_ID_AVCFEI;
}
else
{
return ENCODE_ID_NONE;
}
default:
return ENCODE_ID_NONE;
}
}
bool MediaLibvaCaps::IsDecConfigId(VAConfigID configId)
{
return ((configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE) &&
(configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size())));
}
bool MediaLibvaCaps::IsEncConfigId(VAConfigID configId)
{
return ((configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE) &&
(configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE + m_encConfigs.size())));
}
bool MediaLibvaCaps::IsVpConfigId(VAConfigID configId)
{
return ((configId >= DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE) &&
(configId < (DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE + m_vpConfigs.size())));
}
MediaLibvaCapsCpInterface* MediaLibvaCaps::GetCpCaps()
{
return m_CapsCp;
}
bool MediaLibvaCaps::IsMfeSupportedEntrypoint(VAEntrypoint entrypoint)
{
if (entrypoint != VAEntrypointEncSlice && //MFE only support Encode slice
entrypoint != VAEntrypointFEI ) //and FEI yet
{
return false;
}
return true;
}
bool MediaLibvaCaps::IsMfeSupportedProfile(VAProfile profile)
{
if (profile != VAProfileH264Main && // MFE only support AVC now
profile != VAProfileH264High &&
profile != VAProfileH264ConstrainedBaseline)
{
return false;
}
return true;
}
VAStatus MediaLibvaCaps::DestroyConfig(VAConfigID configId)
{
if( IsDecConfigId(configId) || IsEncConfigId(configId) || IsVpConfigId(configId))
{
return VA_STATUS_SUCCESS;
}
return VA_STATUS_ERROR_INVALID_CONFIG;
}
GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertMediaFmtToGmmFmt(
DDI_MEDIA_FORMAT format)
{
switch (format)
{
case Media_Format_X8R8G8B8 : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE;
case Media_Format_A8R8G8B8 : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE;
case Media_Format_X8B8G8R8 : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE;
case Media_Format_A8B8G8R8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE;
case Media_Format_R8G8B8A8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE;
case Media_Format_R5G6B5 : return GMM_FORMAT_B5G6R5_UNORM_TYPE;
case Media_Format_R8G8B8 : return GMM_FORMAT_R8G8B8_UNORM;
case Media_Format_RGBP : return GMM_FORMAT_RGBP;
case Media_Format_BGRP : return GMM_FORMAT_BGRP;
case Media_Format_NV12 : return GMM_FORMAT_NV12_TYPE;
case Media_Format_NV21 : return GMM_FORMAT_NV21_TYPE;
case Media_Format_AYUV : return GMM_FORMAT_AYUV_TYPE;
case Media_Format_YUY2 : return GMM_FORMAT_YUY2;
case Media_Format_UYVY : return GMM_FORMAT_UYVY;
case Media_Format_YV12 : return GMM_FORMAT_YV12_TYPE;
case Media_Format_IYUV : return GMM_FORMAT_IYUV_TYPE;
case Media_Format_I420 : return GMM_FORMAT_I420_TYPE;
case Media_Format_444P : return GMM_FORMAT_MFX_JPEG_YUV444_TYPE;
case Media_Format_422H : return GMM_FORMAT_MFX_JPEG_YUV422H_TYPE;
case Media_Format_411P : return GMM_FORMAT_MFX_JPEG_YUV411_TYPE;
case Media_Format_422V : return GMM_FORMAT_MFX_JPEG_YUV422V_TYPE;
case Media_Format_IMC3 : return GMM_FORMAT_IMC3_TYPE;
case Media_Format_400P : return GMM_FORMAT_GENERIC_8BIT;
case Media_Format_Buffer : return GMM_FORMAT_RENDER_8BIT;
case Media_Format_P010 : return GMM_FORMAT_P010_TYPE;
case Media_Format_P012 : return GMM_FORMAT_P016_TYPE;
case Media_Format_P016 : return GMM_FORMAT_P016_TYPE;
case Media_Format_Y216 : return GMM_FORMAT_Y216_TYPE;
case Media_Format_Y416 : return GMM_FORMAT_Y416_TYPE;
case Media_Format_R10G10B10A2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE;
case Media_Format_B10G10R10A2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
case Media_Format_R10G10B10X2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE;
case Media_Format_B10G10R10X2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
#if VA_CHECK_VERSION(1, 9, 0)
case Media_Format_Y212 : return GMM_FORMAT_Y212_TYPE;
case Media_Format_Y412 : return GMM_FORMAT_Y412_TYPE;
#endif
default : return GMM_FORMAT_INVALID;
}
}
GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertFourccToGmmFmt(uint32_t fourcc)
{
switch (fourcc)
{
case VA_FOURCC_BGRA : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE;
case VA_FOURCC_ARGB : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE;
case VA_FOURCC_RGBA : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE;
case VA_FOURCC_ABGR : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE;
case VA_FOURCC_BGRX : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE;
case VA_FOURCC_XRGB : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE;
case VA_FOURCC_RGBX : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE;
case VA_FOURCC_XBGR : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE;
case VA_FOURCC_R8G8B8 : return GMM_FORMAT_R8G8B8_UNORM;
case VA_FOURCC_RGBP : return GMM_FORMAT_RGBP;
case VA_FOURCC_BGRP : return GMM_FORMAT_BGRP;
case VA_FOURCC_RGB565 : return GMM_FORMAT_B5G6R5_UNORM_TYPE;
case VA_FOURCC_AYUV : return GMM_FORMAT_AYUV_TYPE;
case VA_FOURCC_NV12 : return GMM_FORMAT_NV12_TYPE;
case VA_FOURCC_NV21 : return GMM_FORMAT_NV21_TYPE;
case VA_FOURCC_YUY2 : return GMM_FORMAT_YUY2;
case VA_FOURCC_UYVY : return GMM_FORMAT_UYVY;
case VA_FOURCC_YV12 : return GMM_FORMAT_YV12_TYPE;
case VA_FOURCC_I420 : return GMM_FORMAT_I420_TYPE;
case VA_FOURCC_IYUV : return GMM_FORMAT_IYUV_TYPE;
case VA_FOURCC_411P : return GMM_FORMAT_MFX_JPEG_YUV411_TYPE;
case VA_FOURCC_422H : return GMM_FORMAT_MFX_JPEG_YUV422H_TYPE;
case VA_FOURCC_422V : return GMM_FORMAT_MFX_JPEG_YUV422V_TYPE;
case VA_FOURCC_444P : return GMM_FORMAT_MFX_JPEG_YUV444_TYPE;
case VA_FOURCC_IMC3 : return GMM_FORMAT_IMC3_TYPE;
case VA_FOURCC_P208 : return GMM_FORMAT_P208_TYPE;
case VA_FOURCC_P010 : return GMM_FORMAT_P010_TYPE;
case VA_FOURCC_P012 : return GMM_FORMAT_P016_TYPE;
case VA_FOURCC_P016 : return GMM_FORMAT_P016_TYPE;
case VA_FOURCC_Y210 : return GMM_FORMAT_Y210_TYPE;
case VA_FOURCC_Y410 : return GMM_FORMAT_Y410_TYPE;
#if VA_CHECK_VERSION(1, 9, 0)
case VA_FOURCC_Y212 : return GMM_FORMAT_Y212_TYPE;
#endif
case VA_FOURCC_Y216 : return GMM_FORMAT_Y216_TYPE;
#if VA_CHECK_VERSION(1, 9, 0)
case VA_FOURCC_Y412 : return GMM_FORMAT_Y412_TYPE;
#endif
case VA_FOURCC_Y416 : return GMM_FORMAT_Y416_TYPE;
case VA_FOURCC_Y800 : return GMM_FORMAT_GENERIC_8BIT;
case VA_FOURCC_A2R10G10B10 : return GMM_FORMAT_R10G10B10A2_UNORM_TYPE;
case VA_FOURCC_A2B10G10R10 : return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
case VA_FOURCC_X2R10G10B10 : return GMM_FORMAT_R10G10B10A2_UNORM_TYPE;
case VA_FOURCC_X2B10G10R10 : return GMM_FORMAT_B10G10R10A2_UNORM_TYPE;
default : return GMM_FORMAT_INVALID;
}
}
bool MediaLibvaCaps::IsMfeSupportedOnPlatform(const PLATFORM &platform)
{
return (GFX_IS_PRODUCT(platform, IGFX_SKYLAKE));
}
VAStatus MediaLibvaCaps::GetMbProcessingRateDec(
MEDIA_FEATURE_TABLE *skuTable,
uint32_t *mbProcessingRatePerSec)
{
uint32_t idx = 0;
DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
const uint32_t mb_rate[2] =
{
// non-ULX, ULX/Atom
4800000, 3600000
};
if (MEDIA_IS_SKU(skuTable, FtrLCIA) || //Atom
MEDIA_IS_SKU(skuTable, FtrULX)) // ULX
{
idx = 1;
}
else
{
// Default is non-ULX
idx = 0;
}
*mbProcessingRatePerSec = mb_rate[idx];
return VA_STATUS_SUCCESS;
}
VAStatus MediaLibvaCaps::GetMbProcessingRateEnc(
MEDIA_FEATURE_TABLE *skuTable,
uint32_t tuIdx,
uint32_t codecMode,
bool vdencActive,
uint32_t *mbProcessingRatePerSec)
{
DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);
uint32_t gtIdx = 0;
// Calculate the GT index based on GT type
if (MEDIA_IS_SKU(skuTable, FtrGT1))
{
gtIdx = 4;
}
else if (MEDIA_IS_SKU(skuTable, FtrGT1_5))
{
gtIdx = 3;
}
else if (MEDIA_IS_SKU(skuTable, FtrGT2))
{
gtIdx = 2;
}
else if (MEDIA_IS_SKU(skuTable, FtrGT3))
{
gtIdx = 1;
}
else if (MEDIA_IS_SKU(skuTable, FtrGT4))
{
gtIdx = 0;
}
else
{
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
if (MEDIA_IS_SKU(skuTable, FtrULX))
{
static const uint32_t mbRate[7][5] =
{
// GT4 | GT3 | GT2 | GT1.5 | GT1
{ 0, 0, 1029393, 1029393, 676280 },
{ 0, 0, 975027, 975027, 661800 },
{ 0, 0, 776921, 776921, 640000 },
{ 0, 0, 776921, 776921, 640000 },
{ 0, 0, 776921, 776921, 640000 },
{ 0, 0, 416051, 416051, 317980 },
{ 0, 0, 214438, 214438, 180655 }
};
if (gtIdx == 0 || gtIdx == 1)
{
return VA_STATUS_ERROR_INVALID_PARAMETER;
}
*mbProcessingRatePerSec = mbRate[tuIdx][gtIdx];
}
else if (MEDIA_IS_SKU(skuTable, FtrULT))
{
static const uint32_t defaultult_mb_rate[7][5] =
{
// GT4 | GT3 | GT2 | GT1.5 | GT1
{ 1544090, 1544090, 1544090, 1029393, 676280 },
{ 1462540, 1462540, 1462540, 975027, 661800 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 624076, 624076, 624076, 416051, 317980 },
{ 321657, 321657, 321657, 214438, 180655 }
};
*mbProcessingRatePerSec = defaultult_mb_rate[tuIdx][gtIdx];
}
else
{
// regular
const uint32_t default_mb_rate[7][5] =
{
// GT4 | GT3 | GT2 | GT1.5 | GT1
{ 1544090, 1544090, 1544090, 1029393, 676280 },
{ 1462540, 1462540, 1462540, 975027, 661800 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 1165381, 1165381, 1165381, 776921, 640000 },
{ 624076, 624076, 624076, 416051, 317980 },
{ 321657, 321657, 321657, 214438, 180655 }
};
*mbProcessingRatePerSec = default_mb_rate[tuIdx][gtIdx];
}
return VA_STATUS_SUCCESS;
}
MediaLibvaCaps * MediaLibvaCaps::CreateMediaLibvaCaps(DDI_MEDIA_CONTEXT *mediaCtx)
{
if (mediaCtx != nullptr)
{
MediaLibvaCaps * Caps = CapsFactory::CreateCaps(
(uint32_t)mediaCtx->platform.eProductFamily + MEDIA_EXT_FLAG, mediaCtx);
if(Caps == nullptr)
{
Caps = CapsFactory::CreateCaps((uint32_t)mediaCtx->platform.eProductFamily, mediaCtx);
}
return Caps;
}
else
{
return nullptr;
}
}
|