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
|
From d64828b1d04a5e48dfcae9dce5b301a3d6a17e42 Mon Sep 17 00:00:00 2001
From: Sefa Eyeoglu <contact@scrumplex.net>
Date: Tue, 5 Jan 2021 17:46:06 +0100
Subject: [PATCH 4/6] refactor: remove ftl_app completely
---
.gitignore | 3 +-
CMakeLists.txt | 174 +++----
Dockerfile | 46 --
Jenkinsfile | 30 --
README.md | 13 -
build.bat | 13 -
ftl_app/bitstream.c | 142 ------
ftl_app/bitstream.h | 21 -
ftl_app/cavlc.c | 0
ftl_app/cavlc.h | 0
ftl_app/dec_obj.h | 247 ----------
ftl_app/decode.c | 98 ----
ftl_app/decode.h | 4 -
ftl_app/file_parser.c | 370 ---------------
ftl_app/file_parser.h | 47 --
ftl_app/gettimeofday.c | 94 ----
ftl_app/gettimeofday.h | 10 -
ftl_app/main.c | 460 ------------------
ftl_app/main.h | 58 ---
ftl_app/nalu.c | 849 ----------------------------------
ftl_app/nalu.h | 9 -
ftl_app/posix/ctrlc_handler.c | 55 ---
ftl_app/utils.c | 112 -----
ftl_app/utils.h | 7 -
ftl_app/win32/ctrlc_handler.c | 73 ---
ftl_app/win32/xgetopt.c | 213 ---------
ftl_app/win32/xgetopt.h | 23 -
get-audio | 16 -
get-video | 15 -
make-deployment-yml | 45 --
scripts/build | 14 -
scripts/docker-build | 17 -
scripts/docker-test | 16 -
scripts/lint | 30 --
scripts/prep-artifacts | 19 -
scripts/test | 95 ----
start-stream | 16 -
37 files changed, 73 insertions(+), 3381 deletions(-)
delete mode 100644 Dockerfile
delete mode 100644 Jenkinsfile
delete mode 100755 build.bat
delete mode 100644 ftl_app/bitstream.c
delete mode 100644 ftl_app/bitstream.h
delete mode 100644 ftl_app/cavlc.c
delete mode 100644 ftl_app/cavlc.h
delete mode 100644 ftl_app/dec_obj.h
delete mode 100644 ftl_app/decode.c
delete mode 100644 ftl_app/decode.h
delete mode 100644 ftl_app/file_parser.c
delete mode 100644 ftl_app/file_parser.h
delete mode 100644 ftl_app/gettimeofday.c
delete mode 100644 ftl_app/gettimeofday.h
delete mode 100644 ftl_app/main.c
delete mode 100644 ftl_app/main.h
delete mode 100644 ftl_app/nalu.c
delete mode 100644 ftl_app/nalu.h
delete mode 100644 ftl_app/posix/ctrlc_handler.c
delete mode 100644 ftl_app/utils.c
delete mode 100644 ftl_app/utils.h
delete mode 100644 ftl_app/win32/ctrlc_handler.c
delete mode 100644 ftl_app/win32/xgetopt.c
delete mode 100644 ftl_app/win32/xgetopt.h
delete mode 100755 get-audio
delete mode 100755 get-video
delete mode 100755 make-deployment-yml
delete mode 100755 scripts/build
delete mode 100755 scripts/docker-build
delete mode 100755 scripts/docker-test
delete mode 100755 scripts/lint
delete mode 100755 scripts/prep-artifacts
delete mode 100755 scripts/test
delete mode 100755 start-stream
diff --git a/.gitignore b/.gitignore
index 1652aa1c2d570d16..db7a6bd452461b11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@
*.orig
.vs/*
publish
-build-output
+build
+cmake-build-debug
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6cb6c28eba784e5..edb7b7b8c50364aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,105 +1,98 @@
-cmake_minimum_required (VERSION 2.8.0)
+cmake_minimum_required(VERSION 3.0)
enable_language(C)
project(libftl)
-SET(FTL_VERSION "0.5.0")
+set(FTL_VERSION "0.10.1")
option(DISABLE_AUTO_INGEST "Set to TRUE to disable auto ingest feature which removes curl and jansson dependancies" FALSE)
-MESSAGE(STATUS "FTL DISABLE_AUTO_INGEST: " ${DISABLE_AUTO_INGEST})
-
-option(DISABLE_FTL_APP "Set to TRUE to disable including the ftl app in the cmake output." FALSE)
-MESSAGE(STATUS "FTL DISABLE_FTL_APP: " ${DISABLE_FTL_APP})
+message(STATUS "FTL DISABLE_AUTO_INGEST: " ${DISABLE_AUTO_INGEST})
option(FTL_STATIC_COMPILE "Set to TRUE if you want ftl to be compiled as a static lib. If TRUE, the program will want to statically link to the ftl cmake object." FALSE)
-MESSAGE(STATUS "FTL FTL_STATIC_COMPILE: " ${FTL_STATIC_COMPILE})
+message(STATUS "FTL FTL_STATIC_COMPILE: " ${FTL_STATIC_COMPILE})
include(GNUInstallDirs)
find_package(Threads REQUIRED)
find_package(PkgConfig)
-set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if (DISABLE_AUTO_INGEST)
- add_definitions(-DDISABLE_AUTO_INGEST)
-endif()
+ add_definitions(-DDISABLE_AUTO_INGEST)
+endif ()
# We will only try to include curl if we have auto ingest enabled.
if (NOT DISABLE_AUTO_INGEST)
- FIND_PACKAGE(CURL)
-endif()
+ find_package(CURL)
+endif ()
if (NOT CURL_FOUND AND NOT DISABLE_AUTO_INGEST)
- SET(CURL_DISABLE_NTLM ON CACHE BOOL "Disabling NTLM")
- SET(CURL_DISABLE_TELNET ON CACHE BOOL "Disabling Telnet")
- SET(CURL_DISABLE_LDAP ON CACHE BOOL "Disabling Ldap")
- SET(CURL_DISABLE_LDAPS ON CACHE BOOL "Disabling secure ldap")
- SET(BUILD_CURL_EXE OFF CACHE BOOL "Building libcurl")
- SET(HTTP_ONLY ON CACHE BOOL "using compiling HTTP")
- SET(BUILD_TESTING OFF CACHE BOOL "Not building Tests")
- add_subdirectory(libcurl)
- SET(CURL_INCLUDE_DIRS libcurl/include ${CMAKE_CURRENT_BINARY_DIR}/libcurl/include/curl)
- SET(CURL_LIBRARIES libcurl)
- include_directories(${CURL_INCLUDE_DIRS})
-endif()
+ set(CURL_DISABLE_NTLM ON CACHE BOOL "Disabling NTLM")
+ set(CURL_DISABLE_TELNET ON CACHE BOOL "Disabling Telnet")
+ set(CURL_DISABLE_LDAP ON CACHE BOOL "Disabling Ldap")
+ set(CURL_DISABLE_LDAPS ON CACHE BOOL "Disabling secure ldap")
+ set(BUILD_CURL_EXE OFF CACHE BOOL "Building libcurl")
+ set(HTTP_ONLY ON CACHE BOOL "using compiling HTTP")
+ set(BUILD_TESTING OFF CACHE BOOL "Not building Tests")
+ add_subdirectory(libcurl)
+ set(CURL_INCLUDE_DIRS libcurl/include ${CMAKE_CURRENT_BINARY_DIR}/libcurl/include/curl)
+ set(CURL_LIBRARIES libcurl)
+ include_directories(${CURL_INCLUDE_DIRS})
+endif ()
# We will only try to include lib jansson if auto ingest is enabled.
if (PKG_CONFIG_FOUND AND NOT DISABLE_AUTO_INGEST)
- pkg_check_modules(JANSSON jansson)
-endif()
+ pkg_check_modules(JANSSON jansson)
+endif ()
if (NOT JANSSON_FOUND AND NOT DISABLE_AUTO_INGEST)
- SET(JANSSON_BUILD_DOCS OFF CACHE BOOL "Jansson docs off")
- SET(JANSSON_WITHOUT_TESTS ON CACHE BOOL "Jansson build without tests")
- SET(JANSSON_EXAMPLES OFF CACHE BOOL "Jansson disable examples")
- SET(USE_WINDOWS_CRYPTOAPI off)
- add_subdirectory(libjansson)
- SET(JANSSON_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libjansson/include)
- SET(JANSSON_LIBRARIES jansson)
- include_directories(${JANSSON_INCLUDE_DIRS})
-endif()
+ set(JANSSON_BUILD_DOCS OFF CACHE BOOL "Jansson docs off")
+ set(JANSSON_WITHOUT_TESTS ON CACHE BOOL "Jansson build without tests")
+ set(JANSSON_EXAMPLES OFF CACHE BOOL "Jansson disable examples")
+ set(USE_WINDOWS_CRYPTOAPI off)
+ add_subdirectory(libjansson)
+ set(JANSSON_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libjansson/include)
+ set(JANSSON_LIBRARIES jansson)
+ include_directories(${JANSSON_INCLUDE_DIRS})
+endif ()
if (WIN32)
- set(FTL_PLATFORM_FILES ftl_app/win32/xgetopt.c
- ftl_app/win32/xgetopt.h
- ftl_app/win32/ctrlc_handler.c)
- #set(FTL_PLATFORM_LIBS kernel32 user32 gdi32 advapi32 )
- #set(FTL_PLATFORM_LIBS ws2_32 )
- set(FTLSDK_PLATFORM_FILES libftl/win32/socket.c
- libftl/win32/socket.h
- libftl/win32/threads.c
- libftl/win32/threads.h)
- include_directories(libftl/win32)
-else()
- set(FTL_PLATFORM_FILES ftl_app/posix/ctrlc_handler.c)
- set(FTLSDK_PLATFORM_FILES libftl/posix/socket.c
- libftl/posix/socket.h
- libftl/posix/threads.c
- libftl/posix/threads.h)
- include_directories(libftl/posix)
-endif()
+ #set(FTL_PLATFORM_LIBS kernel32 user32 gdi32 advapi32 )
+ #set(FTL_PLATFORM_LIBS ws2_32 )
+ set(FTLSDK_PLATFORM_FILES libftl/win32/socket.c
+ libftl/win32/socket.h
+ libftl/win32/threads.c
+ libftl/win32/threads.h)
+ include_directories(libftl/win32)
+else ()
+ set(FTLSDK_PLATFORM_FILES libftl/posix/socket.c
+ libftl/posix/socket.h
+ libftl/posix/threads.c
+ libftl/posix/threads.h)
+ include_directories(libftl/posix)
+endif ()
# Figure out what kind of lib we should be producing.
-if(FTL_STATIC_COMPILE)
- set(FTL_LIB_TYPE STATIC)
- add_definitions(-DFTL_STATIC_COMPILE=1)
-else(FTL_STATIC_COMPILE)
- set(FTL_LIB_TYPE SHARED)
-endif(FTL_STATIC_COMPILE)
+if (FTL_STATIC_COMPILE)
+ set(FTL_LIB_TYPE STATIC)
+ add_definitions(-DFTL_STATIC_COMPILE=1)
+else ()
+ set(FTL_LIB_TYPE SHARED)
+endif ()
add_library(ftl ${FTL_LIB_TYPE} libftl/hmac/hmac.c
- libftl/hmac/hmac.h
- libftl/hmac/sha2.c
- libftl/hmac/sha2.h
- libftl/gettimeofday/gettimeofday.c
- libftl/gettimeofday/gettimeofday.h
- libftl/ftl-sdk.c
- libftl/handshake.c
- libftl/ingest.c
- libftl/ftl_helpers.c
- libftl/media.c
- libftl/logging.c
- libftl/ftl.h
- libftl/ftl_private.h
- ${FTLSDK_PLATFORM_FILES})
+ libftl/hmac/hmac.h
+ libftl/hmac/sha2.c
+ libftl/hmac/sha2.h
+ libftl/gettimeofday/gettimeofday.c
+ libftl/gettimeofday/gettimeofday.h
+ libftl/ftl-sdk.c
+ libftl/handshake.c
+ libftl/ingest.c
+ libftl/ftl_helpers.c
+ libftl/media.c
+ libftl/logging.c
+ libftl/ftl.h
+ libftl/ftl_private.h
+ ${FTLSDK_PLATFORM_FILES})
include_directories(libftl libftl/gettimeofday)
set_target_properties(ftl PROPERTIES VERSION ${FTL_VERSION})
@@ -107,37 +100,12 @@ set_target_properties(ftl PROPERTIES SOVERSION 0)
target_link_libraries(ftl ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
-if(WIN32)
- target_link_libraries(ftl ws2_32)
-endif()
-
-if (NOT DISABLE_FTL_APP)
- add_executable(ftl_app
- ftl_app/main.c
- ftl_app/main.h
- ftl_app/file_parser.c
- ftl_app/file_parser.h
- ftl_app/gettimeofday.c
- ftl_app/gettimeofday.h
- ftl_app/bitstream.c
- ftl_app/bitstream.h
- ftl_app/cavlc.c
- ftl_app/cavlc.h
- ftl_app/decode.c
- ftl_app/decode.h
- ftl_app/nalu.c
- ftl_app/nalu.h
- ftl_app/utils.c
- ftl_app/utils.h
- ftl_app/dec_obj.h
- ${FTL_PLATFORM_FILES})
-
- target_link_libraries(ftl_app ftl ${CURL_LIBRARIES} ${JANSSON_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${FTL_PLATFORM_LIBS})
- target_include_directories(ftl_app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ftl_app)
-endif()
+if (WIN32)
+ target_link_libraries(ftl ws2_32)
+endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftl.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/libftl.pc @ONLY)
+ ${CMAKE_CURRENT_BINARY_DIR}/libftl.pc @ONLY)
# Install rules
install(TARGETS ftl DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index a1b78fbb48dfb0e9..0000000000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,46 +0,0 @@
-FROM debian:9
-
-RUN apt-get update -y
-RUN apt-get install wget -y
-RUN apt-get install -y cmake
-RUN apt-get install git -y
-RUN apt-get install build-essential -y
-RUN apt-get install libssl-dev -y
-RUN apt-get install libcurl4-openssl-dev -y
-RUN apt-get upgrade ca-certificates -y
-
-RUN apt-get install -y jq curl
-
-RUN useradd ftl-user
-
-RUN mkdir -p /opt/ftl-sdk/vid
-
-RUN chown -R ftl-user:ftl-user /opt/ftl-sdk
-
-WORKDIR /opt/ftl-sdk/vid
-
-ARG VIDEO_URL=https://videotestmedia.blob.core.windows.net/ftl/sintel.h264
-RUN wget ${VIDEO_URL}
-ARG AUDIO_URL=https://videotestmedia.blob.core.windows.net/ftl/sintel.opus
-RUN wget ${AUDIO_URL}
-
-COPY --chown=ftl-user:ftl-user ./CMakeLists.txt /opt/ftl-sdk/CMakeLists.txt
-COPY --chown=ftl-user:ftl-user ./libcurl /opt/ftl-sdk/libcurl
-COPY --chown=ftl-user:ftl-user ./libjansson /opt/ftl-sdk/libjansson
-COPY --chown=ftl-user:ftl-user ./libftl /opt/ftl-sdk/libftl
-COPY --chown=ftl-user:ftl-user ./Doxyfile /opt/ftl-sdk/Doxyfile
-COPY --chown=ftl-user:ftl-user ./ftl_app /opt/ftl-sdk/ftl_app
-COPY --chown=ftl-user:ftl-user ./get-video /opt/ftl-sdk/get-video
-COPY --chown=ftl-user:ftl-user ./get-audio /opt/ftl-sdk/get-audio
-COPY --chown=ftl-user:ftl-user ./scripts /opt/ftl-sdk/scripts
-
-USER ftl-user
-
-WORKDIR /opt/ftl-sdk
-
-RUN ./scripts/build
-
-COPY --chown=ftl-user:ftl-user ./start-stream /opt/ftl-sdk/start-stream
-
-ENTRYPOINT ["./start-stream"]
-
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index 8487efe2d682a12b..0000000000000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,30 +0,0 @@
-properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactNumToKeepStr: '2', numToKeepStr: '2']]])
-
-node("master") {
- def projectName = "ftl-sdk"
-
- def projectDir = pwd()+ "/${projectName}"
- def artifactDir = "${projectDir}/build"
-
- try {
- sh "mkdir -p '${projectDir}'"
- dir (projectDir) {
- stage("Checkout") {
- checkout scm
- }
- stage("submodules") {
- sh 'git submodule update --init'
- }
- stage("make all") {
- sh "mkdir -p build && cd build && cmake .. && make"
- }
- stage("deploy") {
- archiveArtifacts artifacts: "build/ftl_app,build/libftl.so*", fingerprint: false
- }
- currentBuild.result = "SUCCESS"
- }
- } catch(e) {
- currentBuild.result = "FAILURE"
- throw e
- }
-}
diff --git a/README.md b/README.md
index 4c9359acf0daad0a..45a43d6073cb32b3 100644
--- a/README.md
+++ b/README.md
@@ -52,16 +52,3 @@ cmake -G "Visual Studio 14 2015 Win64" ..
msbuild /p:Configuration=Release ALL_BUILD.vcxproj OR open libftl.sln in Visual Studio
```
*ftl_app.exe will be placed in build/release directory*
-
-### Running Test Application
-
-download the following test files:
-
- - sintel.h264: https://www.dropbox.com/s/ruijibs0lgjnq51/sintel.h264
- - sintel.opus: https://www.dropbox.com/s/s2r6lggopt9ftw5/sintel.opus
-
-In the directory containing ftl_app
-
-```
-ftl_app -i auto -s "<mixer stream key>" -v path\to\sintel.h264 -a path\to\sintel.opus -f 24
-```
diff --git a/build.bat b/build.bat
deleted file mode 100755
index d9ade4bbb2321aa7..0000000000000000
--- a/build.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-@echo off
-
-IF EXIST build (
- echo Build Folder Exists
-) ELSE (
- mkdir build
-)
-
-cd build
-
-echo Running cmake
-
-cmake -G "Visual Studio 14 2015 Win64" ..
\ No newline at end of file
diff --git a/ftl_app/bitstream.c b/ftl_app/bitstream.c
deleted file mode 100644
index a2d08d202e0614a3..0000000000000000
--- a/ftl_app/bitstream.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "utils.h"
-#include "bitstream.h"
-
-
-unsigned int _read_bits(struct bitstream_elmt_t *bs, int bits, int update);
-
-
-int bitstream_init(struct bitstream_elmt_t *bs, unsigned char *buf)
-{
- bs->bit_idx = 8;
- bs->byte_idx = 0;
- bs->buf = buf;
-
- return 0;
-}
-
-
-/*
- T-REC-H.264-200503-P!!MSW-E.doc
- Section 9.1
-*/
-unsigned int bitstream_ue(struct bitstream_elmt_t *bs)
-{
- int leading_zeros = -1;
- int b;
- unsigned int code_num;
-
- for(b = 0; !b; leading_zeros++)
- {
- b = _read_bits(bs, 1, 1);
- }
-
- code_num = (1 << leading_zeros) - 1 + _read_bits(bs, leading_zeros, 1);
-
- return code_num;
-}
-
-/*
- T-REC-H.264-200503-P!!MSW-E.doc
- Section 9.1.1
-*/
-int bitstream_se(struct bitstream_elmt_t *bs)
-{
- unsigned int code_num;
- int signed_code_num;
- int sign;
-
- code_num = bitstream_ue(bs);
-
- sign = ~code_num & 0x1;
-
- signed_code_num = ((code_num + 1) >> 1) * -sign;
-
- return signed_code_num;
-}
-
-/*
- T-REC-H.264-200503-P!!MSW-E.doc
- Section 7.2
-*/
-unsigned int bitstream_u(struct bitstream_elmt_t *bs, int bits)
-{
- unsigned int value;
-
- value = _read_bits(bs, bits, 1);
-
- return value;
-}
-
-/*
- T-REC-H.264-200503-P!!MSW-E.doc
- Section 7.2
-*/
-int bitstream_i(struct bitstream_elmt_t *bs, int bits)
-{
- unsigned int value;
-
- value = _read_bits(bs, bits, 1);
-
- return ~value + 1;
-}
-
-unsigned int bitstream_peak(struct bitstream_elmt_t *bs, int bits)
-{
- unsigned int value;
-
- value = _read_bits(bs, bits, 0);
-
- return value;
-}
-
-int bitstream_bytealigned(struct bitstream_elmt_t *bs)
-{
- return (bs->bit_idx == 8);
-}
-
-unsigned int _read_bits(struct bitstream_elmt_t *bs, int bits, int update)
-{
- unsigned int val = 0;
- int byte_idx;
- int bit_idx;
- int b_cnt;
- int rshft, lshft;
-
- if(bits == 0)
- {
- return 0;
- }
-
- byte_idx = bs->byte_idx;
- bit_idx = bs->bit_idx;
-
- do{
- b_cnt = MIN(bit_idx, bits);
-
- val <<= b_cnt;
-
- lshft = 8 - bit_idx;
- rshft = bit_idx - b_cnt + lshft;
-
- val |= ((bs->buf[byte_idx] << lshft) & 0xFF) >> rshft;
-
- bits -= b_cnt;
-
- bit_idx -= b_cnt;
-
- if(bit_idx == 0)
- {
- bit_idx = 8;
- byte_idx++;
- }
-
- }while(bits > 0);
-
- if(update)
- {
- bs->byte_idx = byte_idx;
- bs->bit_idx = bit_idx;
- }
-
- return val;
-}
\ No newline at end of file
diff --git a/ftl_app/bitstream.h b/ftl_app/bitstream.h
deleted file mode 100644
index 7f4e8f10e5d4ce3f..0000000000000000
--- a/ftl_app/bitstream.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _BITSTREAM_H_
-#define _BITSTREAM_H_
-
-struct bitstream_elmt_t
-{
- unsigned char *buf;
- int byte_idx;
- int bit_idx;
-};
-
-int bitstream_init(struct bitstream_elmt_t *bs, unsigned char *buf);
-
-
-unsigned int bitstream_ue(struct bitstream_elmt_t *bs);
-int bitstream_se(struct bitstream_elmt_t *bs);
-unsigned int bitstream_u(struct bitstream_elmt_t *bs, int bits);
-int bitstream_i(struct bitstream_elmt_t *bs, int bits);
-unsigned int bitstream_peak(struct bitstream_elmt_t *bs, int bits);
-int bitstream_bytealigned(struct bitstream_elmt_t *bs);
-
-#endif
\ No newline at end of file
diff --git a/ftl_app/cavlc.c b/ftl_app/cavlc.c
deleted file mode 100644
index e69de29bb2d1d643..0000000000000000
diff --git a/ftl_app/cavlc.h b/ftl_app/cavlc.h
deleted file mode 100644
index e69de29bb2d1d643..0000000000000000
diff --git a/ftl_app/dec_obj.h b/ftl_app/dec_obj.h
deleted file mode 100644
index 71c13a0d5528604e..0000000000000000
--- a/ftl_app/dec_obj.h
+++ /dev/null
@@ -1,247 +0,0 @@
-#include "bitstream.h"
-
-enum nalu_type_codes
-{
- NALU_TYPE_NON_IDR_SLICE = 1,
- NALU_TYPE_IDR_SLICE = 5,
- NALU_TYPE_SPS = 7,
- NALU_TYPE_PPS = 8
-};
-
-enum slice_types
-{
- SLICE_TYPE_P = 0,
- SLICE_TYPE_B = 1,
- SLICE_TYPE_I = 2,
- SLICE_TYPE_SP = 3,
- SLICE_TYPE_SI = 4
-};
-
-enum sample_aspect_ratio_indicator
-{
- VUI_SAR_EXTENDED = 255
-};
-
-struct nalu_t
-{
- int forbidden_zero_bit;
- int nal_ref_idc;
- int nal_unit_type;
- int svc_extension_flag;
- int idr_flag;
- int priority_id;
- int no_inter_layer_pred_flag;
- int dependency_id;
- int quality_id;
- int temporal_id;
- int use_ref_base_pic_flag;
- int discardable_flag;
- int output_flag;
- int reserved_three_2bits;
-};
-
-struct hrd_params_t
-{
- int cpb_cnt_minus1;
- int bit_rate_scale;
- int cpb_size_scale;
- int *bit_rate_value_minus1;
- int *cpb_size_value_minus1;
- int *cbr_flag;
- int initial_cpb_removal_delay_length_minus1;
- int cpb_removal_delay_length_minus1;
- int dpb_output_delay_length_minus1;
- int time_offset_length;
-};
-
-struct vui_params_t
-{
- int aspect_ratio_info_present_flag;
- int aspect_ratio_idc;
- int sar_width;
- int sar_height;
- int overscan_info_present_flag;
- int overscan_appropriate_flag;
- int video_signal_type_present_flag;
- int video_format;
- int video_full_range_flag;
- int colour_description_present_flag;
- int colour_primaries;
- int transfer_characteristics;
- int matrix_coefficients;
- int chroma_loc_info_present_flag;
- int chroma_sample_loc_type_top_field;
- int chroma_sample_loc_type_bottom_field;
- int timing_info_present_flag;
- int num_units_in_tick;
- int time_scale;
- int fixed_frame_rate_flag;
- int nal_hrd_parameters_present_flag;
- struct hrd_params_t nal_hrd;
- int vcl_hrd_parameters_present_flag;
- struct hrd_params_t vlc_hrd;
- int low_delay_hrd_flag;
- int pic_struct_present_flag;
- int bitstream_restriction_flag;
- int motion_vectors_over_pic_boundaries_flag;
- int max_bytes_per_pic_denom;
- int max_bits_per_mb_denom;
- int log2_max_mv_length_horizontal;
- int log2_max_mv_length_vertical;
- int num_reorder_frames;
- int max_dec_frame_buffering;
-};
-
-struct sequence_params_set_t
-{
- int profile_idc;
- int constraint_set0_flag;
- int constraint_set1_flag;
- int constraint_set2_flag;
- int constraint_set3_flag;
- int reserved_zero_4bits; /* equal to 0 */
- int level_idc;
- int seq_parameter_set_id;
- int log2_max_frame_num_minus4;
- int pic_order_cnt_type;
- int log2_max_pic_order_cnt_lsb_minus4;
- int delta_pic_order_always_zero_flag;
- int offset_for_non_ref_pic;
- int offset_for_top_to_bottom_field;
- int num_ref_frames_in_pic_order_cnt_cycle;
- int *offset_for_ref_frame;
- int num_ref_frames;
- int gaps_in_frame_num_value_allowed_flag;
- int pic_width_in_mbs_minus1;
- int pic_height_in_map_units_minus1;
- int frame_mbs_only_flag;
- int mb_adaptive_frame_field_flag;
- int direct_8x8_inference_flag;
- int frame_cropping_flag;
- int frame_crop_left_offset;
- int frame_crop_right_offset;
- int frame_crop_top_offset;
- int frame_crop_bottom_offset;
- int vui_parameters_present_flag;
- struct vui_params_t vui;
-
- struct sequence_params_set_t *next;
-};
-
-struct picture_params_set_t
-{
- int pic_parameter_set_id;
- int seq_parameter_set_id;
- int entropy_coding_mode_flag;
- int pic_order_present_flag;
- int num_slice_groups_minus1;
- int slice_group_map_type;
- int *run_length_minus1;
- int *top_left;
- int *bottom_right;
- int slice_group_change_direction_flag;
- int slice_group_change_rate_minus1;
- int pic_size_in_map_units_minus1;
- int *slice_group_id;
- int num_ref_idx_l0_active_minus1;
- int num_ref_idx_l1_active_minus1;
- int weighted_pred_flag;
- int weighted_bipred_idc;
- int pic_init_qp_minus26; /* relative to 26 */
- int pic_init_qs_minus26; /* relative to 26 */
- int chroma_qp_index_offset;
- int deblocking_filter_control_present_flag;
- int constrained_intra_pred_flag;
- int redundant_pic_cnt_present_flag;
- int transform_8x8_mode_flag;
- int pic_scaling_matrix_present_flag;
- int *pic_scaling_list_present_flag;
- int second_chroma_qp_index_offset;
-
- struct picture_params_set_t *next;
-};
-
-struct ref_pic_list_t
-{
- int reordering_of_pic_nums_idc;
- int abs_diff_pic_num_minus1;
- int long_term_pic_num;
-};
-
-struct ref_pic_reorder_t
-{
- int ref_pic_list_reordering_flag_l0;
- struct ref_pic_list_t list0[4];
- int ref_pic_list_reordering_flag_l1;
- struct ref_pic_list_t list1[4];
-};
-
-struct ref_pic_marking_t
-{
- int no_output_of_prior_pics_flag;
- int long_term_reference_flag;
- int adaptive_ref_pic_marking_mode_flag;
- int memory_management_control_operation[4];
- int difference_of_pic_nums_minus1;
- int long_term_pic_num;
- int long_term_frame_idx;
- int max_long_term_frame_idx_plus1;
-};
-
-struct ref_base_pic_marking_t
-{
- int adaptive_ref_base_pic_marking_mode_flag;
- int memory_management_base_control_operation[4];
- int difference_of_base_pic_nums_minus1;
- int long_term_base_pic_num;
-};
-
-struct slice_header_t
-{
- int first_mb_in_slice;
- int slice_type;
- int pic_parameter_set_id;
- int frame_num;
- int field_pic_flag;
- int bottom_field_flag;
- int idr_pic_id;
- int pic_order_cnt_lsb;
- int delta_pic_order_cnt_bottom;
- int delta_pic_order_cnt[2];
- int redundant_pic_cnt;
- int direct_spatial_mv_pred_flag;
- int num_ref_idx_active_override_flag;
- int num_ref_idx_l0_active_minus1;
- int num_ref_idx_l1_active_minus1;
-
- struct ref_pic_reorder_t ref_pic_reorder;
-
- struct ref_pic_marking_t ref_pic_marking;
-
- struct ref_base_pic_marking_t ref_base_pic_marking;
-
- int cabac_init_idc;
- int slice_qp_delta;
- int sp_for_switch_flag;
- int slice_qs_delta;
- int disable_deblocking_filter_idc;
- int slice_alpha_c0_offset_div2;
- int slice_beta_offset_div2;
- int slice_group_change_cycle;
-
- /*svc specific headers*/
- int store_ref_base_pic_flag;
- int slice_skip_flag;
- int scan_idx_start;
- int scan_idx_end;
-};
-
-typedef struct _h264_dec_obj_t
-{
- struct bitstream_elmt_t bs;
- unsigned char *nalu_buf;
- struct nalu_t nalu;
- struct sequence_params_set_t *sps;
- struct picture_params_set_t *pps;
- struct slice_header_t slice;
-}h264_dec_obj_t;
\ No newline at end of file
diff --git a/ftl_app/decode.c b/ftl_app/decode.c
deleted file mode 100644
index 5bfb6489b30ee46a..0000000000000000
--- a/ftl_app/decode.c
+++ /dev/null
@@ -1,98 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-#include "decode.h"
-#include "nalu.h"
-#include "utils.h"
-
-
-h264_dec_obj_t * H264_Decode_Open()
-{
- h264_dec_obj_t *obj;
-
- if( (obj = malloc(sizeof(h264_dec_obj_t))) == NULL)
- {
- return NULL;
- }
-
- memset(obj, 0, sizeof(h264_dec_obj_t));
-
-
- if ((obj->nalu_buf = malloc(10000000)) == NULL)
- {
- return NULL;
- }
-
- return obj;
-}
-
-int H264_Decode_Nalu(h264_dec_obj_t* h264_dec_obj, unsigned char *nalu, int len)
-{
- static int last_mba = -1, last_frame_num = -1;
-
- bitstream_init(&h264_dec_obj->bs, nalu);
-
- /*get the nalu type and remove picture start code emulation prevention bits*/
- len = nal_unit(h264_dec_obj, &h264_dec_obj->bs, &h264_dec_obj->nalu, len);
-
- bitstream_init(&h264_dec_obj->bs, h264_dec_obj->nalu_buf);
-
- switch(h264_dec_obj->nalu.nal_unit_type)
- {
- case NALU_TYPE_NON_IDR_SLICE:
- case NALU_TYPE_IDR_SLICE:
- nalu_parse_slice_header(&h264_dec_obj->bs, &h264_dec_obj->nalu, &h264_dec_obj->slice);
- break;
- case NALU_TYPE_SPS:
- {
- struct sequence_params_set_t sps;
-
- nalu_parse_sps(&h264_dec_obj->bs, &sps);
-
- store_sps(&sps);
- break;
- }
- case NALU_TYPE_PPS:
- {
- struct picture_params_set_t pps;
-
- nalu_parse_pps(&h264_dec_obj->bs, &pps);
-
- store_pps(&pps);
- break;
- }
- default:
- printf("Unknown nal unit type: %d\n", h264_dec_obj->nalu.nal_unit_type);
- }
-
- if(h264_dec_obj->nalu.nal_unit_type == NALU_TYPE_NON_IDR_SLICE || h264_dec_obj->nalu.nal_unit_type == NALU_TYPE_IDR_SLICE )
- {
- if(h264_dec_obj->slice.first_mb_in_slice == 0)
- {
- //printf("Frame %d\n", h264_dec_obj->slice.frame_num);
- }
-
- if(last_mba == -1)
- {
- last_mba = h264_dec_obj->slice.first_mb_in_slice;
- last_frame_num = h264_dec_obj->slice.frame_num;
- }
- else if(last_frame_num == h264_dec_obj->slice.frame_num)
- {
- if(last_mba >= h264_dec_obj->slice.first_mb_in_slice)
- printf("Error: frame %d: current mba is %d, last was %d\n", h264_dec_obj->slice.frame_num, h264_dec_obj->slice.first_mb_in_slice, last_mba);
- }
-
- last_mba = h264_dec_obj->slice.first_mb_in_slice;
- last_frame_num = h264_dec_obj->slice.frame_num;
- }
-
-
- return 0;
-}
-
-int H264_Decode_Close()
-{
-
- return 0;
-}
\ No newline at end of file
diff --git a/ftl_app/decode.h b/ftl_app/decode.h
deleted file mode 100644
index a6e85ffc339f616a..0000000000000000
--- a/ftl_app/decode.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "dec_obj.h"
-
-h264_dec_obj_t* H264_Decode_Open();
-int H264_Decode_Nalu(h264_dec_obj_t* h264_dec_obj, unsigned char *nalu, int len);
diff --git a/ftl_app/file_parser.c b/ftl_app/file_parser.c
deleted file mode 100644
index ec023d526a1a3071..0000000000000000
--- a/ftl_app/file_parser.c
+++ /dev/null
@@ -1,370 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef _WIN32
-#include <Windows.h>
-#endif
-
-
-#include "ftl.h"
-#include "file_parser.h"
-
-int _store_first_nalu(h264_obj_t *handle);
-
-int h264_get_nalu(FILE *fp, uint8_t *buf, uint32_t *length);
-int get_ogg_page(opus_obj_t *handle);
-
-int init_video(h264_obj_t *handle, const char *video_file) {
-
- if (video_file == NULL) {
- return 0;
- }
-
- if ((handle->fp = fopen(video_file, "rb")) == NULL) {
- return 0;
- }
-
- if ((handle->h264_handle = H264_Decode_Open()) < 0)
- {
- return -1;
- }
-
- nalu_item_t *nalu;
-
- if ((nalu = malloc(sizeof(nalu_item_t))) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- return -1;
- }
-
- if ((nalu->buf = malloc(10000000)) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- free(nalu);
- return -1;
- }
-
- handle->curr_nalu = nalu;
-
- if ((nalu = malloc(sizeof(nalu_item_t))) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- return -1;
- }
-
- if ((nalu->buf = malloc(10000000)) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- free(nalu);
- return -1;
- }
-
- handle->next_nalu = nalu;
-
- _store_first_nalu(handle);
-
- return 1;
-}
-
-int reset_video(h264_obj_t *handle) {
- fseek(handle->fp, 0, SEEK_SET);
- _store_first_nalu(handle);
- return 1;
-}
-
-int _store_first_nalu(h264_obj_t *handle) {
- h264_get_nalu(handle->fp, handle->curr_nalu->buf, &handle->curr_nalu->len);
- H264_Decode_Nalu(handle->h264_handle, handle->curr_nalu->buf, handle->curr_nalu->len);
- memcpy(&handle->curr_nalu->slice, &handle->h264_handle->slice, sizeof(struct slice_header_t));
- memcpy(&handle->curr_nalu->nalu, &handle->h264_handle->nalu, sizeof(struct nalu_t));
-
- return 1;
-}
-
-int get_video_frame(h264_obj_t *handle, uint8_t *buf, uint32_t *length, int *last_nalu_in_frame) {
- int got_sc = 0;
- uint32_t pos = 0;
- uint8_t nalu_type = 0;
- size_t file_pos;
- struct slice_header_t *curr_slice, *next_slice;;
- struct nalu_t *curr_nalu, *next_nalu;
-
- *last_nalu_in_frame = 0;
- curr_nalu = &handle->curr_nalu->nalu;
- curr_slice = &handle->curr_nalu->slice;
-
- /*read ahead to next packet*/
- if (h264_get_nalu(handle->fp, handle->next_nalu->buf, &handle->next_nalu->len)) {
- H264_Decode_Nalu(handle->h264_handle, handle->next_nalu->buf, handle->next_nalu->len);
- memcpy(&handle->next_nalu->slice, &handle->h264_handle->slice, sizeof(struct slice_header_t));
- memcpy(&handle->next_nalu->nalu, &handle->h264_handle->nalu, sizeof(struct nalu_t));
- next_nalu = &handle->next_nalu->nalu;
- next_slice = &handle->next_nalu->slice;
- }
-
- if (curr_nalu->nal_unit_type == NALU_TYPE_NON_IDR_SLICE || curr_nalu->nal_unit_type == NALU_TYPE_IDR_SLICE) {
- //if the next packet is an sps/pps then the current packet is the end of the frame
- if (next_nalu->nal_unit_type != NALU_TYPE_NON_IDR_SLICE && next_nalu->nal_unit_type != NALU_TYPE_IDR_SLICE) {
- *last_nalu_in_frame = 1;
- }
- else if (curr_slice->frame_num != next_slice->frame_num) {
- *last_nalu_in_frame = 1;
- }
- }
-
- memcpy(buf, handle->curr_nalu->buf, handle->curr_nalu->len);
- *length = handle->curr_nalu->len;
-
- /*swap next with current*/
- nalu_item_t *tmp = handle->curr_nalu;
- handle->curr_nalu = handle->next_nalu;
- handle->next_nalu = tmp;
-
- return 1;
- }
-
- int init_audio(opus_obj_t *handle, const char *audio_file, int raw_opus) {
-
-
- if (audio_file == NULL) {
- return 0;
- }
-
- if ((handle->fp = fopen(audio_file, "rb")) == NULL) {
- return 0;
- }
-
- if ((handle->page_buf = malloc(MAX_OGG_PAGE_LEN)) == NULL) {
- return 0;
- }
-
- handle->raw_opus = raw_opus;
-
- handle->current_segment = 0;
- handle->consumed = 0;
- handle->page_len = 0;
-
- return 1;
- }
-
- void close_audio(opus_obj_t *handle) {
- if (handle->page_buf != NULL) {
- free(handle->page_buf);
- }
- }
-
- int reset_audio(opus_obj_t *handle) {
- fseek(handle->fp, 0, SEEK_SET);
-
- handle->consumed = 0;
- handle->page_len = 0;
-
- return 1;
- }
-
- int get_audio_packet(opus_obj_t *handle, uint8_t *buf, uint32_t *length) {
-
- *length = 0;
-
- if (handle->raw_opus) {
- if (feof(handle->fp)) {
- return 0;
- }
-
- fread(length, 1, 4, handle->fp);
- fread(buf, 1, *length, handle->fp);
- }
- else {
-
- if (handle->consumed >= handle->page_len) {
- if (get_ogg_page(handle) != 1) {
- return 0;
- }
- }
-
- int seg_len;
-
- do {
- seg_len = handle->seg_len_table[handle->current_segment];
- memcpy(buf, handle->page_buf + handle->consumed, seg_len);
- buf += seg_len;
- *length += seg_len;
- handle->consumed += seg_len;
- handle->current_segment++;
- } while (seg_len == 255);
- }
-
- return 1;
- }
-
- int h264_get_nalu(FILE *fp, uint8_t *buf, uint32_t *length) {
- uint32_t sc = 0;
- uint8_t byte;
- uint32_t pos = 0;
- int got_sc = 0;
-
- do {
- while (!feof(fp)) {
- fread(&byte, 1, 1, fp);
-
- if (buf != NULL) {
- buf[pos] = byte;
- }
-
- pos++;
-
- sc = (sc << 8) | byte;
-
- if (sc == 1 || ((sc & 0xFFFFFF) == 1)) {
-
- pos -= 3;
-
- if (sc == 1) {
- pos -= 1;
- }
-
- got_sc = 1;
- break;
- }
- }
- } while (pos == 0);
-
- *length = pos;
-
- return got_sc;
- }
-
- uint8_t get_8bits(uint8_t **buf, uint32_t *len) {
- uint8_t val = 0;
- uint32_t bytes = sizeof(uint8_t);
-
- if (*len >= bytes) {
- *len -= bytes;
- }
-
- val = (*buf)[0];
-
- (*buf) += bytes;
-
- return val;
- }
-
- uint16_t get_16bits(uint8_t **buf, uint32_t *len) {
- uint16_t val;
- uint32_t bytes = sizeof(uint16_t);
-
- if (*len >= bytes) {
- *len -= bytes;
- }
-
- int i;
- for (i = sizeof(uint16_t) - 1; i >= 0; i--) {
- val = (val << 8) | (*buf)[i];
- }
-
- (*buf) += bytes;
-
- return val;
- }
-
- uint32_t get_32bits(uint8_t **buf, uint32_t *len) {
- uint32_t val;
- uint32_t bytes = sizeof(uint32_t);
-
- if (*len >= bytes) {
- *len -= bytes;
- }
-
- int i;
- for (i = bytes - 1; i >= 0; i--) {
- val = (val << 8) | (*buf)[i];
- }
-
- (*buf) += bytes;
-
- return val;
- }
-
- uint64_t get_64bits(uint8_t **buf, uint32_t *len) {
- uint64_t val;
- uint32_t bytes = sizeof(uint64_t);
-
- if (*len >= bytes) {
- *len -= bytes;
- }
-
- int i;
- for (i = bytes - 1; i >= 0; i--) {
- val = (val << 8) | (*buf)[i];
- }
-
- (*buf) += bytes;
-
- return val;
- }
-
- int get_ogg_page(opus_obj_t *handle) {
- uint32_t magic_num = 0;
- uint8_t byte;
- uint32_t pos = 0;
- int got_page = 0;
-
- while (!feof(handle->fp)) {
- fread(&byte, 1, 1, handle->fp);
-
- handle->page_buf[pos] = byte;
- pos++;
-
- if (pos >= MAX_OGG_PAGE_LEN) {
- printf("Error page size exceeds max\n");
- exit(-1);
- }
-
- magic_num = (magic_num << 8) | byte;
-
- if (magic_num == 0x4F676753) {
-
- pos -= 4;
-
- if (pos == 0) {
- continue;
- }
-
- uint8_t *p = handle->page_buf;
- uint32_t bytes_available = pos;
-
- handle->packets_in_page = 0;
-
- handle->version = get_8bits(&p, &bytes_available);
- handle->header_type = get_8bits(&p, &bytes_available);
- handle->granule_pos = get_64bits(&p, &bytes_available);
- handle->bs_serial = get_32bits(&p, &bytes_available);
- handle->page_sn = get_32bits(&p, &bytes_available);
- handle->checksum = get_32bits(&p, &bytes_available);
- handle->page_segs = get_8bits(&p, &bytes_available);
-
- int i;
- for (i = 0; i < handle->page_segs; i++) {
- handle->seg_len_table[i] = get_8bits(&p, &bytes_available);
- if (handle->seg_len_table[i] != 255) {
- handle->packets_in_page++;
- }
- }
-
- //printf("Page %d, pos %ul, page segs %d, packets %d\n", handle->page_sn, handle->granule_pos, handle->page_segs, handle->packets_in_page);
-
- handle->consumed = pos - bytes_available;
- handle->current_segment = 0;
-
- got_page = 1;
- break;
- }
- }
-
- handle->page_len = pos;
-
- return got_page;
- }
-
-
-
diff --git a/ftl_app/file_parser.h b/ftl_app/file_parser.h
deleted file mode 100644
index 672840196c624f4b..0000000000000000
--- a/ftl_app/file_parser.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "decode.h"
-
-#define MAX_OGG_PAGE_LEN 100000
-
-
-typedef struct {
- FILE *fp;
- uint8_t *page_buf;
- int page_len;
- int consumed;
- int raw_opus;
- uint8_t version;
- uint8_t header_type;
- uint8_t seg_length;
- uint8_t page_segs;
- uint64_t granule_pos;
- uint32_t bs_serial;
- uint32_t page_sn;
- uint32_t checksum;
- uint8_t seg_len_table[255];
- uint8_t current_segment;
- uint8_t packets_in_page;
-}opus_obj_t;
-
-typedef struct _nalu_item_t {
- uint8_t *buf;
- int len;
- struct slice_header_t slice;
- struct nalu_t nalu;
-}nalu_item_t;
-
-typedef struct {
- FILE *fp;
- h264_dec_obj_t *h264_handle;
- nalu_item_t *curr_nalu;
- nalu_item_t *next_nalu;
-}h264_obj_t;
-
-
-int init_video(h264_obj_t *handle, const char *video_file);
-int reset_video(h264_obj_t *handle);
-int get_video_frame(h264_obj_t *handle, uint8_t *buf, uint32_t *length, int *end_of_frame);
-int init_audio(opus_obj_t *handle, const char *audio_file, int raw_opus);
-void close_audio(opus_obj_t *handle);
-int reset_audio(opus_obj_t *handle);
-int get_audio_packet(opus_obj_t *handle, uint8_t *buf, uint32_t *length);
-
diff --git a/ftl_app/gettimeofday.c b/ftl_app/gettimeofday.c
deleted file mode 100644
index b01166f2a6a71582..0000000000000000
--- a/ftl_app/gettimeofday.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* gettimeofday.c
-* Win32 gettimeofday() replacement
-*
-* src/port/gettimeofday.c
-*
-* Copyright (c) 2003 SRA, Inc.
-* Copyright (c) 2003 SKC, Inc.
-*
-* Permission to use, copy, modify, and distribute this software and
-* its documentation for any purpose, without fee, and without a
-* written agreement is hereby granted, provided that the above
-* copyright notice and this paragraph and the following two
-* paragraphs appear in all copies.
-*
-* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
-* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
-* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
-* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
-* OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
-* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
-* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-*/
-#include "gettimeofday.h"
-#ifdef _WIN32
-#include <Windows.h>
-
-/* FILETIME of Jan 1 1970 00:00:00. */
-static const unsigned __int64 epoch = ((unsigned __int64)116444736000000000ULL);
-
-/*
-* timezone information is stored outside the kernel so tzp isn't used anymore.
-*
-* Note: this function is not for Win32 high precision timing purpose. See
-* elapsed_time().
-*/
-int gettimeofday(struct timeval * tp, struct timezone * tzp)
-{
- FILETIME file_time;
- SYSTEMTIME system_time;
- ULARGE_INTEGER ularge;
-
- GetSystemTime(&system_time);
- SystemTimeToFileTime(&system_time, &file_time);
- ularge.LowPart = file_time.dwLowDateTime;
- ularge.HighPart = file_time.dwHighDateTime;
-
- tp->tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L);
- tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
-
- return 0;
-}
-#endif
-
-int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
-{
- /* Perform the carry for the later subtraction by updating y. */
- if (x->tv_usec < y->tv_usec) {
- int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
- y->tv_usec -= 1000000 * nsec;
- y->tv_sec += nsec;
- }
- if (x->tv_usec - y->tv_usec > 1000000) {
- int nsec = (x->tv_usec - y->tv_usec) / 1000000;
- y->tv_usec += 1000000 * nsec;
- y->tv_sec -= nsec;
- }
-
- /* Compute the time remaining to wait.
- tv_usec is certainly positive. */
- result->tv_sec = x->tv_sec - y->tv_sec;
- result->tv_usec = x->tv_usec - y->tv_usec;
-
- /* Return 1 if result is negative. */
- return x->tv_sec < y->tv_sec;
-}
-
-float timeval_to_ms(struct timeval *tv) {
- double sec, usec;
-
- sec = (float)tv->tv_sec;
- usec = (float)tv->tv_usec;
-
- return (float)(sec * 1000 + usec / 1000);
-}
-
-uint64_t timeval_to_us(struct timeval *tv)
-{
- return tv->tv_sec * (uint64_t)1000000 + tv->tv_usec;
-}
diff --git a/ftl_app/gettimeofday.h b/ftl_app/gettimeofday.h
deleted file mode 100644
index 5421c8481921d7b6..0000000000000000
--- a/ftl_app/gettimeofday.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdint.h>
-
-#ifdef _WIN32
-int gettimeofday(struct timeval * tp, struct timezone * tzp);
-#else
-#include <sys/time.h>
-#endif
-int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
-float timeval_to_ms(struct timeval *tv);
-uint64_t timeval_to_us(struct timeval *tv);
diff --git a/ftl_app/main.c b/ftl_app/main.c
deleted file mode 100644
index 7750e50f0cbffe61..0000000000000000
--- a/ftl_app/main.c
+++ /dev/null
@@ -1,460 +0,0 @@
-/**
- * main.c - Charon client for the FTL SDK
- *
- * Copyright (c) 2015 Michael Casadevall
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- **/
-
-#include "main.h"
-#include "gettimeofday.h"
-#ifdef _WIN32
-#define _CRTDBG_MAP_ALLOC
-#include <stdlib.h>
-#include <crtdbg.h>
-#include <Windows.h>
-#include <WinSock2.h>
-#else
-#include <pthread.h>
-#include <sys/time.h>
-#endif
-#include "file_parser.h"
-
-void sleep_ms(int ms)
-{
-#ifdef _WIN32
- Sleep(ms);
-#else
- usleep(ms * 1000);
-#endif
-}
-
-void log_test(ftl_log_severity_t log_level, const char *message)
-{
- fprintf(stderr, "libftl message: %s\n", message);
- return;
-}
-
-void usage()
-{
- printf("Usage: ftl_app -i <ingest uri> -s <stream_key> - v <h264_annex_b_file> -a <opus in ogg container>\n");
- exit(0);
-}
-
-#ifdef _WIN32
-int WINAPI ftl_status_thread(LPVOID data);
-#else
-static void *ftl_status_thread(void *data);
-#endif
-
-int speedtest_duration = 0;
-
-int main(int argc, char **argv)
-{
- ftl_status_t status_code;
-
- char *ingest_location = NULL;
- char *video_input = NULL;
- char *audio_input = NULL;
- char *stream_key = NULL;
- int fps_num = 30;
- int fps_den = 1;
- int raw_opus = 0;
- int speedtest_kbps = 1000;
- int c;
- int audio_pps = 50;
- int target_bw_kbps = 0;
-
- int success = 0;
- int verbose = 0;
-
- opterr = 0;
-
- charon_install_ctrlc_handler();
-
-
- if (FTL_VERSION_MAINTENANCE != 0)
- {
- printf("FTLSDK - version %d.%d.%d\n", FTL_VERSION_MAJOR, FTL_VERSION_MINOR, FTL_VERSION_MAINTENANCE);
- }
- else
- {
- printf("FTLSDK - version %d.%d\n", FTL_VERSION_MAJOR, FTL_VERSION_MINOR);
- }
-
- while ((c = getopt(argc, argv, "a:i:v:s:f:b:t:r:?")) != -1)
- {
- switch (c)
- {
- case 'i':
- ingest_location = optarg;
- break;
- case 'v':
- video_input = optarg;
- break;
- case 'a':
- audio_input = optarg;
- break;
- case 'r':
- if (strcmp(optarg, "a") == 0) {
- raw_opus = 1;
- }
- break;
- case 's':
- stream_key = optarg;
- break;
- case 'f':
- sscanf(optarg, "%d:%d", &fps_num, &fps_den);
- break;
- case 'b':
- sscanf(optarg, "%d", &target_bw_kbps);
- break;
- case 't':
- sscanf(optarg, "%d:%d", &speedtest_duration, &speedtest_kbps);
- break;
- case '?':
- usage();
- break;
- }
- }
-
- /* Make sure we have all the required bits */
- if ((!stream_key || !ingest_location) || ((!video_input || !audio_input) && (!speedtest_duration)))
- {
- usage();
- }
-
- FILE *video_fp = NULL;
- uint32_t len = 0;
- uint8_t *h264_frame = 0;
- uint8_t *audio_frame = 0;
- opus_obj_t opus_handle;
- h264_obj_t h264_handle;
- int retval = 0;
-
- if (video_input != NULL)
- {
- if ((h264_frame = malloc(10000000)) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- return -1;
- }
-
- if (!init_video(&h264_handle, video_input))
- {
- printf("Failed to open video file\n");
- return -1;
- }
- }
-
- if (audio_input != NULL)
- {
- if ((audio_frame = malloc(1000)) == NULL)
- {
- printf("Failed to allocate memory for bitstream\n");
- return -1;
- }
-
- if (!init_audio(&opus_handle, audio_input, raw_opus))
- {
- printf("Failed to open audio file\n");
- return -1;
- }
- }
-
- ftl_init();
- ftl_handle_t handle;
- ftl_ingest_params_t params;
-
- params.stream_key = stream_key;
- params.video_codec = FTL_VIDEO_H264;
- params.audio_codec = FTL_AUDIO_OPUS;
- params.ingest_hostname = ingest_location;
- params.fps_num = fps_num;
- params.fps_den = fps_den;
- params.peak_kbps = target_bw_kbps;
- params.vendor_name = "ftl_app";
- params.vendor_version = "0.0.1";
-
- struct timeval proc_start_tv, proc_end_tv, proc_delta_tv;
- struct timeval profile_start, profile_stop, profile_delta;
-#ifdef _WIN32
- HANDLE status_thread_handle;
- int status_thread_id;
-#else
- pthread_t status_thread_handle;
-#endif
-
- if ((status_code = ftl_ingest_create(&handle, ¶ms)) != FTL_SUCCESS)
- {
- printf("Failed to create ingest handle: %s\n", ftl_status_code_to_string(status_code));
- return -1;
- }
-
- if ((status_code = ftl_ingest_connect(&handle)) != FTL_SUCCESS)
- {
- printf("Failed to connect to ingest: %s\n", ftl_status_code_to_string(status_code));
- return -1;
- }
-#ifdef _WIN32
- if ((status_thread_handle = CreateThread(NULL, 0, ftl_status_thread, &handle, 0, &status_thread_id)) == NULL)
- {
-#else
- if ((pthread_create(&status_thread_handle, NULL, ftl_status_thread, &handle)) != 0)
- {
-#endif
- return FTL_MALLOC_FAILURE;
- }
-
- if (speedtest_duration)
- {
- printf("Running Speed test: sending %d kbps for %d ms", speedtest_kbps, speedtest_duration);
- speed_test_t results;
- if ((status_code = ftl_ingest_speed_test_ex(&handle, speedtest_kbps, speedtest_duration, &results)) == FTL_SUCCESS) {
- printf("Speed test completed: Peak kbps %d, initial rtt %d, final rtt %d, %3.2f lost packets\n",
- results.peak_kbps, results.starting_rtt, results.ending_rtt, (float)results.lost_pkts * 100.f / (float)results.pkts_sent);
- }
- else {
- printf("Speed test failed with: %s\n", ftl_status_code_to_string(status_code));
- }
-
- goto cleanup;
- }
-
- printf("Stream online!\n");
- printf("Press Ctrl-C to shutdown your stream in this window\n");
-
- float video_send_delay = 0, actual_sleep, time_delta;
- float video_time_step = (float)(1000 * params.fps_den) / (float)params.fps_num;
-
- float audio_send_accumulator = video_time_step;
- float audio_time_step = 1000.f / audio_pps;
- int audio_pkts_sent;
- int end_of_frame;
-
- gettimeofday(&proc_start_tv, NULL);
- struct timeval frameTime;
- gettimeofday(&frameTime, NULL); // NOTE! In a real app these timestamps should come from the samples!
-
- while (!ctrlc_pressed())
- {
- uint8_t nalu_type;
- int audio_read_len;
-
- if (feof(h264_handle.fp) || feof(opus_handle.fp))
- {
- printf("Restarting Stream\n");
- reset_video(&h264_handle);
- reset_audio(&opus_handle);
- continue;
- }
-
- if (get_video_frame(&h264_handle, h264_frame, &len, &end_of_frame) == 0)
- {
- continue;
- }
-
- ftl_ingest_send_media_dts(&handle, FTL_VIDEO_DATA, timeval_to_us(&frameTime), h264_frame, len, end_of_frame);
-
- audio_pkts_sent = 0;
- while (audio_send_accumulator > audio_time_step)
- {
- if (get_audio_packet(&opus_handle, audio_frame, &len) == 0)
- {
- break;
- }
-
- ftl_ingest_send_media(&handle, FTL_AUDIO_DATA, audio_frame, len, 0);
- audio_send_accumulator -= audio_time_step;
- audio_pkts_sent++;
- }
-
- nalu_type = h264_frame[0] & 0x1F;
-
- if (end_of_frame)
- {
- gettimeofday(&frameTime, NULL); // NOTE! In a real app these timestamps should come from the samples!
- gettimeofday(&proc_end_tv, NULL);
- timeval_subtract(&proc_delta_tv, &proc_end_tv, &proc_start_tv);
-
- video_send_delay += video_time_step;
- time_delta = (float)timeval_to_ms(&proc_delta_tv);
- video_send_delay -= time_delta;
-
- if (video_send_delay > 0)
- {
- gettimeofday(&profile_start, NULL);
- sleep_ms((int)video_send_delay);
- gettimeofday(&profile_stop, NULL);
- timeval_subtract(&profile_delta, &profile_stop, &profile_start);
- actual_sleep = (float)timeval_to_ms(&profile_delta);
- }
- else
- {
- actual_sleep = 0;
- }
-
- video_send_delay -= actual_sleep;
-
- gettimeofday(&proc_start_tv, NULL);
-
- audio_send_accumulator += video_time_step;
- }
- }
-
-cleanup:
-
- if (h264_frame != NULL) {
- free(h264_frame);
- }
-
- if (audio_frame != NULL) {
- free(audio_frame);
- }
-
- close_audio(&opus_handle);
-
- if ((status_code = ftl_ingest_disconnect(&handle)) != FTL_SUCCESS)
- {
- printf("Failed to disconnect from ingest: %s\n", ftl_status_code_to_string(status_code));
- retval = -1;
- }
-
- if ((status_code = ftl_ingest_destroy(&handle)) != FTL_SUCCESS)
- {
- printf("Failed to disconnect from ingest: %s\n", ftl_status_code_to_string(status_code));
- retval = -1;
- }
-
-#ifdef _WIN32
- WaitForSingleObject(status_thread_handle, INFINITE);
- CloseHandle(status_thread_handle);
-#else
- pthread_join(status_thread_handle, NULL);
-#endif
-
-#ifdef _WIN32
- _CrtDumpMemoryLeaks();
-#endif
-
- return retval;
-}
-
-#ifdef _WIN32
-int WINAPI ftl_status_thread(LPVOID data)
-#else
-static void *ftl_status_thread(void *data)
-#endif
-{
- ftl_handle_t *handle = (ftl_handle_t *)data;
- ftl_status_msg_t status;
- ftl_status_t status_code;
- int retries = 10;
- int retry_sleep = 5000;
-
- while (1)
- {
- if ((status_code = ftl_ingest_get_status(handle, &status, 1000)) == FTL_STATUS_TIMEOUT)
- {
- continue;
- }
-
- if (status_code == FTL_NOT_INITIALIZED)
- {
- break;
- }
-
- if (status.type == FTL_STATUS_EVENT && status.msg.event.type == FTL_STATUS_EVENT_TYPE_DESTROYED)
- {
- break;
- }
-
- if (status.type == FTL_STATUS_EVENT && status.msg.event.type == FTL_STATUS_EVENT_TYPE_DISCONNECTED)
- {
- printf("Disconnected from ingest for reason: %s (%d)\n", ftl_status_code_to_string(status.msg.event.error_code), status.msg.event.reason);
-
- if (status.msg.event.reason == FTL_STATUS_EVENT_REASON_API_REQUEST)
- {
- continue;
- }
-
- /*dont reconnect for speed test*/
- if (speedtest_duration) {
- continue;
- }
-
- //attempt reconnection
- while (retries-- > 0)
- {
- sleep_ms(retry_sleep);
- printf("Attempting to reconnect to ingest (retires left %d)\n", retries);
- if ((status_code = ftl_ingest_connect(handle)) == FTL_SUCCESS)
- {
- retries = 10;
- break;
- }
- printf("Failed to connect to ingest: %s (%d)\n", ftl_status_code_to_string(status_code), status_code);
- retry_sleep = retry_sleep * 3 / 2;
- }
- if (retries <= 0)
- {
- break;
- }
- }
- else if (status.type == FTL_STATUS_LOG)
- {
- printf("[%d] %s\n", status.msg.log.log_level, status.msg.log.string);
- }
- else if (status.type == FTL_STATUS_VIDEO_PACKETS)
- {
- ftl_packet_stats_msg_t *p = &status.msg.pkt_stats;
-
- printf("Avg packet send per second %3.1f, total nack requests %d\n",
- (float)p->sent * 1000.f / p->period,
- p->nack_reqs);
- }
- else if (status.type == FTL_STATUS_VIDEO_PACKETS_INSTANT)
- {
- ftl_packet_stats_instant_msg_t *p = &status.msg.ipkt_stats;
-
- printf("avg transmit delay %dms (min: %d, max: %d), avg rtt %dms (min: %d, max: %d)\n",
- p->avg_xmit_delay, p->min_xmit_delay, p->max_xmit_delay,
- p->avg_rtt, p->min_rtt, p->max_rtt);
- }
- else if (status.type == FTL_STATUS_VIDEO)
- {
- ftl_video_frame_stats_msg_t *v = &status.msg.video_stats;
-
- printf("Queue an average of %3.2f fps (%3.1f kbps), sent an average of %3.2f fps (%3.1f kbps), queue fullness %d, max frame size %d\n",
- (float)v->frames_queued * 1000.f / v->period,
- (float)v->bytes_queued / v->period * 8,
- (float)v->frames_sent * 1000.f / v->period,
- (float)v->bytes_sent / v->period * 8,
- v->queue_fullness, v->max_frame_size);
- }
- else
- {
- printf("Status: Got Status message of type %d\n", status.type);
- }
- }
-
- printf("exited ftl_status_thread\n");
-
- return 0;
-}
diff --git a/ftl_app/main.h b/ftl_app/main.h
deleted file mode 100644
index 0a9bae821d343682..0000000000000000
--- a/ftl_app/main.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * charon.h - Global Header for the Charon client
- *
- * Copyright (c) 2015 Michael Casadevall
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- **/
-
-/* Include definitions */
-#include "ftl.h"
-
-/* Windows specific includes */
-#ifdef _WIN32
-
-/**
- * We have to define LEAN_AND_MEAN because winsock will pull in duplicate
- * header definitions without it as the winsock 1.1 API is in windows.h vs
- * ws2_32.h.
- *
- * Yay for backwards source compatability
- **/
-
-#define WIN32_LEAN_AND_MEAN 1
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include "win32/xgetopt.h"
-#else
-/* POSIX headers */
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#endif
-
-/***
- * Functions related to Ctrl-C handling
- **/
-
-void charon_install_ctrlc_handler();
-void charon_loop_until_ctrlc();
-int ctrlc_pressed();
diff --git a/ftl_app/nalu.c b/ftl_app/nalu.c
deleted file mode 100644
index da55b0d752c4184c..0000000000000000
--- a/ftl_app/nalu.c
+++ /dev/null
@@ -1,849 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "bitstream.h"
-#include "dec_obj.h"
-#include "utils.h"
-#include "nalu.h"
-
-int _rbsp_trailing_bits(struct bitstream_elmt_t *bs);
-
-/*
- T-REC-H.264-200503-P!!MSW-E.doc
- Section 7.3.1
-*/
-
-int nal_unit(h264_dec_obj_t *obj, struct bitstream_elmt_t *bs, struct nalu_t *nalu, int len)
-{
- int rbsp_len;
- int i;
- int val;
- unsigned char *rbsp;
-
- rbsp = obj->nalu_buf;
-
- /*forbidden zero bit*/
- nalu->forbidden_zero_bit = bitstream_u(bs, 1);
-
- /*nal ref idc*/
- nalu->nal_ref_idc = bitstream_u(bs, 2);
-
- /*nal unit type*/
- nalu->nal_unit_type = bitstream_u(bs, 5);
-
- if(nalu->nal_unit_type == 14 || nalu->nal_unit_type == 20)
- {
- nalu->svc_extension_flag = bitstream_u(bs, 1);
-
- if(nalu->svc_extension_flag != 1)
- {
- printf("nal_unit_header_mvc_extension() parsing not supported\n");
- return -1;
- }
-
- nalu->idr_flag = bitstream_u(bs, 1);
-
- nalu->priority_id = bitstream_u(bs, 6);
-
- nalu->no_inter_layer_pred_flag = bitstream_u(bs, 1);
-
- nalu->dependency_id = bitstream_u(bs, 3);
-
- nalu->quality_id = bitstream_u(bs, 4);
-
- nalu->temporal_id = bitstream_u(bs, 3);
-
- nalu->use_ref_base_pic_flag = bitstream_u(bs, 1);
-
- nalu->discardable_flag = bitstream_u(bs, 1);
-
- nalu->output_flag = bitstream_u(bs, 1);
-
- nalu->reserved_three_2bits = bitstream_u(bs, 2);
- }
-
- rbsp_len = 0;
-
- for(i=1; i < len; i++)
- {
- /*check for start code emulation prevention bits*/
- if(i + 2 < len && bitstream_peak(bs, 24) == 0x000003 )
- {
- rbsp[rbsp_len++] = bitstream_u(bs, 8);
- rbsp[rbsp_len++] = bitstream_u(bs, 8);
- i+=2;
-
- /*read off start code emulation prevention bits*/
- bitstream_u(bs, 8);
- }
- else
- {
- rbsp[rbsp_len++] = bitstream_u(bs, 8);
- }
- }
-
- return rbsp_len;
-}
-
-void nalu_parse_slice_header(struct bitstream_elmt_t *bs, struct nalu_t* nalu, struct slice_header_t *slice)
-{
- struct sequence_params_set_t *sps;
- struct picture_params_set_t *pps;
- int slice_skip_flag = 0;
- int i;
-
- memset(slice, 0, sizeof(struct slice_header_t));
-
- slice->first_mb_in_slice = bitstream_ue(bs);
- slice->slice_type = bitstream_ue(bs) % 5;
- slice->pic_parameter_set_id = bitstream_ue(bs);
-
- pps = find_pps(slice->pic_parameter_set_id);
- sps = find_sps(nalu->nal_unit_type, pps->seq_parameter_set_id);
-
- slice->frame_num = bitstream_u(bs, sps->log2_max_frame_num_minus4 + 4);
-#if 0
- slice->field_pic_flag = 0;
-
- if( !sps->frame_mbs_only_flag )
- {
- slice->field_pic_flag = bitstream_u(bs, 1);
-
- if( slice->field_pic_flag )
- {
- slice->bottom_field_flag = bitstream_u(bs, 1);
- }
- }
-
- if( nalu->nal_unit_type == NALU_TYPE_IDR_SLICE || (nalu->nal_unit_type == 20 && nalu->idr_flag))
- {
- slice->idr_pic_id = bitstream_ue(bs);
- }
-
- if( sps->pic_order_cnt_type == 0 )
- {
- slice->pic_order_cnt_lsb = bitstream_u(bs, sps->log2_max_pic_order_cnt_lsb_minus4 + 4);
-
- if( pps->pic_order_present_flag && !slice->field_pic_flag )
- {
- slice->delta_pic_order_cnt_bottom = bitstream_se(bs);
- }
- }
-
- if( sps->pic_order_cnt_type == 1 && !sps->delta_pic_order_always_zero_flag )
- {
- slice->delta_pic_order_cnt[0] = bitstream_se(bs);
-
- if( pps->pic_order_present_flag && !slice->field_pic_flag )
- {
- slice->delta_pic_order_cnt[1] = bitstream_se(bs);
- }
- }
-
- if( pps->redundant_pic_cnt_present_flag )
- {
- slice->redundant_pic_cnt = bitstream_ue(bs);
- }
-
- if( slice->slice_type == SLICE_TYPE_B )
- {
- slice->direct_spatial_mv_pred_flag = bitstream_u(bs, 1);
- }
-
- if( slice->slice_type == SLICE_TYPE_P || slice->slice_type == SLICE_TYPE_SP || slice->slice_type == SLICE_TYPE_B )
- {
- slice->num_ref_idx_active_override_flag = bitstream_u(bs, 1);
-
- if( slice->num_ref_idx_active_override_flag )
- {
- slice->num_ref_idx_l0_active_minus1 = bitstream_ue(bs);
-
- if( slice->slice_type == SLICE_TYPE_B )
- {
- slice->num_ref_idx_l1_active_minus1 = bitstream_ue(bs);
- }
- }
- }
-
- /*7.3.3.1 -- Reference picture list reordering */
- if( slice->slice_type != SLICE_TYPE_I && slice->slice_type != SLICE_TYPE_SI )
- {
- slice->ref_pic_reorder.ref_pic_list_reordering_flag_l0 = bitstream_u(bs, 1);
-
- if( slice->ref_pic_reorder.ref_pic_list_reordering_flag_l0 )
- {
- i = -1;
-
- do {
- i++;
-
- slice->ref_pic_reorder.list0[i].reordering_of_pic_nums_idc = bitstream_ue(bs);
-
- if( slice->ref_pic_reorder.list0[i].reordering_of_pic_nums_idc == 0
- || slice->ref_pic_reorder.list0[i].reordering_of_pic_nums_idc == 1)
- {
- slice->ref_pic_reorder.list0[i].abs_diff_pic_num_minus1 = bitstream_ue(bs);
- }
- else if(slice->ref_pic_reorder.list0[i].reordering_of_pic_nums_idc == 2)
- {
- slice->ref_pic_reorder.list0[i].long_term_pic_num = bitstream_ue(bs);
- }
- } while( slice->ref_pic_reorder.list0[i].reordering_of_pic_nums_idc != 3 );
- }
- }
-
- if( slice->slice_type == SLICE_TYPE_B )
- {
- slice->ref_pic_reorder.ref_pic_list_reordering_flag_l1 = bitstream_u(bs, 1);
-
- if( slice->ref_pic_reorder.ref_pic_list_reordering_flag_l1 )
- {
- i = -1;
-
- do {
- i++;
-
- slice->ref_pic_reorder.list1[i].reordering_of_pic_nums_idc = bitstream_ue(bs);
-
- if( slice->ref_pic_reorder.list1[i].reordering_of_pic_nums_idc == 0
- || slice->ref_pic_reorder.list1[i].reordering_of_pic_nums_idc == 1)
- {
- slice->ref_pic_reorder.list1[i].abs_diff_pic_num_minus1 = bitstream_ue(bs);
- }
- else if(slice->ref_pic_reorder.list1[i].reordering_of_pic_nums_idc == 2)
- {
- slice->ref_pic_reorder.list1[i].long_term_pic_num = bitstream_ue(bs);
- }
- } while( slice->ref_pic_reorder.list1[i].reordering_of_pic_nums_idc != 3 );
- }
- }
-
-
- if( ( pps->weighted_pred_flag && ( slice->slice_type == SLICE_TYPE_P || slice->slice_type == SLICE_TYPE_SP ) )
- || ( pps->weighted_bipred_idc == 1 && slice->slice_type == SLICE_TYPE_B )
- )
- {
- //pred_weight_table( )
- //printf("Weighted Table not supported\n");
- }
-
- if( nalu->nal_ref_idc != 0 )
- {
- /*7.3.3.3 Decoded reference picture marking*/
- if( nalu->nal_unit_type == NALU_TYPE_IDR_SLICE || (nalu->nal_unit_type == 20 && nalu->idr_flag))
- {
- slice->ref_pic_marking.no_output_of_prior_pics_flag = bitstream_u(bs, 1);
- slice->ref_pic_marking.long_term_reference_flag = bitstream_u(bs, 1);
- }
- else
- {
- slice->ref_pic_marking.adaptive_ref_pic_marking_mode_flag = bitstream_u(bs, 1);
-
- if( slice->ref_pic_marking.adaptive_ref_pic_marking_mode_flag )
- {
- slice->ref_pic_marking.difference_of_pic_nums_minus1 = -1;
- slice->ref_pic_marking.long_term_pic_num = -1;
- slice->ref_pic_marking.long_term_frame_idx = -1;
- slice->ref_pic_marking.max_long_term_frame_idx_plus1 = -1;
-
- i = -1;
-
- memset(slice->ref_pic_marking.memory_management_control_operation, 0, sizeof(slice->ref_pic_marking.memory_management_control_operation));
-
- do {
- i++;
-
- slice->ref_pic_marking.memory_management_control_operation[i] = bitstream_ue(bs);
-
- if( slice->ref_pic_marking.memory_management_control_operation[i] == 1
- || slice->ref_pic_marking.memory_management_control_operation[i] == 3 )
- {
- slice->ref_pic_marking.difference_of_pic_nums_minus1 = bitstream_ue(bs);
- }
-
- if(slice->ref_pic_marking.memory_management_control_operation[i] == 2 )
- {
- slice->ref_pic_marking.long_term_pic_num = bitstream_ue(bs);
- }
-
- if( slice->ref_pic_marking.memory_management_control_operation[i] == 3 ||
- slice->ref_pic_marking.memory_management_control_operation[i] == 6)
- {
- slice->ref_pic_marking.long_term_frame_idx = bitstream_ue(bs);
- }
-
- if( slice->ref_pic_marking.memory_management_control_operation[i] == 4)
- {
- slice->ref_pic_marking.max_long_term_frame_idx_plus1 = bitstream_ue(bs);
- }
-
- } while( slice->ref_pic_marking.memory_management_control_operation[i] != 0 );
- }
- }
-
-#ifdef READ_SVC
- if( sps->profile_idc == 83 || sps->profile_idc == 86 )
- {
- if(!sps->sps_svc.slice_header_restriction_flag)
- {
- slice->store_ref_base_pic_flag = bitstream_u(bs, 1);
-
- if ( ( nalu->use_ref_base_pic_flag || slice->store_ref_base_pic_flag ) && !nalu->idr_flag )
- {
- int i = -1;
-
- //dec_ref_base_pic_marking( )
- slice->ref_base_pic_marking.adaptive_ref_base_pic_marking_mode_flag = bitstream_u(bs, 1);
-
- if( slice->ref_base_pic_marking.adaptive_ref_base_pic_marking_mode_flag )
- {
- do
- {
- i++;
-
- slice->ref_base_pic_marking.memory_management_base_control_operation[i] = bitstream_ue(bs);
-
- if( slice->ref_base_pic_marking.memory_management_base_control_operation[i] == 1 )
- {
- slice->ref_base_pic_marking.difference_of_base_pic_nums_minus1 = bitstream_ue(bs);
- }
-
- if( slice->ref_base_pic_marking.memory_management_base_control_operation[i] == 2 )
- {
- slice->ref_base_pic_marking.long_term_base_pic_num = bitstream_ue(bs);
- }
- } while( slice->ref_base_pic_marking.memory_management_base_control_operation[i] != 0 );
- }
- }
- }
- }
-#endif
- }
-
- if( pps->entropy_coding_mode_flag && slice->slice_type != SLICE_TYPE_I && slice->slice_type != SLICE_TYPE_SI )
- {
- slice->cabac_init_idc = bitstream_ue(bs);
- }
-
- slice->slice_qp_delta = bitstream_se(bs);
-
- if( slice->slice_type == SLICE_TYPE_SP || slice->slice_type == SLICE_TYPE_SI )
- {
- if( slice->slice_type == SLICE_TYPE_SP )
- {
- slice->sp_for_switch_flag = bitstream_u(bs, 1);
- }
-
- slice->slice_qs_delta = bitstream_se(bs);
- }
-
- if( pps->deblocking_filter_control_present_flag )
- {
- slice->disable_deblocking_filter_idc = bitstream_ue(bs);
-
- if( slice->disable_deblocking_filter_idc != 1 )
- {
- slice->slice_alpha_c0_offset_div2 = bitstream_se(bs);
- slice->slice_beta_offset_div2 = bitstream_se(bs);
- }
- }
-
- if( pps->num_slice_groups_minus1 > 0
- && pps->slice_group_map_type >= 3
- && pps->slice_group_map_type <= 5)
- {
-
- int bits=0;
- int pic_size, change_rate;
- unsigned int value;
-
- pic_size = pps->pic_size_in_map_units_minus1 + 1;
- change_rate = pps->slice_group_change_rate_minus1 + 1;
-
- value = pic_size / change_rate + 1;
-
- while(value != 0)
- {
- bits++;
- value >>= 1;
- }
-
- slice->slice_group_change_cycle = bitstream_u(bs, bits);
- }
-
-#ifdef READ_SVC
- if( sps->profile_idc == 83 || sps->profile_idc == 86 )
- {
- if(!sps->sps_svc.slice_header_restriction_flag && !slice_skip_flag)
- {
- slice->scan_idx_start = read_u(bs, 4);
- slice->scan_idx_end = read_u(bs, 4);
- }
- }
-#endif
-#endif
-}
-
-
-int nalu_parse_sps(struct bitstream_elmt_t *bs, struct sequence_params_set_t *sps)
-{
- int i;
-
- sps->profile_idc = bitstream_u(bs, 8);
- sps->constraint_set0_flag = bitstream_u(bs, 1);
- sps->constraint_set1_flag = bitstream_u(bs, 1);
- sps->constraint_set2_flag = bitstream_u(bs, 1);
- sps->constraint_set3_flag = bitstream_u(bs, 1);
- sps->reserved_zero_4bits = bitstream_u(bs, 4); /* equal to 0 */
- sps->level_idc = bitstream_u(bs, 8);
- sps->seq_parameter_set_id = bitstream_ue(bs);
- sps->log2_max_frame_num_minus4 = bitstream_ue(bs);
- sps->pic_order_cnt_type = bitstream_ue(bs);
-
- if(sps->pic_order_cnt_type == 0)
- {
- sps->log2_max_pic_order_cnt_lsb_minus4 = bitstream_ue(bs);
- }
- else if(sps->pic_order_cnt_type == 1)
- {
- sps->delta_pic_order_always_zero_flag = bitstream_u(bs, 1);
- sps->offset_for_non_ref_pic = bitstream_se(bs);
- sps->offset_for_top_to_bottom_field = bitstream_se(bs);
- sps->num_ref_frames_in_pic_order_cnt_cycle = bitstream_ue(bs);
-
- sps->offset_for_ref_frame = malloc(sizeof(sps->offset_for_ref_frame[0]) * sps->num_ref_frames_in_pic_order_cnt_cycle);
-
- for(i=0; i < sps->num_ref_frames_in_pic_order_cnt_cycle; i++)
- {
- sps->offset_for_ref_frame[i] = bitstream_se(bs);
- }
- }
-
- sps->num_ref_frames = bitstream_ue(bs);
- sps->gaps_in_frame_num_value_allowed_flag = bitstream_u(bs, 1);
- sps->pic_width_in_mbs_minus1 = bitstream_ue(bs);
- sps->pic_height_in_map_units_minus1 = bitstream_ue(bs);
- sps->frame_mbs_only_flag = bitstream_u(bs, 1);
-
- if(!sps->frame_mbs_only_flag)
- {
- sps->mb_adaptive_frame_field_flag = bitstream_u(bs, 1);
- }
-
- sps->direct_8x8_inference_flag = bitstream_u(bs, 1);
- sps->frame_cropping_flag = bitstream_u(bs, 1);
-
- if(sps->frame_cropping_flag)
- {
- sps->frame_crop_left_offset = bitstream_ue(bs);
- sps->frame_crop_right_offset = bitstream_ue(bs);
- sps->frame_crop_top_offset = bitstream_ue(bs);
- sps->frame_crop_bottom_offset = bitstream_ue(bs);
- }
-
- sps->vui_parameters_present_flag = bitstream_u(bs, 1);
-
- if(sps->vui_parameters_present_flag)
- {
- sps->vui.aspect_ratio_info_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.aspect_ratio_info_present_flag )
- {
- sps->vui.aspect_ratio_idc = bitstream_u(bs, 8);
-
- if( sps->vui.aspect_ratio_idc == VUI_SAR_EXTENDED)
- {
- sps->vui.sar_width = bitstream_u(bs, 16);
- sps->vui.sar_height = bitstream_u(bs, 16);
- }
- }
-
- sps->vui.overscan_info_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.overscan_info_present_flag )
- {
- sps->vui.overscan_appropriate_flag = bitstream_u(bs, 1);
- }
-
- sps->vui.video_signal_type_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.video_signal_type_present_flag )
- {
- sps->vui.video_format = bitstream_u(bs, 3);
- sps->vui.video_full_range_flag = bitstream_u(bs, 1);
- sps->vui.colour_description_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.colour_description_present_flag )
- {
- sps->vui.colour_primaries = bitstream_u(bs, 8);
- sps->vui.transfer_characteristics = bitstream_u(bs, 8);
- sps->vui.matrix_coefficients = bitstream_u(bs, 8);
- }
- }
-
- sps->vui.chroma_loc_info_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.chroma_loc_info_present_flag )
- {
- sps->vui.chroma_sample_loc_type_top_field = bitstream_ue(bs);
- sps->vui.chroma_sample_loc_type_bottom_field = bitstream_ue(bs);
- }
-
- sps->vui.timing_info_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.timing_info_present_flag )
- {
- sps->vui.num_units_in_tick = bitstream_u(bs, 32);
- sps->vui.time_scale = bitstream_u(bs, 32);
- sps->vui.fixed_frame_rate_flag = bitstream_u(bs, 1);
- }
-
- sps->vui.nal_hrd_parameters_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.nal_hrd_parameters_present_flag )
- {
- int SchedSelIdx;
-
- sps->vui.nal_hrd.cpb_cnt_minus1 = bitstream_ue(bs);
- sps->vui.nal_hrd.bit_rate_scale = bitstream_u(bs, 4);
- sps->vui.nal_hrd.cpb_size_scale = bitstream_u(bs, 4);
-
- sps->vui.nal_hrd.bit_rate_value_minus1 = malloc(sizeof(sps->vui.nal_hrd.bit_rate_value_minus1[0]) * (sps->vui.nal_hrd.cpb_cnt_minus1 + 1));
- sps->vui.nal_hrd.cpb_size_value_minus1 = malloc(sizeof(sps->vui.nal_hrd.cpb_size_value_minus1[0]) * (sps->vui.nal_hrd.cpb_cnt_minus1 + 1));
- sps->vui.nal_hrd.cbr_flag = malloc(sizeof(sps->vui.nal_hrd.cbr_flag[0]) * (sps->vui.nal_hrd.cpb_cnt_minus1 + 1));
-
- for( SchedSelIdx = 0; SchedSelIdx <= sps->vui.nal_hrd.cpb_cnt_minus1; SchedSelIdx++ )
- {
- sps->vui.nal_hrd.bit_rate_value_minus1[ SchedSelIdx ] = bitstream_ue(bs);
- sps->vui.nal_hrd.cpb_size_value_minus1[ SchedSelIdx ] = bitstream_ue(bs);
- sps->vui.nal_hrd.cbr_flag[ SchedSelIdx ] = bitstream_u(bs, 1);
- }
-
- sps->vui.nal_hrd.initial_cpb_removal_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.nal_hrd.cpb_removal_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.nal_hrd.dpb_output_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.nal_hrd.time_offset_length = bitstream_u(bs, 5);
- }
-
- sps->vui.vcl_hrd_parameters_present_flag = bitstream_u(bs, 1);
-
- if( sps->vui.vcl_hrd_parameters_present_flag )
- {
- int SchedSelIdx;
-
- sps->vui.vlc_hrd.cpb_cnt_minus1 = bitstream_ue(bs);
- sps->vui.vlc_hrd.bit_rate_scale = bitstream_u(bs, 4);
- sps->vui.vlc_hrd.cpb_size_scale = bitstream_u(bs, 4);
-
- sps->vui.vlc_hrd.bit_rate_value_minus1 = malloc(sizeof(sps->vui.vlc_hrd.bit_rate_value_minus1[0]) * (sps->vui.vlc_hrd.cpb_cnt_minus1 + 1));
- sps->vui.vlc_hrd.cpb_size_value_minus1 = malloc(sizeof(sps->vui.vlc_hrd.cpb_size_value_minus1[0]) * (sps->vui.vlc_hrd.cpb_cnt_minus1 + 1));
- sps->vui.vlc_hrd.cbr_flag = malloc(sizeof(sps->vui.vlc_hrd.cbr_flag[0]) * (sps->vui.vlc_hrd.cpb_cnt_minus1 + 1));
-
- for( SchedSelIdx = 0; SchedSelIdx <= sps->vui.vlc_hrd.cpb_cnt_minus1; SchedSelIdx++ )
- {
- sps->vui.vlc_hrd.bit_rate_value_minus1[ SchedSelIdx ] = bitstream_ue(bs);
- sps->vui.vlc_hrd.cpb_size_value_minus1[ SchedSelIdx ] = bitstream_ue(bs);
- sps->vui.vlc_hrd.cbr_flag[ SchedSelIdx ] = bitstream_u(bs, 1);
- }
-
- sps->vui.vlc_hrd.initial_cpb_removal_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.vlc_hrd.cpb_removal_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.vlc_hrd.dpb_output_delay_length_minus1 = bitstream_u(bs, 5);
- sps->vui.vlc_hrd.time_offset_length = bitstream_u(bs, 5);
- }
-
- if( sps->vui.nal_hrd_parameters_present_flag || sps->vui.vcl_hrd_parameters_present_flag )
- {
- sps->vui.low_delay_hrd_flag = bitstream_u(bs, 1);
- }
-
- sps->vui.pic_struct_present_flag = bitstream_u(bs, 1);
- sps->vui.bitstream_restriction_flag = bitstream_u(bs, 1);
-
- if( sps->vui.bitstream_restriction_flag )
- {
- sps->vui.motion_vectors_over_pic_boundaries_flag = bitstream_u(bs, 1);
- sps->vui.max_bytes_per_pic_denom = bitstream_ue(bs);
- sps->vui.max_bits_per_mb_denom = bitstream_ue(bs);
- sps->vui.log2_max_mv_length_horizontal = bitstream_ue(bs);
- sps->vui.log2_max_mv_length_vertical = bitstream_ue(bs);
- sps->vui.num_reorder_frames = bitstream_ue(bs);
- sps->vui.max_dec_frame_buffering = bitstream_ue(bs);
- }
- }
-
- _rbsp_trailing_bits(bs);
-
- return 0;
-}
-
-int nalu_parse_pps(struct bitstream_elmt_t *bs, struct picture_params_set_t *pps)
-{
- pps->pic_parameter_set_id = bitstream_ue(bs);
- pps->seq_parameter_set_id = bitstream_ue(bs);
- pps->entropy_coding_mode_flag = bitstream_u(bs, 1);
- pps->pic_order_present_flag = bitstream_u(bs, 1);
- pps->num_slice_groups_minus1 = bitstream_ue(bs);
-
- if( pps->num_slice_groups_minus1 > 0 )
- {
- pps->slice_group_map_type = bitstream_ue(bs);
-
- if( pps->slice_group_map_type == 0 )
- {
- int iGroup;
-
- pps->run_length_minus1 = malloc( (pps->num_slice_groups_minus1 + 1) * sizeof(pps->run_length_minus1[0]));
-
- for( iGroup = 0; iGroup <= pps->num_slice_groups_minus1; iGroup++ )
- {
- pps->run_length_minus1[iGroup] = bitstream_ue(bs);
- }
- }
- else if( pps->slice_group_map_type == 2 )
- {
- int iGroup;
-
- pps->top_left = malloc( (pps->num_slice_groups_minus1 + 1) * sizeof(pps->top_left[0]));
- pps->bottom_right = malloc( (pps->num_slice_groups_minus1 + 1) * sizeof(pps->bottom_right[0]));
-
- for( iGroup = 0; iGroup < pps->num_slice_groups_minus1; iGroup++ )
- {
- pps->top_left[iGroup] = bitstream_ue(bs);
- pps->bottom_right[iGroup] = bitstream_ue(bs);
- }
- }
- else if( pps->slice_group_map_type == 3 ||
- pps->slice_group_map_type == 4 ||
- pps->slice_group_map_type == 5 )
- {
- pps->slice_group_change_direction_flag = bitstream_u(bs, 1);
- pps->slice_group_change_rate_minus1 = bitstream_ue(bs);
- }
- else if( pps->slice_group_map_type == 6 )
- {
- int i;
- int bits=0;
- int pic_size;
-
-
- pps->pic_size_in_map_units_minus1 = bitstream_ue(bs);
-
- pps->slice_group_id = malloc( (pps->pic_size_in_map_units_minus1 + 1) * sizeof(pps->slice_group_id[0]));
-
- pic_size = pps->pic_size_in_map_units_minus1 + 1;
-
- while(pic_size != 0)
- {
- bits++;
- pic_size >>= 1;
- }
-
-
- for( i = 0; i <= pps->pic_size_in_map_units_minus1; i++ )
- {
- pps->slice_group_id[i] = bitstream_u(bs, bits);
- }
- }
- }
-
- pps->num_ref_idx_l0_active_minus1 = bitstream_ue(bs);
- pps->num_ref_idx_l1_active_minus1 = bitstream_ue(bs);
- pps->weighted_pred_flag = bitstream_u(bs, 1);
- pps->weighted_bipred_idc = bitstream_u(bs, 2);
- pps->pic_init_qp_minus26 = bitstream_se(bs); /* relative to 26 */
- pps->pic_init_qs_minus26 = bitstream_se(bs); /* relative to 26 */
- pps->chroma_qp_index_offset = bitstream_se(bs);
- pps->deblocking_filter_control_present_flag = bitstream_u(bs, 1);
- pps->constrained_intra_pred_flag = bitstream_u(bs, 1);
- pps->redundant_pic_cnt_present_flag = bitstream_u(bs, 1);
-
-#if 0
- if( more_rbsp_data( ) )
- {
- pps->transform_8x8_mode_flag
- pps->pic_scaling_matrix_present_flag
- if( pps->pic_scaling_matrix_present_flag )
- {
- for( i = 0; i < 6 + 2 * pps->transform_8x8_mode_flag; i++ )
- {
- pps->pic_scaling_list_present_flag[i]
- if( pps->pic_scaling_list_present_flag[i] )
- {
- if( i < 6 )
- {
- scaling_list( ScalingList4x4[ i ], 16,
- UseDefaultScalingMatrix4x4Flag[ i ] )
- }
- else
- {
- scaling_list( ScalingList8x8[ i - 6 ], 64,
- UseDefaultScalingMatrix8x8Flag[ i - 6 ] )
- }
- }
- }
- }
-
- second_chroma_qp_index_offset
- }
-#endif
-
- _rbsp_trailing_bits(bs);
-
- return 0;
-}
-
-
-
-int _rbsp_trailing_bits(struct bitstream_elmt_t *bs)
-{
- int bit;
-
- if( (bit = bitstream_u(bs, 1)) != 1)/*stop bit -- should be 1*/
- {
- return -1;
- }
-
- while(!bitstream_bytealigned(bs))
- {
- if( (bit = bitstream_u(bs, 1)) != 0)/*alignment bit -- should be 0*/
- {
- return -1;
- }
- }
-
- return 0;
-}
-
-int nalu_read(FILE *fp, unsigned char *buf)
-{
- /*buffer in 100 bytes then start parsing*/
- unsigned int psc = 0, byte = 0;
- int psc_found = 0;
- int i;
- int nalu_len;
- int bytes_in_buffer;
-
- struct bitstream_elmt_t bs;
- int leading_zero_byte_cnt = 0;
-
-#if 1
- while( (fread(&byte, 1, 1, fp)) == 1)
- {
- if(byte == 1)
- {
- if(leading_zero_byte_cnt >= 2)
- {
- psc_found = 1;
- break;
- }
- }
-
- if(byte == 0)
- leading_zero_byte_cnt++;
- else
- leading_zero_byte_cnt = 0;
- }
-
- if(!psc_found)
- return -1;
-
- leading_zero_byte_cnt = 0;
- psc_found = 0;
- nalu_len = 0;
- bytes_in_buffer = 0;
- while( (fread(&byte, 1, 1, fp)) == 1)
- {
- if(byte == 1)
- {
- if(leading_zero_byte_cnt >= 2)
- {
- /*backup 3 bytes so next run sees the start code*/
- psc_found = 1;
- fseek(fp, -3, SEEK_CUR);
- bytes_in_buffer -= 3;
- break;
- }
- }
-
- if(byte == 0)
- leading_zero_byte_cnt++;
- else
- leading_zero_byte_cnt = 0;
-
- buf[bytes_in_buffer] = byte;
- bytes_in_buffer++;
- }
-
- if(leading_zero_byte_cnt > 3)
- {
- printf("Found packet with too many leading zero's in start code");
- }
-
- if(!psc_found)
- {
- printf("End of stream\n");
- }
-
- nalu_len = bytes_in_buffer;
-#endif
-
-#if 0
-
- fread(&psc, 1, 3, fp);
-
- if(psc != 0x000001)
- {
- psc = psc << 8;
-
- fread(&byte, 1, 1, fp);
-
- psc = (psc & 0xFFFFFF00) | (byte & 0xFF);
-
- if(psc != 0x00000001)
- {
- /*rewind stream*/
- fseek(fp, -4, SEEK_CUR);
-
- return -1;
- }
- }
-
- bitstream_init(&bs, buf);
- nalu_len = 0;
- bytes_in_buffer = 0;
- do
- {
- bytes_in_buffer += fread(buf, 1, NALU_READ_PRELOAD, fp);
-
- for(i=0; i < bytes_in_buffer-3; i++)
- {
- if(bitstream_peak(&bs, 24) == 1 || bitstream_peak(&bs, 32) == 1)
- {
- psc_found = 1;
- break;
- }
-
- bitstream_u(&bs, 8);
- nalu_len++;
- }
-
- bytes_in_buffer -= i;
- buf += NALU_READ_PRELOAD;
- }while(!psc_found);
-
- fseek(fp, -bytes_in_buffer, SEEK_CUR);
-#endif
-
-#if 0
-
- fread(&psc, 1, 4, fp);
-
- fread(buf, 1, 8, fp);
-
- nalu_len = 8;
-#endif
-
- return nalu_len;
-}
diff --git a/ftl_app/nalu.h b/ftl_app/nalu.h
deleted file mode 100644
index 41f62e40fcb3bbbe..0000000000000000
--- a/ftl_app/nalu.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdio.h>
-
-#define NALU_READ_PRELOAD 100
-
-int nal_unit(h264_dec_obj_t *obj, struct bitstream_elmt_t *bs, struct nalu_t *nalu, int len);
-int nalu_read(FILE *fp, unsigned char *buf);
-int nalu_parse_sps(struct bitstream_elmt_t *bs, struct sequence_params_set_t *sps);
-int nalu_parse_pps(struct bitstream_elmt_t *bs, struct picture_params_set_t *pps);
-void nalu_parse_slice_header(struct bitstream_elmt_t *bs, struct nalu_t *nalu, struct slice_header_t *slice);
\ No newline at end of file
diff --git a/ftl_app/posix/ctrlc_handler.c b/ftl_app/posix/ctrlc_handler.c
deleted file mode 100644
index 359307921f4f66c9..0000000000000000
--- a/ftl_app/posix/ctrlc_handler.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
-* ctrlc_handler.cpp - POSIX handler for Ctrl-C behavior
-*
-* Copyright (c) 2015 Michael Casadevall
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-**/
-
-#include "main.h"
-
-/**
- * On POSIX platforms, we need to catch SIGINT, and and change the state
- * of the shutdown flag. When we're in a signal handler, we've very limited
- * in the type of calls we can safely make due to the state of the stack
- * and potentially being anywhere in the calling program's execution.
- *
- * As such, the "safest" thing to do is simply set a global variable which
- * breaks us out of the loop, and brings us to our shutdown code.
- */
-
-volatile sig_atomic_t shutdown_flag = 0;
-
-void charon_shutdown_stream(int sig) {
- shutdown_flag = 1;
-}
-
-void charon_install_ctrlc_handler() {
- signal(SIGINT, charon_shutdown_stream);
-}
-
-void charon_loop_until_ctrlc() {
- while (shutdown_flag != 1) {
- sleep(1);
- }
-}
-
-int ctrlc_pressed() {
- return shutdown_flag;
-}
diff --git a/ftl_app/utils.c b/ftl_app/utils.c
deleted file mode 100644
index a88f0d98ed2f1e38..0000000000000000
--- a/ftl_app/utils.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "bitstream.h"
-#include "dec_obj.h"
-#include "utils.h"
-
-struct picture_params_set_t *pps_head = NULL;
-struct sequence_params_set_t *sps_head = NULL;
-
-void store_sps(struct sequence_params_set_t *sps)
-{
- struct sequence_params_set_t *sps_new, *tmp;
-
- sps_new = (struct sequence_params_set_t *)malloc(sizeof(struct sequence_params_set_t));
- memcpy(sps_new, sps, sizeof(struct sequence_params_set_t));
- sps_new->next = NULL;
-
- if(sps_head == NULL)
- {
- sps_head = sps_new;
- }
- else
- {
- /*find the tail*/
- tmp = sps_head;
-
- while(tmp->next != NULL)
- {
- tmp = tmp->next;
- }
-
- tmp->next = sps_new;
- }
-}
-
-struct sequence_params_set_t * find_sps(int nal_unit_type, int seq_parameter_set_id)
-{
- struct sequence_params_set_t *tmp;
-
- tmp = sps_head;
-
- while(tmp != NULL)
- {
- if(nal_unit_type == 20 || nal_unit_type == 14)
- {
- if( (tmp->profile_idc == 83 || tmp->profile_idc == 86) && tmp->seq_parameter_set_id == seq_parameter_set_id)
- {
- return tmp;
- }
- }
- else
- {
-
- if(tmp->seq_parameter_set_id == seq_parameter_set_id)
- {
- return tmp;
- }
- }
-
- tmp = tmp->next;
- }
-
- return NULL;
-}
-
-
-
-void store_pps(struct picture_params_set_t *pps)
-{
- struct picture_params_set_t *pps_new, *tmp;
-
- pps_new = (struct picture_params_set_t *)malloc(sizeof(struct picture_params_set_t));
- memcpy(pps_new, pps, sizeof(struct picture_params_set_t));
- pps_new->next = NULL;
-
- if(pps_head == NULL)
- {
- pps_head = pps_new;
- }
- else
- {
- /*find the tail*/
- tmp = pps_head;
-
- while(tmp->next != NULL)
- {
- tmp = tmp->next;
- }
-
- tmp->next = pps_new;
- }
-}
-
-struct picture_params_set_t * find_pps(int pic_parameter_set_id)
-{
- struct picture_params_set_t *tmp;
-
- tmp = pps_head;
-
- while(tmp != NULL)
- {
- if(tmp->pic_parameter_set_id == pic_parameter_set_id)
- {
- return tmp;
- }
-
- tmp = tmp->next;
- }
-
- return NULL;
-}
diff --git a/ftl_app/utils.h b/ftl_app/utils.h
deleted file mode 100644
index 472c555014c46402..0000000000000000
--- a/ftl_app/utils.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#define MIN(x,y) ((x < y) ? x : y)
-#define MAX(x,y) ((x > y) ? x : y)
-
-void store_sps(struct sequence_params_set_t *sps);
-struct sequence_params_set_t * find_sps(int nal_unit_type, int seq_parameter_set_id);
-void store_pps(struct picture_params_set_t *pps);
-struct picture_params_set_t * find_pps(int pic_parameter_set_id);
\ No newline at end of file
diff --git a/ftl_app/win32/ctrlc_handler.c b/ftl_app/win32/ctrlc_handler.c
deleted file mode 100644
index 885f2ab6290d7a4f..0000000000000000
--- a/ftl_app/win32/ctrlc_handler.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
-* ctrlc_handler.cpp - Win32 handler for Ctrl-C behavior
-*
-* Copyright (c) 2015 Michael Casadevall
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-**/
-
-#include "main.h"
-
-/**
-* On POSIX platforms, we need to catch SIGINT, and and change the state
-* of the shutdown flag. When we're in a signal handler, we've very limited
-* in the type of calls we can safely make due to the state of the stack
-* and potentially being anywhere in the calling program's execution.
-*
-* As such, the "safest" thing to do is simply set a global variable which
-* breaks us out of the loop, and brings us to our shutdown code.
-*/
-
-volatile int shutdown_flag = 0;
-
-BOOL charon_shutdown_stream(DWORD fdwCtrlType) {
- // We always shutdown regardless of control message
- shutdown_flag = 1;
-
- // Ugh, hacky hacky hacky. CtrlCHandler calls this
- // on its own thread, not on the main thread.
-
- // Once this function returns, we get grim-reaped. On Win7
- // and later, we have 10 seconds before we get nuked from
- // orbit.
-
- Sleep(3000);
- switch (fdwCtrlType) {
- case CTRL_C_EVENT:
- case CTRL_CLOSE_EVENT:
- return TRUE;
- }
-
- // Some messages need to go the next handler
- return FALSE;
-}
-
-void charon_install_ctrlc_handler() {
- SetConsoleCtrlHandler((PHANDLER_ROUTINE)charon_shutdown_stream, TRUE);
-}
-
-BOOL ctrlc_pressed() {
- return shutdown_flag;
-}
-
-void charon_loop_until_ctrlc() {
- while (shutdown_flag != 1) {
- Sleep(1000);
- }
-}
diff --git a/ftl_app/win32/xgetopt.c b/ftl_app/win32/xgetopt.c
deleted file mode 100644
index 9712c0c01b8ea5a1..0000000000000000
--- a/ftl_app/win32/xgetopt.c
+++ /dev/null
@@ -1,213 +0,0 @@
-// XGetopt.cpp Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// Description:
-// XGetopt.cpp implements getopt(), a function to parse command lines.
-//
-// History
-// Version 1.2 - 2003 May 17
-// - Added Unicode support
-//
-// Version 1.1 - 2002 March 10
-// - Added example to XGetopt.cpp module header
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-
-///////////////////////////////////////////////////////////////////////////////
-// if you are not using precompiled headers then include these lines:
-#include <windows.h>
-#include <stdio.h>
-#include <tchar.h>
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include "XGetopt.h"
-
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// X G e t o p t . c p p
-//
-//
-// NAME
-// getopt -- parse command line options
-//
-// SYNOPSIS
-// int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
-//
-// extern TCHAR *optarg;
-// extern int optind;
-//
-// DESCRIPTION
-// The getopt() function parses the command line arguments. Its
-// arguments argc and argv are the argument count and array as
-// passed into the application on program invocation. In the case
-// of Visual C++ programs, argc and argv are available via the
-// variables __argc and __argv (double underscores), respectively.
-// getopt returns the next option letter in argv that matches a
-// letter in optstring. (Note: Unicode programs should use
-// __targv instead of __argv. Also, all character and string
-// literals should be enclosed in _T( ) ).
-//
-// optstring is a string of recognized option letters; if a letter
-// is followed by a colon, the option is expected to have an argument
-// that may or may not be separated from it by white space. optarg
-// is set to point to the start of the option argument on return from
-// getopt.
-//
-// Option letters may be combined, e.g., "-ab" is equivalent to
-// "-a -b". Option letters are case sensitive.
-//
-// getopt places in the external variable optind the argv index
-// of the next argument to be processed. optind is initialized
-// to 0 before the first call to getopt.
-//
-// When all options have been processed (i.e., up to the first
-// non-option argument), getopt returns EOF, optarg will point
-// to the argument, and optind will be set to the argv index of
-// the argument. If there are no non-option arguments, optarg
-// will be set to NULL.
-//
-// The special option "--" may be used to delimit the end of the
-// options; EOF will be returned, and "--" (and everything after it)
-// will be skipped.
-//
-// RETURN VALUE
-// For option letters contained in the string optstring, getopt
-// will return the option letter. getopt returns a question mark (?)
-// when it encounters an option letter not included in optstring.
-// EOF is returned when processing is finished.
-//
-// BUGS
-// 1) Long options are not supported.
-// 2) The GNU double-colon extension is not supported.
-// 3) The environment variable POSIXLY_CORRECT is not supported.
-// 4) The + syntax is not supported.
-// 5) The automatic permutation of arguments is not supported.
-// 6) This implementation of getopt() returns EOF if an error is
-// encountered, instead of -1 as the latest standard requires.
-//
-// EXAMPLE
-// BOOL CMyApp::ProcessCommandLine(int argc, TCHAR *argv[])
-// {
-// int c;
-//
-// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
-// {
-// switch (c)
-// {
-// case _T('a'):
-// TRACE(_T("option a\n"));
-// //
-// // set some flag here
-// //
-// break;
-//
-// case _T('B'):
-// TRACE( _T("option B\n"));
-// //
-// // set some other flag here
-// //
-// break;
-//
-// case _T('n'):
-// TRACE(_T("option n: value=%d\n"), atoi(optarg));
-// //
-// // do something with value here
-// //
-// break;
-//
-// case _T('?'):
-// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
-// return FALSE;
-// break;
-//
-// default:
-// TRACE(_T("WARNING: no handler for option %c\n"), c);
-// return FALSE;
-// break;
-// }
-// }
-// //
-// // check for non-option args here
-// //
-// return TRUE;
-// }
-//
-///////////////////////////////////////////////////////////////////////////////
-
-TCHAR *optarg; // global argument pointer
-int optind = 0; // global argv index
-
-int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
-{
- static TCHAR *next = NULL;
- if (optind == 0)
- next = NULL;
-
- optarg = NULL;
-
- if (next == NULL || *next == _T('\0'))
- {
- if (optind == 0)
- optind++;
-
- if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
- {
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- if (_tcscmp(argv[optind], _T("--")) == 0)
- {
- optind++;
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- next = argv[optind];
- next++; // skip past -
- optind++;
- }
-
- TCHAR c = *next++;
- TCHAR *cp = _tcschr(optstring, c);
-
- if (cp == NULL || c == _T(':'))
- return _T('?');
-
- cp++;
- if (*cp == _T(':'))
- {
- if (*next != _T('\0'))
- {
- optarg = next;
- next = NULL;
- }
- else if (optind < argc)
- {
- optarg = argv[optind];
- optind++;
- }
- else
- {
- return _T('?');
- }
- }
-
- return c;
-}
diff --git a/ftl_app/win32/xgetopt.h b/ftl_app/win32/xgetopt.h
deleted file mode 100644
index 55455d8ed130a724..0000000000000000
--- a/ftl_app/win32/xgetopt.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// XGetopt.h Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef XGETOPT_H
-#define XGETOPT_H
-
-int optind, opterr;
-extern TCHAR *optarg;
-
-int getopt(int argc, TCHAR *argv[], TCHAR *optstring);
-
-#endif //XGETOPT_H
diff --git a/get-audio b/get-audio
deleted file mode 100755
index e1418688296a3219..0000000000000000
--- a/get-audio
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-set -ue
-
-OUTPUT=$1
-
-curl 'https://www.dropbox.com/s/s2r6lggopt9ftw5/sintel.opus' \
- -H 'authority: www.dropbox.com' \
- -H 'cache-control: max-age=0' \
- -H 'upgrade-insecure-requests: 1' \
- -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' \
- -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' \
- -H 'accept-encoding: gzip, deflate, br' \
- -H 'accept-language: en-US,en;q=0.9' \
- -H 'cookie: __Host-ss=UsByWdIPus; locale=en; gvc=MjU4NzQxNzA3MDE4MjU3MDIzNDY0Nzc2NjAxNDg5MTU4MTg0MjYz; seen-sl-signup-modal=VHJ1ZQ%3D%3D; t=0-Hq7tZ1TDyj-aBNiWYv8YQl; __Host-js_csrf=0-Hq7tZ1TDyj-aBNiWYv8YQl; seen-sl-download-modal=VHJ1ZQ%3D%3D' \
- --compressed > $OUTPUT
-
diff --git a/get-video b/get-video
deleted file mode 100755
index f247f2847ab829e1..0000000000000000
--- a/get-video
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-set -ue
-
-OUTPUT=$1
-
-curl 'https://www.dropbox.com/s/ruijibs0lgjnq51/sintel.h264' \
- -H 'authority: www.dropbox.com' \
- -H 'cache-control: max-age=0' \
- -H 'upgrade-insecure-requests: 1' \
- -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' \
- -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' \
- -H 'accept-encoding: gzip, deflate, br' \
- -H 'accept-language: en-US,en;q=0.9' \
- -H 'cookie: __Host-ss=UsByWdIPus; locale=en; gvc=MjU4NzQxNzA3MDE4MjU3MDIzNDY0Nzc2NjAxNDg5MTU4MTg0MjYz; seen-sl-signup-modal=VHJ1ZQ%3D%3D; t=0-Hq7tZ1TDyj-aBNiWYv8YQl; __Host-js_csrf=0-Hq7tZ1TDyj-aBNiWYv8YQl; seen-sl-download-modal=VHJ1ZQ%3D%3D' \
- --compressed > $OUTPUT
diff --git a/make-deployment-yml b/make-deployment-yml
deleted file mode 100755
index dd571c2546e03c0e..0000000000000000
--- a/make-deployment-yml
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-set -eu
-
-TOTAL_CPU=150
-TOTAL_MEM=50
-
-CPU_LIMIT=$((TOTAL_CPU))
-MEM_LIMIT=$((TOTAL_MEM))
-
-cat <<EOF
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: ftl-sdk-deployment
- labels:
- app: ftl-sdk
-spec:
- replicas: 1
- selector:
- matchLabels:
- app: ftl-sdk
-
- template:
- metadata:
- labels:
- app: ftl-sdk
- spec:
- containers:
- - name: ftl-sdk
- image: $IMAGE
- resources:
- requests:
- memory: "${TOTAL_MEM}Mi"
- cpu: "${TOTAL_CPU}m"
- limits:
- memory: "${MEM_LIMIT}Mi"
- cpu: "${CPU_LIMIT}m"
- env:
- - name: MIXER_STREAMER_KEY
- value: "$MIXER_STREAMER_KEY"
- - name: FPS
- value: "24"
- imagePullSecrets:
- - name: docker-secret
-EOF
diff --git a/scripts/build b/scripts/build
deleted file mode 100755
index 99b8067bc3cb3b52..0000000000000000
--- a/scripts/build
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-set -ue
-
-BUILD_DIR='build-output'
-mkdir -p "$BUILD_DIR"
-pushd "$BUILD_DIR"
-cmake ..
-make "-j$(nproc --all)"
-
-popd
-mkdir -p publish
-cp "${BUILD_DIR}/ftl_app" publish
-cp "${BUILD_DIR}"/libftl.so* publish
-
diff --git a/scripts/docker-build b/scripts/docker-build
deleted file mode 100755
index 3eaa72e635e7d79d..0000000000000000
--- a/scripts/docker-build
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-set -ue
-
-: "${DOCKER_TAG:=ftl-sdk}"
-: "${VIDEO_URL:=https://videotestmedia.blob.core.windows.net/ftl/sintel.h264}"
-: "${AUDIO_URL:=https://videotestmedia.blob.core.windows.net/ftl/sintel.opus}"
-
-git submodule init
-git submodule update
-
-docker build \
- --build-arg VIDEO_URL="$VIDEO_URL" \
- --build-arg AUDIO_URL="$AUDIO_URL" \
- -t "$DOCKER_TAG" \
- .
-
-docker push "$DOCKER_TAG"
diff --git a/scripts/docker-test b/scripts/docker-test
deleted file mode 100755
index 1043684934941544..0000000000000000
--- a/scripts/docker-test
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-set -ue
-
-: "${DOCKER_TAG:=ftl-sdk}"
-
-main () {
- echo "running linter"
-
- local lint_script;
- lint_script="$(dirname "$(realpath -s "$0")")/lint"
- "${lint_script}"
-
-}
-
-main
-
diff --git a/scripts/lint b/scripts/lint
deleted file mode 100755
index 6f4b9ceeab384a3a..0000000000000000
--- a/scripts/lint
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-set -ue
-
-MOUNT_DIR='/build'
-IMAGE='koalaman/shellcheck'
-
-scripts_to_lint () {
- grep -Erl '^#!/bin/(ba)?sh' "${base_dir}/scripts" \
- | grep -v '^.git'
-}
-
-main () {
- local base_dir
- base_dir="$(dirname "$(dirname "$(realpath -s "$0")")")"
-
- local scripts
- scripts="$(scripts_to_lint | sed "s|$base_dir|$MOUNT_DIR|")"
-
- for script in $scripts; do
- echo "linting ${script}..."
- docker run \
- --rm \
- -w "$base_dir" \
- -v "${base_dir}:${MOUNT_DIR}" \
- "$IMAGE" \
- "${script}"
- done
-}
-
-main
diff --git a/scripts/prep-artifacts b/scripts/prep-artifacts
deleted file mode 100755
index 87669ed6abd4e3c7..0000000000000000
--- a/scripts/prep-artifacts
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-set -ue
-
-: "${DOCKER_TAG:=ftl-sdk}"
-
-echo "> docker create $DOCKER_TAG"
-CONTAINER_ID=$(docker create "$DOCKER_TAG")
-
-rm -rf publish
-
-echo "> docker cp ${CONTAINER_ID}:/opt/ftl-sdk/publish ."
-docker cp "${CONTAINER_ID}:/opt/ftl-sdk/publish" .
-
-echo "> docker rm $CONTAINER_ID"
-docker rm "$CONTAINER_ID"
-
-echo '> tar czvpf publish.tar.gz publish'
-tar czvpf publish.tar.gz publish
-
diff --git a/scripts/test b/scripts/test
deleted file mode 100755
index c112faeb7ddf489f..0000000000000000
--- a/scripts/test
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/bash
-set -ue
-
-fail () {
- local error_message="$1"
- local exit_code=$2
- echo "$error_message" >&2
- exit "$exit_code"
-}
-
-check_dependency () {
- local cmd="$1"
- command -v "$cmd" > /dev/null || fail "please install $cmd" 2
-}
-
-check_dependencies () {
- check_dependency 'curl' \
- && check_dependency 'jq'
-}
-
-check_ingest () {
- local ingest="$1"
- [ "$ingest" = 'auto' ] \
- || ping -c 1 "$ingest" \
- || fail "failed to ping ingest '${ingest}'" 5
-}
-
-channel_online_status () {
- local channel="$1"
- curl -sL "https://mixer.com/api/v1/channels/${channel}" \
- | jq .online \
- | grep -E '(true)|(false)'
-}
-
-channel_online () {
- local channel="$1"
- channel_online_status "$channel" | grep -q 'true' && echo "${channel} online!"
-}
-
-channel_offline () {
- local channel="$1"
- channel_online_status "$channel" | grep -q 'false' && echo "${channel} offline!"
-}
-
-main () {
- check_dependencies
- check_ingest "$INGEST"
-
- local max_wait=300
- local sleep_duration=5
- local i=0
- echo "wait for channel ${CHANNEL:?} to go offline"
- until channel_offline "$CHANNEL"; do
- echo .
- sleep $sleep_duration
- (( i += sleep_duration ))
- if [ "$i" -gt $max_wait ]; then
- echo "channel ${CHANNEL} still online after ${max_wait} sec."
- echo "exiting."
- exit 42
- fi
- done
-
- echo "starting stream"
-
- export MIXER_STREAMER_KEY
- export INGEST
- export FPS
-
- ./start-stream &
- local pid="$!"
-
- local j=0
- echo "wait for channel ${CHANNEL} to come online"
- until channel_online "$CHANNEL"; do
- echo .
- sleep $sleep_duration
- (( j += sleep_duration ))
- if [ "$j" -gt $max_wait ]; then
- echo "channel ${CHANNEL} still offline after ${max_wait} sec."
- echo "exiting."
- exit 43
- fi
-
- ps -p "$pid" > /dev/null \
- || fail "ftl_app (pid ${pid}) exited unexpectedly. exiting" 44
- done
-
- echo "channel ${CHANNEL} is online!"
-
- kill -INT "$pid"
- wait "$pid"
-}
-
-main
diff --git a/start-stream b/start-stream
deleted file mode 100755
index baf4b60abe11f515..0000000000000000
--- a/start-stream
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-set -ue
-
-: "${INGEST:=auto}"
-: "${FPS:=24000:1001}"
-
-echo "streaming to $INGEST"
-echo "FPS = $FPS"
-
-exec ./publish/ftl_app \
- -i "$INGEST" \
- -s "$MIXER_STREAMER_KEY" \
- -v vid/sintel.h264 \
- -a vid/sintel.opus \
- -f "$FPS"
-
--
2.31.1
|