1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729
|
/* gap_player_dialog.c
*
* video (preview) playback of video frames by Wolfgang Hofer (hof)
* supports both (fast) thumbnail based playback
* and full image playback (slow)
* the current implementation has audio support for RIFF WAV audiofiles
* but requires the wavplay executable as external audioserver program.
* 2003/09/07
*
*/
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Revision history
* (2007/11/01) v2.3.0 hof: - gimprc changed to "show-tooltips" with gimp-2.4
* (2004/11/12) v2.1.0 hof: - added help button
* (2004/03/17) v1.3.27a hof: - go_timer does check if video api is busy and retries
* to display the wanted frame if video fetch (of previous frame)
* has finished.
* - use go_timer to display final frame when play_timer stops.
* - use go_timer to display current frame on_framenr_spinbutton_changed
* (2004/03/16) v1.3.27a hof: - merged in changes from stable branch:
* declare varibales for audiosupport only if GAP_ENABLE_AUDIO_SUPPORT defined
* (2004/03/07) v1.3.26b hof: - click on preview opens/replaces the mtrace image
* (2004/03/04) v1.3.26b hof: - bugfixes Videofile playback
* (2004/02/29) v1.3.26b hof: - Basic Videoapi support (p_fetch_videoframe)
* (2004/02/26) v1.3.26b hof: - From/To convert from Button to Label
* (2004/02/14) v1.3.26b hof: - if not standalone: Player can run in docked_mode (without having own shell window)
* (2004/02/01) v1.3.26b hof: - Player can run in standalone mode (as it did before)
* or act as Playback widget window that does not call gtk_main_quit
* as it is required for use in the Storyboard dialog module.
* - Support for Storyboard level1 playback
* - most callbacks now directly use GapPlayerMainGlobalParams *gpp
* rather than gpointer *user_data
* (2004/01/22) v1.3.25a hof: performance tuning: use gap_thumb_file_load_pixbuf_thumbnail
* (2004/01/19) v1.3.24b hof: bugfix: spinbutton callbacks must connect to "value_changed" signal
* (2004/01/16) v1.3.22c hof: use gap_thumb_file_load_thumbnail (for faster thumb loading)
* (2003/11/15) v1.3.22c hof: bugfix: SHIFT size button
* (2003/11/01) v1.3.21d hof: cleanup messages
* (2003/10/14) v1.3.20d hof: sourcecode cleanup
* (2003/10/06) v1.3.20d hof: bugfix: changed shell_window resize handling
* (2003/09/29) v1.3.20c hof: moved gap_arr_overwrite_file_dialog to module gap_arr_dialog.c
* (2003/09/23) v1.3.20b hof: use GAPLIBDIR to locate audioconvert_to_wav.sh
* (2003/09/14) v1.3.20a hof: bugfix: added p_create_wav_dialog
* now can create and resample WAVFILE from other audiofiles (MP3 and others)
* based on external shellscript (using SOX and LAME to do that job)
* Replaced direct wavplay Procedure calls
* by abstracted AudioPlayerClient (APCL_) Procedures
* (2003/09/09) v1.3.19b hof: bugfix: on_framenr_spinbutton_changed must resync audio to the new Position when playing
* bugfix: Selection of a new audiofile did continue play the old one
* (2003/09/07) v1.3.19a hof: audiosupport (based on wavplay, for UNIX only),
* audiosupport is on by default, and can be disabled by defining
* GAP_DISABLE_WAV_AUDIOSUPPORT
* (2003/08/27) v1.3.18b hof: added ctrl/alt modifiers on_go_button_clicked,
* added p_printout_range (for STORYBOARD FILE Processing
* in the still unpublished GAP Videoencoder Project)
* (2003/07/31) v1.3.17b hof: message text fixes for translators (# 118392)
* (2003/06/26) v1.3.16a hof: bugfix: make preview drawing_area fit into frame (use an aspect_frame)
* query gimprc for "show-tool-tips"
* (2003/06/21) v1.3.15a hof: created
*/
/* undefining GAP_ENABLE_AUDIO_SUPPORT will disable all audio stuff
* at compiletime
*/
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "gap_libgapbase.h"
#include "gap_player_main.h"
#include "gap_player_dialog.h"
#include "gap_pdb_calls.h"
#include "gap_pview_da.h"
#include "gap_stock.h"
#include "gap_lib.h"
#include "gap_image.h"
#include "gap_vin.h"
#include "gap_timeconv.h"
#include "gap_thumbnail.h"
#include "gap_arr_dialog.h"
#include "gap_story_file.h"
#include "gap_story_render_processor.h"
#include "gap_layer_copy.h"
#include "gap_onion_base.h"
#include "gap_audio_extract.h"
#include "gap_audio_extract.h"
#include "gap_drawable_vref_parasite.h"
#include "gap-intl.h"
extern int gap_debug; /* 1 == print debug infos , 0 dont print debug infos */
int cmdopt_x = 0; /* Debug option flag for wavplay */
#ifdef GAP_ENABLE_AUDIO_SUPPORT
#include "wpc_lib.h" /* headerfile for libwavplayclient (preferred) */
char *env_WAVPLAYPATH = WAVPLAYPATH; /* Default pathname of executable /usr/local/bin/wavplay */
char *env_AUDIODEV = AUDIODEV; /* Default compiled in audio device */
unsigned long env_AUDIOLCK = AUDIOLCK; /* Default compiled in locking semaphore */
#else
char *env_WAVPLAYPATH = NULL; /* Default pathname of executable /usr/local/bin/wavplay */
char *env_AUDIODEV = NULL; /* Default compiled in audio device */
unsigned long env_AUDIOLCK = 0; /* Default compiled in locking semaphore */
#endif
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
#include "gap_vid_api.h"
#endif
#define GAP_PLAYER_MIN_SIZE 64
#define GAP_PLAYER_MAX_SIZE 800
#define GAP_STANDARD_PREVIEW_SIZE 256
#define GAP_SMALL_PREVIEW_SIZE 128
#define GAP_PLAYER_CHECK_SIZE 6
#define GAP_PLAY_MAX_GOBUTTONS 51
#define GAP_PLAY_MAX_GOBUTTONS_DOCKED 41
#define GAP_PLAYER_MIDDLE_GO_NUMBER ((GAP_PLAY_MAX_GOBUTTONS / 2))
#define GAP_PLAY_AUDIO_ENTRY_WIDTH 300
#define GAP_PLAY_AUDIO_ENTRY_WIDTH_DOCKED 130
#define GAP_PLAYER_VID_FRAMES_TO_KEEP_CACHED 50
#define KEY_FRAMENR_BUTTON_TYPE "gap_player_framnr_button_type"
#define FRAMENR_BUTTON_BEGIN 0
#define FRAMENR_BUTTON_END 1
typedef struct t_gobutton
{
GapPlayerMainGlobalParams *gpp;
gint go_number;
} t_gobutton;
static gint32 global_max_vid_frames_to_keep_cached = 0;
/* the callbacks */
static void on_shell_window_destroy (GtkObject *object,
GapPlayerMainGlobalParams *gpp);
static void on_help_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_from_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void on_to_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static gboolean on_vid_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp);
static gboolean on_warp_frame_scroll_event (GtkWidget *widget,
GdkEventScroll *sevent,
GapPlayerMainGlobalParams *gpp);
static gboolean on_vid_preview_expose_event (GtkWidget *widget,
GdkEventExpose *eevent,
GapPlayerMainGlobalParams *gpp);
static void on_vid_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GapPlayerMainGlobalParams *gpp);
static void on_shell_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GapPlayerMainGlobalParams *gpp);
static void on_framenr_button_clicked (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp);
static void on_from_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_to_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static gboolean on_framenr_scale_clicked (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp);
static void on_framenr_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void on_origspeed_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_speed_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void p_fit_initial_shell_window (GapPlayerMainGlobalParams *gpp);
static void p_fit_shell_window (GapPlayerMainGlobalParams *gpp);
static gboolean on_size_button_button_press_event (GtkWidget *widget,
GdkEventButton *event,
GapPlayerMainGlobalParams *gpp);
static void on_size_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static gboolean on_size_spinbutton_enter (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp);
static gboolean on_shell_window_leave (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp);
static void on_exact_timing_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_use_thumb_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_pinpong_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_selonly_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_loop_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_show_gobuttons_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_show_positionscale_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_play_button_clicked (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp);
static gboolean on_pause_button_press_event (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp);
static void on_back_button_clicked (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp);
static void on_close_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_timer_playback (GapPlayerMainGlobalParams *gpp);
static void on_timer_go_job (GapPlayerMainGlobalParams *gpp);
static void on_go_button_clicked (GtkButton *button,
GdkEventButton *bevent,
t_gobutton *gob);
static gboolean on_go_button_enter (GtkButton *button,
GdkEvent *event,
t_gobutton *gob);
static void on_gobutton_hbox_leave (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp);
static void on_audio_enable_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_audio_volume_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void on_audio_frame_offset_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void on_audio_reset_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_audio_create_copy_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_audio_filesel_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_audio_filename_entry_changed (GtkWidget *widget,
GapPlayerMainGlobalParams *gpp);
static void on_cancel_vindex_button_clicked (GtkObject *object,
GapPlayerMainGlobalParams *gpp);
static void on_audio_auto_offset_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp);
static void on_audio_otone_extract_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp);
static void on_audio_otone_atrack_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp);
static void p_msg_progress_bar_audio(GapPlayerMainGlobalParams *gpp, const char *msg);
static void p_reset_progress_bar_audio(GapPlayerMainGlobalParams *gpp);
static void p_step_frame(GapPlayerMainGlobalParams *gpp, gint stepsize);
static void p_set_frame_with_name_label(GapPlayerMainGlobalParams *gpp);
static void p_update_position_widgets(GapPlayerMainGlobalParams *gpp);
static void p_stop_playback(GapPlayerMainGlobalParams *gpp);
static void p_connect_resize_handler(GapPlayerMainGlobalParams *gpp);
static void p_disconnect_resize_handler(GapPlayerMainGlobalParams *gpp);
static gboolean p_vid_progress_callback(gdouble progress
,gpointer user_data
);
static void p_close_videofile(GapPlayerMainGlobalParams *gpp);
static void p_open_videofile(GapPlayerMainGlobalParams *gpp
, char *filename
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
);
static guchar * p_fetch_videoframe(GapPlayerMainGlobalParams *gpp
, char *gva_videofile
, gint32 framenumber
, gint32 rangesize
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
, gint32 *th_bpp
, gint32 *th_width
, gint32 *th_height
);
static void p_init_video_playback_cache(GapPlayerMainGlobalParams *gpp);
static void p_init_layout_options(GapPlayerMainGlobalParams *gpp);
static guchar * p_fetch_frame_via_cache(GapPlayerMainGlobalParams *gpp
, const gchar *ckey
, gint32 *th_bpp_ptr
, gint32 *th_width_ptr
, gint32 *th_height_ptr
, gint32 *flip_status_ptr
);
static guchar * p_fetch_videoframe_via_cache(GapPlayerMainGlobalParams *gpp
, char *gva_videofile
, gint32 framenumber
, gint32 rangesize
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
, gint32 *th_bpp_ptr
, gint32 *th_width_ptr
, gint32 *th_height_ptr
, gint32 *flip_status_ptr
, const gchar *ckey
);
static void p_frame_chache_processing(GapPlayerMainGlobalParams *gpp
, const gchar *ckey);
static void p_update_cache_status (GapPlayerMainGlobalParams *gpp);
static void p_audio_startup_server(GapPlayerMainGlobalParams *gpp);
static gint32 p_get_audio_relevant_FrameNr(GapPlayerMainGlobalParams *gpp, gint32 framenr);
static const char* p_get_default_tmp_otone_audiofilename();
static char * p_build_otone_audiofilename(const char *videofilename, gint32 atrack, const char *suffix);
static gboolean p_check_otone_workfile_up_to_date(const char *videofilename, const char *audiofilename,
gint32 l_extract_audiotrack);
static void p_update_ainfo_for_videofile(GapPlayerMainGlobalParams *gpp);
/* -----------------------------
* p_check_tooltips
* -----------------------------
*/
static void
p_check_tooltips(void)
{
gap_base_check_tooltips(NULL);
} /* end p_check_tooltips */
/* -----------------------------
* p_audio_errfunc
* -----------------------------
*/
static void
p_audio_errfunc(const char *format,va_list ap)
{
char buf[1024];
vsnprintf(buf,sizeof(buf),format,ap); /* Format the message */
g_message(_("Problem with audioplayback. The audiolib reported:\n%s"),buf);
} /* end p_audio_errfunc */
/* -----------------------------
* p_create_wav_dialog
* -----------------------------
* return TRUE : OK, caller can create the wavefile
* FALSE: user has cancelled, dont create wavefile
*/
static gboolean
p_create_wav_dialog(GapPlayerMainGlobalParams *gpp)
{
static GapArrArg argv[4];
gint l_ii;
gint l_ii_resample;
gint l_ii_samplerate;
l_ii = 0;
gap_arr_arg_init(&argv[l_ii], GAP_ARR_WGT_LABEL_LEFT);
argv[l_ii].label_txt = _("Audiosource:");
argv[l_ii].text_buf_ret = gpp->audio_filename;
g_snprintf(gpp->audio_wavfile_tmp
,sizeof(gpp->audio_wavfile_tmp)
,"%s.tmp.wav"
,gpp->audio_filename
);
l_ii++;
gap_arr_arg_init(&argv[l_ii], GAP_ARR_WGT_FILESEL);
argv[l_ii].label_txt = _("Wavefile:");
argv[l_ii].entry_width = 400;
argv[l_ii].help_txt = _("Name of wavefile to create as copy in RIFF WAVE format");
argv[l_ii].text_buf_len = sizeof(gpp->audio_wavfile_tmp);
argv[l_ii].text_buf_ret = gpp->audio_wavfile_tmp;
l_ii++;
l_ii_resample = l_ii;
gap_arr_arg_init(&argv[l_ii], GAP_ARR_WGT_TOGGLE);
argv[l_ii].label_txt = _("Resample:");
argv[l_ii].help_txt = _("ON: Resample the copy at specified samplerate.\n"
"OFF: Use original samplerate");
argv[l_ii].int_ret = 1;
l_ii++;
l_ii_samplerate = l_ii;
gap_arr_arg_init(&argv[l_ii], GAP_ARR_WGT_INT_PAIR);
argv[l_ii].constraint = TRUE;
argv[l_ii].label_txt = _("Samplerate:");
argv[l_ii].help_txt = _("Target audio samplerate in samples/sec. Ignored if resample is off");
argv[l_ii].int_min = (gint)GAP_PLAYER_MAIN_MIN_SAMPLERATE;
argv[l_ii].int_max = (gint)GAP_PLAYER_MAIN_MAX_SAMPLERATE;
argv[l_ii].int_ret = (gint)22050;
if(gpp->audio_samples > 0)
{
/* the original is a valid wavefile
* in that case we know the samplerate of the original audiofile
* and can limit the samplerate of the copy to this size
* (resample with higher rates does not improve quality and is a waste of memory.
* Making a copy of the input wavfile should use a lower samplerate
* that makes it possible for the audioserver to follow fast videoplayback
* by switching from the original to the copy)
*/
argv[l_ii].int_min = (gint)GAP_PLAYER_MAIN_MIN_SAMPLERATE;
argv[l_ii].int_max = (gint)MIN(gpp->audio_samplerate, GAP_PLAYER_MAIN_MAX_SAMPLERATE);
argv[l_ii].int_ret = (gint)MIN((gpp->audio_samplerate / 2), GAP_PLAYER_MAIN_MAX_SAMPLERATE);
}
if(TRUE == gap_arr_ok_cancel_dialog( _("Copy Audiofile as Wavefile"),
_("Settings"),
G_N_ELEMENTS(argv), argv))
{
gpp->audio_tmp_resample = (gboolean)(argv[l_ii_resample].int_ret);
gpp->audio_tmp_samplerate = (gint32)(argv[l_ii_samplerate].int_ret);
return (gap_arr_overwrite_file_dialog(gpp->audio_wavfile_tmp));
}
return (FALSE);
} /* end p_create_wav_dialog */
/* -----------------------------
* p_audio_shut_server
* -----------------------------
*/
static void
p_audio_shut_server(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
/* if (gap_debug) printf("p_audio_shut_server\n"); */
if(gpp->audio_status > GAP_PLAYER_MAIN_AUSTAT_NONE)
{
apcl_bye(0, p_audio_errfunc);
}
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_NONE;
#endif
return;
} /* end p_audio_shut_server */
/* -----------------------------
* p_audio_resync
* -----------------------------
*/
static void
p_audio_resync(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
if(gpp->audio_resync < 1)
{
gpp->audio_resync = 1 + (gpp->speed / 5);
}
/* if (gap_debug) printf("p_audio_resync :%d\n", (int)gpp->audio_resync); */
#endif
return;
} /* end p_audio_resync */
/* -----------------------------
* p_audio_stop
* -----------------------------
*/
static void
p_audio_stop(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
/* if (gap_debug) printf("p_audio_stop\n"); */
if(gpp->audio_status > GAP_PLAYER_MAIN_AUSTAT_NONE)
{
apcl_stop(0,p_audio_errfunc); /* Tell the server to stop */
gpp->audio_status = MIN(gpp->audio_status, GAP_PLAYER_MAIN_AUSTAT_FILENAME_SET);
}
#endif
return;
} /* end p_audio_stop */
/* -----------------------------
* p_audio_init
* -----------------------------
*/
static void
p_audio_init(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
/* if (gap_debug) printf("p_audio_init\n"); */
if(gpp->audio_samples > 0) /* audiofile has samples (seems to be a valid audiofile) */
{
if(gpp->audio_status == GAP_PLAYER_MAIN_AUSTAT_UNCHECKED)
{
p_audio_startup_server(gpp);
if(gpp->audio_enable != TRUE)
{
return;
}
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_NONE;
}
if(gpp->audio_status <= GAP_PLAYER_MAIN_AUSTAT_NONE)
{
if ( apcl_start(p_audio_errfunc) < 0 )
{
g_message(_("Failure to start the wavplay server is fatal.\n"
"Please check the executability of the 'wavplay' command.\n"
"If you have installed the wavplay executeable somewhere\n"
"you can set the Environmentvariable WAVPLAYPATH before gimp startup\n"));
}
else
{
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_SERVER_STARTED;
}
/* apcl_semreset(0,p_audio_errfunc); */ /* Tell server to reset semaphores */
}
else
{
p_audio_stop(gpp);
}
if(gpp->audio_status < GAP_PLAYER_MAIN_AUSTAT_FILENAME_SET)
{
apcl_path(gpp->audio_filename,0,p_audio_errfunc); /* Tell server the new path */
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_FILENAME_SET;
}
}
#endif
return;
} /* end p_audio_init */
/* -----------------------------
* p_audio_print_labels
* -----------------------------
*/
static void
p_audio_print_labels(GapPlayerMainGlobalParams *gpp)
{
char txt_buf[100];
gint len;
gint32 l_samplerate;
gint32 l_samples;
gint32 l_videoframes;
l_samples = gpp->audio_samples;
l_samplerate = gpp->audio_samplerate;
if (gap_debug)
{
printf("p_audio_print_labels\n");
printf("audio_filename: %s\n", gpp->audio_filename);
printf("audio_enable: %d\n", (int)gpp->audio_enable);
printf("audio_frame_offset: %d\n", (int)gpp->audio_frame_offset);
printf("audio_bits: %d\n", (int)gpp->audio_bits);
printf("audio_channels: %d\n", (int)gpp->audio_channels);
printf("audio_samplerate: %d\n", (int)gpp->audio_samplerate);
printf("audio_samples: %d\n", (int)gpp->audio_samples);
printf("audio_status: %d\n", (int)gpp->audio_status);
}
if(gpp->audio_frame_offset < 0)
{
gap_timeconv_framenr_to_timestr( (gint32)(0 - gpp->audio_frame_offset)
, (gdouble)gpp->original_speed
, txt_buf
, sizeof(txt_buf)
);
len = strlen(txt_buf);
g_snprintf(&txt_buf[len], sizeof(txt_buf)-len, " %s", _("Audio Delay"));
}
else
{
gap_timeconv_framenr_to_timestr( (gint32)(gpp->audio_frame_offset)
, (gdouble)gpp->original_speed
, txt_buf
, sizeof(txt_buf)
);
len = strlen(txt_buf);
if(gpp->audio_frame_offset == 0)
{
g_snprintf(&txt_buf[len], sizeof(txt_buf)-len, " %s", _("Syncron"));
}
else
{
g_snprintf(&txt_buf[len], sizeof(txt_buf)-len, " %s", _("Audio Skipped"));
}
}
gtk_label_set_text ( GTK_LABEL(gpp->audio_offset_time_label), txt_buf);
gap_timeconv_samples_to_timestr( l_samples
, (gdouble)l_samplerate
, txt_buf
, sizeof(txt_buf)
);
gtk_label_set_text ( GTK_LABEL(gpp->audio_total_time_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), _("%d (at %.4f frames/sec)")
, (int)gap_timeconv_samples_to_frames(l_samples
,(gdouble)l_samplerate
,(gdouble)gpp->original_speed /* framerate */
)
, (float)gpp->original_speed
);
gtk_label_set_text ( GTK_LABEL(gpp->audio_total_frames_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), "%d", (int)l_samples );
gtk_label_set_text ( GTK_LABEL(gpp->audio_samples_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), "%d", (int)l_samplerate );
gtk_label_set_text ( GTK_LABEL(gpp->audio_samplerate_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), "%d", (int)gpp->audio_bits );
gtk_label_set_text ( GTK_LABEL(gpp->audio_bits_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), "%d", (int)gpp->audio_channels );
gtk_label_set_text ( GTK_LABEL(gpp->audio_channels_label), txt_buf);
l_videoframes = 0;
if(gpp->ainfo_ptr)
{
l_videoframes = 1+ (gpp->ainfo_ptr->last_frame_nr - gpp->ainfo_ptr->first_frame_nr);
}
gap_timeconv_framenr_to_timestr( l_videoframes
, gpp->original_speed
, txt_buf
, sizeof(txt_buf)
);
gtk_label_set_text ( GTK_LABEL(gpp->video_total_time_label), txt_buf);
g_snprintf(txt_buf, sizeof(txt_buf), "%d", (int)l_videoframes);
gtk_label_set_text ( GTK_LABEL(gpp->video_total_frames_label), txt_buf);
} /* end p_audio_print_labels */
/* -----------------------------
* p_print_and_clear_audiolabels
* -----------------------------
*/
static void
p_print_and_clear_audiolabels(GapPlayerMainGlobalParams *gpp)
{
gpp->audio_samplerate = 0;
gpp->audio_bits = 0;
gpp->audio_channels = 0;
gpp->audio_samples = 0;
p_audio_print_labels(gpp);
} /* end p_print_and_clear_audiolabels */
/* -----------------------------
* p_audio_filename_changed
* -----------------------------
* check if audiofile is a valid wavefile,
* and tell audioserver to prepare if its OK
* (but dont start to play, just keep audioserver stand by)
*/
static void
p_audio_filename_changed(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
int fd;
int rc;
int channels; /* Channels recorded in this wav file */
u_long samplerate; /* Sampling rate */
int sample_bits; /* data bit size (8/12/16) */
u_long samples; /* The number of samples in this file */
u_long datastart; /* The offset to the wav data */
if (gap_debug)
{
printf("p_audio_filename_changed to:%s:\n", gpp->audio_filename);
}
p_audio_stop(gpp);
gpp->audio_status = MIN(gpp->audio_status, GAP_PLAYER_MAIN_AUSTAT_SERVER_STARTED);
/* Open the file for reading: */
if ( (fd = g_open(gpp->audio_filename,O_RDONLY)) < 0 )
{
p_print_and_clear_audiolabels(gpp);
return;
}
rc = WaveReadHeader(fd
,&channels
,&samplerate
,&sample_bits
,&samples
,&datastart
,p_audio_errfunc);
close(fd);
if(rc != 0)
{
g_message (_("Error at reading WAV header from file '%s'")
, gpp->audio_filename);
p_print_and_clear_audiolabels(gpp);
return;
}
gpp->audio_samplerate = samplerate;
gpp->audio_bits = sample_bits;
gpp->audio_channels = channels;
gpp->audio_samples = samples;
if (gap_debug)
{
printf("p_audio_filename_changed :%s:\n", gpp->audio_filename);
printf(" audio_samplerate:%d:\n", gpp->audio_samplerate);
printf(" audio_bits:%d:\n", gpp->audio_bits);
printf(" audio_channels:%d:\n", gpp->audio_channels);
printf(" audio_samples:%d:\n", gpp->audio_samples);
}
p_audio_print_labels(gpp);
/* p_audio_init(gpp) must not be called here.
* becuase it calls p_audio_startup_server and this will recursive call
* p_audio_filename_changed in an endless loop....
* For now the audio_init is done later on 1st attempt to start playback.
*/
#endif
return;
} /* end p_audio_filename_changed */
/* ---------------------------------
* p_get_audio_relevant_FrameNr
* ---------------------------------
* get relevant framenumber respecting offsets
* local to the referenced video clip.
* (if playback currently does not refer to a vide
* return framenr unchanged)
*/
static gint32
p_get_audio_relevant_FrameNr(GapPlayerMainGlobalParams *gpp, gint32 framenr)
{
GapStoryLocateRet *stb_ret;
gint32 localFrameNr;
/* prepare standard behaviour
*
*/
localFrameNr = framenr - gpp->ainfo_ptr->first_frame_nr;
if(gpp->stb_ptr)
{
stb_ret = gap_story_locate_framenr(gpp->stb_ptr
, framenr
, gpp->stb_in_track
);
if(stb_ret)
{
if((stb_ret->locate_ok)
&& (stb_ret->stb_elem))
{
/* playback of a videoclip via storyboard clip */
if(stb_ret->stb_elem->record_type == GAP_STBREC_VID_MOVIE)
{
localFrameNr = stb_ret->ret_framenr;
}
}
}
}
else
{
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
/* playback of a single videoclip */
localFrameNr = framenr;
}
}
if(gap_debug)
{
printf("p_get_audio_relevant_FrameNr: framenr:%d localFrameNr:%d\n"
,framenr
,localFrameNr
);
}
return (localFrameNr);
} /* end p_get_audio_relevant_FrameNr */
/* -----------------------------------------
* p_get_default_tmp_otone_audiofilename
* -----------------------------------------
* returns a default name for the temporary otone audiofile.
* (The caller must NOT g_free the returned string after usage).
*/
const char*
p_get_default_tmp_otone_audiofilename()
{
static const char *name = "tmp_gap_extracted_original_audiotrack.wav";
return (name);
} /* end p_get_default_tmp_otone_audiofilename */
/* -----------------------------------------
* p_build_otone_audiofilename
* -----------------------------------------
* on writeable directory use videofilename + audiotrack + ".wav" extension
* otherwise use a fixed name for the audiofile.
* (The caller shall g_free the returned string after usage).
*/
char *
p_build_otone_audiofilename(const char *videofilename, gint32 atrack, const char *suffix)
{
char *l_audiofilename;
FILE *l_fp;
if (suffix == NULL)
{
l_audiofilename = g_strdup_printf("%s.%d.wav", videofilename, atrack);
}
else
{
l_audiofilename = g_strdup_printf("%s%s.%d.wav", videofilename, suffix, atrack);
}
if(g_file_test(l_audiofilename, G_FILE_TEST_EXISTS))
{
return(l_audiofilename);
}
/* test creation of l_audiofilename is possible */
l_fp = fopen(l_audiofilename, "w");
if (l_fp)
{
fclose(l_fp);
/* file creation OK (we have write permission)
* but immediate remove the file.
*/
g_remove(l_audiofilename);
return(l_audiofilename);
}
l_audiofilename = g_strdup(p_get_default_tmp_otone_audiofilename());
return(l_audiofilename);
} /* end p_build_otone_audiofilename */
/* -----------------------------------------
* p_check_otone_workfile_up_to_date
* -----------------------------------------
* TODO: additional check if audiofile is complete
* (in case extract was cancelled before the full length of the audiotrack could be written)
*/
gboolean
p_check_otone_workfile_up_to_date(const char *videofilename, const char *audiofilename,
gint32 l_extract_audiotrack)
{
char *l_audiofilename;
if(!g_file_test(audiofilename, G_FILE_TEST_EXISTS))
{
return(FALSE);
}
if(!g_file_test(videofilename, G_FILE_TEST_EXISTS))
{
return(FALSE);
}
l_audiofilename = p_build_otone_audiofilename(videofilename
, l_extract_audiotrack
, NULL /* no suffix used */
);
if (strcmp(l_audiofilename, audiofilename) != 0)
{
return(FALSE);
}
if (strcmp(l_audiofilename, p_get_default_tmp_otone_audiofilename()) == 0)
{
return(FALSE);
}
if (gap_file_get_mtime(l_audiofilename) < gap_file_get_mtime(videofilename))
{
return(FALSE);
}
return (TRUE);
} /* end p_check_otone_workfile_up_to_date */
/* -----------------------------
* p_audio_start_play
* -----------------------------
* conditional start audioplayback
* note: if already playing this procedure does noting.
* (first call p_audio_stop to stop the old playing audiofile
* before you start another one)
*/
static void
p_audio_start_play(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
gdouble offset_start_sec;
gint32 offset_start_samples;
gdouble flt_samplerate;
gint32 l_samplerate;
gint32 l_samples;
gdouble l_referedClipSpeed;
/* if (gap_debug) printf("p_audio_start_play\n"); */
/* Never play audio when disabled, or video play backwards,
* (reverse audio is not supported by the wavplay server)
*/
if(!gpp->audio_enable) { return; }
if(gpp->audio_status >= GAP_PLAYER_MAIN_AUSTAT_PLAYING) { return; }
if(gpp->play_backward) { return; }
if(gpp->ainfo_ptr == NULL) { return; }
l_samples = gpp->audio_samples;
l_samplerate = gpp->audio_samplerate;
l_referedClipSpeed = gpp->original_speed;
if (gpp->audio_auto_offset_by_framenr == TRUE)
{
gint32 localFramenr;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if (gpp->gvahand)
{
l_referedClipSpeed = gpp->gvahand->framerate;
l_samplerate = gpp->gvahand->samplerate;
}
#endif
localFramenr = p_get_audio_relevant_FrameNr(gpp, gpp->play_current_framenr);
offset_start_sec = ( localFramenr
+ gpp->audio_frame_offset
) / MAX(1, l_referedClipSpeed);
}
else
{
offset_start_sec = ( gpp->play_current_framenr
- gpp->ainfo_ptr->first_frame_nr
+ gpp->audio_frame_offset
) / MAX(1, gpp->original_speed);
}
offset_start_samples = offset_start_sec * l_samplerate;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(gap_debug)
{
printf("p_audio_start_play original_speed:%.3f refSpeed:%.3f audio_frame_offset:%d l_samples:%d l_samplerate:%d (gvahand:%d) offset_start_samples:%d\n\n"
,gpp->original_speed
,l_referedClipSpeed
,gpp->audio_frame_offset
,l_samples
,l_samplerate
,gpp->gvahand->samplerate
,offset_start_samples
);
}
#endif
if(l_referedClipSpeed > 0)
{
/* use moidfied samplerate if video is not played at original speed
*/
flt_samplerate = l_samplerate * gpp->speed / l_referedClipSpeed;
}
else
{
flt_samplerate = l_samplerate;
}
/* check if offset and rate is within playable limits */
if((offset_start_samples >= 0)
&& ((gdouble)offset_start_samples < ((gdouble)l_samples - 1024.0))
&& (flt_samplerate >= GAP_PLAYER_MAIN_MIN_SAMPLERATE)
)
{
UInt32 lu_samplerate;
p_audio_init(gpp); /* tell ausioserver to go standby for this audiofile */
gpp->audio_required_samplerate = (guint32)flt_samplerate;
if(flt_samplerate > GAP_PLAYER_MAIN_MAX_SAMPLERATE)
{
lu_samplerate = (UInt32)GAP_PLAYER_MAIN_MAX_SAMPLERATE;
/* required samplerate is faster than highest possible audioplayback speed
* (the audioplayback will be played but runs out of sync and cant follow)
*/
}
else
{
lu_samplerate = (UInt32)flt_samplerate;
}
apcl_sampling_rate(lu_samplerate,0,p_audio_errfunc);
apcl_start_sample((UInt32)offset_start_samples,0,p_audio_errfunc);
apcl_play(0,p_audio_errfunc); /* Tell server to play */
apcl_volume(gpp->audio_volume, 0, p_audio_errfunc);
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_PLAYING;
gpp->audio_resync = 0;
}
#endif
return;
} /* end p_audio_start_play */
/* -----------------------------
* p_audio_startup_server
* -----------------------------
*/
static void
p_audio_startup_server(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
const char *cp;
gboolean wavplay_server_found;
if (gap_debug)
{
printf("p_audio_startup_server\n");
}
wavplay_server_found = FALSE;
/*
* Set environmental values for the wavplay audio server:
*/
/* check gimprc for the wavplay audio server: */
if ( (cp = gimp_gimprc_query("wavplay_prog")) != NULL )
{
env_WAVPLAYPATH = g_strdup(cp); /* Environment overrides compiled in default for WAVPLAYPATH */
if(g_file_test (env_WAVPLAYPATH, G_FILE_TEST_IS_EXECUTABLE) )
{
wavplay_server_found = TRUE;
}
else
{
g_message(_("WARNING: your gimprc file configuration for the wavplay audio server\n"
"does not point to an executable program\n"
"the configured value for %s is: %s\n")
, "wavplay_prog"
, env_WAVPLAYPATH
);
}
}
/* check environment variable for the wavplay audio server: */
if(!wavplay_server_found)
{
if ( (cp = g_getenv("WAVPLAYPATH")) != NULL )
{
env_WAVPLAYPATH = g_strdup(cp); /* Environment overrides compiled in default for WAVPLAYPATH */
if(g_file_test (env_WAVPLAYPATH, G_FILE_TEST_IS_EXECUTABLE) )
{
wavplay_server_found = TRUE;
}
else
{
g_message(_("WARNING: the environment variable %s\n"
"does not point to an executable program\n"
"the current value is: %s\n")
, "WAVPLAYPATH"
, env_WAVPLAYPATH
);
}
}
}
if(!wavplay_server_found)
{
if ( (cp = g_getenv("PATH")) != NULL )
{
env_WAVPLAYPATH = gap_lib_searchpath_for_exefile("wavplay", cp);
if(env_WAVPLAYPATH)
{
wavplay_server_found = TRUE;
}
}
}
if ( (cp = g_getenv("AUDIODEV")) != NULL )
env_AUDIODEV = g_strdup(cp); /* Environment overrides compiled in default for AUDIODEV */
if ( (cp = g_getenv("AUDIOLCK")) == NULL || sscanf(cp,"%lX",&env_AUDIOLCK) != 1 )
env_AUDIOLCK = AUDIOLCK; /* Use compiled in default, if no environment, or its bad */
if(wavplay_server_found)
{
p_audio_filename_changed(gpp);
gpp->audio_enable = TRUE;
}
else
{
gpp->audio_enable = FALSE;
g_message(_("No audiosupport available\n"
"the audioserver executable file '%s' was not found.\n"
"If you have installed '%s'\n"
"you should add the installation dir to your PATH\n"
"or set environment variable %s to the name of the executable\n"
"before you start GIMP")
, "wavplay"
, "wavplay 1.4"
, "WAVPLAYPATH"
);
}
#endif
return;
} /* end p_audio_startup_server */
/* ------------------------------
* p_mtrace_image_alive
* ------------------------------
* Check if the mtrace_image_id is valid (== belongs to an existing image)
* if INVALID (there was no mlayer image or it was closed by the user) then
* create a new mtrace_image
* if valid then deliver width and height
*
* OUT: *mtrace_width *mtrace_height .. the size of the mtrace image
*/
static void
p_mtrace_image_alive(GapPlayerMainGlobalParams *gpp
, gint32 width
, gint32 height
, gint32 *mtrace_width
, gint32 *mtrace_height
)
{
GimpImageBaseType image_type;
image_type = GIMP_RGB;
if(gpp->image_id >= 0)
{
image_type = gimp_image_base_type(gpp->image_id);
}
if(gap_image_is_alive(gpp->mtrace_image_id))
{
*mtrace_width = gimp_image_width(gpp->mtrace_image_id);
*mtrace_height = gimp_image_height(gpp->mtrace_image_id);
}
else
{
if(gpp->mtrace_mode == GAP_PLAYER_MTRACE_IMG_SIZE)
{
*mtrace_width = width;
*mtrace_height = height;
}
else
{
*mtrace_width = gpp->pv_width;
*mtrace_height = gpp->pv_height;
}
gpp->mtrace_image_id = gimp_image_new( *mtrace_width
, *mtrace_height
, image_type
);
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
/* if there is an active videohandle
* set image resolution according to
* aspect_ratio of the videofile
*/
if(gpp->gvahand)
{
GVA_image_set_aspect(gpp->gvahand, gpp->mtrace_image_id);
}
#endif
gimp_display_new(gpp->mtrace_image_id);
}
} /* end p_mtrace_image_alive */
/* ------------------------------
* p_conditional_attach_dvref
* ------------------------------
* check if there is a valid current videoreference.
* if yes attach the reference as (temporary) videoreferenc parasite
* to the specified drawable_id
* (that is typically the layer in the mtrace image)
*/
static void
p_conditional_attach_dvref(GapPlayerMainGlobalParams *gpp
,gint32 drawable_id)
{
if(gap_debug)
{
printf("MTRACE: mtrace_mode:%d (GAP_PLAYER_MTRACE_IMG_SIZE == %d) dvref\n"
,(int)gpp->mtrace_mode
,(int)GAP_PLAYER_MTRACE_IMG_SIZE
);
gap_dvref_debug_print_GapDrawableVideoRef(gpp->dvref_ptr);
}
if((gpp->mtrace_mode == GAP_PLAYER_MTRACE_IMG_SIZE)
&& (gpp->dvref_ptr != NULL))
{
if(gpp->dvref_ptr->videofile != NULL)
{
if (gpp->dvref_ptr->videofile == gpp->gva_videofile)
{
gap_dvref_assign_videoref_parasites(gpp->dvref_ptr, drawable_id);
}
}
}
} /* end p_conditional_attach_dvref */
/* ------------------------------
* p_mtrace_image
* ------------------------------
* add image as one composite layer
* to the mtrace image.
* IMPORTANT: all visible layers of the input image are merged
*/
static void
p_mtrace_image( GapPlayerMainGlobalParams *gpp
,gint32 image_id
)
{
gint32 width;
gint32 height;
gint32 mtrace_width;
gint32 mtrace_height;
gint32 src_layer_id;
gint32 dst_layer_id;
gint l_src_offset_x, l_src_offset_y; /* layeroffsets as they were in src_image */
if(gap_debug)
{
printf("MTRACE:p_mtrace_image START mtrace_mode:%d (GAP_PLAYER_MTRACE_IMG_SIZE == %d)\n"
,(int)gpp->mtrace_mode
,(int)GAP_PLAYER_MTRACE_IMG_SIZE
);
gap_dvref_debug_print_GapDrawableVideoRef(gpp->dvref_ptr);
}
if(gpp->mtrace_mode != GAP_PLAYER_MTRACE_OFF)
{
width = MAX(gimp_image_width(image_id), 1);
height = MAX(gimp_image_height(image_id), 1);
p_mtrace_image_alive(gpp
,width
,height
, &mtrace_width
, &mtrace_height
);
src_layer_id = gap_image_merge_visible_layers(image_id, GIMP_CLIP_TO_IMAGE);
dst_layer_id = gap_layer_copy_to_dest_image(gpp->mtrace_image_id /* the dest image */
, src_layer_id /* the layer to copy */
, 100.0 /* opacity */
, 0 /* NORMAL paintmode */
,&l_src_offset_x
,&l_src_offset_y);
gimp_image_add_layer(gpp->mtrace_image_id
, dst_layer_id
, 0 /* top of layerstack */
);
if((width != mtrace_width)
|| (height != mtrace_height))
{
gimp_layer_scale(dst_layer_id, mtrace_width, mtrace_height, 0);
l_src_offset_x = (gint32)(((gdouble)mtrace_width / (gdouble)width) * (gdouble)l_src_offset_x);
l_src_offset_y = (gint32)(((gdouble)mtrace_height / (gdouble)height) * (gdouble)l_src_offset_y);
}
gimp_layer_set_offsets(dst_layer_id, l_src_offset_x, l_src_offset_y);
p_conditional_attach_dvref(gpp, dst_layer_id);
{
gchar *l_name;
l_name = g_strdup_printf("frame_%06d (%dms)"
,(int)gpp->play_current_framenr
,(int)(1000 / gpp->speed)
);
gimp_drawable_set_name(dst_layer_id, l_name);
g_free(l_name);
}
gimp_displays_flush();
}
} /* end p_mtrace_image */
/* ------------------------------
* p_mtrace_tmpbuf
* ------------------------------
* add buffer as one composite layer
* to the mtrace image.
*/
static void
p_mtrace_tmpbuf( GapPlayerMainGlobalParams *gpp
, guchar *th_data
, gint32 th_width
, gint32 th_height
, gint32 th_bpp
)
{
gint32 mtrace_width;
gint32 mtrace_height;
gint32 dst_layer_id;
if(gpp->mtrace_mode != GAP_PLAYER_MTRACE_OFF)
{
p_mtrace_image_alive(gpp
,th_width
,th_height
, &mtrace_width
, &mtrace_height
);
dst_layer_id = gap_layer_new_from_buffer(gpp->mtrace_image_id
, th_width
, th_height
, th_bpp
, th_data
);
gimp_image_add_layer(gpp->mtrace_image_id
, dst_layer_id
, 0 /* top of layerstack */
);
if(th_bpp == 3)
{
gimp_layer_add_alpha(dst_layer_id);
}
if((th_width != mtrace_width)
|| (th_height != mtrace_height))
{
gimp_layer_scale(dst_layer_id, mtrace_width, mtrace_height, 0);
}
gimp_layer_set_offsets(dst_layer_id
, 0 /* offset_x */
, 0 /* offset_y */
);
p_conditional_attach_dvref(gpp, dst_layer_id);
{
gchar *l_name;
l_name = g_strdup_printf("thumb_%06d (%dms)"
,(int)gpp->play_current_framenr
,(int)(1000 / gpp->speed)
);
gimp_drawable_set_name(dst_layer_id, l_name);
g_free(l_name);
}
gimp_displays_flush();
}
} /* end p_mtrace_tmpbuf */
/* ------------------------------
* p_mtrace_pixbuf
* ------------------------------
* add buffer as one composite layer
* to the mtrace image.
*/
static void
p_mtrace_pixbuf( GapPlayerMainGlobalParams *gpp
, GdkPixbuf *pixbuf
)
{
if(gpp->mtrace_mode != GAP_PLAYER_MTRACE_OFF)
{
if(pixbuf)
{
gint32 nchannels;
gint32 rowstride;
gint32 width;
gint32 height;
guchar *pix_data;
width = gdk_pixbuf_get_width(pixbuf);
height = gdk_pixbuf_get_height(pixbuf);
nchannels = gdk_pixbuf_get_n_channels(pixbuf);
pix_data = gdk_pixbuf_get_pixels(pixbuf);
rowstride = gdk_pixbuf_get_rowstride(pixbuf);
p_mtrace_tmpbuf(gpp
, pix_data
, width
, height
, nchannels
);
}
}
} /* end p_mtrace_pixbuf */
/* -----------------------------
* p_printout_range
* -----------------------------
* call fptr_set_range
* if such a callback function for setting the framerange is available (!= NULL)
* typically for the case where the player is called from storyboard dialog.
*
* Another optional functionality
* prints the selected RANGE to stdout
* (Line Formated for STORYBOARD_FILE processing)
*
* if the Player is in Storyboard mode
* the printout is just a comment with range numbers
*/
static void
p_printout_range(GapPlayerMainGlobalParams *gpp, gboolean inverse, gboolean printflag)
{
gint32 l_begin;
gint32 l_end;
l_begin = gpp->begin_frame;
l_end = gpp->end_frame;
if(inverse)
{
l_end = gpp->begin_frame;
l_begin = gpp->end_frame;
}
if(gpp->ainfo_ptr == NULL) { return; }
if(gpp->ainfo_ptr->basename == NULL) { return; }
if(gpp->stb_ptr)
{
if(printflag)
{
printf("# storyboard %06d=frame_from %06d=frame_to normal 1=nloops\n"
, (int)l_begin
, (int)l_end
);
}
return;
}
if(printflag)
{
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
/* Storyboard command line for playback of GAP singleframe range */
printf("VID_PLAY_MOVIE 1=track \"%s\" %06d=frame_from %06d=frame_to normal 1=nloops %d=seltrack\n"
, gpp->ainfo_ptr->old_filename
, (int)l_begin
, (int)l_end
, (int)gpp->ainfo_ptr->seltrack
);
}
else
{
/* Storyboard command line for playback of GAP singleframe range */
printf("VID_PLAY_FRAMES 1=track \"%s\" %s %06d=frame_from %06d=frame_to normal 1=nloops\n"
, gpp->ainfo_ptr->basename
, &gpp->ainfo_ptr->extension[1]
, (int)l_begin
, (int)l_end
);
}
}
/* callback function for adding range as cliplist */
if(gpp->fptr_set_range)
{
GapPlayerAddClip *plac_ptr;
plac_ptr = g_new(GapPlayerAddClip, 1);
if(plac_ptr)
{
plac_ptr->user_data_ptr = gpp->user_data_ptr;
plac_ptr->ainfo_ptr = gpp->ainfo_ptr;
plac_ptr->range_from = l_begin;
plac_ptr->range_to = l_end;
(*gpp->fptr_set_range)(plac_ptr);
g_free(plac_ptr);
}
}
} /* end p_printout_range */
/* --------------------------------
* p_update_ainfo_for_videofile
* --------------------------------
* typical called after creation of a videoindex
* to update the total_frames information
* (that may have changed from the guess value to
* an exact value when all frames were counted)
*/
static void
p_update_ainfo_for_videofile(GapPlayerMainGlobalParams *gpp)
{
GapAnimInfo *ainfo_ptr;
if(gpp == NULL)
{
return;
}
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(gap_debug)
{
printf("p_update_ainfo_for_videofile gpp->ainfo_ptr:%d gpp->gvahand:%d\n"
, (int)gpp->ainfo_ptr
, (int)gpp->gvahand
);
}
ainfo_ptr = gpp->ainfo_ptr;
if ((ainfo_ptr == NULL) || (gpp->gvahand == NULL))
{
return;
}
if(ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
if(gpp->gvahand->all_frames_counted)
{
if(gap_debug)
{
printf("p_update_ainfo_for_videofile ainfo_ptr->frame_cnt:%d gpp->gvahand->total_frames:%d\n"
, (int)ainfo_ptr->frame_cnt
, (int)gpp->gvahand->total_frames
);
}
ainfo_ptr->frame_cnt = gpp->gvahand->total_frames;
ainfo_ptr->last_frame_nr = gpp->gvahand->total_frames;
}
}
#endif
} /* end p_update_ainfo_for_videofile*/
/* --------------------------------
* p_alloc_ainfo_for_videofile
* --------------------------------
* get anim information from filename for videofiles
* return NULL if filename is not a supported videofile
* if filename is a supported video
* return anim information
* and keep the used videohandle gpp->gvahand open
* for the expected read access.
*/
static GapAnimInfo *
p_alloc_ainfo_for_videofile(GapPlayerMainGlobalParams *gpp
, char *filename
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
)
{
GapAnimInfo *l_ainfo_ptr;
l_ainfo_ptr = NULL;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(filename == NULL)
{
return (NULL);
}
if(!g_file_test(filename, G_FILE_TEST_EXISTS))
{
if(gap_debug)
{
printf ("p_alloc_ainfo_for_videofile: file %s does not exist\n"
, filename
);
}
return (NULL);
}
if(!gap_story_filename_is_videofile_by_ext(filename))
{
if(gap_debug)
{
printf ("p_alloc_ainfo_for_videofile: file %s has no typical video extension\n"
, filename
);
}
if(!gpp->force_open_as_video)
{
return (NULL);
}
}
gpp->gva_lock = TRUE;
p_close_videofile(gpp);
p_open_videofile(gpp, filename, seltrack, delace, preferred_decoder);
gpp->gva_lock = FALSE;
if(gpp->gvahand == NULL)
{
if(gap_debug)
{
printf ("p_alloc_ainfo_for_videofile: file %s NO compatible Decoder available\n"
, filename
);
}
return (NULL);
}
l_ainfo_ptr = (GapAnimInfo*)g_malloc(sizeof(GapAnimInfo));
if(l_ainfo_ptr == NULL) return(NULL);
l_ainfo_ptr->basename = g_strdup(filename);
l_ainfo_ptr->extension = gap_lib_alloc_extension(filename);
l_ainfo_ptr->new_filename = NULL;
l_ainfo_ptr->image_id = -1;
l_ainfo_ptr->old_filename = g_strdup(filename);
l_ainfo_ptr->ainfo_type = GAP_AINFO_MOVIE;
l_ainfo_ptr->seltrack = seltrack;
l_ainfo_ptr->delace = delace;
l_ainfo_ptr->curr_frame_nr = 1;
l_ainfo_ptr->first_frame_nr = 1;
l_ainfo_ptr->frame_cnt = gpp->gvahand->total_frames;
if(!gpp->gvahand->all_frames_counted)
{
/* frames are not counted yet,
* and the total_frames information is just a guess
* in this case we assume 2 times more frames
*/
l_ainfo_ptr->frame_cnt *= 2;
}
l_ainfo_ptr->last_frame_nr = l_ainfo_ptr->frame_cnt;
l_ainfo_ptr->width = gpp->gvahand->width;
l_ainfo_ptr->height = gpp->gvahand->height;
gpp->original_speed = gpp->gvahand->framerate;
#endif
return(l_ainfo_ptr);
} /* end p_alloc_ainfo_for_videofile */
/* -----------------------------
* p_reload_ainfo_ptr
* -----------------------------
* get anim information from imagename or image_id
* NO operation when Player is in storyboard mode
* when called with a negative image_id
* then assume that gpp->imagename refers to a videofile
* and try to allocate anim info from videofile.
*/
static void
p_reload_ainfo_ptr(GapPlayerMainGlobalParams *gpp, gint32 image_id)
{
gboolean l_hasImagename;
gpp->image_id = image_id;
l_hasImagename = FALSE;
if(gpp->stb_ptr) { return; }
if(gpp->ainfo_ptr) { gap_lib_free_ainfo(&gpp->ainfo_ptr); }
if((image_id < 0) && (gpp->imagename))
{
gpp->ainfo_ptr = p_alloc_ainfo_for_videofile(gpp
,gpp->imagename
,gpp->seltrack
,gpp->delace
,gpp->preferred_decoder
);
if(gpp->ainfo_ptr)
{
return;
}
gpp->ainfo_ptr = gap_lib_alloc_ainfo_from_name(gpp->imagename, gpp->run_mode);
l_hasImagename = TRUE;
}
else
{
char *imagename;
imagename = gimp_image_get_filename(image_id);
if (imagename)
{
l_hasImagename = TRUE;
g_free(imagename);
}
/* normal mode using anim frames or single image */
gpp->ainfo_ptr = gap_lib_alloc_ainfo(gpp->image_id, gpp->run_mode);
}
if(gpp->ainfo_ptr == NULL)
{
return;
}
if (0 == gap_lib_dir_ainfo(gpp->ainfo_ptr))
{
if(gpp->image_id >= 0)
{
gpp->ainfo_ptr->width = gimp_image_width(gpp->image_id);
gpp->ainfo_ptr->height = gimp_image_height(gpp->image_id);
}
else
{
gpp->ainfo_ptr->width = gpp->imagewidth;
gpp->ainfo_ptr->height = gpp->imageheight;
}
if((gpp->ainfo_ptr->frame_cnt != 0) && (l_hasImagename == TRUE))
{
GapVinVideoInfo *vin_ptr;
vin_ptr = gap_vin_get_all(gpp->ainfo_ptr->basename);
gpp->onion_delete = FALSE;
gpp->original_speed = 24.0;
if(vin_ptr)
{
if(vin_ptr->framerate > 0.0)
{
gpp->original_speed = vin_ptr->framerate;
}
/* check if automatic onionskin layer removal is turned on */
if((vin_ptr->auto_delete_before_save)
&& (vin_ptr->onionskin_auto_enable))
{
/* yes, in this case the player must show the active image
* without onionskin layers
*/
gpp->onion_delete = TRUE;
}
}
if(vin_ptr)
{
g_free(vin_ptr);
}
}
else
{
/* player operates on a single image that is not a numbered frame
* patch the ainfo structure
*/
if(gap_debug)
{
printf("p_reload_ainfo_ptr: player operates on a single image that is not a numbered frame\n");
printf("basename: %s\n", gpp->ainfo_ptr->basename );
printf("extension: %s\n", gpp->ainfo_ptr->extension );
}
gpp->ainfo_ptr->curr_frame_nr = 1;
gpp->ainfo_ptr->first_frame_nr = 1;
gpp->ainfo_ptr->last_frame_nr = 1;
gpp->original_speed = 24.0;
}
}
} /* end p_reload_ainfo_ptr */
/* --------------------------------
* p_update_ainfo_dependent_widgets
* --------------------------------
*/
static void
p_update_ainfo_dependent_widgets(GapPlayerMainGlobalParams *gpp)
{
gdouble l_lower;
gdouble l_upper;
gdouble l_value;
if(gpp == NULL) { return; }
if(gpp->ainfo_ptr == NULL) { return; }
l_lower = (gdouble)gpp->ainfo_ptr->first_frame_nr;
l_upper = (gdouble)gpp->ainfo_ptr->last_frame_nr;
GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->lower = l_lower;
GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->upper = l_upper;
GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->value = CLAMP(GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->value
,l_lower, l_upper);
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)CLAMP(GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->value, l_lower, l_upper)
);
GTK_ADJUSTMENT(gpp->to_spinbutton_adj)->lower = l_lower;
GTK_ADJUSTMENT(gpp->to_spinbutton_adj)->upper = l_upper;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat) CLAMP(GTK_ADJUSTMENT(gpp->to_spinbutton_adj)->value, l_lower, l_upper)
);
l_value = CLAMP(GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)->value, l_lower, l_upper);
if(gap_debug)
{
printf("## tmp p_update_ainfo_dependent_widgets adj l_value:%.2f l_lower:%.2f l_upper:%.2f\n"
,(float)l_value
,(float)l_lower
,(float)l_upper
);
}
GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)->lower = l_lower;
GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)->upper = l_upper;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj), l_value);
} /* end p_update_ainfo_dependent_widgets */
/* ------------------------------------
* p_find_master_image_id
* ------------------------------------
* try to find the master image by filename
* matching at basename and extension part
*
* return positive image_id on success
* return -1 if nothing found
*/
static gint32
p_find_master_image_id(GapPlayerMainGlobalParams *gpp)
{
gint32 *images;
gint nimages;
gint l_idi;
gint l_baselen;
gint l_extlen;
gint32 l_found_image_id;
if(gpp->ainfo_ptr == NULL) { return -1; }
if(gpp->ainfo_ptr->basename == NULL) { return -1; }
if(gap_debug)
{
printf("p_find_master_image_id: image_id %s %s START\n"
, gpp->ainfo_ptr->basename
, gpp->ainfo_ptr->extension
);
}
l_baselen = strlen(gpp->ainfo_ptr->basename);
l_extlen = strlen(gpp->ainfo_ptr->extension);
images = gimp_image_list(&nimages);
l_idi = nimages -1;
l_found_image_id = -1;
while((l_idi >= 0) && images)
{
gchar *l_filename;
l_filename = gimp_image_get_filename(images[l_idi]);
if(l_filename)
{
if(gap_debug) printf("p_find_master_image_id: comare with %s\n", l_filename);
if(strncmp(l_filename, gpp->ainfo_ptr->basename, l_baselen) == 0)
{
gint l_len;
l_len = strlen(l_filename);
if(l_len > l_extlen)
{
if(strncmp(&l_filename[l_len - l_extlen], gpp->ainfo_ptr->extension, l_extlen) == 0)
{
l_found_image_id = images[l_idi];
break;
}
}
}
g_free(l_filename);
}
l_idi--;
}
if(images) g_free(images);
return l_found_image_id;
} /* end p_find_master_image_id */
/* ------------------------------------
* p_keep_track_of_active_master_image
* ------------------------------------
* Note: in storyboard mode there is no active master image
* just return without any action in that case.
*/
static void
p_keep_track_of_active_master_image(GapPlayerMainGlobalParams *gpp)
{
p_stop_playback(gpp);
if(gpp->stb_ptr) { return; }
if(gpp->imagename) { return; }
gpp->image_id = p_find_master_image_id(gpp);
if(gpp->image_id >= 0)
{
p_reload_ainfo_ptr(gpp, gpp->image_id);
p_update_ainfo_dependent_widgets(gpp);
}
else
{
/* cannot find the master image, so quit immediate */
printf("p_keep_track_of_active_master_image: Master Image not found (may have been closed)\n");
printf("Exiting Playback\n");
on_shell_window_destroy(NULL, gpp);
}
} /* end p_keep_track_of_active_master_image */
/* -----------------------------
* on_help_button_clicked
* -----------------------------
*/
static void
on_help_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
if(gpp->help_id)
{
gimp_standard_help_func(gpp->help_id, gpp->shell_window);
}
}
} /* end on_help_button_clicked */
/* -----------------------------
* p_check_for_active_image
* -----------------------------
* check if framenr is the the active image
* (from where we were called at plug-in invocation time)
*
* this procedure also tries to keep track of changes
* of the active master image_id outside this plug-in.
*
* (stepping to another frame, using other GAP plug-ins
* changes the master image_id outside ...)
*/
gboolean
p_check_for_active_image(GapPlayerMainGlobalParams *gpp, gint32 framenr)
{
if (gap_image_is_alive(gpp->image_id))
{
if(framenr == gpp->ainfo_ptr->curr_frame_nr)
{
return(TRUE);
}
}
else
{
p_keep_track_of_active_master_image(gpp);
if(framenr == gpp->ainfo_ptr->curr_frame_nr)
{
return(TRUE);
}
return (FALSE);
}
return (FALSE);
} /* end p_check_for_active_image */
/* -----------------------------
* p_update_pviewsize
* -----------------------------
* set preview size nd size spinbutton
*/
static void
p_update_pviewsize(GapPlayerMainGlobalParams *gpp)
{
gint32 l_width;
gint32 l_height;
l_width = gpp->ainfo_ptr->width;
l_height = gpp->ainfo_ptr->height;
if(gpp->aspect_ratio > 0.0)
{
gdouble asp_height;
/* force playback at specified aspect ratio */
asp_height = (gdouble)(l_width) / gpp->aspect_ratio;
l_height = (gint32)asp_height;
}
/*
* Resize the greater one of dwidth and dheight to PREVIEW_SIZE
*/
if ( l_width > l_height )
{
/* landscape */
gpp->pv_height = l_height * gpp->pv_pixelsize / l_width;
gpp->pv_height = MAX (1, gpp->pv_height);
gpp->pv_width = gpp->pv_pixelsize;
}
else
{
/* portrait */
gpp->pv_width = l_width * gpp->pv_pixelsize / l_height;
gpp->pv_width = MAX(1, gpp->pv_width);
gpp->pv_height = gpp->pv_pixelsize;
}
if(gpp->pv_pixelsize != (gint32)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value)
{
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->size_spinbutton_adj)
, (gfloat)gpp->pv_pixelsize
);
}
gpp->pv_pixelsize = (gint32)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value;
gap_pview_set_size(gpp->pv_ptr
, gpp->pv_width
, gpp->pv_height
, MAX(GAP_PLAYER_CHECK_SIZE, (gpp->pv_pixelsize / 16))
);
} /* end p_update_pviewsize */
/* -----------------------------
* p_set_frame_with_name_label
* -----------------------------
* set labeltext as filename (or basename) with type indicator prefix
*/
static void
p_set_frame_with_name_label(GapPlayerMainGlobalParams *gpp)
{
#define MAX_CHARS 60
char *frame_title;
frame_title = NULL;
if(gpp->stb_ptr)
{
gchar *l_prefix;
l_prefix = NULL;
if(gpp->stb_in_track > 0)
{
/* filename prefix shortcut for storyboard single track playback for specified track number */
l_prefix = g_strdup_printf(_("STB:[%d]"), (int)gpp->stb_in_track);
}
else
{
/* filename prefix shortcut for storyboard in composite video playback mode */
l_prefix = g_strdup(_("STB:"));
}
/* shortname prefix to indicate that displayed filename is from type storyboard file */
frame_title = gap_base_shorten_filename(l_prefix /* prefix short for storyboard */
,gpp->stb_ptr->storyboardfile /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
);
g_free(l_prefix);
}
else
{
if((gpp->imagename) && (gpp->ainfo_ptr))
{
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
/* shortname prefix to indicate that displayed filename is a single videofile */
frame_title = gap_base_shorten_filename(_("VIDEO:") /* prefix short for storyboard */
,gpp->ainfo_ptr->basename /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
);
}
}
}
if(frame_title == NULL)
{
/* shortname prefix to indicate that displayed filename is basename of the frames */
frame_title = gap_base_shorten_filename(_("FRAMES:") /* prefix short for storyboard */
,gpp->ainfo_ptr->basename /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
);
}
gtk_frame_set_label (GTK_FRAME (gpp->frame_with_name)
, frame_title);
g_free(frame_title);
} /* end p_set_frame_with_name_label */
/* -----------------------------
* p_update_position_widgets
* -----------------------------
* set position spinbutton and time entry
*/
static void
p_update_position_widgets(GapPlayerMainGlobalParams *gpp)
{
static gchar time_txt[12];
if((gint32)GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)->value != gpp->play_current_framenr)
{
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)
, (gfloat)gpp->play_current_framenr
);
}
gap_timeconv_framenr_to_timestr( (gpp->play_current_framenr - gpp->ainfo_ptr->first_frame_nr)
, gpp->original_speed
, time_txt
, sizeof(time_txt)
);
gtk_label_set_text ( GTK_LABEL(gpp->timepos_label), time_txt);
} /* end p_update_position_widgets */
/* -----------------------------
* p_start_playback_timer
* -----------------------------
* this procedure sets up the delay
* until next timercall.
*/
static void
p_start_playback_timer(GapPlayerMainGlobalParams *gpp)
{
gint32 delay_until_next_timercall_millisec;
gdouble cycle_time_secs;
cycle_time_secs = 1.0 / MAX(gpp->speed, 1.0);
if(cycle_time_secs != gpp->cycle_time_secs)
{
/* playback speed has changed while playing
* reset timing (restart playing with new speed on the fly)
* use a half delay, as guess after speed has changed
*/
gpp->rest_secs = cycle_time_secs / 2.0;
gpp->delay_secs = 0.0; /* reset the absolute delay (since start or speedchange) */
gpp->framecnt = 0.0;
g_timer_start(gpp->gtimer); /* (re)start timer at start of playback (== reset to 0) */
}
else
{
if(gpp->rest_secs < 0)
{
/* use a minimal delay, bacause we are LATE */;
gpp->rest_secs = 10.0 / 1000.0;
gpp->framecnt = 0.0;
g_timer_start(gpp->gtimer); /* (re)start timer at start of playback (== reset to 0) */
}
}
gpp->cycle_time_secs = cycle_time_secs;
delay_until_next_timercall_millisec = (gpp->rest_secs) * 1000.0;
/*if(gap_debug) printf("p_start_playback_timer: START delay_until_next_timercall_millisec:%d\n", (int)delay_until_next_timercall_millisec);*/
gpp->play_is_active = TRUE;
gpp->play_timertag = (gint32) g_timeout_add(delay_until_next_timercall_millisec,
(GtkFunction)on_timer_playback, gpp);
} /* end p_start_playback_timer */
/* -----------------------------
* p_initial_start_playback_timer
* -----------------------------
*/
static void
p_initial_start_playback_timer(GapPlayerMainGlobalParams *gpp)
{
p_audio_stop(gpp); /* stop old playback if there is any */
gpp->audio_resync = 0;
gpp->cycle_time_secs = 1.0 / MAX(gpp->speed, 1.0);
gpp->rest_secs = 10.0 / 1000.0; /* use minimal delay for the 1st call */
gpp->delay_secs = 0.0; /* absolute delay (for display) */
gpp->framecnt = 0.0;
gpp->go_job_framenr = -1; /* pending timer_go_job gets useless, since we start playback now */
gtk_label_set_text ( GTK_LABEL(gpp->status_label), _("Playing"));
g_timer_start(gpp->gtimer); /* (re)start timer at start of playback (== reset to 0) */
p_start_playback_timer(gpp);
p_audio_start_play(gpp);
} /* end p_initial_start_playback_timer */
/* -----------------------------
* p_remove_play_timer
* -----------------------------
*/
static void
p_remove_play_timer(GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf("p_remove_play_timer\n");*/
if(gpp->play_timertag >= 0)
{
g_source_remove(gpp->play_timertag);
}
gpp->play_timertag = -1;
} /* end p_remove_play_timer */
/* -----------------------------
* p_stop_playback
* -----------------------------
*/
static void
p_stop_playback(GapPlayerMainGlobalParams *gpp)
{
/* if(gap_debug) printf("p_stop_playback\n"); */
p_remove_play_timer(gpp);
gpp->mtrace_mode = GAP_PLAYER_MTRACE_OFF;
gpp->request_cancel_video_api = TRUE;
gpp->play_is_active = FALSE;
gpp->pingpong_count = 0;
gtk_label_set_text ( GTK_LABEL(gpp->status_label), _("Ready"));
p_check_tooltips();
p_audio_stop(gpp);
gpp->audio_resync = 0;
} /* end p_stop_playback */
/* ---------------------------------
* on_cancel_vindex_button_clicked
* ---------------------------------
*/
static void
on_cancel_vindex_button_clicked (GtkObject *object,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
gpp->cancel_video_api = TRUE;
gpp->request_cancel_video_api = FALSE;
}
} /* end on_cancel_vindex_button_clicked */
/* -----------------------------------------
* on_audio_auto_offset_checkbutton_toggled
* -----------------------------------------
*/
static void
on_audio_auto_offset_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->audio_auto_offset_by_framenr = TRUE;
}
else
{
gpp->audio_auto_offset_by_framenr = FALSE;
gpp->audio_resync = 0;
}
p_audio_resync(gpp);
} /* end on_audio_auto_offset_checkbutton_toggled */
/* -----------------------------------------
* p_msg_progress_bar_audio
* -----------------------------------------
*/
static void
p_msg_progress_bar_audio(GapPlayerMainGlobalParams *gpp, const char *msg)
{
if (gpp->progress_bar_audio)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar_audio), msg);
}
} /* end p_msg_progress_bar_audio */
/* -----------------------------------------
* p_reset_progress_bar_audio
* -----------------------------------------
*/
static void
p_reset_progress_bar_audio(GapPlayerMainGlobalParams *gpp)
{
if (gpp->progress_bar_audio)
{
/* reset audio extract progress when done */
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar_audio)," ");
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gpp->progress_bar_audio), 0.0);
}
} /* end p_reset_progress_bar_audio */
/* -----------------------------------------
* on_audio_otone_extract_button_clicked
* -----------------------------------------
*/
static void
on_audio_otone_extract_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
gboolean l_otone_is_up_to_date;
gint32 l_extract_audiotrack;
gint32 l_begin_frame_nr;
gint32 l_end_frame_nr;
char *l_audiofilename;
char *l_audiofilename_cancel;
if(gpp == NULL)
{
return;
}
if(gpp->gva_lock)
{
/* do not attempt displaying frames while we are inside
* of p_alloc_ainfo_for_videofile procedure
*/
return;
}
if(gpp->gvahand == NULL)
{
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
p_open_videofile(gpp
, gpp->ainfo_ptr->old_filename
, gpp->ainfo_ptr->seltrack
, gpp->ainfo_ptr->delace
, gpp->preferred_decoder
);
}
}
if((gpp->gvahand == NULL) || (gpp->gva_videofile == NULL))
{
/* no videofile or no videohandle available */
return;
}
if(gpp->gvahand->audio_cannels <= 0)
{
/* video has no audiotracks */
return;
}
p_reset_progress_bar_audio(gpp);
p_msg_progress_bar_audio(gpp, _("cheking audiotrack"));
l_extract_audiotrack = CLAMP(GTK_ADJUSTMENT(gpp->audio_otone_atrack_spinbutton_adj)->value
, 1
, gpp->gvahand->audio_cannels
);
/* build otone workfile name (set gpp->audio_otone_wavfile ) */
l_audiofilename = p_build_otone_audiofilename(gpp->gva_videofile
, l_extract_audiotrack
, NULL /* no special suffix used here */
);
l_audiofilename_cancel = p_build_otone_audiofilename(gpp->gva_videofile
, l_extract_audiotrack
, ".incomplete"
);
l_otone_is_up_to_date = p_check_otone_workfile_up_to_date(gpp->gva_videofile, l_audiofilename, l_extract_audiotrack);
if (l_otone_is_up_to_date == TRUE)
{
p_msg_progress_bar_audio(gpp, _("extracted audio is up to date"));
}
else
{
gdouble l_dbl_total_frames;
l_begin_frame_nr = 1;
l_end_frame_nr = gpp->gvahand->total_frames;
l_dbl_total_frames = (gdouble)gpp->gvahand->total_frames;
p_msg_progress_bar_audio(gpp, _("extracting audio"));
if(g_file_test(l_audiofilename, G_FILE_TEST_EXISTS))
{
g_remove(l_audiofilename);
}
if(g_file_test(l_audiofilename_cancel, G_FILE_TEST_EXISTS))
{
g_remove(l_audiofilename_cancel);
}
gpp->cancel_video_api = FALSE;
gpp->request_cancel_video_api = FALSE;
/* extract audio segment (in full length) to otone workfile */
gap_audio_extract_from_videofile(gpp->gva_videofile
, l_audiofilename
, l_extract_audiotrack
, gpp->preferred_decoder /* preferred_decoder */
, TRUE /* exact_seek */
, GVA_UPOS_FRAMES /* pos_unit */
, l_begin_frame_nr
, l_dbl_total_frames /* extracted_frames */
, l_dbl_total_frames /* expected_frames */
, TRUE /* do_progress */
, gpp->progress_bar_audio /* GtkWidget *progressBar using NULL for gimp_progress */
, p_vid_progress_callback /* fptr_progress_callback */
, gpp /* user_data */
);
if (gpp->cancel_video_api == TRUE)
{
p_msg_progress_bar_audio(gpp, _("Audio Extract CANCELLED"));
}
else
{
/* reset audio extract progress when successfully done */
p_reset_progress_bar_audio(gpp);
}
if(!g_file_test(l_audiofilename, G_FILE_TEST_EXISTS))
{
p_msg_progress_bar_audio(gpp, _("Audio Extract FAILED"));
g_message(_("Extract of audiotrack failed on videofile: %s"), gpp->gva_videofile);
goto cleanup;
}
else
{
gint32 l_audiofile_size;
l_audiofile_size = gap_file_get_filesize(l_audiofilename);
if (l_audiofile_size < 1)
{
p_msg_progress_bar_audio(gpp, _("Audio Extract FAILED"));
g_message(_("Extract of audiotrack failed on videofile: %s"), gpp->gva_videofile);
goto cleanup;
}
if (gpp->cancel_video_api == TRUE)
{
/* due to cancel the extracted audiofile is not complete
* Therefore rename with suffix "incomplete"
*/
if (strcmp(l_audiofilename_cancel, l_audiofilename) != 0)
{
g_rename(l_audiofilename, l_audiofilename_cancel);
g_free(l_audiofilename);
l_audiofilename = l_audiofilename_cancel;
l_audiofilename_cancel = NULL;
}
}
}
}
gpp->audio_auto_offset_by_framenr = TRUE;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->audio_auto_offset_by_framenr_checkbutton),
gpp->audio_auto_offset_by_framenr);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->audio_enable_checkbutton),
TRUE);
/* before the gtk_entry_set_text call, already set the gpp->audio_filename
* explicite to the new name l_audiofilename
* (this fakes "name has not changed" and prevents the callback
* on_audio_filename_entry_changed from resetting the progress_bar_audio message
* that shall be kept until the user enters the audiofilename manually)
*
*/
g_snprintf(gpp->audio_filename, sizeof(gpp->audio_filename), "%s"
, l_audiofilename
);
gtk_entry_set_text(GTK_ENTRY(gpp->audio_filename_entry), l_audiofilename);
p_audio_filename_changed (gpp);
cleanup:
gpp->cancel_video_api = FALSE;
if(l_audiofilename) { g_free(l_audiofilename); }
if(l_audiofilename_cancel) { g_free(l_audiofilename_cancel);}
#endif /* GAP_ENABLE_VIDEOAPI_SUPPORT */
#endif /* GAP_ENABLE_VIDEOAPI_SUPPORT */
} /* end on_audio_otone_extract_button_clicked */
/* ----------------------------------------
* on_audio_otone_atrack_spinbutton_changed
* ----------------------------------------
*/
static void
on_audio_otone_atrack_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->audio_otone_atrack != (gdouble)GTK_ADJUSTMENT(gpp->audio_otone_atrack_spinbutton_adj)->value)
{
gpp->audio_otone_atrack = (gdouble)GTK_ADJUSTMENT(gpp->audio_otone_atrack_spinbutton_adj)->value;
#ifdef GAP_ENABLE_AUDIO_SUPPORT
p_audio_stop(gpp);
#endif
}
} /* end on_audio_otone_atrack_spinbutton_changed */
/* --------------------------------
* p_vid_progress_callback
* --------------------------------
* this callback is used while searching videoframes
* return: TRUE: cancel videoapi immediate
* FALSE: continue
*/
static gboolean
p_vid_progress_callback(gdouble progress
,gpointer user_data
)
{
GapPlayerMainGlobalParams *gpp;
gpp = (GapPlayerMainGlobalParams *)user_data;
if(gpp == NULL)
{
if(gap_debug)
{
printf("PLAYER: gpp == NULL p_vid_progress_callback CANCEL == true\n");
}
return (TRUE);
}
if(gpp->progress_bar == NULL)
{
if(gap_debug)
{
printf("PLAYER: gpp->progress_bar == NULL p_vid_progress_callback CANCEL == trUE\n");
}
return (TRUE);
}
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gpp->progress_bar), progress);
/* g_main_context_iteration makes sure that
* gtk does refresh widgets, and react on events while the videoapi
* is busy with searching for the next frame.
*/
while(g_main_context_iteration(NULL, FALSE));
/* if vthe long running videoindex creation is running
* cancel is done only explicite when the cancel_vindex_button is clicked.
*/
if(!gpp->vindex_creation_is_running)
{
/* no videoindex creation is running
* (in most cases we are in a seek to frame operation at this point)
* in this case we do cancel immedate on request.
* request_cancel_video_api is set on most user actions
* on the player widgets when he wants positioning or start/stop playing
*/
gpp->cancel_video_api = gpp->request_cancel_video_api;
}
if(gpp->cancel_video_api)
{
if(gap_debug)
{
printf("PLAYER: cancel_video_api is TRUE p_vid_progress_callback CANCEL == TRUE\n");
}
return (TRUE); /* cancel video api if playback was stopped */
}
return(FALSE); /* continue with video API */
} /* end p_vid_progress_callback */
/* --------------------------------
* p_close_videofile
* --------------------------------
*/
static void
p_close_videofile(GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(gpp->gvahand)
{
if(gpp->gva_videofile) g_free(gpp->gva_videofile);
GVA_close(gpp->gvahand);
gpp->gvahand = NULL;
gpp->gva_videofile = NULL;
}
#endif
} /* end p_close_videofile */
/* --------------------------------
* p_reopen_videofile
* --------------------------------
*/
static void
p_reopen_videofile(GapPlayerMainGlobalParams *gpp
, char *filename
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
)
{
const char *l_preferred_decoder;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
p_close_videofile(gpp);
/* use global preferred_decoder setting per default */
l_preferred_decoder = gpp->preferred_decoder;
if(preferred_decoder)
{
if(*preferred_decoder != '\0')
{
/* use element specific preferred_decoder if available */
l_preferred_decoder = preferred_decoder;
}
}
/*
* printf("PLAYER: open START\n");
* if(l_preferred_decoder)
* {
* printf("PLAYER: (decoder:%s)\n", l_preferred_decoder);
* }
*/
gpp->gvahand = GVA_open_read_pref(filename
, seltrack
, 1 /* aud_track */
, l_preferred_decoder
, FALSE /* use MMX if available (disable_mmx == FALSE) */
);
/*printf("PLAYER: open gpp->gvahand:%d\n", (int)gpp->gvahand);*/
if(gpp->gvahand)
{
gpp->gva_videofile = g_strdup(filename);
/* gpp->gvahand->emulate_seek = TRUE; */
gpp->gvahand->do_gimp_progress = FALSE;
gpp->gvahand->progress_cb_user_data = gpp;
gpp->gvahand->fptr_progress_callback = p_vid_progress_callback;
if(gap_debug)
{
printf("## p_reopen_videofile gpp->gvahand->total_frames:%d\n"
,(int)gpp->gvahand->total_frames
);
}
/* printf("PLAYER: open fptr_progress_callback FPTR:%d\n"
* , (int)gpp->gvahand->fptr_progress_callback);
*/
/* set decoder name as progress idle text */
{
t_GVA_DecoderElem *dec_elem;
if(gpp->progress_bar_idle_txt)
{
g_free(gpp->progress_bar_idle_txt);
}
dec_elem = (t_GVA_DecoderElem *)gpp->gvahand->dec_elem;
if(dec_elem->decoder_name)
{
gpp->progress_bar_idle_txt = g_strdup(dec_elem->decoder_name);
}
else
{
gpp->progress_bar_idle_txt = g_strdup(" ");
}
}
}
#endif
} /* end p_reopen_videofile */
/* --------------------------------
* p_open_videofile
* --------------------------------
* open videofile handle
* with checks for video index creation.
* in case where video index creation is recommanded
* this is done after asking the user for permission.
*/
static void
p_open_videofile(GapPlayerMainGlobalParams *gpp
, char *filename
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
)
{
char *vindex_file;
gboolean l_have_valid_vindex;
l_have_valid_vindex = FALSE;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
p_reopen_videofile(gpp, filename, seltrack, delace, preferred_decoder);
vindex_file = NULL;
if(gpp->gvahand)
{
/* set decoder name as progress idle text */
{
t_GVA_DecoderElem *dec_elem;
dec_elem = (t_GVA_DecoderElem *)gpp->gvahand->dec_elem;
if(dec_elem->decoder_name)
{
vindex_file = GVA_build_videoindex_filename(gpp->gva_videofile
,1 /* track */
,dec_elem->decoder_name
);
}
}
if(gpp->gvahand->vindex)
{
if(gpp->gvahand->vindex->total_frames > 0)
{
l_have_valid_vindex = TRUE;
}
}
if((l_have_valid_vindex == FALSE)
&&(gpp->startup == FALSE))
{
gboolean vindex_permission;
t_GVA_SeekSupport seekSupp;
gpp->cancel_video_api = FALSE;
gpp->request_cancel_video_api = FALSE;
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar), _("seek-selftest"));
}
seekSupp = GVA_check_seek_support(gpp->gvahand);
/* check for permission to create a videoindex file */
vindex_permission = gap_arr_create_vindex_permission(gpp->gva_videofile
, vindex_file
, (gint32)seekSupp
);
if(vindex_permission)
{
/* create video index
* (dont do that while we are in startup
* because the shell window and progress_bar widget and many other things
* are not set up yet and this long running operation
* would be done without any visible sign)
*/
gpp->cancel_video_api = FALSE;
gpp->request_cancel_video_api = FALSE;
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar), _("Creating Index"));
}
gpp->gvahand->create_vindex = TRUE;
/* while videoindex creation show cancel button and hide play/stop buttons */
gtk_widget_hide (gpp->play_n_stop_hbox);
gtk_widget_show (gpp->cancel_vindex_button);
/* printf("PLAYER: open before GVA_count_frames\n"); */
gpp->vindex_creation_is_running = TRUE;
GVA_count_frames(gpp->gvahand);
gpp->vindex_creation_is_running = FALSE;
/* printf("PLAYER: open after GVA_count_frames\n"); */
gtk_widget_hide (gpp->cancel_vindex_button);
gtk_widget_show (gpp->play_n_stop_hbox);
if(!gpp->cancel_video_api)
{
if(gpp->gvahand->vindex != NULL)
{
p_update_ainfo_for_videofile(gpp);
p_update_ainfo_dependent_widgets(gpp);
p_reopen_videofile(gpp, filename, seltrack, delace, preferred_decoder);
}
else
{
g_message(_("No videoindex available. "
"Access is limited to (slow) sequential read "
"on file: %s")
, gpp->gvahand->filename
);
}
}
}
}
/* GVA_debug_print_videoindex(gpp->gvahand); */
if(vindex_file)
{
g_free(vindex_file);
}
}
/* printf("PLAYER: open END\n"); */
#endif
} /* end p_open_videofile */
/* -----------------------------
* p_fetch_videoframe
* -----------------------------
*/
static guchar *
p_fetch_videoframe(GapPlayerMainGlobalParams *gpp
, char *gva_videofile
, gint32 framenumber
, gint32 rangesize
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
, gint32 *th_bpp
, gint32 *th_width
, gint32 *th_height
)
{
guchar *th_data;
th_data = NULL;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(gpp->gva_lock)
{
return(NULL);
}
gpp->gva_lock = TRUE;
if((gpp->gva_videofile) && (gpp->gvahand))
{
if((strcmp(gpp->gva_videofile, gva_videofile) != 0)
||(seltrack != (gpp->gvahand->vid_track+1)))
{
//printf(" VIDFETCH (..) CALL p_close_videofile\n");
//printf(" VIDFETCH (..) gpp->gva_videofile: %s\n", gpp->gva_videofile);
//printf(" VIDFETCH (..) gpp->gvahand->vid_track: %d\n", (int)gpp->gvahand->vid_track);
//printf(" VIDFETCH (..) gva_videofile: %s\n", gva_videofile);
//printf(" VIDFETCH (..) seltrack: %d\n", (int)seltrack);
p_close_videofile(gpp);
}
}
//printf(" VIDFETCH (0) gpp->gvahand: %d framenumber:%06d\n", (int)gpp->gvahand, (int)framenumber);
if(gpp->gvahand == NULL)
{
p_open_videofile(gpp, gva_videofile, seltrack, delace, preferred_decoder);
}
if(gpp->gvahand)
{
gint32 l_deinterlace;
gdouble l_threshold;
gboolean do_scale;
gint32 fcache_size;
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar), _("Videoseek"));
}
//printf(" VIDFETCH (3) gimprc: FCACHE SIZE: %d\n", (int)gpp->gvahand->fcache.frame_cache_size);
if(global_max_vid_frames_to_keep_cached < 1)
{
char *value_string;
value_string = gimp_gimprc_query("video-max-frames-keep-cached");
if(value_string)
{
//printf(" VIDFETCH (4) gimprc: value_string: %s\n", value_string);
global_max_vid_frames_to_keep_cached = atol(value_string);
}
if(global_max_vid_frames_to_keep_cached < 1)
{
global_max_vid_frames_to_keep_cached = GAP_PLAYER_VID_FRAMES_TO_KEEP_CACHED;
}
}
fcache_size = CLAMP(rangesize, 1, global_max_vid_frames_to_keep_cached);
if(fcache_size > gpp->gvahand->fcache.frame_cache_size)
{
//printf(" VIDFETCH (5) gimprc: FCACHE_MAX:%d fcache_size:%d rangesize:%d\n"
// , (int)global_max_vid_frames_to_keep_cached
// , (int)fcache_size
// , (int)rangesize
// );
GVA_set_fcache_size(gpp->gvahand, fcache_size);
}
do_scale = TRUE;
if(*th_width < 1)
{
*th_bpp = gpp->gvahand->frame_bpp;
*th_width = gpp->gvahand->width;
*th_height = gpp->gvahand->height;
do_scale = FALSE;
}
/* split delace value: integer part is deinterlace mode, rest is threshold */
l_deinterlace = delace;
l_threshold = delace - (gdouble)l_deinterlace;
gpp->cancel_video_api = FALSE;
gpp->request_cancel_video_api = FALSE;
//printf(" VIDFETCH (6) current_seek_nr:%d current_frame_nr:%d\n", (int)gpp->gvahand->current_seek_nr ,(int)gpp->gvahand->current_frame_nr );
/* fetch the wanted framenr */
th_data = GVA_fetch_frame_to_buffer(gpp->gvahand
, do_scale
, framenumber
, l_deinterlace
, l_threshold
, th_bpp
, th_width
, th_height
);
//printf(" VIDFETCH (7) current_seek_nr:%d current_frame_nr:%d\n", (int)gpp->gvahand->current_seek_nr ,(int)gpp->gvahand->current_frame_nr );
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar)
,gpp->progress_bar_idle_txt
);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gpp->progress_bar), 0.0);
}
}
if(th_data)
{
/* throw away frame data because the fetch was cancelled
* (an empty display is better than trash or the wrong frame)
*/
if(gpp->cancel_video_api)
{
g_free(th_data);
th_data = NULL;
}
else if (gpp->dvref_ptr != NULL)
{
/* refresh current videofile reference
* Note: the dvref_ptr->videofile gets no COPY but only a rference to the current videofilename
* this pointer can be reset to NULL any time (at p_display_frame)
* but MUST NOT free up the refered name.
*/
gpp->dvref_ptr->videofile = gpp->gva_videofile;
gpp->dvref_ptr->para.framenr = framenumber;
gpp->dvref_ptr->para.seltrack = seltrack;
g_snprintf(&gpp->dvref_ptr->para.preferred_decoder[0], sizeof(gpp->dvref_ptr->para.preferred_decoder), "%s"
, preferred_decoder
);
if(gap_debug)
{
printf("p_fetch_videoframe: dvref\n");
gap_dvref_debug_print_GapDrawableVideoRef(gpp->dvref_ptr);
}
}
}
else
{
/* one possible reason for a videframe fetch failure
* could be an EOF in the video
* (in this moment the GVA API might know the exactly
* number of total_frames and we can set the limits in the player widget
* if we are running on a single videofile -- but NOT in storyboard mode)
*/
if(!gpp->stb_ptr)
{
if((gpp->imagename) && (gpp->gvahand->all_frames_counted))
{
if(gap_debug)
{
printf("p_fetch_videoframe CALL p_update_ainfo_dependent_widgets ainfo_ptr->frame_cnt:%d gpp->gvahand->total_frames:%d\n"
, (int)gpp->ainfo_ptr->frame_cnt
, (int)gpp->gvahand->total_frames
);
}
gpp->ainfo_ptr->frame_cnt = gpp->gvahand->total_frames;
gpp->ainfo_ptr->last_frame_nr = gpp->gvahand->total_frames;
p_update_ainfo_dependent_widgets(gpp);
}
}
}
gpp->gva_lock = FALSE;
#endif
return (th_data);
} /* end p_fetch_videoframe */
/* -----------------------------
* p_init_video_playback_cache
* -----------------------------
*/
static void
p_init_video_playback_cache(GapPlayerMainGlobalParams *gpp)
{
gpp->max_player_cache = gap_player_cache_get_gimprc_bytesize();
gap_player_cache_set_max_bytesize(gpp->max_player_cache);
} /* end p_init_video_playback_cache */
/* -----------------------------
* p_init_layout_options
* -----------------------------
*/
static void
p_init_layout_options(GapPlayerMainGlobalParams *gpp)
{
gchar *value_string;
gpp->show_go_buttons = TRUE;
gpp->show_position_scale = TRUE;
value_string = gimp_gimprc_query("video_player_show_go_buttons");
if(value_string)
{
if ((*value_string == 'Y') || (*value_string == 'y'))
{
gpp->show_go_buttons = TRUE;
}
else
{
gpp->show_go_buttons = FALSE;
}
g_free(value_string);
}
value_string = gimp_gimprc_query("video_player_show_position_scale");
if(value_string)
{
if ((*value_string == 'Y') || (*value_string == 'y'))
{
gpp->show_position_scale = TRUE;
}
else
{
gpp->show_position_scale = FALSE;
}
g_free(value_string);
}
} /* end p_init_layout_options */
/* ------------------------------
* p_fetch_frame_via_cache
* ------------------------------
* fetch any type of frame from the players cache.
* returns NULL
* - if no frame for the specified ckey was found in the cache,
* - or if the player runs in MTRACE mode,
* the parameters th_bpp, th_width, th_height are not changed
* in case when NULL is the return value
* If cached frame is returned,
* the parameters th_bpp, th_width, th_height are set
* according to the size of the cached frame
*/
static guchar *
p_fetch_frame_via_cache(GapPlayerMainGlobalParams *gpp
, const gchar *ckey
, gint32 *th_bpp_ptr /* IN/OUT */
, gint32 *th_width_ptr /* IN/OUT */
, gint32 *th_height_ptr /* IN/OUT */
, gint32 *flip_status_ptr /* IN/OUT */
)
{
GapPlayerCacheData* cdata;
guchar *th_data;
cdata = NULL;
th_data = NULL;
if (gpp->mtrace_mode == GAP_PLAYER_MTRACE_OFF)
{
cdata = gap_player_cache_lookup(ckey);
}
if(cdata != NULL)
{
th_data = gap_player_cache_decompress(cdata);
*th_bpp_ptr = cdata->th_bpp;
*th_width_ptr = cdata->th_width;
*th_height_ptr = cdata->th_height;
*flip_status_ptr = cdata->flip_status;
}
return (th_data);
} /* end p_fetch_frame_via_cache */
/* ------------------------------
* p_fetch_videoframe_via_cache
* ------------------------------
* fetch frame from the players cache
* or alternatively from the videofile.
*
* No cache lookup is done if the player
* runs in MTRACE mode, because the cache
* holds a scaled copy, but MTRACE shall
* deliver the original image quality and size.
*/
static guchar *
p_fetch_videoframe_via_cache(GapPlayerMainGlobalParams *gpp
, char *gva_videofile
, gint32 framenumber
, gint32 rangesize
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
, gint32 *th_bpp_ptr
, gint32 *th_width_ptr
, gint32 *th_height_ptr
, gint32 *flip_status_ptr
, const gchar *ckey
)
{
guchar *th_data;
th_data = p_fetch_frame_via_cache(gpp
, ckey
, th_bpp_ptr
, th_width_ptr
, th_height_ptr
, flip_status_ptr
);
if(th_data == NULL)
{
th_data = p_fetch_videoframe(gpp
, gva_videofile
, framenumber
, rangesize
, seltrack
, delace
, preferred_decoder
, th_bpp_ptr
, th_width_ptr
, th_height_ptr
);
}
return (th_data);
} /* end p_fetch_videoframe_via_cache */
/* ------------------------------
* p_frame_chache_processing
* ------------------------------
*/
static void
p_frame_chache_processing(GapPlayerMainGlobalParams *gpp
, const gchar *ckey)
{
GapPlayerCacheData *cdata;
guchar *th_data;
gint32 th_size;
gint32 th_width;
gint32 th_height;
gint32 th_bpp;
gboolean th_has_alpha;
if (gpp->max_player_cache <= 0)
{
/* chaching is turned OFF */
return;
}
if(gap_player_cache_lookup(ckey) != NULL)
{
/* frame with ckey is already cached */
return;
}
th_data = gap_pview_get_repaint_thdata(gpp->pv_ptr
, &th_size
, &th_width
, &th_height
, &th_bpp
, &th_has_alpha
);
if (th_data != NULL)
{
cdata = gap_player_cache_new_data(th_data
, th_size
, th_width
, th_height
, th_bpp
, gpp->cache_compression
, gpp->pv_ptr->flip_status
);
if(cdata != NULL)
{
/* insert frame into cache
*/
gap_player_cache_insert(ckey, cdata);
p_update_cache_status(gpp);
}
}
} /* end p_frame_chache_processing */
/* --------------------------------
* p_close_composite_storyboard
* --------------------------------
*/
static void
p_close_composite_storyboard(GapPlayerMainGlobalParams *gpp)
{
if(gpp->stb_ptr == NULL)
{
return;
}
gpp->stb_parttype = -1;
gpp->stb_unique_id = -1;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
if(gpp->stb_comp_vidhand)
{
gap_story_render_close_vid_handle(gpp->stb_comp_vidhand);;
gpp->stb_comp_vidhand = NULL;
}
#endif
} /* end p_close_composite_storyboard */
/* --------------------------------
* p_open_composite_storyboard
* --------------------------------
*/
static void
p_open_composite_storyboard(GapPlayerMainGlobalParams *gpp)
{
gint32 l_total_framecount;
if(gpp->stb_ptr == NULL)
{
return;
}
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
p_close_composite_storyboard(gpp);
gpp->stb_comp_vidhand = gap_story_render_open_vid_handle_from_stb (gpp->stb_ptr
,&l_total_framecount
);
if(gap_debug)
{
printf("p_open_composite_storyboard: %s comp_vidhand:%d type:%d(%d) id:%d(%d)\n"
,gpp->stb_ptr->storyboardfile
,(int)gpp->stb_comp_vidhand
,(int)gpp->stb_ptr->stb_parttype
,(int)gpp->stb_parttype
,(int)gpp->stb_ptr->stb_unique_id
,(int)gpp->stb_unique_id
);
gap_story_render_debug_print_framerange_list(gpp->stb_comp_vidhand->frn_list, -1);
}
if(gpp->stb_comp_vidhand)
{
/* store identifiers of the opened storyboard */
gpp->stb_parttype = gpp->stb_ptr->stb_parttype;
gpp->stb_unique_id = gpp->stb_ptr->stb_unique_id;
}
#endif
} /* end p_open_composite_storyboard */
/* -----------------------------
* p_fetch_composite_image
* -----------------------------
*/
static gint32
p_fetch_composite_image(GapPlayerMainGlobalParams *gpp
, gint32 framenumber
, gint32 width
, gint32 height
)
{
gint32 composite_image_id;
composite_image_id = -1;
if(gpp->stb_ptr == NULL)
{
return (composite_image_id);
}
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
/* (re)open if nothing already open or ident data has changed */
if ((gpp->stb_comp_vidhand == NULL)
|| (gpp->stb_parttype != gpp->stb_ptr->stb_parttype)
|| (gpp->stb_unique_id != gpp->stb_ptr->stb_unique_id))
{
p_open_composite_storyboard(gpp);
}
if(gpp->stb_comp_vidhand)
{
gint32 l_layer_id;
l_layer_id = -1;
/* The storyboard render processor is used to fetch
* the frame as rendered gimp image of desired size.
*
* NOTE:flip_request transformations are already rendered by
* the storyboard render processor
* therefore no changes to propagate to the players
* pview widget
*/
composite_image_id = gap_story_render_fetch_composite_image(
gpp->stb_comp_vidhand
, framenumber
, width
, height
, NULL /* filtermacro_file */
, &l_layer_id
);
if(gap_debug)
{
printf("p_fetch_composite_image: comp_vidhand:%d composite_image_id:%d\n"
,(int)gpp->stb_comp_vidhand
,(int)composite_image_id
);
}
}
#endif
return (composite_image_id);
} /* end p_fetch_composite_image */
/* ---------------------------------------
* p_fetch_display_th_data_from_storyboard
* ---------------------------------------
* fetch the requested framnr as th_data
* by interpreting the relevant storyboard clip element.
*
* return th_data if the clip is from type MOVIE
* return NULL in case of other clip types (of error)
* for other clip types (IMAGE or FRAME range)
* the filename of the relevant image is set into the
* output parameter filename_pptr.
* OUT: ckey_pptr the string for caching the frame fetched from clip type MOVIE
* (no changes for other clip types)
* OUT: filename_pptr filename for fetching frame in case clip type is no MOVIE
* is reset to NULL for clip type MOVIE
*/
guchar *
p_fetch_display_th_data_from_storyboard(GapPlayerMainGlobalParams *gpp
, gint32 framenr
, gchar **ckey_pptr
, gchar **filename_pptr
, gint32 *th_width_ptr
, gint32 *th_height_ptr
, gint32 *th_bpp_ptr
, gint32 *flip_request_ptr
, gint32 *flip_status_ptr
)
{
GapStoryLocateRet *stb_ret;
guchar *l_th_data;
l_th_data = NULL;
stb_ret = gap_story_locate_framenr(gpp->stb_ptr
, framenr
, gpp->stb_in_track
);
if(stb_ret)
{
if((stb_ret->locate_ok)
&& (stb_ret->stb_elem))
{
*filename_pptr = gap_story_get_filename_from_elem_nr(stb_ret->stb_elem
, stb_ret->ret_framenr
);
*flip_request_ptr = stb_ret->stb_elem->flip_request;
if(stb_ret->stb_elem->record_type == GAP_STBREC_VID_MOVIE)
{
if(*filename_pptr)
{
if(gpp->use_thumbnails)
{
/* fetch does already scale down to current preview size */
*th_width_ptr = gpp->pv_ptr->pv_width;
*th_height_ptr = gpp->pv_ptr->pv_height;
}
else
{
/* negative width/height does force fetch at original video size */
*th_width_ptr = -1;
*th_height_ptr = -1;
}
if (gpp->max_player_cache > 0)
{
*ckey_pptr = gap_player_cache_new_movie_key(*filename_pptr
, stb_ret->ret_framenr
, stb_ret->stb_elem->seltrack
, stb_ret->stb_elem->delace
);
}
l_th_data = p_fetch_videoframe_via_cache(gpp
, *filename_pptr
, stb_ret->ret_framenr
, 1 + (abs(stb_ret->stb_elem->to_frame) - abs(stb_ret->stb_elem->from_frame))
, stb_ret->stb_elem->seltrack
, stb_ret->stb_elem->delace
, stb_ret->stb_elem->preferred_decoder
, th_bpp_ptr /* IN/OUT */
, th_width_ptr /* IN/OUT */
, th_height_ptr /* IN/OUT */
, flip_status_ptr /* IN/OUT */
, *ckey_pptr /* IN */
);
if(gpp->cancel_video_api)
{
if(l_th_data)
{
g_free(l_th_data); /* throw away undefined data in case of cancel */
l_th_data = NULL;
}
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar)
, _("Canceled"));
}
}
g_free(*filename_pptr);
*filename_pptr = NULL;
}
}
}
g_free(stb_ret);
}
return (l_th_data);
} /* end p_fetch_display_th_data_from_storyboard */
/* -----------------------------------------------
* p_fetch_display_composite_image_from_storyboard
* -----------------------------------------------
* fetch the requested framnr as th_data (if already cached)
* or as gimp image id (if fetched as composite video frame
* via storyboard render processor)
*
* return th_data if the frame was in the cache. (NULL if not)
* OUT: ckey_pptr the string for caching the frame
* OUT: composite_image_id_ptr image id if fetched via processing.
* (-1 is output if no image was fetched)
*/
guchar *
p_fetch_display_composite_image_from_storyboard(GapPlayerMainGlobalParams *gpp
, gint32 framenr
, gchar **ckey_pptr
, gint32 *composite_image_id_ptr
, gint32 *th_width_ptr
, gint32 *th_height_ptr
, gint32 *th_bpp_ptr
, gint32 *flip_request_ptr
, gint32 *flip_status_ptr
)
{
gint32 l_width;
gint32 l_height;
guchar *l_th_data;
l_th_data = NULL;
*composite_image_id_ptr = -1;
if(gpp->stb_ptr == NULL)
{
return (NULL);
}
l_width = gpp->stb_ptr->master_width;
l_height = gpp->stb_ptr->master_height;
if(gpp->use_thumbnails)
{
/* fetch does already scale down to current preview size */
l_width = gpp->pv_ptr->pv_width;
l_height = gpp->pv_ptr->pv_height;
}
if(gpp->stb_comp_vidhand == NULL)
{
p_open_composite_storyboard(gpp);
}
if(gpp->stb_comp_vidhand)
{
*ckey_pptr = gap_player_cache_new_composite_video_key(
gpp->stb_ptr->storyboardfile
, framenr
, gpp->stb_ptr->stb_parttype
, gpp->stb_ptr->stb_unique_id
);
l_th_data = p_fetch_frame_via_cache(gpp
, *ckey_pptr
, th_bpp_ptr
, th_width_ptr
, th_height_ptr
, flip_status_ptr
);
if(gap_debug)
{
printf("COMPOSITE thdata:%d ckey: %s\n"
,(int)l_th_data
,*ckey_pptr
);
}
if(l_th_data == NULL)
{
/* The storyboard render processor is used to fetch
* the frame as rendered gimp image of desired size.
* in this case th_data is returned as NULL.
*
* NOTE:flip_request transformations are already rendered by
* the storyboard render processor
* therefore no changes to propagate to the players
* pview widget
*/
*composite_image_id_ptr = p_fetch_composite_image(gpp
, framenr
, l_width
, l_height
);
*flip_status_ptr = *flip_request_ptr;
}
}
return (l_th_data);
} /* end p_fetch_display_composite_image_from_storyboard */
/* ------------------------------
* p_render_display_free_pixbuf
* ------------------------------
* render form pixbuf
* free the pixbuf after rendering (unref)
*/
static void
p_render_display_free_pixbuf(GapPlayerMainGlobalParams *gpp
, GdkPixbuf *pixbuf
, gint32 flip_request
, gint32 flip_status
)
{
/* copy pixbuf as layer into the mtrace_image (only of mtrace_mode not OFF) */
p_mtrace_pixbuf(gpp, pixbuf);
gap_pview_render_f_from_pixbuf (gpp->pv_ptr
, pixbuf
, flip_request
, flip_status
);
g_object_unref(pixbuf);
} /* end p_render_display_free_pixbuf */
/* ------------------------------
* p_render_display_free_thdata
* ------------------------------
* render form th_data buffer
* free the th_data buffer after rendering
* (but only if data was not grabbed for refresh)
*/
static void
p_render_display_free_thdata(GapPlayerMainGlobalParams *gpp
, guchar *th_data
, gint32 th_width
, gint32 th_height
, gint32 th_bpp
, gint32 flip_request
, gint32 flip_status
)
{
gboolean th_data_was_grabbed;
p_mtrace_tmpbuf(gpp
, th_data
, th_width
, th_height
, th_bpp
);
th_data_was_grabbed = gap_pview_render_f_from_buf (gpp->pv_ptr
, th_data
, th_width
, th_height
, th_bpp
, TRUE /* allow_grab_src_data */
, flip_request
, flip_status
);
if(th_data_was_grabbed)
{
/* the gap_pview_render_f_from_buf procedure can grab the th_data
* instead of making a ptivate copy for later use on repaint demands.
* if such a grab happened it returns TRUE.
* (this is done for optimal performance reasons)
* in such a case the caller must NOT free the src_data (th_data) !!!
*/
th_data = NULL;
}
if(th_data) g_free(th_data);
} /* end p_render_display_free_thdata */
/* ------------------------------
* p_render_display_free_image_id
* ------------------------------
* render from the specified image_id
* and delete this image after rendering
*/
static void
p_render_display_free_image_id(GapPlayerMainGlobalParams *gpp
, gint32 image_id
, gint32 flip_request
, gint32 flip_status
)
{
/* there is no need for undo on this scratch image
* so we turn undo off for performance reasons
*/
gimp_image_undo_disable (image_id);
/* copy image as layer into the mtrace_image (only if mtrace_mode not OFF) */
p_mtrace_image(gpp, image_id);
gap_pview_render_f_from_image (gpp->pv_ptr
, image_id
, flip_request
, flip_status
);
gimp_image_delete(image_id);
} /* end p_render_display_free_image_id */
/* ------------------------------------------
* p_render_display_from_active_image_or_file
* ------------------------------------------
*/
static void
p_render_display_from_active_image_or_file(GapPlayerMainGlobalParams *gpp
, char *img_filename
, gboolean framenr_is_the_active_image
, gint32 flip_request
, gint32 flip_status
)
{
gint32 l_image_id;
/* got no thumbnail data, must use the full image */
if(framenr_is_the_active_image)
{
/* check if automatic onionskin layer removal is turned on
* (in this case the player must display the image without
* onionskin layers)
*/
if(gpp->onion_delete)
{
l_image_id = gap_onion_base_image_duplicate(gpp->image_id);
gap_onion_base_onionskin_delete(l_image_id);
}
else
{
l_image_id = gimp_image_duplicate(gpp->image_id);
}
}
else
{
l_image_id = gap_lib_load_image(img_filename);
if (l_image_id < 0)
{
/* could not read the image
* one reason could be, that frames were deleted while this plugin is active
* so we stop playback,
* and try to reload informations about all frames
*/
if(gap_debug) printf("LOAD IMAGE_ID: %s failed\n", img_filename);
if(gpp->image_id < 0)
{
/* give up, because we could not get any imagedata
* (this case may happen if images are deleted while playback
* or if videofiles with unknown extensions were passed
* to the player and were tried to load as gimp image
* because they are not recognized as video)
*/
return;
}
p_keep_track_of_active_master_image(gpp);
}
}
if(gpp->use_thumbnails)
{
gap_thumb_cond_gimp_file_save_thumbnail(l_image_id, img_filename);
}
p_render_display_free_image_id(gpp
, l_image_id
, flip_request
, flip_status
);
} /* end p_render_display_from_active_image_or_file */
/* ------------------------------
* p_display_frame
* ------------------------------
* display framnr from thumbnail or from full image
* the active image (the one from where we were invoked)
* is not read from discfile to reflect actual changes.
*
* Alternative sources for fetching the frame are
* A) storyboard files (gpp->stb_ptr != NULL)
* in this case the fetch for a single track is done by
* interpreting the relevant videoclip,
*
* or via calling the fetcher from the storyboard render processor
* to get the composite image (if stb_in_track -1)
*
* B) fetching from a single movie file
* when invoked from the video extract plug-in.
* (gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
*
* Note:
* there is no active image if the player was invoked
* for storyboard playback (gpp->stb_ptr != NULL)
* or for filename based playback (gpp->imagename != NULL)
* in those cases we always have to fetch from file (thumb or full image)
*/
static void
p_display_frame(GapPlayerMainGlobalParams *gpp, gint32 framenr)
{
char *l_filename;
gint32 l_th_width;
gint32 l_th_height;
gint32 l_th_data_count;
gint32 l_th_bpp;
gint32 l_flip_request;
gint32 l_flip_status;
gint32 l_composite_image_id;
guchar *l_th_data;
gboolean framenr_is_the_active_image;
GdkPixbuf *pixbuf;
gchar *ckey;
/*if(gap_debug) printf("p_display_frame START: framenr:%d\n", (int)framenr);*/
if(gpp->gva_lock)
{
/* do not attempt displaying frames while we are inside
* of p_alloc_ainfo_for_videofile procedure
*/
return;
}
ckey = NULL;
l_th_data = NULL;
pixbuf = NULL;
l_th_bpp = 3;
l_filename = NULL;
framenr_is_the_active_image = FALSE;
l_composite_image_id = -1;
if(gpp->dvref_ptr != NULL)
{
gpp->dvref_ptr->videofile = NULL;
}
if(gpp->stb_ptr)
{
l_flip_request = GAP_STB_FLIP_NONE;
l_flip_status = GAP_STB_FLIP_NONE;
if(gpp->stb_in_track >= 0)
{
l_th_data = p_fetch_display_th_data_from_storyboard(gpp
, framenr
, &ckey
, &l_filename
, &l_th_width
, &l_th_height
, &l_th_bpp
, &l_flip_request
, &l_flip_status
);
if(gpp->cancel_video_api)
{
return;
}
}
else
{
gint32 mapped_framenr =
gap_story_get_mapped_master_frame_number(gpp->stb_ptr->mapping, framenr);
if(gap_debug)
{
printf(" >> PLAY composite framenr:%d mapped_framenr:%d\n"
,(int)framenr
,(int)mapped_framenr
);
}
l_th_data = p_fetch_display_composite_image_from_storyboard(gpp
, mapped_framenr
, &ckey
, &l_composite_image_id
, &l_th_width
, &l_th_height
, &l_th_bpp
, &l_flip_request
, &l_flip_status
);
}
}
else
{
l_flip_request = gpp->flip_request;
l_flip_status = gpp->flip_status;
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
/* playback of a single videoclip */
if(gpp->use_thumbnails)
{
/* fetch does alread scale down to current preview size */
l_th_width = gpp->pv_ptr->pv_width;
l_th_height = gpp->pv_ptr->pv_height;
}
else
{
/* negative width/height does force fetch at original video size */
l_th_width = -1;
l_th_height = -1;
}
if (gpp->max_player_cache > 0)
{
ckey = gap_player_cache_new_movie_key(gpp->ainfo_ptr->old_filename
, framenr
, gpp->ainfo_ptr->seltrack
, gpp->ainfo_ptr->delace
);
}
l_th_data = p_fetch_videoframe_via_cache(gpp
, gpp->ainfo_ptr->old_filename
, framenr
, 1 + (abs(gpp->ainfo_ptr->last_frame_nr) - abs(gpp->ainfo_ptr->first_frame_nr))
, gpp->ainfo_ptr->seltrack
, gpp->ainfo_ptr->delace
, gpp->preferred_decoder
, &l_th_bpp /* IN/OUT */
, &l_th_width /* IN/OUT */
, &l_th_height /* IN/OUT */
, &l_flip_status /* OUT */
, ckey /* IN */
);
if(gpp->cancel_video_api)
{
if(l_th_data)
{
g_free(l_th_data); /* throw away undefined data in case of cancel */
l_th_data = NULL;
}
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar)
, _("Canceled"));
}
return;
}
}
else
{
if(gpp->ainfo_ptr->frame_cnt > 0)
{
l_filename = gap_lib_alloc_fname(gpp->ainfo_ptr->basename, framenr, gpp->ainfo_ptr->extension);
}
else
{
/* if player operates on a single image we have to build
* the filename just of basename or basename+extension part
* (this rare case can occure when the player is invoked
* from a storyboard to playback a clip that is made up of a single image)
*/
if(gpp->ainfo_ptr->extension)
{
l_filename = g_strdup_printf("%s%s"
,gpp->ainfo_ptr->basename
,gpp->ainfo_ptr->extension
);
}
else
{
l_filename = g_strdup(gpp->ainfo_ptr->basename);
}
}
if(gpp->imagename == NULL)
{
framenr_is_the_active_image = p_check_for_active_image(gpp, framenr);
}
}
}
/* --------------------- */
if((l_filename == NULL)
&& (l_th_data == NULL)
&& (l_composite_image_id < 0))
{
/* frame not available, create black fully transparent buffer
* ( renders as empty checkerboard)
*/
l_th_bpp = 4;
l_th_width = gpp->pv_width;
l_th_height = gpp->pv_height;
l_th_data_count = l_th_width * l_th_height * l_th_bpp;
l_th_data = g_malloc0(l_th_data_count);
}
else
{
if(gpp->use_thumbnails)
{
if(framenr_is_the_active_image)
{
gint32 l_tmp_image_id;
l_tmp_image_id = -1;
/* check if automatic onionskin layer removal is turned on */
if(gpp->onion_delete)
{
/* check if image has visible onionskin layers */
if(gap_onion_image_has_oinonlayers(gpp->image_id, TRUE /* only visible*/))
{
l_tmp_image_id = gap_onion_base_image_duplicate(gpp->image_id);
}
}
if(l_tmp_image_id == -1)
{
gap_pdb_gimp_image_thumbnail(gpp->image_id
, gpp->pv_width
, gpp->pv_height
, &l_th_width
, &l_th_height
, &l_th_bpp
, &l_th_data_count
, &l_th_data
);
}
else
{
gap_onion_base_onionskin_delete(l_tmp_image_id);
gap_pdb_gimp_image_thumbnail(l_tmp_image_id
, gpp->pv_width
, gpp->pv_height
, &l_th_width
, &l_th_height
, &l_th_bpp
, &l_th_data_count
, &l_th_data
);
gimp_image_delete(l_tmp_image_id);
}
}
else
{
/* init preferred width and height
* (as hint for the thumbnail loader to decide
* if thumbnail is to fetch from normal or large thumbnail directory
* just for the case when both sizes are available)
*/
l_th_width = gpp->pv_width;
l_th_height = gpp->pv_height;
pixbuf = gap_thumb_file_load_pixbuf_thumbnail(l_filename
, &l_th_width, &l_th_height
, &l_th_bpp
);
}
}
}
if(l_composite_image_id >= 0)
{
p_render_display_free_image_id(gpp
, l_composite_image_id
, l_flip_request
, l_flip_status
);
}
else
{
if(pixbuf)
{
p_render_display_free_pixbuf(gpp, pixbuf, l_flip_request, l_flip_status);
}
else
{
if((l_th_data == NULL)
&& (!framenr_is_the_active_image)
&& (gpp->max_player_cache > 0))
{
ckey = gap_player_cache_new_image_key(l_filename);
l_th_data = p_fetch_frame_via_cache(gpp
, ckey
, &l_th_bpp
, &l_th_width
, &l_th_height
, &l_flip_status
);
}
if (l_th_data)
{
p_render_display_free_thdata(gpp
, l_th_data
, l_th_width
, l_th_height
, l_th_bpp
, l_flip_request
, l_flip_status
);
l_th_data = NULL;
}
else
{
/* got no thumbnail data, must use the full image */
p_render_display_from_active_image_or_file(gpp
, l_filename
, framenr_is_the_active_image
, l_flip_request
, l_flip_status
);
}
}
}
if (ckey != NULL)
{
p_frame_chache_processing(gpp, ckey);
g_free(ckey);
}
gpp->play_current_framenr = framenr;
p_update_position_widgets(gpp);
gdk_flush();
if(l_th_data) g_free(l_th_data);
if(l_filename) g_free(l_filename);
} /* end p_display_frame */
/* ------------------------------
* p_get_next_framenr_in_sequence /2
* ------------------------------
*/
gint32
p_get_next_framenr_in_sequence2(GapPlayerMainGlobalParams *gpp)
{
gint32 l_first;
gint32 l_last;
l_first = gpp->ainfo_ptr->first_frame_nr;
l_last = gpp->ainfo_ptr->last_frame_nr;
if(gpp->play_selection_only)
{
l_first = gpp->begin_frame;
l_last = gpp->end_frame;
}
if(gpp->play_backward)
{
if(gpp->play_current_framenr <= l_first)
{
p_audio_resync(gpp);
if(gpp->play_loop)
{
if(gpp->play_pingpong)
{
gpp->play_current_framenr = l_first + 1;
gpp->play_backward = FALSE;
gpp->pingpong_count++;
}
else
{
gpp->play_current_framenr = l_last;
}
}
else
{
if((gpp->play_pingpong) && (gpp->pingpong_count <= 0))
{
gpp->play_current_framenr = l_first + 1;
gpp->play_backward = FALSE;
gpp->pingpong_count++;
}
else
{
gpp->pingpong_count = 0;
return -1; /* STOP if first frame reached */
}
}
}
else
{
gpp->play_current_framenr--;
}
}
else
{
if(gpp->play_current_framenr >= l_last)
{
p_audio_resync(gpp);
if(gpp->play_loop)
{
if(gpp->play_pingpong)
{
gpp->play_current_framenr = l_last - 1;
gpp->play_backward = TRUE;
gpp->pingpong_count++;
}
else
{
gpp->play_current_framenr = l_first;
}
}
else
{
if((gpp->play_pingpong) && (gpp->pingpong_count <= 0))
{
gpp->play_current_framenr = l_last - 1;
gpp->play_backward = TRUE;
gpp->pingpong_count++;
}
else
{
gpp->pingpong_count = 0;
return -1; /* STOP if last frame reached */
}
}
}
else
{
gpp->play_current_framenr++;
}
}
gpp->play_current_framenr = CLAMP(gpp->play_current_framenr, l_first, l_last);
return (gpp->play_current_framenr);
} /* end p_get_next_framenr_in_sequence2 */
gint32
p_get_next_framenr_in_sequence(GapPlayerMainGlobalParams *gpp)
{
gint32 framenr;
framenr = p_get_next_framenr_in_sequence2(gpp);
if((framenr < 0)
|| (gpp->play_backward)
|| (gpp->audio_resync > 0))
{
/* stop audio at end (-1) or when video plays revers or resync needed */
p_audio_stop(gpp);
/* RESYNC: break for N frames, then restart audio at sync position
* (NOTE: ideally we should restart immediate without any break
* but restarting the playback often and very quickly leads to
* deadlock (in the audioserver or clent/server communication)
*/
if(gpp->audio_resync > 0)
{
gpp->audio_resync--;
}
}
else
{
/* conditional audio start
* (can happen on any frame if audio offsets are used)
*/
#ifdef TRY_AUTO_SYNC_AT_FAST_PLAYBACKSPEED
/* this codespart tries to keep audio playing sync at fast speed
* but sounds not good, and does not work reliable
* therefore it should not be compiled in public release version.
* (asynchron audio that will not be able to follow up the videospeed
* will be the result in that case)
*/
if (gpp->audio_required_samplerate > GAP_PLAYER_MAIN_MAX_SAMPLERATE)
{
gint32 nframes;
/* required samplerate is faster than highest possible audioplayback speed
* stop and restart at new offset at every n.th frame to follow the faster video
* (this will result in glitches)
*/
nframes = 8 * (1 + (gpp->speed / 5));
if((framenr % nframes) == 0)
{
printf("WARNING: Audiospeed cant follow up video speed nframes:%d\n", (int)nframes);
p_audio_resync(gpp); /* audioserver does not like tto much stop&go and hangs sometimes */
}
}
#endif
p_audio_start_play(gpp);
}
return(framenr);
} /*end p_get_next_framenr_in_sequence */
/* -----------------------------
* p_step_frame
* -----------------------------
*/
static void
p_step_frame(GapPlayerMainGlobalParams *gpp, gint stepsize)
{
gint32 framenr;
framenr = gpp->play_current_framenr + stepsize;
if(gpp->ainfo_ptr)
{
framenr = CLAMP(framenr
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
);
if(gpp->play_current_framenr != framenr)
{
/* we want the go_timer to display that framenr */
gpp->go_job_framenr = framenr;
if(gpp->go_timertag < 0)
{
/* if the go_timer is not already prepared to fire
* we start p_display_frame(gpp, gpp->go_job_framenr);
* after minimal delay of 8 millisecods.
*/
gpp->go_timertag = (gint32) g_timeout_add(8, (GtkFunction)on_timer_go_job, gpp);
}
}
}
} /* end p_step_frame */
/* ------------------------------
* p_framenr_from_go_number
* ------------------------------
*/
gint32
p_framenr_from_go_number(GapPlayerMainGlobalParams *gpp, gint32 go_number)
{
/*
if(gap_debug) printf("p_framenr_from_go_number go_base_framenr: %d go_base:%d go_number:%d curr_frame:%d\n"
, (int)gpp->go_base_framenr
, (int)gpp->go_base
, (int)go_number
, (int)gpp->play_current_framenr );
*/
if((gpp->go_base_framenr < 0) || (gpp->go_base < 0))
{
gpp->go_base_framenr = gpp->play_current_framenr;
gpp->go_base = go_number;
}
/* printf("p_framenr_from_go_number: result framenr:%d\n", (int)(gpp->go_base_framenr + (go_number - gpp->go_base)) ); */
return CLAMP(gpp->go_base_framenr + (go_number - gpp->go_base)
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
);
} /* end p_framenr_from_go_number */
/* ------------------
* on_timer_playback
* ------------------
* This timer callback is called periodical in intervall depending of playback speed.
* (the playback timer is completely removed while not playing)
*/
static void
on_timer_playback(GapPlayerMainGlobalParams *gpp)
{
gulong elapsed_microsecs;
gdouble elapsed_secs;
static char status_txt[30];
/*if(gap_debug) printf("\non_timer_playback: START\n");*/
if(gpp)
{
p_remove_play_timer(gpp);
if(gpp->in_timer_playback)
{
/* if speed is too fast the timer may fire again, while still processing
* the previous callback. in that case return without any action
* NOTE: at test with gtk2.2.1 this line of CODE was never reached,
* even if the frame is too late.
* the check if in_timer_playback is done just to be at the safe side.
* (late frames are detected by checking the elapsed time).
*/
if(gap_debug) printf("\n\n\n on_timer_playback interrupted by next TIMERCALL \n\n");
return;
}
gpp->in_timer_playback = TRUE;
if(gpp->play_is_active)
{
gint ii;
gint ii_max;
gint32 l_prev_framenr;
gint32 l_framenr = -1;
gboolean l_frame_dropped;
gdouble l_delay;
l_framenr = -1;
l_frame_dropped = FALSE;
l_delay = gpp->delay_secs;
ii_max = (gpp->exact_timing) ? 20 : 2;
/* - if we have exact timing handle (or drop) upto max 20 frames in one timercallback
* - if your machine is fast enough to display the frame at gpp->speed
* this loop will display only one frame. (the ideal case)
* - if NOT fast enough, but the frame is just a little late,
* it tries to display upto (3) frames without restarting the timer.
* (and without giving control back to the gtk main loop)
* - if we are still late at this point
* we begin to drop upto (20) frames to get back in exact time.
* - if this does not help either, we give up
* (results in NON exact timing, regardless to the exact_timing flag).
*/
for(ii=1; ii < ii_max; ii++)
{
l_prev_framenr = l_framenr;
l_framenr = p_get_next_framenr_in_sequence(gpp);
gpp->framecnt += 1.0; /* count each handled frame (for timing purpose) */
/*if(gap_debug) printf("on_timer_playback[%d]: l_framenr:%d\n", (int)ii, (int)l_framenr);*/
if(l_framenr < 0)
{
if((l_frame_dropped) && (l_prev_framenr > 0))
{
/* the last frame in sequence (l_prev_framenr) would be DROPPED
* to keep exact timing, but now it is time to STOP
* in this case we display that frame,
* with minimal delay of 8 millisecs via the one-shot go_timer.
*/
gpp->go_job_framenr = l_prev_framenr;
if(gpp->go_timertag >= 0)
{
g_source_remove(gpp->go_timertag);
}
gpp->go_timertag = (gint32) g_timeout_add(8, (GtkFunction)on_timer_go_job, gpp);
}
p_stop_playback(gpp); /* STOP at end of sequence */
break;
}
else
{
if((ii > 3)
|| ((0 - gpp->rest_secs) > (gpp->cycle_time_secs * 2)) )
{
/* if delay is too much
* (we are 2 cycletimes back, or already had handled 3 LATE frames in sequence)
* start dropping frames now
* until we are in time again
*/
l_frame_dropped = TRUE;
/* printf("DROP (SKIP) frame\n"); */
gtk_label_set_text ( GTK_LABEL(gpp->status_label), _("Skip"));
}
else
{
p_display_frame(gpp, l_framenr);
}
/* get secs elapsed since playbackstart (or last speed change) */
elapsed_secs = g_timer_elapsed(gpp->gtimer, &elapsed_microsecs);
gpp->rest_secs = (gpp->cycle_time_secs * gpp->framecnt) - elapsed_secs;
/*if(gap_debug) printf("on_timer_playback[%d]: rest:%.4f\n", (int)ii, (float)gpp->rest_secs); */
if(gpp->rest_secs > 0)
{
if((!l_frame_dropped) && (ii == 1))
{
gtk_label_set_text ( GTK_LABEL(gpp->status_label), _("Playing"));
}
/* we are fast enough, there is rest time to wait until next frame */
l_delay = gpp->delay_secs; /* we have no additional delay */
break;
}
l_delay = gpp->delay_secs - gpp->rest_secs;
/* no time left at this point, try to display (or drop) next frame immediate */
if(!l_frame_dropped)
{
g_snprintf(status_txt, sizeof(status_txt), _("Delay %.2f"), (float)(l_delay));
gtk_label_set_text ( GTK_LABEL(gpp->status_label), status_txt);
}
}
} /* end for */
/* keep track of absolute delay (since start or speed change) just for display purposes */
gpp->delay_secs = l_delay;
/* restart timer for next cycle */
if(gpp->play_is_active)
{
p_start_playback_timer(gpp);
}
}
gpp->in_timer_playback = FALSE;
}
} /* end on_timer_playback */
/* ------------------
* on_timer_go_job
* ------------------
* This timer callback is called once after a go_button enter/clicked
* callback with a miniamal delay of 8 millisecs.
*
* here is an example how it works:
*
* consider the user moves the mouse from left to right
* passing go_buttons 1 upto 7
*
* (1) (2) (3) (4) (5) (6) (7)
* +-------+-------+-------+------+------+------+-------> time axis
* ..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* < -- RENDER time for (1) ------------>
*
* - at (1) the on_timer_go_job Timer is initialized
* - The timer will fire after 8 millsecs, and starts rendering.
* while renderng 2,3,4,5,6 do happen, and get queued as pending events.
* - after render has finished
* the events are processed in sequence
* the first of the queued evnts (2) will init the go_timer again,
* and each of the oter events just sets the go_framenr (upto 6).
* - after another 8 millisecs delay the timer callback will start again
* and now processes the most recent go_framenr (6)
*
* that way it is possible to skip frames for fast mousemoves on slow machines
* (without that trick, the GUI would block until all visited go_bottons
* are processed)
*/
static void
on_timer_go_job(GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf("\non_timer_go_job: START\n");*/
if(gpp)
{
if(gpp->go_timertag >= 0)
{
g_source_remove(gpp->go_timertag);
}
gpp->go_timertag = -1;
if(gpp->go_job_framenr >= 0)
{
if(gpp->gva_lock)
{
/* the video api is still busy with fetching the previous frame
* (do not disturb, but setup the go_timer for a next try
* after 96 milliseconds)
*/
gpp->go_timertag = (gint32) g_timeout_add(96, (GtkFunction)on_timer_go_job, gpp);
/*if(gap_debug) printf("on_timer_go_job: TRY LATER (96msec) %06d\n", (int)gpp->go_job_framenr);*/
}
else
{
/*if(gap_debug) printf("on_timer_go_job: DISPLAY RENDER %06d\n", (int)gpp->go_job_framenr); */
p_display_frame(gpp, gpp->go_job_framenr);
}
}
}
} /* end on_timer_go_job */
/* -----------------------------
* on_play_button_clicked
* -----------------------------
*/
static void
on_play_button_clicked(GtkButton *button
, GdkEventButton *bevent
, GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->play_backward = FALSE;
gpp->request_cancel_video_api = TRUE;
if(bevent)
{
if(bevent->state & GDK_SHIFT_MASK)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_IMG_SIZE;
}
if (bevent->state & GDK_CONTROL_MASK)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_PV_SIZE;
}
if(bevent->state & GDK_MOD1_MASK)
{
gpp->mtrace_image_id = -1; /* force creation of new image */
}
}
if(gpp->play_is_active)
{
if (gpp->audio_required_samplerate > GAP_PLAYER_MAIN_MAX_SAMPLERATE)
{
p_audio_resync(gpp);
}
return;
}
if(gpp->play_selection_only)
{
if (gpp->play_current_framenr >= gpp->end_frame)
{
/* we are at selection end, start from selection begin */
gpp->play_current_framenr = gpp->begin_frame;
}
}
else
{
if (gpp->play_current_framenr >= gpp->ainfo_ptr->last_frame_nr)
{
/* we are at end, start from begin */
gpp->play_current_framenr = gpp->ainfo_ptr->first_frame_nr;
}
}
p_initial_start_playback_timer(gpp);
} /* end on_play_button_clicked */
/* -----------------------------
* on_pause_button_press_event
* -----------------------------
*/
static gboolean
on_pause_button_press_event (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp)
{
gboolean play_was_active;
if(gpp == NULL)
{
return FALSE;
}
if(gpp->progress_bar)
{
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar)
,gpp->progress_bar_idle_txt
);
}
play_was_active = gpp->play_is_active;
p_stop_playback(gpp);
if(!play_was_active)
{
if ((bevent->button > 1)
&& (bevent->type == GDK_BUTTON_PRESS)
&& (gpp->ainfo_ptr))
{
if(bevent->button > 2)
{
p_display_frame(gpp, gpp->end_frame); /* right mousebutton : goto end */
}
else
{
p_display_frame(gpp, gpp->ainfo_ptr->curr_frame_nr); /* middle mousebutton : goto active image (invoker) */
}
}
else
{
p_display_frame(gpp, gpp->begin_frame); /* left mousebutton : goto begin */
}
}
return FALSE;
} /* end on_pause_button_press_event */
/* -----------------------------
* on_back_button_clicked
* -----------------------------
*/
static void
on_back_button_clicked(GtkButton *button
, GdkEventButton *bevent
, GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->play_backward = TRUE;
gpp->request_cancel_video_api = TRUE;
if(bevent)
{
if(bevent->state & GDK_SHIFT_MASK)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_IMG_SIZE;
}
if (bevent->state & GDK_CONTROL_MASK)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_PV_SIZE;
}
if(bevent->state & GDK_MOD1_MASK)
{
gpp->mtrace_image_id = -1; /* force creation of new image */
}
}
if(gpp->play_is_active)
{
return;
}
if(gpp->play_selection_only)
{
if (gpp->play_current_framenr <= gpp->begin_frame)
{
/* we are already at selection begin, start from selection end */
gpp->play_current_framenr = gpp->end_frame;
}
}
else
{
if (gpp->play_current_framenr <= gpp->ainfo_ptr->first_frame_nr)
{
/* we are already at begin, start from end */
gpp->play_current_framenr = gpp->ainfo_ptr->last_frame_nr;
}
}
p_initial_start_playback_timer(gpp);
} /* end on_back_button_clicked */
/* -----------------------------
* on_from_spinbutton_changed
* -----------------------------
*/
static void
on_from_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->begin_frame = (gint32)GTK_ADJUSTMENT(gpp->from_spinbutton_adj)->value;
if(gpp->begin_frame > gpp->end_frame)
{
gpp->end_frame = gpp->begin_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)gpp->end_frame
);
}
else
{
if(gpp->caller_range_linked)
{
p_printout_range(gpp, FALSE, FALSE);
}
}
} /* end on_from_spinbutton_changed */
/* -----------------------------
* on_to_spinbutton_changed
* -----------------------------
*/
static void
on_to_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->end_frame = (gint32)GTK_ADJUSTMENT(gpp->to_spinbutton_adj)->value;
if(gpp->end_frame < gpp->begin_frame)
{
gpp->begin_frame = gpp->end_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)gpp->begin_frame
);
}
else
{
if(gpp->caller_range_linked)
{
p_printout_range(gpp, FALSE, FALSE);
}
}
} /* end on_to_spinbutton_changed */
/* -----------------------------
* on_vid_preview_button_press_event
* -----------------------------
*/
gboolean
on_vid_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp)
{
if(gap_debug)
{
printf("on_vid_preview_button_press_event: START\n");
}
if(gpp->mtrace_mode == GAP_PLAYER_MTRACE_OFF)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_IMG_SIZE;
if (bevent->state & GDK_CONTROL_MASK)
{
gpp->mtrace_mode = GAP_PLAYER_MTRACE_PV_SIZE;
}
if(bevent->state & GDK_MOD1_MASK)
{
gpp->mtrace_image_id = -1; /* force creation of new image */
}
p_display_frame(gpp, gpp->play_current_framenr);
gpp->mtrace_mode = GAP_PLAYER_MTRACE_OFF;
}
return FALSE;
} /* end on_vid_preview_button_press_event */
/* -----------------------------
* on_warp_frame_scroll_event
* -----------------------------
* handle scroll event (inludes wheel mose)
*/
static gboolean
on_warp_frame_scroll_event (GtkWidget *widget,
GdkEventScroll *sevent,
GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf("on_warp_frame_scroll_event: START\n"); */
p_stop_playback(gpp);
if((sevent->direction == GDK_SCROLL_UP)
|| (sevent->direction == GDK_SCROLL_RIGHT))
{
p_step_frame(gpp, -1);
}
else
{
p_step_frame(gpp, 1);
}
return FALSE;
} /* end on_warp_frame_scroll_event */
/* -----------------------------
* on_vid_preview_expose_event
* -----------------------------
*/
gboolean
on_vid_preview_expose_event (GtkWidget *widget,
GdkEventExpose *eevent,
GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf(" xxxxxxxx on_vid_preview_expose_event: START\n");*/
if(gpp == NULL)
{
return FALSE;
}
if (gpp->play_is_active && (gpp->rest_secs < 0.2))
{
/* we are playing and the next frame update is very near (less than 2/10 sec)
* in that case it is better choice to skip the repaint
* on expose events.
* (dont waste time for repaint in that case)
*/
return FALSE;
}
gap_pview_repaint(gpp->pv_ptr);
return FALSE;
} /* end on_vid_preview_expose_event */
/* -----------------------------
* on_shell_window_size_allocate
* -----------------------------
*/
static void
on_shell_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GapPlayerMainGlobalParams *gpp)
{
if((gpp == NULL) || (allocation == NULL))
{
return;
}
if(gap_debug) printf("on_shell_window_size_allocate: START shell_alloc: w:%d h:%d \n"
, (int)allocation->width
, (int)allocation->height
);
if(gpp->shell_initial_width < 0)
{
gpp->shell_initial_width = allocation->width;
gpp->shell_initial_height = allocation->height;
p_fit_initial_shell_window(gpp); /* for setting window default size */
}
else
{
if((allocation->width < gpp->shell_initial_width)
|| (allocation->height < gpp->shell_initial_height))
{
/* dont allow shrink below initial size */
p_fit_initial_shell_window(gpp);
}
}
} /* end on_shell_window_size_allocate */
/* -----------------------------
* on_vid_preview_size_allocate
* -----------------------------
* this procedure handles automatic
* resize of the preview when the user resizes the window.
* While sizechanges via the Size spinbutton this handler is usually
* disconnected, and will be reconnected when the mouse leaves the shell window.
* This handlerprocedure acts on the drawing_area widget of the preview.
* Size changes of drawing_area are propagated to
* the preview (aspect_frame and drawing_area) by calls to p_update_pviewsize.
*/
static void
on_vid_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GapPlayerMainGlobalParams *gpp)
{
gint32 allo_width;
gint32 allo_height;
#define PV_BORDER_X 10
#define PV_BORDER_Y 10
if((gpp == NULL) || (allocation == NULL))
{
return;
}
if(gap_debug) printf("on_vid_preview_size_allocate: START old: ow:%d oh:%d new: w:%d h:%d \n"
, (int)gpp->old_resize_width
, (int)gpp->old_resize_height
, (int)allocation->width
, (int)allocation->height
);
if(gpp->pv_ptr->da_widget == NULL) { return; }
if(gpp->pv_ptr->da_widget->window == NULL) { return; }
if(gap_debug) printf(" on_vid_preview_size_allocate: ORIGINAL pv_w:%d pv_h:%d handler_id:%d\n"
, (int)gpp->pv_ptr->pv_width
, (int)gpp->pv_ptr->pv_height
, (int)gpp->resize_handler_id
);
allo_width = allocation->width;
allo_height = allocation->height;
/* react on significant changes (min 6 pixels) only) */
if(((gpp->old_resize_width / 6) != (allo_width / 6))
|| ((gpp->old_resize_height / 6) != (allo_height / 6)))
{
gint32 pv_pixelsize;
gboolean blocked;
gdouble img_ratio;
gdouble alloc_ratio;
img_ratio = 1.0;
blocked = FALSE;
alloc_ratio = (gdouble)allo_width / (gdouble)allo_height;
if(gpp->ainfo_ptr == NULL)
{
blocked = FALSE;
pv_pixelsize = gpp->pv_pixelsize;
}
else
{
img_ratio = (gdouble)gpp->ainfo_ptr->width / (gdouble)gpp->ainfo_ptr->height;
if(img_ratio >= 1.0)
{
/* imageorientation is landscape */
if(alloc_ratio <= img_ratio)
{
pv_pixelsize = CLAMP( (allo_width - PV_BORDER_X)
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE);
}
else
{
pv_pixelsize = CLAMP( (((allo_height - PV_BORDER_Y) * gpp->ainfo_ptr->width) / gpp->ainfo_ptr->height)
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE);
}
}
else
{
/* imageorientation is portrait */
if(alloc_ratio <= img_ratio)
{
pv_pixelsize = CLAMP( (((allo_width - PV_BORDER_X) * gpp->ainfo_ptr->height) / gpp->ainfo_ptr->width)
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE);
}
else
{
pv_pixelsize = CLAMP( (allo_height - PV_BORDER_Y)
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE);
}
}
}
if (gap_debug) printf("pv_pixelsize: %d img_ratio:%.3f alloc_ratio:%.3f\n"
, (int)pv_pixelsize
, (float)img_ratio
, (float)alloc_ratio
);
if(pv_pixelsize > gpp->pv_pixelsize)
{
if ((alloc_ratio > 1.0) /* landscape */
&& (allo_width < gpp->old_resize_width))
{
if(gap_debug) printf(" BLOCK preview grow on width shrink\n");
blocked = TRUE;
}
if ((alloc_ratio <= 1.0) /* portrait */
&& (allo_height < gpp->old_resize_height))
{
if(gap_debug) printf(" BLOCK preview grow on height shrink\n");
blocked = TRUE;
}
}
if(!blocked)
{
gpp->pv_pixelsize = pv_pixelsize;
p_update_pviewsize(gpp);
if(!gpp->play_is_active)
{
/* have to refresh current frame
* repaint is not enough because size has changed
* (if play_is_active we can skip this, because the next update is on the way)
*/
p_display_frame(gpp, gpp->play_current_framenr);
}
}
if(gap_debug) printf(" on_vid_preview_size_allocate: AFTER resize pv_w:%d pv_h:%d\n"
, (int)gpp->pv_ptr->pv_width
, (int)gpp->pv_ptr->pv_height
);
}
gpp->old_resize_width = allo_width;
gpp->old_resize_height = allo_height;
if(gap_debug) printf(" on_vid_preview_size_allocate: END\n");
} /* end on_vid_preview_size_allocate */
/* -----------------------------
* on_framenr_button_clicked
* -----------------------------
* SHIFT-click: goto frame
* else: (normal click or other modifier keys ...)
* set END of range if inoked from the framenr_2_button widget
* set BEGIN of range if NOT inoked from the framenr_2_button widget
*/
static void
on_framenr_button_clicked (GtkButton *button,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp)
{
GimpParam *return_vals;
int nreturn_vals;
gint button_type;
gint32 dummy_layer_id;
/*if(gap_debug) printf("on_framenr_button_clicked: START\n"); */
if(gpp == NULL)
{
return;
}
p_stop_playback(gpp);
if(button)
{
button_type = (gint) g_object_get_data (G_OBJECT (button), KEY_FRAMENR_BUTTON_TYPE);
}
else
{
button_type = FRAMENR_BUTTON_BEGIN;
}
if(bevent)
{
if (!(bevent->state & GDK_SHIFT_MASK)) /* normal Click */
{
/* for normal click and other modifiers other than SHIFT (GDK_CONTROL_MASK) */
if(button_type == FRAMENR_BUTTON_END)
{
/* set END of the range */
gpp->end_frame = gpp->play_current_framenr;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)gpp->play_current_framenr
);
if(gpp->end_frame < gpp->begin_frame)
{
gpp->begin_frame = gpp->end_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)gpp->begin_frame
);
}
return;
}
/* set BEGIN of the range */
gpp->begin_frame = gpp->play_current_framenr;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)gpp->play_current_framenr
);
if(gpp->begin_frame > gpp->end_frame)
{
gpp->end_frame = gpp->begin_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)gpp->end_frame
);
}
return;
}
}
if((gpp->stb_ptr)
|| (gpp->image_id < 0))
{
/* NOP in storyboard mode */
return;
}
dummy_layer_id = gap_image_get_any_layer(gpp->image_id);
return_vals = gimp_run_procedure ("plug_in_gap_goto",
&nreturn_vals,
GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE,
GIMP_PDB_IMAGE, gpp->image_id,
GIMP_PDB_DRAWABLE, dummy_layer_id,
GIMP_PDB_INT32, gpp->play_current_framenr,
GIMP_PDB_END);
if(return_vals)
{
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
p_reload_ainfo_ptr(gpp, return_vals[1].data.d_image);
p_update_ainfo_dependent_widgets(gpp);
gimp_displays_flush();
}
gimp_destroy_params(return_vals, nreturn_vals);
}
} /* end on_framenr_button_clicked */
/* -----------------------------
* on_from_button_clicked
* -----------------------------
*/
static void
on_from_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
gboolean printflag;
printflag = TRUE;
if(gpp->fptr_set_range)
{
printflag = FALSE;
}
p_printout_range(gpp, FALSE, printflag);
}
} /* end on_from_button_clicked */
/* -----------------------------
* on_to_button_clicked
* -----------------------------
*/
static void
on_to_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
gboolean printflag;
printflag = TRUE;
if(gpp->fptr_set_range)
{
printflag = FALSE;
}
p_printout_range(gpp, TRUE, printflag);
}
} /* end on_to_button_clicked */
/* -----------------------------
* on_framenr_scale_clicked
* -----------------------------
*/
static gboolean
on_framenr_scale_clicked (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
if(gap_debug) printf("SCALE CLICKED\n");
if(gpp->play_is_active)
{
p_stop_playback(gpp);
}
}
return(FALSE); /* event not completely handled, continue calling other handlers */
} /* end on_framenr_scale_clicked */
/* -----------------------------
* on_framenr_spinbutton_changed
* -----------------------------
*/
static void
on_framenr_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
gint32 framenr;
if(gpp == NULL)
{
return;
}
framenr = (gint32)GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)->value;
/* force redraw of the framenr_scale widget
* that refers to the framenr_spinbutton_adj adjustment
*/
gtk_widget_queue_draw(gpp->framenr_scale);
if(gpp->play_current_framenr != framenr)
{
/* force adjustment to the integer value */
GTK_ADJUSTMENT (gpp->framenr_spinbutton_adj)->value = framenr;
gpp->play_current_framenr = framenr;
if(gpp->play_is_active)
{
if(gpp->rest_secs < 0.2)
{
/* currently playing and next update is near,
* just set the framenr and let the play_timer do the display render job
*/
gpp->play_current_framenr = framenr;
}
else
{
/* currently playing, but next update not near
* render display immediate
*/
p_display_frame(gpp, framenr);
}
}
else
{
/* currently not playing, setup a go_timer job to display framenr */
if(gpp->go_timertag >= 0)
{
g_source_remove(gpp->go_timertag);
}
gpp->go_job_framenr = framenr;
gpp->go_timertag = (gint32) g_timeout_add(8, (GtkFunction)on_timer_go_job, gpp);
}
p_audio_resync(gpp); /* force audio resync */
}
} /* end on_framenr_spinbutton_changed */
/* -----------------------------
* on_origspeed_button_clicked
* -----------------------------
*/
static void
on_origspeed_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->speed != gpp->original_speed)
{
gpp->prev_speed = gpp->speed;
gpp->speed = gpp->original_speed;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->speed_spinbutton_adj)
, (gfloat)gpp->speed
);
}
else
{
if(gpp->original_speed != gpp->prev_speed)
{
gpp->speed = gpp->prev_speed;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->speed_spinbutton_adj)
, (gfloat)gpp->speed
);
}
}
p_audio_resync(gpp);
} /* end on_origspeed_button_clicked */
/* -----------------------------
* on_speed_spinbutton_changed
* -----------------------------
*/
static void
on_speed_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->speed = GTK_ADJUSTMENT(gpp->speed_spinbutton_adj)->value;
/* stop audio at speed changes
* (audio will restart automatically at next frame with samplerate matching new speed)
*/
p_audio_resync(gpp);
} /* end on_speed_spinbutton_changed */
/* --------------------------
* p_fit_initial_shell_window
* --------------------------
*/
static void
p_fit_initial_shell_window(GapPlayerMainGlobalParams *gpp)
{
gint width;
gint height;
if(gpp == NULL) { return; }
if(gpp->shell_initial_width < 0) { return; }
if(gpp->shell_window == NULL) { return; }
width = gpp->shell_initial_width;
height = gpp->shell_initial_height;
gtk_widget_set_size_request (gpp->shell_window, width, height); /* shrink shell window */
gtk_window_set_default_size(GTK_WINDOW(gpp->shell_window), width, height); /* shrink shell window */
gtk_window_resize (GTK_WINDOW(gpp->shell_window), width, height); /* shrink shell window */
} /* end p_fit_initial_shell_window */
/* ---------------------
* p_fit_shell_window
* ---------------------
*/
static void
p_fit_shell_window(GapPlayerMainGlobalParams *gpp)
{
gint width;
gint height;
if(gpp->shell_window == NULL) { return; }
if((gpp->pv_ptr->pv_width <= GAP_STANDARD_PREVIEW_SIZE)
&& (gpp->pv_ptr->pv_height <= GAP_STANDARD_PREVIEW_SIZE))
{
p_fit_initial_shell_window(gpp);
return;
}
/* FIXME: use preview size plus fix offsets (the offsets are just a guess
* and may be too small for other languages and/or fonts
*/
width = MAX(gpp->pv_ptr->pv_width, GAP_STANDARD_PREVIEW_SIZE) + 272;
#ifdef GAP_ENABLE_AUDIO_SUPPORT
height = MAX(gpp->pv_ptr->pv_height, GAP_STANDARD_PREVIEW_SIZE) + 178;
#else
height = MAX(gpp->pv_ptr->pv_height, GAP_STANDARD_PREVIEW_SIZE) + 128;
#endif
gtk_window_set_default_size(GTK_WINDOW(gpp->shell_window), width, height); /* shrink shell window */
gtk_window_resize (GTK_WINDOW(gpp->shell_window), width, height); /* resize shell window */
} /* end p_fit_shell_window */
/* -----------------------------
* on_size_button_button_press_event
* -----------------------------
*/
static gboolean
on_size_button_button_press_event (GtkWidget *widget,
GdkEventButton *bevent,
GapPlayerMainGlobalParams *gpp)
{
gboolean fit_initial_flag;
if(gap_debug) printf("\nON_SIZE_BUTTON_BUTTON_PRESS_EVENT START\n");
if(gpp == NULL)
{
return FALSE;
}
p_disconnect_resize_handler(gpp);
fit_initial_flag = TRUE;
if ((bevent->state & GDK_SHIFT_MASK)
&& (bevent->type == GDK_BUTTON_PRESS)
&& (gpp->ainfo_ptr))
{
if(gap_debug) printf("GDK_SHIFT_MASK !!\n\n");
gpp->pv_pixelsize = CLAMP(MAX(gpp->ainfo_ptr->width, gpp->ainfo_ptr->height)
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE);
fit_initial_flag = FALSE;
}
else
{
/* toggle between normal and large thumbnail size */
if(gpp->pv_pixelsize == GAP_STANDARD_PREVIEW_SIZE)
{
gpp->pv_pixelsize = GAP_SMALL_PREVIEW_SIZE;
}
else
{
gpp->pv_pixelsize = GAP_STANDARD_PREVIEW_SIZE;
}
}
if(gpp->pv_pixelsize != (gint32)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value)
{
p_update_pviewsize(gpp);
if(!gpp->play_is_active)
{
p_display_frame(gpp, gpp->play_current_framenr);
}
}
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->size_spinbutton_adj)
, (gfloat)gpp->pv_pixelsize
);
if(fit_initial_flag)
{
p_fit_initial_shell_window(gpp);
}
else
{
p_fit_shell_window(gpp);
}
p_connect_resize_handler(gpp);
return FALSE;
} /* end on_size_button_button_press_event */
/* -----------------------------
* on_size_spinbutton_changed
* -----------------------------
*/
static void
on_size_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gap_debug)
{
printf("on_size_spinbutton_changed: value: %d pv_pixelsize: %d\n"
, (int)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value
,(int)gpp->pv_pixelsize
);
}
if(gpp->pv_pixelsize != (gint32)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value)
{
gpp->pv_pixelsize = (gint32)GTK_ADJUSTMENT(gpp->size_spinbutton_adj)->value;
p_update_pviewsize(gpp);
if(!gpp->play_is_active)
{
p_display_frame(gpp, gpp->play_current_framenr);
}
p_fit_shell_window(gpp);
}
} /* end on_size_spinbutton_changed */
/* -----------------------------
* on_size_spinbutton_enter
* -----------------------------
*/
static gboolean on_size_spinbutton_enter (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf("\n on_size_spinbutton_enter START\n");*/
if(gpp)
{
p_disconnect_resize_handler(gpp);
}
return FALSE;
} /* end on_size_spinbutton_enter */
/* -----------------------------
* on_shell_window_leave
* -----------------------------
*/
static gboolean on_shell_window_leave (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp)
{
/*if(gap_debug) printf("\n on_shell_window_leave START\n");*/
if(gpp)
{
p_connect_resize_handler(gpp);
}
return FALSE;
} /* end on_shell_window_leave */
/* -----------------------------
* on_exact_timing_checkbutton_toggled
* -----------------------------
*/
static void
on_exact_timing_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->exact_timing = TRUE;
}
else
{
gpp->exact_timing = FALSE;
}
} /* end on_exact_timing_checkbutton_toggled */
/* -----------------------------
* on_use_thumb_checkbutton_toggled
* -----------------------------
*/
static void
on_use_thumb_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->use_thumbnails = TRUE;
}
else
{
gpp->use_thumbnails = FALSE;
}
} /* end on_use_thumb_checkbutton_toggled */
/* -----------------------------
* on_pinpong_checkbutton_toggled
* -----------------------------
*/
static void
on_pinpong_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->play_pingpong = TRUE;
}
else
{
gpp->play_pingpong = FALSE;
}
} /* end on_pinpong_checkbutton_toggled */
/* -----------------------------
* on_selonly_checkbutton_toggled
* -----------------------------
*/
static void
on_selonly_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->play_selection_only = TRUE;
}
else
{
gpp->play_selection_only = FALSE;
}
} /* end on_selonly_checkbutton_toggled */
/* -----------------------------
* on_loop_checkbutton_toggled
* -----------------------------
*/
static void
on_loop_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->play_loop = TRUE;
}
else
{
gpp->play_loop = FALSE;
}
} /* end on_loop_checkbutton_toggled */
/* -------------------------------------
* on_show_gobuttons_checkbutton_toggled
* -------------------------------------
*/
static void
on_show_gobuttons_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->show_go_buttons = TRUE;
gtk_widget_show(gpp->gobutton_hbox);
}
else
{
gpp->show_go_buttons = FALSE;
gtk_widget_hide(gpp->gobutton_hbox);
}
} /* end on_show_gobuttons_checkbutton_toggled */
/* -----------------------------------------
* on_show_positionscale_checkbutton_toggled
* -----------------------------------------
*/
static void
on_show_positionscale_checkbutton_toggled(GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->show_position_scale = TRUE;
gtk_widget_show(gpp->frame_scale_hbox);
}
else
{
gpp->show_position_scale = FALSE;
gtk_widget_hide(gpp->frame_scale_hbox);
}
} /* end on_show_positionscale_checkbutton_toggled */
/* -----------------------------
* on_close_button_clicked
* -----------------------------
*/
static void
on_close_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
p_stop_playback(gpp);
if(gpp->gva_lock)
{
gpp->request_cancel_video_api = TRUE;
return;
}
if(gpp->audio_tmp_dialog_is_open)
{
/* ignore close as long as sub dialog is open */
return;
}
gtk_widget_destroy (GTK_WIDGET (gpp->shell_window)); /* close & destroy dialog window */
if(gpp->standalone_mode)
{
gtk_main_quit ();
}
} /* end on_close_button_clicked */
/* -----------------------------
* on_shell_window_destroy
* -----------------------------
*/
static void
on_shell_window_destroy (GtkObject *object,
GapPlayerMainGlobalParams *gpp)
{
if(gpp)
{
p_stop_playback(gpp);
}
gpp->shell_window = NULL;
p_close_videofile(gpp);
p_close_composite_storyboard(gpp);
if(gpp->standalone_mode)
{
gtk_main_quit ();
}
} /* end on_shell_window_destroy */
/* -----------------------------
* on_go_button_clicked
* -----------------------------
*/
static void
on_go_button_clicked (GtkButton *button,
GdkEventButton *bevent,
t_gobutton *gob)
{
GapPlayerMainGlobalParams *gpp;
gint32 framenr;
if(gob == NULL) { return; }
gpp = gob->gpp;
if(gpp == NULL) { return; }
/*if (gap_debug) printf("on_go_button_clicked: go_number:%d\n", (int)gob->go_number );*/
p_stop_playback(gpp);
framenr = p_framenr_from_go_number(gpp, gob->go_number);
if(gpp->play_current_framenr != framenr)
{
p_display_frame(gpp, framenr);
}
if(bevent->type == GDK_BUTTON_PRESS)
{
if(bevent->state & GDK_CONTROL_MASK)
{
gpp->begin_frame = framenr;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)gpp->begin_frame
);
if(gpp->begin_frame > gpp->end_frame)
{
gpp->end_frame = gpp->begin_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)gpp->end_frame
);
}
return;
}
if(bevent->state & GDK_MOD1_MASK) /* ALT modifier Key */
{
gpp->end_frame = framenr;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)gpp->end_frame
);
if(gpp->end_frame < gpp->begin_frame)
{
gpp->begin_frame = gpp->end_frame;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)gpp->begin_frame
);
}
return;
}
}
if(framenr != gpp->ainfo_ptr->curr_frame_nr)
{
on_framenr_button_clicked(NULL, NULL, gpp);
}
} /* end on_go_button_clicked */
/* -----------------------------
* on_go_button_enter
* -----------------------------
*/
static gboolean
on_go_button_enter (GtkButton *button,
GdkEvent *event,
t_gobutton *gob)
{
GapPlayerMainGlobalParams *gpp;
gint32 framenr;
if(gob == NULL) { return FALSE; }
gpp = gob->gpp;
if(gpp == NULL) { return FALSE; }
/*if (gap_debug) printf("ON_GO_BUTTON_ENTER: go_number:%d\n", (int)gob->go_number ); */
p_stop_playback(gpp);
/* skip display on full sized image mode
* (gui cant follow that fast on many machines, and would react slow)
*/
/*if(gpp->use_thumbnails) */
{
framenr = p_framenr_from_go_number(gpp, gob->go_number);
if(gpp->play_current_framenr != framenr)
{
if(gap_debug)
{
if(gpp->go_timertag >= 0)
{
if(gap_debug) printf("on_go_button_enter: DROP GO_FRAMENR: %d\n", (int)gpp->go_job_framenr);
}
}
/* we want the go_timer to display that framenr */
gpp->go_job_framenr = framenr;
if(gpp->go_timertag < 0)
{
/* if the go_timer is not already prepared to fire
* we start p_display_frame(gpp, gpp->go_job_framenr);
* after minimal delay of 8 millisecods.
*/
gpp->go_timertag = (gint32) g_timeout_add(8, (GtkFunction)on_timer_go_job, gpp);
}
}
}
return FALSE;
} /* end on_go_button_enter */
/* -----------------------------
* on_gobutton_hbox_leave
* -----------------------------
*/
static void
on_gobutton_hbox_leave (GtkWidget *widget,
GdkEvent *event,
GapPlayerMainGlobalParams *gpp)
{
/*if (gap_debug) printf("ON_GOBUTTON_HBOX_LEAVE\n");*/
if(gpp == NULL)
{
return;
}
/* reset go_base */
gpp->go_base_framenr = -1;
gpp->go_base = -1;
p_check_tooltips();
} /* end on_gobutton_hbox_leave */
/* -----------------------------------
* on_audio_enable_checkbutton_toggled
* -----------------------------------
*/
static void
on_audio_enable_checkbutton_toggled (GtkToggleButton *togglebutton,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if (togglebutton->active)
{
gpp->audio_enable = TRUE;
/* audio will start automatic at next frame when playback is running */
}
else
{
gpp->audio_enable = FALSE;
gpp->audio_resync = 0;
p_audio_stop(gpp);
}
} /* end on_audio_enable_checkbutton_toggled */
/* -----------------------------
* on_audio_volume_spinbutton_changed
* -----------------------------
*/
static void
on_audio_volume_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->audio_volume != (gdouble)GTK_ADJUSTMENT(gpp->audio_volume_spinbutton_adj)->value)
{
gpp->audio_volume = (gdouble)GTK_ADJUSTMENT(gpp->audio_volume_spinbutton_adj)->value;
#ifdef GAP_ENABLE_AUDIO_SUPPORT
if(gpp->audio_status >= GAP_PLAYER_MAIN_AUSTAT_PLAYING)
{
apcl_volume(gpp->audio_volume, 0, p_audio_errfunc);
}
#endif
}
} /* end on_audio_volume_spinbutton_changed */
/* -----------------------------------------
* on_audio_frame_offset_spinbutton_changed
* -----------------------------------------
*/
static void
on_audio_frame_offset_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->audio_frame_offset != (gint32)GTK_ADJUSTMENT(gpp->audio_frame_offset_spinbutton_adj)->value)
{
gpp->audio_frame_offset = (gint32)GTK_ADJUSTMENT(gpp->audio_frame_offset_spinbutton_adj)->value;
/* resync audio will cause an automatic restart respecting te new audio_offset value
*/
p_audio_resync(gpp);
p_audio_print_labels(gpp);
}
} /* end on_audio_frame_offset_spinbutton_changed */
/* -----------------------------------------
* on_audio_reset_button_clicked
* -----------------------------------------
*/
static void
on_audio_reset_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gpp->audio_frame_offset = 0;
gpp->audio_volume = 1.0;
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->audio_frame_offset_spinbutton_adj)
, (gfloat)gpp->audio_frame_offset
);
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->audio_volume_spinbutton_adj)
, (gfloat)gpp->audio_volume
);
/* resync audio (for the case its already playing this
* will cause an automatic restart respecting te new audio_offset value
*/
p_audio_resync(gpp);
p_audio_print_labels(gpp);
} /* end on_audio_reset_button_clicked */
/* -----------------------------------------
* on_audio_create_copy_button_clicked
* -----------------------------------------
*/
static void
on_audio_create_copy_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
#ifdef GAP_ENABLE_AUDIO_SUPPORT
const char *cp;
char *envAUDIOCONVERT_TO_WAV;
gboolean script_found;
gboolean use_newly_created_wavfile;
if(gpp == NULL)
{
return;
}
if(gpp->audio_tmp_dialog_is_open)
{
return;
}
script_found = FALSE;
use_newly_created_wavfile = FALSE;
envAUDIOCONVERT_TO_WAV = g_strdup(" ");
/* check gimprc for the audioconvert_program */
if ( (cp = gimp_gimprc_query("audioconvert_program")) != NULL )
{
g_free(envAUDIOCONVERT_TO_WAV);
envAUDIOCONVERT_TO_WAV = g_strdup(cp);
if(g_file_test (envAUDIOCONVERT_TO_WAV, G_FILE_TEST_IS_EXECUTABLE) )
{
script_found = TRUE;
}
else
{
g_message(_("WARNING: Your gimprc file configuration for the audioconverter script\n"
"does not point to an executable program\n"
"the configured value for %s is: %s\n")
, "audioconvert_program"
, envAUDIOCONVERT_TO_WAV
);
}
}
/* check environment variable for the audioconvert_program */
if(!script_found)
{
if ( (cp = g_getenv("AUDIOCONVERT_TO_WAV")) != NULL )
{
g_free(envAUDIOCONVERT_TO_WAV);
envAUDIOCONVERT_TO_WAV = g_strdup(cp); /* Environment overrides compiled in default for WAVPLAYPATH */
if(g_file_test (env_WAVPLAYPATH, G_FILE_TEST_IS_EXECUTABLE) )
{
script_found = TRUE;
}
else
{
g_message(_("WARNING: The environment variable %s\n"
"does not point to an executable program\n"
"the current value is: %s\n")
, "AUDIOCONVERT_TO_WAV"
, envAUDIOCONVERT_TO_WAV
);
}
}
}
if(!script_found)
{
g_free(envAUDIOCONVERT_TO_WAV);
envAUDIOCONVERT_TO_WAV = g_build_filename(GAPLIBDIR
, "audioconvert_to_wav.sh"
, NULL
);
if(!g_file_test(envAUDIOCONVERT_TO_WAV, G_FILE_TEST_IS_EXECUTABLE))
{
g_message(_("ERROR: The external program for audioconversion is not executable.\n"
"Filename: '%s'\n")
, envAUDIOCONVERT_TO_WAV
);
return;
}
script_found = TRUE;
}
gpp->audio_tmp_dialog_is_open = TRUE;
if(p_create_wav_dialog(gpp))
{
gint l_rc;
gchar *l_cmd;
gchar *l_resample_params;
printf("CREATE WAVFILE as %s\n"
" in progress ***\n"
,gpp->audio_wavfile_tmp );
gtk_label_set_text ( GTK_LABEL(gpp->audio_status_label), _("Creating audiofile - please wait"));
gtk_widget_hide(gpp->audio_table);
gtk_widget_show(gpp->audio_status_label);
while (gtk_events_pending ())
{
gtk_main_iteration ();
}
if(gpp->audio_tmp_resample)
{
l_resample_params = g_strdup_printf("--resample %d"
, (int)gpp->audio_tmp_samplerate
);
}
else
{
l_resample_params = g_strdup(" "); /* do not resample */
}
if(g_file_test(gpp->audio_wavfile_tmp, G_FILE_TEST_EXISTS))
{
g_remove(gpp->audio_wavfile_tmp);
}
l_cmd = g_strdup_printf("%s --in \"%s\" --out \"%s\" %s"
, envAUDIOCONVERT_TO_WAV
, gpp->audio_filename
, gpp->audio_wavfile_tmp
, l_resample_params
);
/* CALL the external audioconverter Program */
l_rc = system(l_cmd);
if (l_rc != 0)
{
printf("extern audioconverter FAILED. cmd:%s\n", l_cmd);
g_message(_("external audioconverter FAILED."));
p_msg_progress_bar_audio(gpp, _("extern audioconverter FAILED"));
}
g_free(l_cmd);
g_free(l_resample_params);
/* if the external converter created the wavfile
* then use the newly created wavfile
*/
if(g_file_test(gpp->audio_wavfile_tmp, G_FILE_TEST_EXISTS))
{
use_newly_created_wavfile = TRUE;
}
}
g_free(envAUDIOCONVERT_TO_WAV);
gpp->audio_tmp_dialog_is_open = FALSE;
gtk_label_set_text ( GTK_LABEL(gpp->audio_status_label), " ");
gtk_widget_hide(gpp->audio_status_label);
gtk_widget_show(gpp->audio_table);
if(use_newly_created_wavfile)
{
gtk_entry_set_text(GTK_ENTRY(gpp->audio_filename_entry), gpp->audio_wavfile_tmp);
}
#endif
return;
} /* end on_audio_create_copy_button_clicked */
/* -----------------------------------------
* on_audio_filename_entry_changed
* -----------------------------------------
*/
static void
on_audio_filename_entry_changed (GtkWidget *widget,
GapPlayerMainGlobalParams *gpp)
{
gboolean has_changed;
if(gpp == NULL)
{
return;
}
has_changed = TRUE;
if (gpp->audio_filename)
{
if(gap_debug)
{
printf("\non_audio_filename_entry_changed\n");
printf(" ()) gpp->audio_filename:%s\n"
, gpp->audio_filename);
printf(" ()) gtk_entry_get_text:%s\n"
, gtk_entry_get_text(GTK_ENTRY(gpp->audio_filename_entry)));
}
if (gtk_entry_get_text(GTK_ENTRY(gpp->audio_filename_entry)) != NULL)
{
if (strcmp(gpp->audio_filename, gtk_entry_get_text(GTK_ENTRY(gpp->audio_filename_entry))) == 0)
{
has_changed = FALSE;
}
}
}
g_snprintf(gpp->audio_filename, sizeof(gpp->audio_filename), "%s"
, gtk_entry_get_text(GTK_ENTRY(gpp->audio_filename_entry))
);
p_audio_filename_changed(gpp);
if(has_changed == TRUE)
{
p_reset_progress_bar_audio(gpp);
}
} /* end on_audio_filename_entry_changed */
/* --------------------------
* AUDIO_FILESEL
* --------------------------
*/
static void
on_audio_filesel_close_cb(GtkWidget *widget, GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->audio_filesel == NULL)
{
gtk_window_present(GTK_WINDOW(gpp->audio_filesel));
return; /* filesel is already closed */
}
gtk_widget_destroy(GTK_WIDGET(gpp->audio_filesel));
gpp->audio_filesel = NULL;
} /* end on_audio_filesel_close_cb */
static void
on_audio_filesel_ok_cb(GtkWidget *widget, GapPlayerMainGlobalParams *gpp)
{
const gchar *filename;
if(gpp == NULL)
{
return;
}
if(gpp->audio_filesel == NULL)
{
return; /* filesel is already closed */
}
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (gpp->audio_filesel));
if(filename)
{
if(*filename != '\0')
{
gtk_entry_set_text(GTK_ENTRY(gpp->audio_filename_entry), filename);
}
}
on_audio_filesel_close_cb(widget, gpp);
} /* end on_audio_filesel_ok_cb */
/* -----------------------------------------
* on_audio_filesel_button_clicked
* -----------------------------------------
*/
static void
on_audio_filesel_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
if(gpp->audio_filesel)
{
gtk_window_present(GTK_WINDOW(gpp->audio_filesel));
return; /* filesection dialog is already open */
}
gpp->audio_filesel = gtk_file_selection_new (_("Select Audiofile"));
gtk_window_set_position (GTK_WINDOW (gpp->audio_filesel), GTK_WIN_POS_MOUSE);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (gpp->audio_filesel),
gpp->audio_filename);
gtk_widget_show (gpp->audio_filesel);
g_signal_connect (G_OBJECT (gpp->audio_filesel), "destroy",
G_CALLBACK (on_audio_filesel_close_cb),
gpp);
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (gpp->audio_filesel)->ok_button),
"clicked",
G_CALLBACK (on_audio_filesel_ok_cb),
gpp);
g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (gpp->audio_filesel)->cancel_button),
"clicked",
G_CALLBACK (on_audio_filesel_close_cb),
gpp);
} /* end on_audio_filesel_button_clicked */
/* -----------------------------
* p_new_audioframe
* -----------------------------
* create widgets for the audio options
*/
static GtkWidget *
p_new_audioframe(GapPlayerMainGlobalParams *gpp)
{
GtkWidget *frame0a;
GtkWidget *hseparator;
GtkWidget *label;
GtkWidget *vbox1;
GtkWidget *table1;
GtkWidget *entry;
GtkWidget *button;
GtkWidget *check_button;
GtkWidget *spinbutton;
GtkWidget *progress_bar;
GtkObject *adj;
gint row;
if (gap_debug) printf("p_new_audioframe\n");
frame0a = gimp_frame_new ("Audio Playback Settings");
/* the vbox */
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (frame0a), vbox1);
/* table */
table1 = gtk_table_new (14, 3, FALSE);
gpp->audio_table = table1;
gtk_widget_show (table1);
gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table1), 4);
gtk_table_set_col_spacings (GTK_TABLE (table1), 4);
/* status label */
label = gtk_label_new(" ");
gpp->audio_status_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox1), label, TRUE, TRUE, 0);
gtk_widget_hide(label);
row = 0;
/* audiofile label */
label = gtk_label_new (_("Audiofile:"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
/*gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);*/ /* right alligned */
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); /* left alligned */
/* audiofile entry */
entry = gtk_entry_new();
gpp->audio_filename_entry = entry;
gtk_widget_show (entry);
gimp_help_set_help_data(entry, _("Enter an audiofile. The file must be in RIFF WAVE fileformat."),NULL);
if(gpp->docking_container)
{
gtk_widget_set_size_request(entry, GAP_PLAY_AUDIO_ENTRY_WIDTH_DOCKED, -1);
}
else
{
gtk_widget_set_size_request(entry, GAP_PLAY_AUDIO_ENTRY_WIDTH, -1);
}
gtk_entry_set_text(GTK_ENTRY(entry), gpp->audio_filename);
gtk_table_attach(GTK_TABLE(table1), entry, 1, 2, row, row + 1,
(GtkAttachOptions) GTK_FILL | GTK_EXPAND | GTK_SHRINK,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect(G_OBJECT(entry), "changed",
G_CALLBACK (on_audio_filename_entry_changed),
gpp);
/* audiofile button (fileselect invoker) */
button = gtk_button_new_with_label ( "...");
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Open audiofile selection browser dialog window"),NULL);
gtk_table_attach(GTK_TABLE(table1), button, 2, 3, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_audio_filesel_button_clicked),
gpp);
row++;
/* Volume */
label = gtk_label_new(_("Volume:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
/* volume spinutton */
spinbutton = gimp_spin_button_new (&adj, /* return value */
gpp->audio_volume, /* initial_val */
0.0, /* umin */
1.0, /* umax */
0.01, /* sstep */
0.1, /* pagestep */
0.0, /* page_size */
0.1, /* climb_rate */
2 /* digits */
);
gtk_widget_show (spinbutton);
/*gtk_widget_set_sensitive(spinbutton, FALSE);*/ /* VOLUME CONTROL NOT IMPLEMENTED YET !!! */
gpp->audio_volume_spinbutton_adj = adj;
gtk_table_attach(GTK_TABLE(table1), spinbutton, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 4, 0);
gimp_help_set_help_data(spinbutton, _("Audio Volume"),NULL);
g_signal_connect (G_OBJECT (gpp->audio_volume_spinbutton_adj), "value_changed",
G_CALLBACK (on_audio_volume_spinbutton_changed),
gpp);
/* check button */
check_button = gtk_check_button_new_with_label (_("Enable"));
gpp->audio_enable_checkbutton = check_button;
gtk_table_attach ( GTK_TABLE (table1), check_button, 2, 3, row, row+1, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
gpp->audio_enable);
gimp_help_set_help_data(check_button, _("ON: Play button plays video + audio.\n"
"OFF: Play video silently"),NULL);
gtk_widget_show (check_button);
g_signal_connect (G_OBJECT (check_button), "toggled",
G_CALLBACK (on_audio_enable_checkbutton_toggled),
gpp);
row++;
/* Sample Offset */
label = gtk_label_new(_("Offset:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
/* offset spinutton */
spinbutton = gimp_spin_button_new (&adj, /* return value */
gpp->audio_frame_offset, /* initial_val */
-500000, /* umin */
500000, /* umax */
1.0, /* sstep */
100, /* pagestep */
0, /* page_size */
1, /* climb_rate */
0 /* digits */
);
gtk_widget_show (spinbutton);
gpp->audio_frame_offset_spinbutton_adj = adj;
gtk_table_attach(GTK_TABLE(table1), spinbutton, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 4, 0);
gimp_help_set_help_data(spinbutton
, _("Audio offset in frames at original video playback speed. "
"A value of 0 starts audio and video at synchron time. "
"A value of -10 will play frame 1 up to frame 9 silently "
"and start audio at frame 10. "
"A value of 10 starts audio at frame 1, "
"but skips the audio begin part in a length that is "
"equal to the duration of 10 frames "
"at original video playback speed.")
,NULL);
g_signal_connect (G_OBJECT (gpp->audio_frame_offset_spinbutton_adj), "value_changed",
G_CALLBACK (on_audio_frame_offset_spinbutton_changed),
gpp);
/* check button */
check_button = gtk_check_button_new_with_label (_("original audio"));
gpp->audio_auto_offset_by_framenr_checkbutton = check_button;
gtk_table_attach ( GTK_TABLE (table1), check_button, 2, 3, row, row+1, GTK_FILL, 0, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
gpp->audio_auto_offset_by_framenr);
gimp_help_set_help_data(check_button, _("ON: for video clip playback sync audio startposition according"
" to original position in the referenced video."
" Use this option if the audiofile is an extracted audiotrack"
" of the full referenced videofile\n"
"OFF: do not sync audio with original position in the referenced videos."
" Use this for independent audiofile playback.")
,NULL);
gtk_widget_show (check_button);
g_signal_connect (G_OBJECT (check_button), "toggled",
G_CALLBACK (on_audio_auto_offset_checkbutton_toggled),
gpp);
row++;
/* Sample Offset */
label = gtk_label_new(_("Audiotrack:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
/* create the audio_otone_atrack_spinbutton spinutton */
spinbutton = gimp_spin_button_new (&adj, /* return value */
1, /* initial_val */
0.0, /* umin */
10.0, /* umax */
1.0, /* sstep */
1.0, /* pagestep */
0.0, /* page_size */
1.0, /* climb_rate */
0 /* digits */
);
gtk_widget_show (spinbutton);
gpp->audio_otone_atrack_spinbutton_adj = adj;
gpp->audio_otone_atrack_spinbutton = spinbutton;
gtk_table_attach(GTK_TABLE(table1), spinbutton, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 4, 0);
gimp_help_set_help_data(spinbutton, _("Audio Track"),NULL);
g_signal_connect (G_OBJECT (gpp->audio_volume_spinbutton_adj), "value_changed",
G_CALLBACK (on_audio_otone_atrack_spinbutton_changed),
gpp);
/* create extract audio otone track button */
button = gtk_button_new_with_label(_("Extract Audio"));
gpp->audio_otone_extract_button = button;
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Extract Audio Track from videofile "
"for the current videofile and use it for origial audiotrack playback")
,NULL);
gtk_table_attach(GTK_TABLE(table1), button, 2, 3, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_audio_otone_extract_button_clicked),
gpp);
row++;
/* create wavfile button */
button = gtk_button_new_with_label(_("Copy As Wavfile"));
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Create a copy from audiofile as RIFF WAVE audiofile "
"and use the copy for audio playback"),NULL);
gtk_table_attach(GTK_TABLE(table1), button, 1, 2, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_audio_create_copy_button_clicked),
gpp);
/* reset button */
button = gtk_button_new_from_stock (GIMP_STOCK_RESET);
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Reset offset and volume"),NULL);
gtk_table_attach(GTK_TABLE(table1), button, 2, 3, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_audio_reset_button_clicked),
gpp);
row++;
/* create the audio extract progressbar */
progress_bar = gtk_progress_bar_new ();
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), " ");
gtk_widget_show (progress_bar);
gtk_table_attach (GTK_TABLE (table1), progress_bar, 1, 3, row, row+1,
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL), 4, 0);
gpp->progress_bar_audio = progress_bar;
row++;
hseparator = gtk_hseparator_new ();
gtk_widget_show (hseparator);
gtk_table_attach(GTK_TABLE(table1), hseparator, 0, 3, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL,
0, 0);
row++;
/* Audio Offset Length (mm:ss:msec) */
label = gtk_label_new(_("Offsettime:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("mm:ss:msec");
gpp->audio_offset_time_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Total Audio Length (mm:ss:msec) */
label = gtk_label_new(_("Audiotime:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("mm:ss:msec");
gpp->audio_total_time_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Length (frames) */
label = gtk_label_new(_("Audioframes:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("####");
gpp->audio_total_frames_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Audiolength (Samples) */
label = gtk_label_new(_("Samples:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("######");
gpp->audio_samples_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Audio Samplerate */
label = gtk_label_new(_("Samplerate:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("######");
gpp->audio_samplerate_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Audio Channels */
label = gtk_label_new(_("Channels:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("#");
gpp->audio_channels_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Bits per Audio Sample */
label = gtk_label_new(_("Bits/Sample:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("##");
gpp->audio_bits_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Total Video Length (mm:ss:msec) */
label = gtk_label_new(_("Videotime:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("mm:ss:msec");
gpp->video_total_time_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
row++;
/* Video Length (frames) */
label = gtk_label_new(_("Videoframes:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
label = gtk_label_new("000000");
gpp->video_total_frames_label = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
return(frame0a);
} /* end p_new_audioframe */
/* -----------------------------------------
* p_update_cache_status
* -----------------------------------------
*/
static void
p_update_cache_status (GapPlayerMainGlobalParams *gpp)
{
static char status_txt[50];
gint32 elem_counter;
gint32 bytes_used;
gint32 max_bytes;
elem_counter = gap_player_cache_get_current_frames_cached();
bytes_used = gap_player_cache_get_current_bytes_used();
max_bytes = gap_player_cache_get_max_bytesize();
g_snprintf(status_txt, sizeof(status_txt), "%d", (int)elem_counter);
gtk_label_set_text ( GTK_LABEL(gpp->label_current_cache_values)
, status_txt);
if(gpp->progress_bar_cache_usage)
{
float mb_used;
gdouble progress;
mb_used = (float)bytes_used / (1024.0 * 1024.0);
progress = (gdouble)bytes_used / MAX((gdouble)max_bytes, 1.0);
g_snprintf(status_txt, sizeof(status_txt), "%.4f MB", mb_used);
if(gap_debug)
{
printf("p_update_cache_status: bytes_used:%d max_bytes:%d, max_player_cache:%d progress:%f\n"
, (int)bytes_used
, (int)max_bytes
, (int)gpp->max_player_cache
, (float)progress
);
}
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gpp->progress_bar_cache_usage)
, CLAMP(progress, 0.0, 1.0));
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(gpp->progress_bar_cache_usage)
, status_txt);
}
} /* end p_update_cache_status */
/* -----------------------------------------
* on_cache_size_spinbutton_changed
* -----------------------------------------
*/
static void
on_cache_size_spinbutton_changed (GtkEditable *editable,
GapPlayerMainGlobalParams *gpp)
{
gdouble mb_chachesize;
gdouble bytesize;
if(gpp == NULL)
{
return;
}
mb_chachesize = GTK_ADJUSTMENT(gpp->cache_size_spinbutton_adj)->value;
bytesize = mb_chachesize * (1024.0 * 1024.0);
if(gpp->max_player_cache != (gint32)bytesize)
{
gpp->max_player_cache = (gint32)bytesize;
if(gap_debug)
{
printf("on_cache_size_spinbutton_changed: max_player_cache:%d\n"
, (int) gpp->max_player_cache
);
}
gap_player_cache_set_max_bytesize(gpp->max_player_cache);
p_update_cache_status(gpp);
}
} /* end on_cache_size_spinbutton_changed */
/* -----------------------------------------
* on_cache_clear_button_clicked
* -----------------------------------------
*/
static void
on_cache_clear_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gap_player_cache_free_all();
p_update_cache_status(gpp);
} /* end on_cache_clear_button_clicked */
/* -----------------------------------------
* p_gimprc_save_boolen_option
* -----------------------------------------
*/
static void
p_gimprc_save_boolen_option (const char *option_name, gboolean value)
{
if(value)
{
gimp_gimprc_set(option_name, "yes");
}
else
{
gimp_gimprc_set(option_name, "no");
}
} /* end p_gimprc_save_boolen_option */
/* -----------------------------------------
* on_prefs_save_gimprc_button_clicked
* -----------------------------------------
*/
static void
on_prefs_save_gimprc_button_clicked (GtkButton *button,
GapPlayerMainGlobalParams *gpp)
{
if(gpp == NULL)
{
return;
}
gap_player_cache_set_gimprc_bytesize(gpp->max_player_cache);
p_gimprc_save_boolen_option("video_player_show_go_buttons"
,gpp->show_go_buttons);
p_gimprc_save_boolen_option("video_player_show_position_scale"
,gpp->show_position_scale);
} /* end on_prefs_save_gimprc_button_clicked */
/* -----------------------------
* p_new_configframe
* -----------------------------
* create widgets for the audio options
*/
static GtkWidget *
p_new_configframe(GapPlayerMainGlobalParams *gpp)
{
GtkWidget *frame0c;
GtkWidget *label;
GtkWidget *vbox1;
GtkWidget *table1;
GtkWidget *button;
GtkWidget *progress_bar;
GtkWidget *spinbutton;
GtkWidget *checkbutton;
GtkObject *adj;
gint row;
if (gap_debug) printf("p_new_configframe\n");
frame0c = gimp_frame_new ("Playback Preferences");
/* the vbox */
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (frame0c), vbox1);
/* table */
table1 = gtk_table_new (14, 3, FALSE);
gpp->audio_table = table1;
gtk_widget_show (table1);
gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table1), 4);
gtk_table_set_col_spacings (GTK_TABLE (table1), 4);
row = 0;
/* Cahe size label */
label = gtk_label_new (_("Cache Size (MB):"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); /* left alligned */
{
gdouble mb_cachesize;
mb_cachesize = (gdouble)gpp->max_player_cache / (1024.0 * 1024.0);
/* frame cache size spinutton */
spinbutton = gimp_spin_button_new (&adj, /* return value */
mb_cachesize, /* initial_val */
0.0, /* umin */
9000.0, /* umax */
1.0, /* sstep */
10.0, /* pagestep */
0.0, /* page_size */
10.0, /* climb_rate */
4 /* digits */
);
gtk_widget_show (spinbutton);
gpp->cache_size_spinbutton_adj = adj;
gtk_table_attach(GTK_TABLE(table1), spinbutton, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 4, 0);
gimp_help_set_help_data(spinbutton, _("Player frame cache maximum size in MB. Value 0 turns the cache off."),NULL);
g_signal_connect (G_OBJECT (gpp->cache_size_spinbutton_adj), "value_changed",
G_CALLBACK (on_cache_size_spinbutton_changed),
gpp);
}
/* clear player frame cache button */
button = gtk_button_new_from_stock (GIMP_STOCK_RESET);
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Clear the frame cache"),NULL);
gtk_table_attach(GTK_TABLE(table1), button, 2, 3, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_cache_clear_button_clicked),
gpp);
row++;
/* Chache Status (number of frames currently in the cache) */
label = gtk_label_new(_("Cached Frames:"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
/* current number of frames in the player cache */
label = gtk_label_new("0");
gpp->label_current_cache_values = label;
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach(GTK_TABLE(table1), label, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, 4, 0);
gtk_widget_show(label);
/* cache usage percentage progressbar */
progress_bar = gtk_progress_bar_new ();
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), " ");
gtk_widget_show (progress_bar);
gtk_table_attach (GTK_TABLE (table1), progress_bar, 2, 3, row, row+1,
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL), 4, 0);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), "0.0 MB");
gpp->progress_bar_cache_usage = progress_bar;
row++;
/* Layout Options label */
label = gtk_label_new (_("Layout Options:"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); /* left alligned */
row++;
/* Show Go button array (configure to show/hide this optional positioning tool) */
checkbutton = gtk_check_button_new_with_label (_("Show Button Array"));
gpp->show_go_buttons_checkbutton = checkbutton;
gtk_widget_show (checkbutton);
gtk_table_attach (GTK_TABLE (table1), checkbutton, 1, 3, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (checkbutton, _("ON: Show the go button array positioning tool.\n"
"OFF: Hide the go button array."), NULL);
if(gpp->show_go_buttons)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (checkbutton), "toggled",
G_CALLBACK (on_show_gobuttons_checkbutton_toggled),
gpp);
row++;
/* Show Position Scale (configure to show/hide this optional positioning tool) */
checkbutton = gtk_check_button_new_with_label (_("Show Position Scale"));
gpp->show_position_scale_checkbutton = checkbutton;
gtk_widget_show (checkbutton);
gtk_table_attach (GTK_TABLE (table1), checkbutton, 1, 3, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (checkbutton, _("ON: Show the position scale.\n"
"OFF: Hide the position scale."), NULL);
if(gpp->show_position_scale)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (checkbutton), "toggled",
G_CALLBACK (on_show_positionscale_checkbutton_toggled),
gpp);
row++;
/* Save Player Preferences label */
label = gtk_label_new (_("Save Preferences:"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table1), label, 0, 1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); /* left alligned */
/* save player frame cache settings to gimprc */
button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
gtk_widget_show (button);
gimp_help_set_help_data(button, _("Save player cache and layout settings (as gimprc parameters)"),NULL);
gtk_table_attach(GTK_TABLE(table1), button, 1, 2, row, row + 1,
(GtkAttachOptions) GTK_FILL,
(GtkAttachOptions) GTK_FILL, 4, 0);
g_signal_connect (G_OBJECT (button), "pressed",
G_CALLBACK (on_prefs_save_gimprc_button_clicked),
gpp);
return(frame0c);
} /* end p_new_configframe */
/* -----------------------------
* p_create_player_window
* -----------------------------
*/
GtkWidget*
p_create_player_window (GapPlayerMainGlobalParams *gpp)
{
GtkWidget *shell_window;
GtkWidget *event_box;
GtkWidget *frame0;
GtkWidget *aspect_frame;
GtkWidget *frame2;
GtkWidget *vbox0;
GtkWidget *vbox1;
GtkWidget *hbox1;
GtkWidget *play_n_stop_hbox;
GtkWidget *gobutton_hbox;
GtkWidget *table1;
GtkWidget *table11;
GtkWidget *table2;
GtkWidget *vid_preview;
GtkWidget *status_label;
GtkWidget *timepos_label;
GtkWidget *label;
GtkObject *from_spinbutton_adj;
GtkWidget *from_spinbutton;
GtkObject *to_spinbutton_adj;
GtkWidget *to_spinbutton;
GtkObject *framenr_spinbutton_adj;
GtkWidget *framenr_spinbutton;
GtkWidget *framenr_scale;
GtkObject *speed_spinbutton_adj;
GtkWidget *speed_spinbutton;
GtkObject *size_spinbutton_adj;
GtkWidget *size_spinbutton;
GtkWidget *cancel_vindex_button;
GtkWidget *play_button;
GtkWidget *pause_button;
GtkWidget *back_button;
GtkWidget *close_button;
GtkWidget *origspeed_button;
GtkWidget *size_button;
GtkWidget *framenr_1_button;
GtkWidget *framenr_2_button;
GtkWidget *from_button;
GtkWidget *to_button;
GtkWidget *progress_bar;
GtkWidget *use_thumb_checkbutton;
GtkWidget *exact_timing_checkbutton;
GtkWidget *pinpong_checkbutton;
GtkWidget *selonly_checkbutton;
GtkWidget *loop_checkbutton;
GtkWidget *spc_hbox0;
GtkWidget *spc_label;
GtkWidget *notebook;
GtkWidget *label_vid;
GtkWidget *label_cfg;
GtkWidget *frame0c;
GtkWidget *spc_hbox0c;
#ifdef GAP_ENABLE_AUDIO_SUPPORT
GtkWidget *frame0a;
GtkWidget *spc_hbox0a;
GtkWidget *label_aud;
#endif
GtkWidget *frame_scale_hbox;
#define ROW_EXTRA_SPACING 8
gint row;
gint notebook_idx;
/* columns for the spinbutton and buttons */
gint colspin;
gint colbutton;
colspin = 0;
colbutton = 1;
shell_window = NULL;
if(gpp->docking_container)
{
shell_window = gpp->docking_container;
}
else
{
shell_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gpp->shell_window = shell_window;
gtk_window_set_title (GTK_WINDOW (shell_window), _("Videoframe Playback"));
gtk_window_set_resizable(GTK_WINDOW (shell_window), TRUE);
}
g_signal_connect (G_OBJECT (shell_window), "destroy",
G_CALLBACK (on_shell_window_destroy),
gpp);
vbox0 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox0);
gtk_container_add (GTK_CONTAINER (shell_window), vbox0);
/* vid options TAB frame */
label_vid = gtk_label_new (_("Video Options"));
gtk_widget_show (label_vid);
if(gpp->stb_ptr)
{
frame0 = gimp_frame_new (gpp->stb_ptr->storyboardfile);
}
else
{
frame0 = gimp_frame_new (gpp->ainfo_ptr->basename);
}
gtk_widget_show (frame0);
gpp->frame_with_name = frame0;
spc_label = gtk_label_new(" ");
gtk_widget_show (spc_label);
spc_hbox0 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (spc_hbox0);
gtk_box_pack_start (GTK_BOX (spc_hbox0), spc_label, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (spc_hbox0), frame0, TRUE, TRUE, 4);
/* configure options TAB frame */
label_cfg = gtk_label_new (_("Preferences"));
gtk_widget_show (label_cfg);
spc_label = gtk_label_new(" ");
gtk_widget_show (spc_label);
frame0c = p_new_configframe (gpp);
gtk_widget_show (frame0c);
spc_hbox0c = gtk_hbox_new (FALSE, 0);
gtk_widget_show (spc_hbox0c);
gtk_box_pack_start (GTK_BOX (spc_hbox0c), spc_label, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (spc_hbox0c), frame0c, TRUE, TRUE, 4);
#ifdef GAP_ENABLE_AUDIO_SUPPORT
/* audio options TAB frame */
label_aud = gtk_label_new (_("Audio Options"));
gtk_widget_show (label_aud);
frame0a = p_new_audioframe (gpp);
gtk_widget_show (frame0a);
spc_label = gtk_label_new(" ");
gtk_widget_show (spc_label);
spc_hbox0a = gtk_hbox_new (FALSE, 0);
gtk_widget_show (spc_hbox0a);
gtk_box_pack_start (GTK_BOX (spc_hbox0a), spc_label, FALSE, FALSE, 2);
gtk_box_pack_start (GTK_BOX (spc_hbox0a), frame0a, TRUE, TRUE, 4);
#endif
notebook = gtk_notebook_new();
gtk_widget_show (notebook);
notebook_idx = 0;
gtk_container_add (GTK_CONTAINER (notebook), spc_hbox0);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook)
, gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), notebook_idx)
, label_vid
);
notebook_idx++;
#ifdef GAP_ENABLE_AUDIO_SUPPORT
gtk_container_add (GTK_CONTAINER (notebook), spc_hbox0a);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook)
, gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), notebook_idx)
, label_aud
);
notebook_idx++;
#endif
gtk_container_add (GTK_CONTAINER (notebook), spc_hbox0c);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook)
, gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), notebook_idx)
, label_cfg
);
notebook_idx++;
gtk_box_pack_start (GTK_BOX (vbox0), notebook, TRUE, TRUE, 0);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (frame0), vbox1);
/* the hbox for the go button array */
gobutton_hbox = gtk_hbox_new (TRUE, 0);
gpp->gobutton_hbox = gobutton_hbox;
if(gpp->show_go_buttons)
{
gtk_widget_show (gobutton_hbox);
}
else
{
gtk_widget_hide (gobutton_hbox);
}
if(gobutton_hbox)
{
gint go_number;
gint max_go_buttons;
GtkWidget *go_button;
t_gobutton *gob;
/* the gobutton array is be filled with [n] gobuttons */
max_go_buttons = GAP_PLAY_MAX_GOBUTTONS;
if(gpp->docking_container)
{
max_go_buttons = GAP_PLAY_MAX_GOBUTTONS_DOCKED;
}
for(go_number=0; go_number < max_go_buttons; go_number++)
{
/* the go_button[s] */
gob = g_malloc0(sizeof(t_gobutton));
gob->gpp = gpp;
gob->go_number = go_number;
go_button = gtk_button_new ();
gtk_widget_show (go_button);
gtk_widget_set_events(go_button, GDK_ENTER_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK);
gtk_box_pack_start (GTK_BOX (gobutton_hbox), go_button, FALSE, TRUE, 0);
gtk_widget_set_size_request (go_button, -1, 40);
if(go_number == 0)
{
gimp_help_set_help_data (go_button, _("Click: go to frame, Ctrl-Click: set 'From Frame', Alt-Click: set 'To Frame'"), NULL);
}
g_signal_connect (go_button, "enter_notify_event",
G_CALLBACK (on_go_button_enter)
,gob);
g_signal_connect (G_OBJECT (go_button), "button_press_event",
G_CALLBACK (on_go_button_clicked),
gob);
}
}
/* Create an EventBox and for the gobutton_hbox leave Event */
event_box = gtk_event_box_new ();
gtk_widget_show (event_box);
gtk_container_add (GTK_CONTAINER (event_box), gobutton_hbox);
gtk_widget_set_events(event_box
, GDK_LEAVE_NOTIFY_MASK /* | gtk_widget_get_events (event_box) */
);
gtk_box_pack_start (GTK_BOX (vbox1), event_box, FALSE, FALSE, 0);
g_signal_connect (event_box, "leave_notify_event",
G_CALLBACK (on_gobutton_hbox_leave)
,gpp);
/* the FRAMENR adjustment (for spinbutton and scale) */
{
gdouble l_value;
gdouble l_lower;
gdouble l_upper;
l_lower = MIN(gpp->ainfo_ptr->first_frame_nr, gpp->ainfo_ptr->last_frame_nr);
l_upper = MAX(gpp->ainfo_ptr->first_frame_nr, gpp->ainfo_ptr->last_frame_nr);
l_value = CLAMP(gpp->play_current_framenr, l_lower, l_upper);
if(gap_debug) printf("CREATE framenr_spinbutton_adj: value: %d, lower:%d, upper:%d\n"
,(int)l_value
,(int)l_lower
,(int)l_upper
);
framenr_spinbutton_adj = gtk_adjustment_new (l_value
, l_lower
, l_upper
, 1.0 /* step_increment */
, 10.0 /* page_increment */
, 0.0 /* page_size must be 0 for simple scalar value */
);
}
/* hbox for scale and time position label mm:ss:msec */
frame_scale_hbox = gtk_hbox_new (FALSE, 0);
gpp->frame_scale_hbox = frame_scale_hbox;
/* the framenr_scale (tool for positioning) */
framenr_scale = gtk_hscale_new (GTK_ADJUSTMENT (framenr_spinbutton_adj));
gpp->framenr_scale = framenr_scale;
gtk_scale_set_digits (GTK_SCALE (framenr_scale), 0 /* digits */);
/* gtk_scale_set_draw_value (GTK_SCALE (framenr_scale), FALSE); */
/* Dont know why, but without displaying the value
* the scale and spinbutton value sometimes seems to differ by 1
*
* Movinge the Scale sometimes displays frame nnnnn but spinbutton shows nnnnn +1
* (could not reproduce such differences with draw_value = TRUE)
*/
gtk_scale_set_draw_value (GTK_SCALE (framenr_scale), FALSE);
gtk_range_set_update_policy (GTK_RANGE (framenr_scale), GTK_UPDATE_DELAYED);
gimp_help_set_help_data (framenr_scale,
_("The currently displayed frame number"), NULL);
gtk_widget_show(framenr_scale);
gtk_box_pack_start (GTK_BOX (frame_scale_hbox), framenr_scale, TRUE, TRUE, 0);
g_signal_connect (framenr_scale, "button_press_event",
G_CALLBACK (on_framenr_scale_clicked)
,gpp);
/* the timepos label */
/* (had used an entry here before but had update performance problems
* beginning at playback speed of 17 frames/sec on PII 300 Mhz)
*/
timepos_label = gtk_label_new ("00:00:000");
gpp->timepos_label = timepos_label;
gtk_widget_show (timepos_label);
gtk_box_pack_start (GTK_BOX (frame_scale_hbox), timepos_label, FALSE, FALSE, 4);
if(gpp->show_position_scale)
{
gtk_widget_show(frame_scale_hbox);
}
else
{
gtk_widget_show(frame_scale_hbox);
}
gtk_box_pack_start (GTK_BOX (vbox1), frame_scale_hbox, FALSE, FALSE, 0);
table1 = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table1);
gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
/* the frame2 for range and playback mode control widgets */
frame2 = gimp_frame_new (NULL);
gtk_widget_show (frame2);
gtk_table_attach (GTK_TABLE (table1), frame2, 1, 2, 0, 1
, (GtkAttachOptions) (0)
, (GtkAttachOptions) (0)
, 0, 0);
/* table2 for range and playback mode control widgets */
table2 = gtk_table_new (18, 2, FALSE);
gtk_widget_show (table2);
gtk_table_set_col_spacings (GTK_TABLE (table2), 4);
gtk_container_add (GTK_CONTAINER (frame2), table2);
row = 0;
/* the framenr buttons */
{
GtkWidget *fnr_hbox;
fnr_hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (fnr_hbox);
gtk_table_attach (GTK_TABLE (table2), fnr_hbox, colbutton, colbutton+1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
/* the framenr 1 button (does set Begin of range) */
framenr_1_button = gtk_button_new_from_stock (GAP_STOCK_SET_RANGE_START);
gtk_widget_show (framenr_1_button);
gtk_box_pack_start (GTK_BOX (fnr_hbox), framenr_1_button, FALSE, FALSE, 0);
g_object_set_data (G_OBJECT (framenr_1_button), KEY_FRAMENR_BUTTON_TYPE, (gpointer)FRAMENR_BUTTON_BEGIN);
g_signal_connect (G_OBJECT (framenr_1_button), "button_press_event",
G_CALLBACK (on_framenr_button_clicked),
gpp);
if((gpp->image_id >= 0)
&& (gpp->docking_container == NULL))
{
gimp_help_set_help_data (framenr_1_button
, _("Click: Set current framenr as selection range start 'From Frame',\n"
"SHIFT-Click: load this frame into the calling image")
, NULL);
}
else
{
/* there is no "calling image" if we are invoked from storyboard
* or from the video extract plug-in
* in this case there is no special SHIFT-click function available
*/
gimp_help_set_help_data (framenr_1_button
, _("Set current framenr as selection range start 'From Frame'")
, NULL);
}
/* the framenr 2 button (does set End of range) */
framenr_2_button = gtk_button_new_from_stock (GAP_STOCK_SET_RANGE_END);
gtk_widget_show (framenr_2_button);
gtk_box_pack_start (GTK_BOX (fnr_hbox), framenr_2_button, TRUE, TRUE, 0);
g_object_set_data (G_OBJECT (framenr_2_button), KEY_FRAMENR_BUTTON_TYPE, (gpointer)FRAMENR_BUTTON_END);
g_signal_connect (G_OBJECT (framenr_2_button), "button_press_event",
G_CALLBACK (on_framenr_button_clicked),
gpp);
if((gpp->image_id >= 0)
&& (gpp->docking_container == NULL))
{
gimp_help_set_help_data (framenr_2_button
, _("Click: Set current framenr as selection range end 'To Frame',\n"
"SHIFT-Click: load this frame into the calling image")
, NULL);
}
else
{
/* there is no "calling image" if we are invoked from storyboard
* or from the video extract plug-in
* in this case there is no special SHIFT-click function available
*/
gimp_help_set_help_data (framenr_2_button
, _("Set current framenr as selection range end 'To Frame'")
, NULL);
}
}
/* the FRAMENR spinbutton (current displayed frame) */
framenr_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (framenr_spinbutton_adj)
, 1 /* climb_rate */
, 0 /* digits */
);
gtk_widget_show (framenr_spinbutton);
gtk_table_attach (GTK_TABLE (table2), framenr_spinbutton, colspin, colspin+1, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
gtk_widget_set_size_request (framenr_spinbutton, 80, -1);
gimp_help_set_help_data (framenr_spinbutton, _("The currently displayed frame number"), NULL);
g_signal_connect (G_OBJECT (framenr_spinbutton_adj), "value_changed",
G_CALLBACK (on_framenr_spinbutton_changed),
gpp);
gtk_table_set_row_spacing (GTK_TABLE (table2), row, ROW_EXTRA_SPACING);
row++;
/* the from button */
from_button = gtk_button_new_from_stock (GAP_STOCK_RANGE_START);
gpp->from_button = from_button;
/* the from button */
gtk_widget_show (from_button);
gtk_table_attach (GTK_TABLE (table2), from_button, colbutton, colbutton+1, row, row+1
, (GtkAttachOptions) (GTK_FILL)
, (GtkAttachOptions) (0)
, 0, 0);
if(gpp->caller_range_linked)
{
gtk_widget_set_sensitive (from_button, FALSE);
}
else
{
if(gpp->fptr_set_range)
{
gimp_help_set_help_data (from_button, _("Add range to cliplist"), NULL);
}
else
{
gimp_help_set_help_data (from_button, _("Print range to stdout"), NULL);
}
g_signal_connect (G_OBJECT (from_button), "clicked",
G_CALLBACK (on_from_button_clicked),
gpp);
}
/* the FROM spinbutton (start of rangeselection) */
from_spinbutton_adj = gtk_adjustment_new ( gpp->begin_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
, 1.0 /* step_increment */
, 10.0 /* page_increment */
, 0.0 /* page_size must be 0 for simple scalar value */
);
from_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (from_spinbutton_adj), 1, 0);
gtk_widget_show (from_spinbutton);
gtk_table_attach (GTK_TABLE (table2), from_spinbutton, colspin, colspin+1, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0),
0, 0);
gtk_widget_set_size_request (from_spinbutton, 80, -1);
gimp_help_set_help_data (from_spinbutton, _("Start framenumber of selection range"), NULL);
g_signal_connect (G_OBJECT (from_spinbutton_adj), "value_changed",
G_CALLBACK (on_from_spinbutton_changed),
gpp);
row++;
/* the to button */
to_button = gtk_button_new_from_stock (GAP_STOCK_RANGE_END);
gpp->to_button = to_button;
gtk_widget_show (to_button);
gtk_table_attach (GTK_TABLE (table2), to_button, colbutton, colbutton+1, row, row+1
, (GtkAttachOptions) (GTK_FILL)
, (GtkAttachOptions) (0)
, 0, 0);
if(gpp->caller_range_linked)
{
gtk_widget_set_sensitive (to_button, FALSE);
}
else
{
if(gpp->fptr_set_range)
{
gimp_help_set_help_data (to_button, _("Add inverse range to cliplist"), NULL);
}
else
{
gimp_help_set_help_data (to_button, _("Print inverse range to stdout"), NULL);
}
g_signal_connect (G_OBJECT (to_button), "clicked",
G_CALLBACK (on_to_button_clicked),
gpp);
}
/* the TO spinbutton (end of rangeselection) */
to_spinbutton_adj = gtk_adjustment_new ( gpp->end_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
, 1.0 /* step_increment */
, 10.0 /* page_increment */
, 0.0 /* page_size must be 0 for simple scalar value */
);
to_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (to_spinbutton_adj), 1, 0);
gtk_widget_show (to_spinbutton);
gtk_table_attach (GTK_TABLE (table2), to_spinbutton, colspin, colspin+1, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0),
0, 0);
gtk_widget_set_size_request (to_spinbutton, 80, -1);
gimp_help_set_help_data (to_spinbutton, _("End framenumber of selection range"), NULL);
g_signal_connect (G_OBJECT (to_spinbutton_adj), "value_changed",
G_CALLBACK (on_to_spinbutton_changed),
gpp);
gtk_table_set_row_spacing (GTK_TABLE (table2), row, ROW_EXTRA_SPACING);
row++;
/* the origspeed_button */
origspeed_button = gtk_button_new_from_stock (GAP_STOCK_SPEED);
gtk_widget_show (origspeed_button);
gtk_table_attach (GTK_TABLE (table2), origspeed_button, colbutton, colbutton+1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (origspeed_button, _("Reset playback speed to original (or previous) value"), NULL);
g_signal_connect (G_OBJECT (origspeed_button), "clicked",
G_CALLBACK (on_origspeed_button_clicked),
gpp);
/* the SPEED spinbutton
* with the given timer resolution of millisecs the theoretical
* maximum speed is 1000 frames/sec that would result in 1 timertick
* this implementation allows a max speed of 250 frames/sec (4 timerticks)
*/
speed_spinbutton_adj = gtk_adjustment_new ( gpp->speed
, 1.0
, 250.0
, 1.0 /* step_increment */
, 10.0 /* page_increment */
, 0.0 /* page_size must be 0 for simple scalar value */
);
speed_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (speed_spinbutton_adj), 1, 4);
gtk_widget_show (speed_spinbutton);
gtk_table_attach (GTK_TABLE (table2), speed_spinbutton, colspin, colspin+1, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
gtk_widget_set_size_request (speed_spinbutton, 80, -1);
gimp_help_set_help_data (speed_spinbutton, _("Current playback speed (frames/sec)"), NULL);
g_signal_connect (G_OBJECT (speed_spinbutton_adj), "value_changed",
G_CALLBACK (on_speed_spinbutton_changed),
gpp);
row++;
/* the size button */
{
/* we use the same icon as the gimp scaling tool */
GtkWidget *image;
image = gtk_image_new_from_stock (GIMP_STOCK_TOOL_SCALE,
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
size_button = gtk_button_new();
gtk_container_add (GTK_CONTAINER (size_button), image);
}
gtk_widget_show (size_button);
gtk_widget_set_events(size_button, GDK_BUTTON_PRESS_MASK);
gtk_table_attach (GTK_TABLE (table2), size_button, colbutton, colbutton+1, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0),
0, 0);
gimp_help_set_help_data (size_button, _("Toggle size 128/256. <Shift> Set 1:1 full image size"), NULL);
g_signal_connect (G_OBJECT (size_button), "button_press_event",
G_CALLBACK (on_size_button_button_press_event),
gpp);
/* the SIZE spinbutton */
size_spinbutton_adj = gtk_adjustment_new (gpp->pv_pixelsize
, GAP_PLAYER_MIN_SIZE
, GAP_PLAYER_MAX_SIZE
, 1.0 /* step_increment */
, 10.0 /* page_increment */
, 0.0 /* page_size must be 0 for simple scalar value */
);
size_spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (size_spinbutton_adj), 1, 0);
gpp->size_spinbutton = size_spinbutton;
gtk_widget_show (size_spinbutton);
gtk_table_attach (GTK_TABLE (table2), size_spinbutton, colspin, colspin+1, row, row+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0),
0, 0);
gtk_widget_set_size_request (size_spinbutton, 80, -1);
gimp_help_set_help_data (size_spinbutton, _("Video preview size (pixels)"), NULL);
g_signal_connect (G_OBJECT (size_spinbutton_adj), "value_changed",
G_CALLBACK (on_size_spinbutton_changed),
gpp);
if(gpp->docking_container == NULL)
{
gtk_widget_set_events(size_spinbutton
, GDK_ENTER_NOTIFY_MASK
);
g_signal_connect (G_OBJECT (size_spinbutton), "enter_notify_event",
G_CALLBACK (on_size_spinbutton_enter),
gpp);
}
gtk_table_set_row_spacing (GTK_TABLE (table2), row, ROW_EXTRA_SPACING);
row++;
/* the playback mode checkbuttons */
/* Loop Toggle */
loop_checkbutton = gtk_check_button_new_with_label (_("Loop"));
gpp->loop_checkbutton = loop_checkbutton;
gtk_widget_show (loop_checkbutton);
gtk_table_attach (GTK_TABLE (table2), loop_checkbutton, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (loop_checkbutton, _("ON: Play in endless loop.\n"
"OFF: Play only once"), NULL);
if(gpp->play_loop)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (loop_checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (loop_checkbutton), "toggled",
G_CALLBACK (on_loop_checkbutton_toggled),
gpp);
row++;
/* SelOnly Toggle (keep text short) */
selonly_checkbutton = gtk_check_button_new_with_label (_("Selection only"));
gpp->selonly_checkbutton = selonly_checkbutton;
gtk_widget_show (selonly_checkbutton);
gtk_table_attach (GTK_TABLE (table2), selonly_checkbutton, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (selonly_checkbutton, _("ON: Play only frames within the selected range.\n"
"OFF: Play all frames"), NULL);
if(gpp->play_selection_only)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selonly_checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (selonly_checkbutton), "toggled",
G_CALLBACK (on_selonly_checkbutton_toggled),
gpp);
row++;
/* PingPong Toggle (keep text short) */
pinpong_checkbutton = gtk_check_button_new_with_label (_("Ping pong"));
gpp->pinpong_checkbutton = pinpong_checkbutton;
gtk_widget_show (pinpong_checkbutton);
gtk_table_attach (GTK_TABLE (table2), pinpong_checkbutton, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (pinpong_checkbutton, _("ON: Play alternating forward/backward"), NULL);
if(gpp->play_pingpong)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pinpong_checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (pinpong_checkbutton), "toggled",
G_CALLBACK (on_pinpong_checkbutton_toggled),
gpp);
row++;
/* UseThumbnails Toggle (keep text short) */
use_thumb_checkbutton = gtk_check_button_new_with_label (_("Thumbnails"));
gpp->use_thumb_checkbutton = use_thumb_checkbutton;
gtk_widget_show (use_thumb_checkbutton);
gtk_table_attach (GTK_TABLE (table2), use_thumb_checkbutton, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (use_thumb_checkbutton, _("ON: Use thumbnails when available.\n"
"OFF: Read full sized frames"), NULL);
if(gpp->use_thumbnails)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (use_thumb_checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (use_thumb_checkbutton), "toggled",
G_CALLBACK (on_use_thumb_checkbutton_toggled),
gpp);
row++;
/* ExactTiming Toggle (keep text short) */
exact_timing_checkbutton = gtk_check_button_new_with_label (_("Exact timing"));
gpp->exact_timing_checkbutton = exact_timing_checkbutton;
gtk_widget_show (exact_timing_checkbutton);
gtk_table_attach (GTK_TABLE (table2), exact_timing_checkbutton, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gimp_help_set_help_data (exact_timing_checkbutton, _("ON: Skip frames to hold exact timing.\n"
"OFF: Disable frame skipping"), NULL);
if(gpp->exact_timing)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (exact_timing_checkbutton), TRUE);
}
g_signal_connect (G_OBJECT (exact_timing_checkbutton), "toggled",
G_CALLBACK (on_exact_timing_checkbutton_toggled),
gpp);
row++;
/* the status value label */
status_label = gtk_label_new (_("Ready"));
gtk_widget_show (status_label);
gtk_table_attach (GTK_TABLE (table2), status_label, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (status_label), 0.0, 0.5);
row++;
/* the progress bar */
progress_bar = NULL;
if(gpp->have_progress_bar)
{
progress_bar = gtk_progress_bar_new ();
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bar), " ");
gtk_widget_show (progress_bar);
gtk_table_attach (GTK_TABLE (table2), progress_bar, 0, 2, row, row+1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
}
gpp->progress_bar = progress_bar;
/* a dummy label to fill up table1 until bottom */
label = gtk_label_new (" ");
gtk_widget_show (label);
// gtk_table_attach (GTK_TABLE (table1), label, 1, 2, 1, 2,
// (GtkAttachOptions) (0),
// (GtkAttachOptions) (GTK_FILL | GTK_SHRINK | GTK_EXPAND), 0, 0);
/* the hbox */
hbox1 = gtk_hbox_new (TRUE, 0);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox0), hbox1, FALSE, FALSE, 0);
/* the playback/pause button box (hidden while videoindex creation is running) */
play_n_stop_hbox = gtk_hbox_new (TRUE, 0);
gpp->play_n_stop_hbox = play_n_stop_hbox;
gtk_widget_show (play_n_stop_hbox);
gtk_box_pack_start (GTK_BOX (hbox1), play_n_stop_hbox, FALSE, TRUE, 0);
/* the Cancel Videoindex Creation button (only visible while creating vindex) */
cancel_vindex_button = gtk_button_new_with_label ( _("Cancel Videoindex creation"));
gpp->cancel_vindex_button = cancel_vindex_button;
gtk_widget_hide (cancel_vindex_button);
gtk_box_pack_start (GTK_BOX (hbox1), cancel_vindex_button, FALSE, TRUE, 0);
gimp_help_set_help_data (cancel_vindex_button, _("Cancel videoindex creation. "
"Videoindex creation requires full scanning of the video "
"but allows fast random access to frames afterwards. "
"Without a videoindex, access is done by a very slow sequential read"), NULL);
g_signal_connect (G_OBJECT (cancel_vindex_button), "clicked",
G_CALLBACK (on_cancel_vindex_button_clicked),
gpp);
if(gpp->help_id && gimp_show_help_button ())
{
GtkWidget *help_button;
/* the HELP button */
help_button = gtk_button_new_from_stock (GTK_STOCK_HELP);
gtk_widget_show (help_button);
gtk_box_pack_start (GTK_BOX (play_n_stop_hbox), help_button, FALSE, TRUE, 0);
gimp_help_set_help_data (help_button, _("Show help page"), NULL);
g_signal_connect (G_OBJECT (help_button), "clicked",
G_CALLBACK (on_help_button_clicked),
gpp);
}
/* the PLAY button */
play_button = gtk_button_new_from_stock (GAP_STOCK_PLAY);
gtk_widget_show (play_button);
gtk_box_pack_start (GTK_BOX (play_n_stop_hbox), play_button, FALSE, TRUE, 0);
gimp_help_set_help_data (play_button, _("Start playback. "
"SHIFT: snapshot frames in a multilayer image at original size "
"CTRL: snapshot at preview size "
"ALT: force creation of new snapshot image"), NULL);
g_signal_connect (G_OBJECT (play_button), "button_press_event",
G_CALLBACK (on_play_button_clicked),
gpp);
/* the PAUSE button */
pause_button = gtk_button_new_from_stock (GAP_STOCK_PAUSE);
gtk_widget_show (pause_button);
gtk_widget_set_events(pause_button, GDK_BUTTON_PRESS_MASK);
gtk_box_pack_start (GTK_BOX (play_n_stop_hbox), pause_button, FALSE, TRUE, 0);
gimp_help_set_help_data (pause_button, _("Pause if playing (any mousebutton). "
"Go to selection start/active/end (left/middle/right mousebutton) if not playing"), NULL);
g_signal_connect (G_OBJECT (pause_button), "button_press_event",
G_CALLBACK (on_pause_button_press_event),
gpp);
/* the PLAY_REVERSE button */
back_button = gtk_button_new_from_stock (GAP_STOCK_PLAY_REVERSE);
gtk_widget_show (back_button);
gtk_box_pack_start (GTK_BOX (play_n_stop_hbox), back_button, FALSE, TRUE, 0);
gimp_help_set_help_data (back_button, _("Start reverse playback. "
"SHIFT: snapshot frames in a multilayer image at original size "
"CTRL: snapshot at preview size "
"ALT: force creation of new snapshot image"), NULL);
g_signal_connect (G_OBJECT (back_button), "button_press_event",
G_CALLBACK (on_back_button_clicked),
gpp);
if(gpp->docking_container == NULL)
{
/* the CLOSE button */
close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_widget_show (close_button);
gtk_box_pack_start (GTK_BOX (play_n_stop_hbox), close_button, FALSE, TRUE, 0);
gimp_help_set_help_data (close_button, _("Close window"), NULL);
g_signal_connect (G_OBJECT (close_button), "clicked",
G_CALLBACK (on_close_button_clicked),
gpp);
}
/* aspect_frame is the CONTAINER for the video preview */
aspect_frame = gtk_aspect_frame_new (NULL /* without label */
, 0.5 /* xalign center */
, 0.5 /* yalign center */
, gpp->ainfo_ptr->width / gpp->ainfo_ptr->height /* ratio */
, TRUE /* obey_child */
);
gtk_widget_show (aspect_frame);
/* table11 is used to center aspect_frame */
table11 = gtk_table_new (3, 3, FALSE);
gtk_widget_show (table11);
{
gint ix;
gint iy;
GtkWidget *dummy;
for(ix = 0; ix < 3; ix++)
{
for(iy = 0; iy < 3; iy++)
{
if((ix == 1) && (iy == 1))
{
gtk_table_attach (GTK_TABLE (table11), aspect_frame, ix, ix+1, iy, iy+1,
(GtkAttachOptions) (0),
(GtkAttachOptions) (0), 0, 0);
}
else
{
/* dummy widgets to fill up table11 */
dummy = gtk_vbox_new (FALSE,3);
gtk_widget_show (dummy);
gtk_table_attach (GTK_TABLE (table11), dummy, ix, ix+1, iy, iy+1,
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK | GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL | GTK_SHRINK | GTK_EXPAND), 0, 0);
}
}
}
}
{
GtkWidget *wrap_frame;
GtkWidget *wrap_event_box;
wrap_event_box = gtk_event_box_new ();
gtk_widget_show (wrap_event_box);
wrap_frame= gimp_frame_new(NULL);
gtk_container_set_border_width (GTK_CONTAINER (wrap_frame), 0);
gpp->resize_box = wrap_frame;
gtk_widget_show(wrap_frame);
gtk_container_add (GTK_CONTAINER (wrap_frame), table11);
gtk_container_add (GTK_CONTAINER (wrap_event_box), wrap_frame);
gtk_table_attach (GTK_TABLE (table1), wrap_event_box, 0, 1, 0, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL),
(GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
g_signal_connect (G_OBJECT (wrap_event_box), "scroll_event",
G_CALLBACK (on_warp_frame_scroll_event),
gpp);
}
gtk_widget_realize (shell_window);
/* the preview drawing_area_widget */
/* ############################### */
gpp->pv_ptr = gap_pview_new(GAP_SMALL_PREVIEW_SIZE, GAP_SMALL_PREVIEW_SIZE, GAP_PLAYER_CHECK_SIZE, aspect_frame);
vid_preview = gpp->pv_ptr->da_widget;
gtk_container_add (GTK_CONTAINER (aspect_frame), vid_preview);
gtk_widget_show (vid_preview);
/* gpp copies of objects used outside this procedure */
gpp->from_spinbutton_adj = from_spinbutton_adj;
gpp->to_spinbutton_adj = to_spinbutton_adj;
gpp->framenr_spinbutton_adj = framenr_spinbutton_adj;
gpp->speed_spinbutton_adj = speed_spinbutton_adj;
gpp->size_spinbutton_adj = size_spinbutton_adj;
gtk_widget_realize (gpp->pv_ptr->da_widget);
p_update_pviewsize(gpp);
/* the call to gtk_widget_set_events results in WARNING:
* (gimp-1.3:13789): Gtk-CRITICAL **: file gtkwidget.c: line 5257 (gtk_widget_set_events): assertion `!GTK_WIDGET_REALIZED (widget)' failed
*
* must use gtk_widget_add_events because the widget is already realized at this time
*/
gtk_widget_add_events (vid_preview, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
g_signal_connect (G_OBJECT (vid_preview), "button_press_event",
G_CALLBACK (on_vid_preview_button_press_event),
gpp);
g_signal_connect (G_OBJECT (vid_preview), "expose_event",
G_CALLBACK (on_vid_preview_expose_event),
gpp);
gpp->status_label = status_label;
return shell_window;
} /* end p_create_player_window */
/* -----------------------------
* p_connect_resize_handler
* -----------------------------
*/
static void
p_connect_resize_handler(GapPlayerMainGlobalParams *gpp)
{
if(gpp->docking_container)
{
/* never connect resize handler when player is docked to a foreign container */
return;
}
if(gpp->resize_handler_id < 0)
{
gpp->resize_handler_id = g_signal_connect (G_OBJECT (gpp->resize_box), "size_allocate",
G_CALLBACK (on_vid_preview_size_allocate),
gpp);
}
} /* end p_connect_resize_handler */
/* -----------------------------
* p_disconnect_resize_handler
* -----------------------------
*/
static void
p_disconnect_resize_handler(GapPlayerMainGlobalParams *gpp)
{
if(gpp->resize_handler_id >= 0)
{
g_signal_handler_disconnect(gpp->resize_box, gpp->resize_handler_id);
gpp->resize_handler_id = -1;
}
} /* end p_disconnect_resize_handler */
/* ---------------------------------
* gap_player_dlg_restart
* ---------------------------------
* This procedure re-initializes an
* already running player dialog for playback
* of a new storyboard or normal image frame playback.
* IN: autostart if TRUE automatically start playback.
* IN: image_id a gimp image_id of a GIMP_GAP typical animation frame
* specify -1 if you want play videofiles or storyboard files.
* IN: imagename name of an image or videofile.
* IN: stb Ponter to a storyboard structure that should be played,
* specify NULL for playback of simple frame ranges
* or single videofiles.
* IN: flip_request flag to specify simple transformation requests (0 none, 1 hor, 2 ver 3 rotate 180)
* ignored for storyboard playback (stb_ptr != NULL)
* IN: flip status same bits as flip_requst, specifies the transformation status of the
* original input frames.
* The rendering calculates the transformation by XOR
* operation flip_request XOR flip_status.
* (in other words: if the status is the same as the request
* no transformation is performed.)
* ignored for storyboard playback (stb_ptr != NULL)
* IN: stb_in_track the storyboard track that should be played
* a value of -1 selects the composite video fro playback
* stb_in_track is ignored if stb_ptr == NULL
*/
void
gap_player_dlg_restart(GapPlayerMainGlobalParams *gpp
, gboolean autostart
, gint32 image_id
, char *imagename
, gint32 imagewidth
, gint32 imageheight
, GapStoryBoard *stb_ptr
, gint32 begin_frame
, gint32 end_frame
, gboolean play_selection_only
, gint32 seltrack
, gdouble delace
, const char *preferred_decoder
, gboolean force_open_as_video
, gint32 flip_request
, gint32 flip_status
, gint32 stb_in_track
)
{
gboolean reverse_play;
gint32 l_begin_frame;
gint32 l_end_frame;
gint32 l_curr_frame;
if(gap_debug) printf("gap_player_dlg_restart: START begin_frame:%d end_frame:%d\n", (int)begin_frame, (int)end_frame);
reverse_play = FALSE;
if(begin_frame > end_frame)
{
gint32 val;
val = end_frame;
end_frame = begin_frame;
begin_frame = val;
reverse_play = TRUE;
}
if(gpp == NULL)
{
return;
}
p_stop_playback(gpp);
if(gpp->audio_tmp_dialog_is_open)
{
/* ignore close as long as sub dialog is open */
return;
}
if(gpp->preferred_decoder)
{
g_free(gpp->preferred_decoder);
gpp->preferred_decoder = NULL;
}
if(preferred_decoder)
{
gpp->preferred_decoder = g_strdup(preferred_decoder);
}
gpp->force_open_as_video = force_open_as_video;
gpp->delace = delace;
gpp->seltrack = seltrack;
gpp->stb_ptr = stb_ptr;
gpp->image_id = image_id;
gpp->imagewidth = imagewidth;
gpp->imageheight = imageheight;
gpp->play_selection_only = play_selection_only;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->selonly_checkbutton), play_selection_only);
if(gpp->imagename)
{
g_free(gpp->imagename);
gpp->imagename = NULL;
}
if(gpp->stb_ptr)
{
GapStoryBoard *stb;
stb = gpp->stb_ptr;
if(gpp->ainfo_ptr)
{
gap_lib_free_ainfo(&gpp->ainfo_ptr);
}
gpp->stb_in_track = stb_in_track;
gpp->ainfo_ptr = gap_story_fake_ainfo_from_stb(stb, stb_in_track);
if(stb->master_framerate > 0.0)
{
gpp->original_speed = stb->master_framerate;
gpp->prev_speed = stb->master_framerate;
}
}
else
{
if(imagename)
{
gpp->imagename = g_strdup(imagename);
p_reload_ainfo_ptr(gpp, -1);
if(gpp->ainfo_ptr == NULL)
{
return;
}
}
else
{
p_reload_ainfo_ptr(gpp, image_id);
if(gpp->ainfo_ptr == NULL)
{
return;
}
if(0 != gap_lib_chk_framerange(gpp->ainfo_ptr))
{
return;
}
}
}
l_curr_frame = gpp->ainfo_ptr->curr_frame_nr;
l_begin_frame = gpp->ainfo_ptr->curr_frame_nr;
l_end_frame = gpp->ainfo_ptr->last_frame_nr;
if(begin_frame >= 0)
{
l_begin_frame = CLAMP(begin_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
);
}
if(end_frame >= 0)
{
l_end_frame = CLAMP(end_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr
);
}
l_curr_frame = CLAMP(l_curr_frame
,l_begin_frame
,l_end_frame
);
gpp->begin_frame = l_begin_frame;
gpp->end_frame = l_end_frame;
gpp->play_current_framenr = l_curr_frame;
/* modify player widgets */
p_update_pviewsize(gpp);
p_update_ainfo_dependent_widgets(gpp);
if(gap_debug)
{
printf(" -- -- RESTART l_begin_frame:%d l_end_frame:%d l_curr_frame:%d\n"
,(int)l_begin_frame
,(int)l_end_frame
,(int)l_curr_frame
);
}
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->from_spinbutton_adj)
, (gfloat)l_begin_frame
);
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->to_spinbutton_adj)
, (gfloat)l_end_frame
);
gtk_adjustment_set_value( GTK_ADJUSTMENT(gpp->framenr_spinbutton_adj)
, (gfloat)l_curr_frame
);
/* workaround: gtk_adjustment_set_value sometimes does not immediate
* show the new value (especially in the to_spinbutton widget)
* to force an update we emit a "value_changed" signal
*/
g_signal_emit_by_name (gpp->to_spinbutton_adj, "value_changed", 0);
g_signal_emit_by_name (gpp->from_spinbutton_adj, "value_changed", 0);
g_signal_emit_by_name (gpp->framenr_spinbutton_adj, "value_changed", 0);
p_update_position_widgets(gpp);
p_set_frame_with_name_label(gpp);
gpp->flip_request = flip_request;
gpp->flip_status = flip_status;
/* now display current frame */
p_display_frame(gpp, gpp->play_current_framenr);
gap_pview_repaint(gpp->pv_ptr);
gdk_flush();
if((gpp->autostart)
&& ((gpp->play_current_framenr != gpp->begin_frame) || (gpp->play_current_framenr != gpp->end_frame)))
{
if(reverse_play)
{
on_back_button_clicked(NULL, NULL, gpp);
}
else
{
on_play_button_clicked(NULL, NULL, gpp);
}
}
} /* end gap_player_dlg_restart */
/* -----------------------------
* gap_player_dlg_create
* -----------------------------
* create the player widget (gpp->shell_window)
*/
void
gap_player_dlg_create(GapPlayerMainGlobalParams *gpp)
{
gboolean reverse_play;
reverse_play = FALSE;
if(gpp->begin_frame > gpp->end_frame)
{
gint32 val;
val = gpp->end_frame;
gpp->end_frame = gpp->begin_frame;
gpp->begin_frame = val;
reverse_play = TRUE;
}
gpp->startup = TRUE;
gpp->onion_delete = FALSE;
gpp->shell_initial_width = -1;
gpp->shell_initial_height = -1;
p_init_video_playback_cache(gpp);
p_init_layout_options(gpp);
gpp->mtrace_image_id = -1;
gpp->mtrace_mode = GAP_PLAYER_MTRACE_OFF;
gpp->vindex_creation_is_running = FALSE;
gpp->request_cancel_video_api = FALSE;
gpp->cancel_video_api = FALSE;
gpp->gvahand = NULL;
gpp->gva_videofile = NULL;
gpp->seltrack = 1;
gpp->delace = 0.0;
gpp->ainfo_ptr = NULL;
gpp->original_speed = 24.0; /* default if framerate is unknown */
gpp->prev_speed = 24.0; /* default if framerate is unknown */
gpp->stb_comp_vidhand = NULL;
gpp->stb_parttype = -1;
gpp->stb_unique_id = -1;
if(gpp->stb_ptr)
{
GapStoryBoard *stb;
stb = gpp->stb_ptr;
gpp->ainfo_ptr = gap_story_fake_ainfo_from_stb(stb, gpp->stb_in_track);
if(stb->master_framerate > 0.0)
{
gpp->original_speed = stb->master_framerate;
gpp->prev_speed = stb->master_framerate;
}
}
else
{
if(gpp->imagename)
{
p_reload_ainfo_ptr(gpp, -1);
if(gpp->ainfo_ptr == NULL)
{
return;
}
}
else
{
p_reload_ainfo_ptr(gpp, gpp->image_id);
if(gpp->ainfo_ptr == NULL)
{
return;
}
if (gpp->standalone_mode == TRUE)
{
if(0 != gap_lib_chk_framerange(gpp->ainfo_ptr))
{
return;
}
}
}
}
gpp->resize_handler_id = -1;
gpp->play_is_active = FALSE;
gpp->play_timertag = -1;
gpp->go_timertag = -1;
gpp->go_base_framenr = -1;
gpp->go_base = -1;
gpp->pingpong_count = 0;
gpp->gtimer = g_timer_new();
gpp->cycle_time_secs = 0.3;
gpp->rest_secs = 0.0;
gpp->framecnt = 0.0;
gpp->audio_volume = 1.0;
gpp->audio_resync = 0;
gpp->audio_frame_offset = 0;
gpp->audio_filesel = NULL;
gpp->audio_tmp_dialog_is_open = FALSE;
gpp->audio_otone_atrack = 1;
gpp->audio_enable_checkbutton = NULL;
gpp->audio_auto_offset_by_framenr_checkbutton = NULL;
gpp->audio_otone_extract_button = NULL;
gpp->audio_otone_atrack_spinbutton = NULL;
gpp->audio_otone_atrack_spinbutton_adj = NULL;
gpp->progress_bar_audio = NULL;
if((gpp->autostart) || (gpp->imagename))
{
gpp->begin_frame = CLAMP(gpp->begin_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr);
gpp->end_frame = CLAMP(gpp->end_frame
, gpp->ainfo_ptr->first_frame_nr
, gpp->ainfo_ptr->last_frame_nr);
gpp->play_current_framenr = CLAMP(gpp->ainfo_ptr->curr_frame_nr
, gpp->begin_frame
, gpp->end_frame);
}
else
{
gpp->begin_frame = gpp->ainfo_ptr->curr_frame_nr;
gpp->end_frame = gpp->ainfo_ptr->last_frame_nr;
gpp->play_current_framenr = gpp->ainfo_ptr->curr_frame_nr;
}
gpp->pb_stepsize = 1;
/* always startup at original speed */
gpp->speed = gpp->original_speed;
gpp->prev_speed = gpp->original_speed;
if((gpp->pv_pixelsize < GAP_PLAYER_MIN_SIZE) || (gpp->pv_pixelsize > GAP_PLAYER_MAX_SIZE))
{
gpp->pv_pixelsize = GAP_STANDARD_PREVIEW_SIZE;
}
if ((gpp->pv_width < GAP_PLAYER_MIN_SIZE) || (gpp->pv_width > GAP_PLAYER_MAX_SIZE))
{
gpp->pv_width = GAP_STANDARD_PREVIEW_SIZE;
}
if ((gpp->pv_height < GAP_PLAYER_MIN_SIZE) || (gpp->pv_height > GAP_PLAYER_MAX_SIZE))
{
gpp->pv_height = GAP_STANDARD_PREVIEW_SIZE;
}
gpp->in_feedback = FALSE;
gpp->in_timer_playback = FALSE;
gpp->old_resize_width = 0;
gpp->old_resize_height = 0;
gpp->dvref_ptr = g_new(GapDrawableVideoRef, 1);
gpp->dvref_ptr->videofile = NULL;
p_create_player_window(gpp);
p_set_frame_with_name_label(gpp);
p_display_frame(gpp, gpp->play_current_framenr);
gap_pview_repaint(gpp->pv_ptr);
gdk_flush();
p_check_tooltips();
/* set audio status to unchecked state
* and do p_audio_startup_server(gpp); deferred on 1st attempt to enter audiofile
*/
gpp->audio_status = GAP_PLAYER_MAIN_AUSTAT_UNCHECKED;
if(gpp->autostart)
{
if(reverse_play)
{
on_back_button_clicked(NULL, NULL, gpp);
}
else
{
on_play_button_clicked(NULL, NULL, gpp);
}
}
if((gpp->docking_container == NULL)
&& (gpp->shell_window))
{
gtk_widget_show (gpp->shell_window);
g_signal_connect (G_OBJECT (gpp->shell_window), "size_allocate",
G_CALLBACK (on_shell_window_size_allocate),
gpp);
g_signal_connect (G_OBJECT (gpp->shell_window), "leave_notify_event",
G_CALLBACK (on_shell_window_leave),
gpp);
}
gpp->startup = FALSE;
/* close videofile after startup.
* this is done to enable videoindex creation
* at next p_open_videofile call
*/
p_close_videofile(gpp);
p_connect_resize_handler(gpp);
} /* end gap_player_dlg_create */
/* -----------------------------
* gap_player_dlg_cleanup
* -----------------------------
*/
void
gap_player_dlg_cleanup(GapPlayerMainGlobalParams *gpp)
{
p_audio_shut_server(gpp);
if(gpp->gtimer)
{
g_timer_destroy(gpp->gtimer);
gpp->gtimer = NULL;
}
if(gpp->ainfo_ptr)
{
gap_lib_free_ainfo(&gpp->ainfo_ptr);
}
gap_player_cache_free_all();
} /* end gap_player_dlg_cleanup */
/* ------------------------------
* gap_player_dlg_playback_dialog
* ------------------------------
* This procedure does Playback
* in standalone mode.
* (when invoked from an anim frame image via the Video/Playback Menu)
*/
void
gap_player_dlg_playback_dialog(GapPlayerMainGlobalParams *gpp)
{
gimp_ui_init ("gap_player_dialog", FALSE);
gap_stock_init();
p_check_tooltips();
gpp->fptr_set_range = NULL;
gpp->user_data_ptr = NULL;
gpp->imagename = NULL;
gpp->docking_container = NULL;
gpp->preferred_decoder = NULL;
gpp->have_progress_bar = FALSE;
gpp->progress_bar_idle_txt = g_strdup(" ");
gpp->exact_timing = TRUE;
gpp->caller_range_linked = FALSE;
gpp->aspect_ratio = GAP_PLAYER_DONT_FORCE_ASPECT;
gap_player_dlg_create(gpp);
if(gpp->shell_window)
{
gpp->standalone_mode = TRUE;
gtk_main ();
gap_player_dlg_cleanup(gpp);
}
gpp->ainfo_ptr = NULL;
gpp->stb_ptr = NULL;
gpp->gvahand = NULL;
gpp->gva_videofile = NULL;
} /* end gap_player_dlg_playback_dialog */
|