ff-sys 0.18.1

Low-level FFmpeg FFI bindings and owned RAII safe wrappers for the ff-* crate family
Documentation
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
// Shape-compatible stubs used by docs.rs builds (DOCS_RS=1).
//
// These definitions mirror the real bindgen-generated FFmpeg bindings in type
// and name, but contain no actual FFmpeg code.  All functions are no-op stubs
// that never run; they exist only to make the dependent crates compile so that
// rustdoc can render their public APIs.
//
// Maintenance note: add entries here whenever a new ff_sys symbol is referenced
// in ff-probe, ff-decode, or ff-encode.  The values of integer constants are
// taken from the FFmpeg 7.x headers for reference accuracy, but correctness at
// runtime is irrelevant — docs.rs never executes this code.

use std::os::raw::{c_char, c_int, c_uint, c_void};
use std::ptr;

// Type aliases

pub type AVCodecID = c_uint;
pub type AVPixelFormat = c_int;
pub type AVSampleFormat = c_int;
pub type AVMediaType = c_int;
pub type AVColorPrimaries = c_uint;
pub type AVColorRange = c_uint;
pub type AVColorSpace = c_uint;
pub type AVHWDeviceType = c_int;
pub type AVChannelOrder = c_uint;
pub type AVPictureType = c_int;

// Opaque types (only ever used behind raw pointers)

pub struct AVDictionary(());
pub struct SwsContext(());
pub struct SwrContext(());
pub struct AVBufferRef(());
pub struct AVIOContext(());
pub struct AVOutputFormat {
    pub flags: c_int,
}
pub struct AVAudioFifo(());

pub struct AVInputFormat {
    pub name: *const c_char,
    pub long_name: *const c_char,
    pub flags: c_int,
}

// Structs with field-level access

#[derive(Copy, Clone)]
#[repr(C)]
pub union AVChannelLayout__bindgen_ty_1 {
    pub mask: u64,
}

impl Default for AVChannelLayout__bindgen_ty_1 {
    fn default() -> Self {
        Self { mask: 0 }
    }
}

#[derive(Copy, Clone)]
pub struct AVChannelLayout {
    pub order: AVChannelOrder,
    pub nb_channels: c_int,
    pub u: AVChannelLayout__bindgen_ty_1,
}

impl Default for AVChannelLayout {
    fn default() -> Self {
        Self {
            order: 0,
            nb_channels: 0,
            u: AVChannelLayout__bindgen_ty_1::default(),
        }
    }
}

#[derive(Copy, Clone)]
pub struct AVRational {
    pub num: c_int,
    pub den: c_int,
}

pub struct AVDictionaryEntry {
    pub key: *mut c_char,
    pub value: *mut c_char,
}

pub struct AVChapter {
    pub id: i64,
    pub time_base: AVRational,
    pub start: i64,
    pub end: i64,
    pub metadata: *mut AVDictionary,
}

pub struct AVCodecParameters {
    pub codec_type: AVMediaType,
    pub codec_id: AVCodecID,
    pub codec_tag: c_uint,
    pub extradata: *mut u8,
    pub extradata_size: c_int,
    pub format: c_int,
    pub bit_rate: i64,
    pub width: c_int,
    pub height: c_int,
    pub sample_rate: c_int,
    pub ch_layout: AVChannelLayout,
    pub sample_fmt: AVSampleFormat,
    pub color_space: AVColorSpace,
    pub color_range: AVColorRange,
    pub color_primaries: AVColorPrimaries,
}

pub struct AVBSFContext {
    pub par_in: *mut AVCodecParameters,
    pub par_out: *mut AVCodecParameters,
    pub time_base_in: AVRational,
    pub time_base_out: AVRational,
}

pub struct AVStream {
    pub index: c_int,
    pub codecpar: *mut AVCodecParameters,
    pub nb_frames: i64,
    pub duration: i64,
    pub time_base: AVRational,
    pub avg_frame_rate: AVRational,
    pub r_frame_rate: AVRational,
    pub start_time: i64,
    pub disposition: c_int,
    pub metadata: *mut AVDictionary,
}

pub struct AVFormatContext {
    pub nb_streams: c_uint,
    pub streams: *mut *mut AVStream,
    pub duration: i64,
    pub metadata: *mut AVDictionary,
    pub nb_chapters: c_uint,
    pub chapters: *mut *mut AVChapter,
    pub iformat: *mut AVInputFormat,
    pub oformat: *const AVOutputFormat,
    pub bit_rate: i64,
    pub pb: *mut AVIOContext,
    pub priv_data: *mut c_void,
}

pub struct AVFrame {
    pub data: [*mut u8; 8],
    pub linesize: [c_int; 8],
    pub width: c_int,
    pub height: c_int,
    pub nb_samples: c_int,
    pub format: c_int,
    pub key_frame: c_int,
    pub pict_type: AVPictureType,
    pub pts: i64,
    pub pkt_dts: i64,
    pub sample_rate: c_int,
    pub ch_layout: AVChannelLayout,
    pub duration: i64,
    pub time_base: AVRational,
    pub hw_frames_ctx: *mut AVBufferRef,
    pub metadata: *mut AVDictionary,
}

pub struct AVPacket {
    pub pts: i64,
    pub dts: i64,
    pub data: *mut u8,
    pub size: c_int,
    pub stream_index: c_int,
    pub flags: c_int,
    pub duration: i64,
}

pub type AVColorTransferCharacteristic = c_uint;

pub struct AVCodecContext {
    pub codec_id: AVCodecID,
    pub bit_rate: i64,
    pub width: c_int,
    pub height: c_int,
    pub pix_fmt: AVPixelFormat,
    pub sample_rate: c_int,
    pub ch_layout: AVChannelLayout,
    pub sample_fmt: AVSampleFormat,
    pub time_base: AVRational,
    pub framerate: AVRational,
    pub gop_size: c_int,
    pub max_b_frames: c_int,
    pub qmin: c_int,
    pub qmax: c_int,
    pub thread_count: c_int,
    pub hw_device_ctx: *mut AVBufferRef,
    pub hw_frames_ctx: *mut AVBufferRef,
    pub priv_data: *mut c_void,
    pub color_primaries: AVColorPrimaries,
    pub color_trc: AVColorTransferCharacteristic,
    pub colorspace: AVColorSpace,
    // Fields added for v0.7.0 feature coverage
    pub frame_size: c_int,
    pub color_range: AVColorRange,
    pub refs: c_int,
    pub rc_max_rate: i64,
    pub rc_buffer_size: c_int,
    pub flags: c_int,
    pub stats_out: *mut c_char,
    pub stats_in: *mut c_char,
}

pub struct AVCodec {
    pub id: AVCodecID,
    pub sample_fmts: *const AVSampleFormat,
    pub capabilities: c_int,
}

// Constants

pub const AV_DICT_IGNORE_SUFFIX: u32 = 2;
pub const AV_NUM_DATA_POINTERS: usize = 8;
pub const AV_TIME_BASE: u32 = 1_000_000;

pub const AVMediaType_AVMEDIA_TYPE_VIDEO: AVMediaType = 0;
pub const AVMediaType_AVMEDIA_TYPE_AUDIO: AVMediaType = 1;
pub const AVMediaType_AVMEDIA_TYPE_SUBTITLE: AVMediaType = 3;
pub const AVMediaType_AVMEDIA_TYPE_ATTACHMENT: AVMediaType = 4;

pub const AV_DISPOSITION_FORCED: u32 = 0x0040;
pub const AV_DISPOSITION_ATTACHED_PIC: u32 = 0x0400;
pub const AV_INPUT_BUFFER_PADDING_SIZE: u32 = 64;

pub const AVChannelOrder_AV_CHANNEL_ORDER_UNSPEC: AVChannelOrder = 0;
pub const AVChannelOrder_AV_CHANNEL_ORDER_NATIVE: AVChannelOrder = 1;

// AVCodecID — video
pub const AVCodecID_AV_CODEC_ID_NONE: AVCodecID = 0;
pub const AVCodecID_AV_CODEC_ID_MPEG2VIDEO: AVCodecID = 2;
pub const AVCodecID_AV_CODEC_ID_MJPEG: AVCodecID = 7;
pub const AVCodecID_AV_CODEC_ID_MPEG4: AVCodecID = 13;
pub const AVCodecID_AV_CODEC_ID_H264: AVCodecID = 27;
pub const AVCodecID_AV_CODEC_ID_THEORA: AVCodecID = 30;
pub const AVCodecID_AV_CODEC_ID_VP8: AVCodecID = 139;
pub const AVCodecID_AV_CODEC_ID_PRORES: AVCodecID = 147;
pub const AVCodecID_AV_CODEC_ID_VP9: AVCodecID = 167;
pub const AVCodecID_AV_CODEC_ID_HEVC: AVCodecID = 173;
pub const AVCodecID_AV_CODEC_ID_AV1: AVCodecID = 226;
pub const AVCodecID_AV_CODEC_ID_DNXHD: AVCodecID = 99;
pub const AVCodecID_AV_CODEC_ID_FFV1: AVCodecID = 33;

// AVCodecID — image (still image)
pub const AVCodecID_AV_CODEC_ID_PNG: AVCodecID = 61;
pub const AVCodecID_AV_CODEC_ID_BMP: AVCodecID = 76;
pub const AVCodecID_AV_CODEC_ID_TIFF: AVCodecID = 90;
pub const AVCodecID_AV_CODEC_ID_WEBP: AVCodecID = 219;
pub const AVCodecID_AV_CODEC_ID_EXR: AVCodecID = 178;

// AVCodecID — animation
pub const AVCodecID_AV_CODEC_ID_GIF: AVCodecID = 97;

// AVCodecID — subtitle
pub const AVCodecID_AV_CODEC_ID_DVB_SUBTITLE: AVCodecID = 94209;
pub const AVCodecID_AV_CODEC_ID_SSA: AVCodecID = 94212;
pub const AVCodecID_AV_CODEC_ID_HDMV_PGS_SUBTITLE: AVCodecID = 94214;
pub const AVCodecID_AV_CODEC_ID_SRT: AVCodecID = 94216;
pub const AVCodecID_AV_CODEC_ID_SUBRIP: AVCodecID = 94248;
pub const AVCodecID_AV_CODEC_ID_WEBVTT: AVCodecID = 94249;
pub const AVCodecID_AV_CODEC_ID_ASS: AVCodecID = 94253;

// AVCodecID — attachment / data
pub const AVCodecID_AV_CODEC_ID_BIN_DATA: AVCodecID = 98314;

// AVCodecID — audio
pub const AVCodecID_AV_CODEC_ID_PCM_S16LE: AVCodecID = 65536;
pub const AVCodecID_AV_CODEC_ID_PCM_S16BE: AVCodecID = 65537;
pub const AVCodecID_AV_CODEC_ID_PCM_U8: AVCodecID = 65542;
pub const AVCodecID_AV_CODEC_ID_PCM_S24LE: AVCodecID = 65544;
pub const AVCodecID_AV_CODEC_ID_PCM_S24BE: AVCodecID = 65545;
pub const AVCodecID_AV_CODEC_ID_PCM_S32LE: AVCodecID = 65556;
pub const AVCodecID_AV_CODEC_ID_PCM_S32BE: AVCodecID = 65557;
pub const AVCodecID_AV_CODEC_ID_PCM_F32LE: AVCodecID = 65558;
pub const AVCodecID_AV_CODEC_ID_PCM_F32BE: AVCodecID = 65559;
pub const AVCodecID_AV_CODEC_ID_PCM_F64LE: AVCodecID = 65560;
pub const AVCodecID_AV_CODEC_ID_PCM_F64BE: AVCodecID = 65561;
pub const AVCodecID_AV_CODEC_ID_MP3: AVCodecID = 86017;
pub const AVCodecID_AV_CODEC_ID_AAC: AVCodecID = 86018;
pub const AVCodecID_AV_CODEC_ID_AC3: AVCodecID = 86019;
pub const AVCodecID_AV_CODEC_ID_DTS: AVCodecID = 86020;
pub const AVCodecID_AV_CODEC_ID_VORBIS: AVCodecID = 86021;
pub const AVCodecID_AV_CODEC_ID_FLAC: AVCodecID = 86028;
pub const AVCodecID_AV_CODEC_ID_ALAC: AVCodecID = 86032;
pub const AVCodecID_AV_CODEC_ID_WMAV2: AVCodecID = 86047;
pub const AVCodecID_AV_CODEC_ID_EAC3: AVCodecID = 86056;
pub const AVCodecID_AV_CODEC_ID_OPUS: AVCodecID = 86076;

// AVPixelFormat
pub const AVPixelFormat_AV_PIX_FMT_NONE: AVPixelFormat = -1;
pub const AVPixelFormat_AV_PIX_FMT_YUV420P: AVPixelFormat = 0;
pub const AVPixelFormat_AV_PIX_FMT_RGB24: AVPixelFormat = 2;
pub const AVPixelFormat_AV_PIX_FMT_BGR24: AVPixelFormat = 3;
pub const AVPixelFormat_AV_PIX_FMT_YUV422P: AVPixelFormat = 4;
pub const AVPixelFormat_AV_PIX_FMT_YUV444P: AVPixelFormat = 5;
pub const AVPixelFormat_AV_PIX_FMT_GRAY8: AVPixelFormat = 8;
pub const AVPixelFormat_AV_PIX_FMT_PAL8: AVPixelFormat = 77;
pub const AVPixelFormat_AV_PIX_FMT_NV12: AVPixelFormat = 23;
pub const AVPixelFormat_AV_PIX_FMT_NV21: AVPixelFormat = 24;
pub const AVPixelFormat_AV_PIX_FMT_RGBA: AVPixelFormat = 26;
pub const AVPixelFormat_AV_PIX_FMT_BGRA: AVPixelFormat = 28;
pub const AVPixelFormat_AV_PIX_FMT_YUVJ420P: AVPixelFormat = 12;
pub const AVPixelFormat_AV_PIX_FMT_YUVJ422P: AVPixelFormat = 13;
pub const AVPixelFormat_AV_PIX_FMT_YUVJ444P: AVPixelFormat = 14;
pub const AVPixelFormat_AV_PIX_FMT_VAAPI: AVPixelFormat = 51;
pub const AVPixelFormat_AV_PIX_FMT_DXVA2_VLD: AVPixelFormat = 53;
pub const AV_OPT_SEARCH_CHILDREN: u32 = 1;
pub const AVPixelFormat_AV_PIX_FMT_YUV420P10LE: AVPixelFormat = 66;
pub const AVPixelFormat_AV_PIX_FMT_YUV422P10LE: AVPixelFormat = 64;
pub const AVPixelFormat_AV_PIX_FMT_YUV444P10LE: AVPixelFormat = 68;
pub const AVPixelFormat_AV_PIX_FMT_YUVA444P10LE: AVPixelFormat = 91;
pub const AVPixelFormat_AV_PIX_FMT_VDPAU: AVPixelFormat = 101;
pub const AVPixelFormat_AV_PIX_FMT_CUDA: AVPixelFormat = 119;
pub const AVPixelFormat_AV_PIX_FMT_QSV: AVPixelFormat = 123;
pub const AVPixelFormat_AV_PIX_FMT_VIDEOTOOLBOX: AVPixelFormat = 135;
pub const AVPixelFormat_AV_PIX_FMT_MEDIACODEC: AVPixelFormat = 165;
pub const AVPixelFormat_AV_PIX_FMT_P010LE: AVPixelFormat = 161;
pub const AVPixelFormat_AV_PIX_FMT_GBRPF32LE: AVPixelFormat = 175;
pub const AVPixelFormat_AV_PIX_FMT_D3D11: AVPixelFormat = 174;
pub const AVPixelFormat_AV_PIX_FMT_OPENCL: AVPixelFormat = 180;
pub const AVPixelFormat_AV_PIX_FMT_VULKAN: AVPixelFormat = 193;

// AVSampleFormat
pub const AVSampleFormat_AV_SAMPLE_FMT_NONE: AVSampleFormat = -1;
pub const AVSampleFormat_AV_SAMPLE_FMT_U8: AVSampleFormat = 0;
pub const AVSampleFormat_AV_SAMPLE_FMT_S16: AVSampleFormat = 1;
pub const AVSampleFormat_AV_SAMPLE_FMT_S32: AVSampleFormat = 2;
pub const AVSampleFormat_AV_SAMPLE_FMT_FLT: AVSampleFormat = 3;
pub const AVSampleFormat_AV_SAMPLE_FMT_DBL: AVSampleFormat = 4;
pub const AVSampleFormat_AV_SAMPLE_FMT_U8P: AVSampleFormat = 5;
pub const AVSampleFormat_AV_SAMPLE_FMT_S16P: AVSampleFormat = 6;
pub const AVSampleFormat_AV_SAMPLE_FMT_S32P: AVSampleFormat = 7;
pub const AVSampleFormat_AV_SAMPLE_FMT_FLTP: AVSampleFormat = 8;
pub const AVSampleFormat_AV_SAMPLE_FMT_DBLP: AVSampleFormat = 9;
pub const AVSampleFormat_AV_SAMPLE_FMT_S64: AVSampleFormat = 10;
pub const AVSampleFormat_AV_SAMPLE_FMT_S64P: AVSampleFormat = 11;

// AVColorPrimaries
pub const AVColorPrimaries_AVCOL_PRI_BT709: AVColorPrimaries = 1;
pub const AVColorPrimaries_AVCOL_PRI_UNSPECIFIED: AVColorPrimaries = 2;
pub const AVColorPrimaries_AVCOL_PRI_BT470BG: AVColorPrimaries = 5;
pub const AVColorPrimaries_AVCOL_PRI_SMPTE170M: AVColorPrimaries = 6;
pub const AVColorPrimaries_AVCOL_PRI_SMPTE240M: AVColorPrimaries = 7;
pub const AVColorPrimaries_AVCOL_PRI_FILM: AVColorPrimaries = 8;
pub const AVColorPrimaries_AVCOL_PRI_BT2020: AVColorPrimaries = 9;
pub const AVColorPrimaries_AVCOL_PRI_SMPTE431: AVColorPrimaries = 11;
pub const AVColorPrimaries_AVCOL_PRI_SMPTE432: AVColorPrimaries = 12;

// AVColorRange
pub const AVColorRange_AVCOL_RANGE_UNSPECIFIED: AVColorRange = 0;
pub const AVColorRange_AVCOL_RANGE_MPEG: AVColorRange = 1;
pub const AVColorRange_AVCOL_RANGE_JPEG: AVColorRange = 2;

// AVColorSpace
pub const AVColorSpace_AVCOL_SPC_RGB: AVColorSpace = 0;
pub const AVColorSpace_AVCOL_SPC_BT709: AVColorSpace = 1;
pub const AVColorSpace_AVCOL_SPC_UNSPECIFIED: AVColorSpace = 2;
pub const AVColorSpace_AVCOL_SPC_FCC: AVColorSpace = 4;
pub const AVColorSpace_AVCOL_SPC_BT470BG: AVColorSpace = 5;
pub const AVColorSpace_AVCOL_SPC_SMPTE170M: AVColorSpace = 6;
pub const AVColorSpace_AVCOL_SPC_SMPTE240M: AVColorSpace = 7;
pub const AVColorSpace_AVCOL_SPC_YCGCO: AVColorSpace = 8;
pub const AVColorSpace_AVCOL_SPC_BT2020_NCL: AVColorSpace = 9;
pub const AVColorSpace_AVCOL_SPC_BT2020_CL: AVColorSpace = 10;

// AVColorTransferCharacteristic
pub const AVColorTransferCharacteristic_AVCOL_TRC_BT709: AVColorTransferCharacteristic = 1;
pub const AVColorTransferCharacteristic_AVCOL_TRC_UNSPECIFIED: AVColorTransferCharacteristic = 2;
pub const AVColorTransferCharacteristic_AVCOL_TRC_GAMMA22: AVColorTransferCharacteristic = 4;
pub const AVColorTransferCharacteristic_AVCOL_TRC_GAMMA28: AVColorTransferCharacteristic = 5;
pub const AVColorTransferCharacteristic_AVCOL_TRC_SMPTE170M: AVColorTransferCharacteristic = 6;
pub const AVColorTransferCharacteristic_AVCOL_TRC_SMPTE240M: AVColorTransferCharacteristic = 7;
pub const AVColorTransferCharacteristic_AVCOL_TRC_LINEAR: AVColorTransferCharacteristic = 8;
pub const AVColorTransferCharacteristic_AVCOL_TRC_IEC61966_2_1: AVColorTransferCharacteristic = 13;
pub const AVColorTransferCharacteristic_AVCOL_TRC_BT2020_10: AVColorTransferCharacteristic = 14;
pub const AVColorTransferCharacteristic_AVCOL_TRC_BT2020_12: AVColorTransferCharacteristic = 15;
pub const AVColorTransferCharacteristic_AVCOL_TRC_SMPTEST2084: AVColorTransferCharacteristic = 16;
pub const AVColorTransferCharacteristic_AVCOL_TRC_ARIB_STD_B67: AVColorTransferCharacteristic = 18;

// AVPacketSideDataType
pub type AVPacketSideDataType = c_uint;
pub const AVPacketSideDataType_AV_PKT_DATA_MASTERING_DISPLAY_METADATA: AVPacketSideDataType = 20;
pub const AVPacketSideDataType_AV_PKT_DATA_CONTENT_LIGHT_LEVEL: AVPacketSideDataType = 22;

// AVHWDeviceType
pub const AVHWDeviceType_AV_HWDEVICE_TYPE_CUDA: AVHWDeviceType = 2;
pub const AVHWDeviceType_AV_HWDEVICE_TYPE_VAAPI: AVHWDeviceType = 4;
pub const AVHWDeviceType_AV_HWDEVICE_TYPE_QSV: AVHWDeviceType = 5;
pub const AVHWDeviceType_AV_HWDEVICE_TYPE_VIDEOTOOLBOX: AVHWDeviceType = 7;
pub const AVHWDeviceType_AV_HWDEVICE_TYPE_D3D11VA: AVHWDeviceType = 8;

// AVPictureType constants
pub const AVPictureType_AV_PICTURE_TYPE_NONE: AVPictureType = 0;
pub const AVPictureType_AV_PICTURE_TYPE_I: AVPictureType = 1;

// Raw FFmpeg functions (bindgen-generated counterparts)
//
// These mirror what bindgen would emit from the real FFmpeg headers.
// All bodies are stubs; the code is compiled but never executed on docs.rs.

// SAFETY: docs.rs stubs — never called at runtime.
pub unsafe fn av_strerror(_errnum: c_int, _errbuf: *mut c_char, _errbuf_size: usize) -> c_int {
    0
}

// av_log bridge (see log_bridge.rs)

pub type va_list = *mut c_char;

pub const AV_LOG_QUIET: i32 = -8;
pub const AV_LOG_PANIC: u32 = 0;
pub const AV_LOG_FATAL: u32 = 8;
pub const AV_LOG_ERROR: u32 = 16;
pub const AV_LOG_WARNING: u32 = 24;
pub const AV_LOG_INFO: u32 = 32;
pub const AV_LOG_VERBOSE: u32 = 40;
pub const AV_LOG_DEBUG: u32 = 48;
pub const AV_LOG_TRACE: u32 = 56;

pub unsafe fn av_log_set_callback(
    _callback: Option<unsafe extern "C" fn(*mut c_void, c_int, *const c_char, va_list)>,
) {
}

pub unsafe fn av_log_set_level(_level: c_int) {}

pub unsafe fn av_log_get_level() -> c_int {
    AV_LOG_INFO as c_int
}

pub unsafe fn av_log_format_line2(
    _ptr: *mut c_void,
    _level: c_int,
    _fmt: *const c_char,
    _vl: va_list,
    _line: *mut c_char,
    _line_size: c_int,
    _print_prefix: *mut c_int,
) -> c_int {
    0
}

pub unsafe fn av_dict_get(
    _m: *const AVDictionary,
    _key: *const c_char,
    _prev: *const AVDictionaryEntry,
    _flags: c_int,
) -> *mut AVDictionaryEntry {
    std::ptr::null_mut()
}

pub unsafe fn av_dict_set(
    _pm: *mut *mut AVDictionary,
    _key: *const c_char,
    _value: *const c_char,
    _flags: c_int,
) -> c_int {
    0
}

pub unsafe fn av_dict_free(_m: *mut *mut AVDictionary) {}

pub unsafe fn av_find_input_format(_short_name: *const c_char) -> *const AVInputFormat {
    std::ptr::null()
}

pub unsafe fn avcodec_get_name(_id: AVCodecID) -> *const c_char {
    std::ptr::null()
}

pub unsafe fn av_frame_alloc() -> *mut AVFrame {
    std::ptr::null_mut()
}

pub unsafe fn av_frame_free(_frame: *mut *mut AVFrame) {}

pub unsafe fn av_frame_get_buffer(_frame: *mut AVFrame, _align: c_int) -> c_int {
    0
}

pub unsafe fn av_frame_move_ref(_dst: *mut AVFrame, _src: *mut AVFrame) {}

pub unsafe fn av_frame_unref(_frame: *mut AVFrame) {}

pub unsafe fn av_packet_alloc() -> *mut AVPacket {
    std::ptr::null_mut()
}

pub unsafe fn av_packet_free(_pkt: *mut *mut AVPacket) {}

pub unsafe fn av_packet_unref(_pkt: *mut AVPacket) {}

pub unsafe fn av_packet_new_side_data(
    _pkt: *mut AVPacket,
    _type_: AVPacketSideDataType,
    _size: usize,
) -> *mut u8 {
    std::ptr::null_mut()
}

pub unsafe fn av_buffer_ref(_buf: *mut AVBufferRef) -> *mut AVBufferRef {
    std::ptr::null_mut()
}

pub unsafe fn av_buffer_unref(_buf: *mut *mut AVBufferRef) {}

pub unsafe fn av_hwdevice_ctx_create(
    _device_ctx: *mut *mut AVBufferRef,
    _type_: AVHWDeviceType,
    _device: *const c_char,
    _opts: *mut AVDictionary,
    _flags: c_int,
) -> c_int {
    -1
}

pub unsafe fn av_hwframe_transfer_data(
    _dst: *mut AVFrame,
    _src: *const AVFrame,
    _flags: c_int,
) -> c_int {
    -1
}

pub unsafe fn av_opt_set(
    _obj: *mut c_void,
    _name: *const c_char,
    _val: *const c_char,
    _search_flags: c_int,
) -> c_int {
    0
}

pub unsafe fn av_read_frame(_s: *mut AVFormatContext, _pkt: *mut AVPacket) -> c_int {
    -1
}

pub unsafe fn av_write_trailer(_s: *mut AVFormatContext) -> c_int {
    0
}

pub unsafe fn av_interleaved_write_frame(
    _s: *mut AVFormatContext,
    _pkt: *mut AVPacket,
) -> c_int {
    0
}

pub unsafe fn avcodec_receive_frame(_avctx: *mut AVCodecContext, _frame: *mut AVFrame) -> c_int {
    -1
}

pub unsafe fn avcodec_send_packet(
    _avctx: *mut AVCodecContext,
    _avpkt: *const AVPacket,
) -> c_int {
    -1
}

pub unsafe fn avformat_alloc_output_context2(
    _ctx: *mut *mut AVFormatContext,
    _oformat: *mut AVOutputFormat,
    _format_name: *const c_char,
    _filename: *const c_char,
) -> c_int {
    -1
}

pub unsafe fn avformat_free_context(_s: *mut AVFormatContext) {}

pub unsafe fn avformat_new_stream(
    _s: *mut AVFormatContext,
    _c: *const AVCodec,
) -> *mut AVStream {
    std::ptr::null_mut()
}

pub unsafe fn avformat_write_header(
    _s: *mut AVFormatContext,
    _options: *mut *mut AVDictionary,
) -> c_int {
    -1
}

pub unsafe fn swr_alloc_set_opts2(
    _ps: *mut *mut SwrContext,
    _out_ch_layout: *const AVChannelLayout,
    _out_sample_fmt: AVSampleFormat,
    _out_sample_rate: c_int,
    _in_ch_layout: *const AVChannelLayout,
    _in_sample_fmt: AVSampleFormat,
    _in_sample_rate: c_int,
    _log_offset: c_int,
    _log_ctx: *mut c_void,
) -> c_int {
    -1
}

pub unsafe fn swr_convert(
    _s: *mut SwrContext,
    _out: *mut *mut u8,
    _out_count: c_int,
    _in_: *const *const u8,
    _in_count: c_int,
) -> c_int {
    -1
}

pub unsafe fn swr_free(_s: *mut *mut SwrContext) {}

pub unsafe fn swr_get_out_samples(_s: *mut SwrContext, _in_samples: c_int) -> c_int {
    0
}

pub unsafe fn swr_init(_s: *mut SwrContext) -> c_int {
    -1
}

pub unsafe fn av_channel_layout_default(_ch_layout: *mut AVChannelLayout, _nb_channels: c_int) {}

pub unsafe fn av_channel_layout_uninit(_ch_layout: *mut AVChannelLayout) {}

pub unsafe fn av_rescale_q(_a: i64, _bq: AVRational, _cq: AVRational) -> i64 {
    0
}

pub unsafe fn av_mallocz(_size: usize) -> *mut c_void {
    std::ptr::null_mut()
}

pub unsafe fn av_malloc(_size: usize) -> *mut c_void {
    std::ptr::null_mut()
}

pub unsafe fn av_free(_ptr: *mut c_void) {}

pub unsafe fn av_new_packet(_pkt: *mut AVPacket, _size: c_int) -> c_int {
    -1
}

pub unsafe fn avcodec_parameters_copy(
    _dst: *mut AVCodecParameters,
    _src: *const AVCodecParameters,
) -> c_int {
    0
}

pub unsafe fn av_packet_rescale_ts(
    _pkt: *mut AVPacket,
    _tb_src: AVRational,
    _tb_dst: AVRational,
) {
}

// Wrapper module stubs
//
// These mirror the safe wrapper modules in avformat.rs, avcodec.rs,
// swresample.rs, and swscale.rs.  Signatures must exactly match those files.

// libavfilter opaque types

pub struct AVFilterGraph(());
pub struct AVFilter(());

pub struct AVFilterContext {
    pub hw_device_ctx: *mut AVBufferRef,
}

/// An unconnected pad of a parsed filter graph, as returned by
/// `avfilter_graph_parse2`.
pub struct AVFilterInOut {
    pub filter_ctx: *mut AVFilterContext,
    pub pad_idx: c_int,
    pub next: *mut AVFilterInOut,
}

// libavfilter constants

/// Flag for `av_buffersrc_add_frame_flags`: keep a reference to the frame.
pub const AV_BUFFERSRC_FLAG_KEEP_REF: c_int = 8;

// libavfilter functions

// SAFETY: docs.rs stubs — never called at runtime.

pub unsafe fn avfilter_graph_alloc() -> *mut AVFilterGraph {
    ptr::null_mut()
}

pub unsafe fn avfilter_graph_free(_graph: *mut *mut AVFilterGraph) {}

pub unsafe fn avfilter_get_by_name(_name: *const c_char) -> *const AVFilter {
    ptr::null()
}

pub unsafe fn avfilter_graph_create_filter(
    _filt_ctx: *mut *mut AVFilterContext,
    _filt: *const AVFilter,
    _name: *const c_char,
    _args: *const c_char,
    _opaque: *mut c_void,
    _graph_ctx: *mut AVFilterGraph,
) -> c_int {
    0
}

pub unsafe fn avfilter_link(
    _src: *mut AVFilterContext,
    _srcpad: c_uint,
    _dst: *mut AVFilterContext,
    _dstpad: c_uint,
) -> c_int {
    0
}

pub unsafe fn avfilter_graph_config(
    _graphctx: *mut AVFilterGraph,
    _log_ctx: *mut c_void,
) -> c_int {
    0
}

pub unsafe fn avfilter_graph_parse2(
    _graph: *mut AVFilterGraph,
    _filters: *const c_char,
    _inputs: *mut *mut AVFilterInOut,
    _outputs: *mut *mut AVFilterInOut,
) -> c_int {
    0
}

pub unsafe fn avfilter_inout_free(_inout: *mut *mut AVFilterInOut) {}

pub unsafe fn avfilter_graph_set_auto_convert(_graph: *mut AVFilterGraph, _flags: c_uint) {}

pub unsafe fn avfilter_graph_send_command(
    _graph: *mut AVFilterGraph,
    _target: *const c_char,
    _cmd: *const c_char,
    _arg: *const c_char,
    _res: *mut c_char,
    _res_len: c_int,
    _flags: c_int,
) -> c_int {
    0
}

pub unsafe fn av_buffersrc_add_frame_flags(
    _ctx: *mut AVFilterContext,
    _frame: *mut AVFrame,
    _flags: c_int,
) -> c_int {
    0
}

pub unsafe fn av_buffersrc_close(
    _ctx: *mut AVFilterContext,
    _pts: i64,
    _flags: c_uint,
) -> c_int {
    0
}

pub unsafe fn av_buffersink_get_frame(
    _ctx: *mut AVFilterContext,
    _frame: *mut AVFrame,
) -> c_int {
    // Return EAGAIN to signal no frame available
    -11
}

pub unsafe fn av_buffersink_get_time_base(_ctx: *const AVFilterContext) -> AVRational {
    AVRational { num: 0, den: 1 }
}

pub unsafe fn av_image_get_linesize(
    _pix_fmt: AVPixelFormat,
    _width: c_int,
    _plane: c_int,
) -> c_int {
    0
}

/// Stub `avformat` wrapper module.
pub mod avformat {
    use std::os::raw::c_int;
    use std::path::Path;

    use super::{AVFormatContext, AVIOContext, AVPacket};

    pub fn srt_available() -> bool {
        false
    }

    pub unsafe fn open_input(_path: &Path) -> Result<*mut AVFormatContext, c_int> {
        Err(-1)
    }

    pub unsafe fn open_input_url(
        _url: &str,
        _connect_timeout: std::time::Duration,
        _read_timeout: std::time::Duration,
    ) -> Result<*mut AVFormatContext, c_int> {
        Err(-1)
    }

    pub unsafe fn open_input_image_sequence(
        _path: &Path,
        _framerate: u32,
    ) -> Result<*mut AVFormatContext, c_int> {
        Err(-1)
    }

    pub unsafe fn close_input(_ctx: *mut *mut AVFormatContext) {}

    pub unsafe fn find_stream_info(_ctx: *mut AVFormatContext) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn seek_frame(
        _ctx: *mut AVFormatContext,
        _stream_index: c_int,
        _timestamp: i64,
        _flags: c_int,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn seek_file(
        _ctx: *mut AVFormatContext,
        _stream_index: c_int,
        _min_ts: i64,
        _ts: i64,
        _max_ts: i64,
        _flags: c_int,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn read_frame(
        _ctx: *mut AVFormatContext,
        _pkt: *mut AVPacket,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn write_frame(
        _ctx: *mut AVFormatContext,
        _pkt: *mut AVPacket,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn open_output(_path: &Path, _flags: c_int) -> Result<*mut AVIOContext, c_int> {
        Err(-1)
    }

    pub unsafe fn close_output(_pb: *mut *mut AVIOContext) {}

    pub mod avio_flags {
        use std::os::raw::c_int;
        pub const READ: c_int = 1;
        pub const WRITE: c_int = 2;
        pub const READ_WRITE: c_int = 3;
    }

    pub mod seek_flags {
        pub const BACKWARD: i32 = 1;
        pub const BYTE: i32 = 2;
        pub const ANY: i32 = 4;
        pub const FRAME: i32 = 8;
    }
}

/// Stub `avcodec` wrapper module.
pub mod avcodec {
    use std::os::raw::c_int;

    use super::{AVCodec, AVCodecContext, AVCodecID, AVCodecParameters, AVDictionary, AVFrame, AVPacket};

    pub unsafe fn find_decoder(_codec_id: AVCodecID) -> Option<*const AVCodec> {
        None
    }

    pub unsafe fn find_decoder_by_name(_name: *const i8) -> Option<*const AVCodec> {
        None
    }

    pub unsafe fn find_encoder(_codec_id: AVCodecID) -> Option<*const AVCodec> {
        None
    }

    pub unsafe fn find_encoder_by_name(_name: *const i8) -> Option<*const AVCodec> {
        None
    }

    pub unsafe fn alloc_context3(_codec: *const AVCodec) -> Result<*mut AVCodecContext, c_int> {
        Err(-1)
    }

    pub unsafe fn parameters_to_context(
        _codec_ctx: *mut AVCodecContext,
        _par: *const AVCodecParameters,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn open2(
        _avctx: *mut AVCodecContext,
        _codec: *const AVCodec,
        _options: *mut *mut AVDictionary,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn send_packet(
        _ctx: *mut AVCodecContext,
        _pkt: *const AVPacket,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn receive_frame(
        _ctx: *mut AVCodecContext,
        _frame: *mut AVFrame,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn send_frame(
        _ctx: *mut AVCodecContext,
        _frame: *const AVFrame,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn receive_packet(
        _ctx: *mut AVCodecContext,
        _pkt: *mut AVPacket,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn flush_buffers(_ctx: *mut AVCodecContext) {}

    pub unsafe fn parameters_from_context(
        _par: *mut AVCodecParameters,
        _ctx: *const AVCodecContext,
    ) -> Result<(), c_int> {
        Err(-1)
    }

    pub mod codec_caps {
        pub const EXPERIMENTAL: u32 = 1 << 9;
        pub const HARDWARE: u32 = 1 << 10;
        pub const HYBRID: u32 = 1 << 11;
        pub const VARIABLE_FRAME_SIZE: u32 = 1 << 16;
        pub const AVOID_PROBING: u32 = 1 << 17;
    }
}

/// Stub `swresample` wrapper module.
pub mod swresample {
    use std::os::raw::c_int;

    use super::{AVChannelLayout, AVSampleFormat, SwrContext};

    pub unsafe fn alloc() -> Result<*mut SwrContext, c_int> {
        Err(-1)
    }

    pub unsafe fn alloc_set_opts2(
        _out_ch_layout: *const AVChannelLayout,
        _out_sample_fmt: AVSampleFormat,
        _out_sample_rate: c_int,
        _in_ch_layout: *const AVChannelLayout,
        _in_sample_fmt: AVSampleFormat,
        _in_sample_rate: c_int,
    ) -> Result<*mut SwrContext, c_int> {
        Err(-1)
    }

    pub unsafe fn init(_ctx: *mut SwrContext) -> Result<(), c_int> {
        Err(-1)
    }

    pub unsafe fn is_initialized(_ctx: *const SwrContext) -> bool {
        false
    }

    pub unsafe fn convert(
        _s: *mut SwrContext,
        _out: *mut *mut u8,
        _out_count: c_int,
        _in_: *const *const u8,
        _in_count: c_int,
    ) -> Result<c_int, c_int> {
        Err(-1)
    }

    pub unsafe fn get_delay(_ctx: *mut SwrContext, _base: i64) -> i64 {
        0
    }

    pub fn estimate_output_samples(
        _out_sample_rate: i32,
        _in_sample_rate: i32,
        _in_samples: i32,
    ) -> i32 {
        0
    }

    pub mod channel_layout {
        use super::super::AVChannelLayout;

        pub unsafe fn set_default(_ch_layout: *mut AVChannelLayout, _nb_channels: i32) {}
        pub unsafe fn uninit(_ch_layout: *mut AVChannelLayout) {}
        pub unsafe fn copy(
            _dst: *mut AVChannelLayout,
            _src: *const AVChannelLayout,
        ) -> Result<(), crate::AvError> {
            Err(crate::AvError::new(-1))
        }
        pub unsafe fn is_equal(
            _chl: *const AVChannelLayout,
            _chl1: *const AVChannelLayout,
        ) -> bool {
            false
        }
        pub fn mono() -> AVChannelLayout {
            AVChannelLayout::default()
        }
        pub fn stereo() -> AVChannelLayout {
            AVChannelLayout::default()
        }
        pub fn with_channels(_nb_channels: i32) -> AVChannelLayout {
            AVChannelLayout::default()
        }
        pub fn is_valid(ch_layout: &AVChannelLayout) -> bool {
            ch_layout.nb_channels > 0
        }
        pub fn nb_channels(ch_layout: &AVChannelLayout) -> i32 {
            ch_layout.nb_channels
        }
        pub fn is_native_order(_ch_layout: &AVChannelLayout) -> bool {
            false
        }
    }

    pub mod audio_fifo {
        use std::ffi::c_void;
        use std::os::raw::c_int;

        use super::super::{AVAudioFifo, AVSampleFormat};

        pub unsafe fn alloc(
            _sample_fmt: AVSampleFormat,
            _channels: c_int,
            _nb_samples: c_int,
        ) -> Result<*mut AVAudioFifo, crate::AvError> {
            Err(crate::AvError::new(-1))
        }

        pub unsafe fn free(_fifo: *mut AVAudioFifo) {}

        pub unsafe fn write(
            _fifo: *mut AVAudioFifo,
            _data: *const *mut c_void,
            _nb_samples: c_int,
        ) -> Result<c_int, crate::AvError> {
            Err(crate::AvError::new(-1))
        }

        pub unsafe fn read(
            _fifo: *mut AVAudioFifo,
            _data: *const *mut c_void,
            _nb_samples: c_int,
        ) -> Result<c_int, crate::AvError> {
            Err(crate::AvError::new(-1))
        }

        pub unsafe fn size(_fifo: *mut AVAudioFifo) -> c_int {
            0
        }

        pub unsafe fn write_frame(
            _fifo: *mut AVAudioFifo,
            _src: &super::super::Frame,
            _nb_samples: c_int,
        ) -> Result<c_int, crate::AvError> {
            Err(crate::AvError::new(-1))
        }

        pub unsafe fn read_frame(
            _fifo: *mut AVAudioFifo,
            _dst: &mut super::super::Frame,
            _nb_samples: c_int,
        ) -> Result<c_int, crate::AvError> {
            Err(crate::AvError::new(-1))
        }
    }

    pub mod sample_format {
        use super::super::{
            AVSampleFormat, AVSampleFormat_AV_SAMPLE_FMT_NONE, AVSampleFormat_AV_SAMPLE_FMT_U8,
            AVSampleFormat_AV_SAMPLE_FMT_S16, AVSampleFormat_AV_SAMPLE_FMT_S32,
            AVSampleFormat_AV_SAMPLE_FMT_FLT, AVSampleFormat_AV_SAMPLE_FMT_DBL,
            AVSampleFormat_AV_SAMPLE_FMT_U8P, AVSampleFormat_AV_SAMPLE_FMT_S16P,
            AVSampleFormat_AV_SAMPLE_FMT_S32P, AVSampleFormat_AV_SAMPLE_FMT_FLTP,
            AVSampleFormat_AV_SAMPLE_FMT_DBLP, AVSampleFormat_AV_SAMPLE_FMT_S64,
            AVSampleFormat_AV_SAMPLE_FMT_S64P,
        };

        pub const NONE: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_NONE;
        pub const U8: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_U8;
        pub const S16: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S16;
        pub const S32: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S32;
        pub const FLT: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_FLT;
        pub const DBL: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_DBL;
        pub const U8P: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_U8P;
        pub const S16P: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S16P;
        pub const S32P: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S32P;
        pub const FLTP: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_FLTP;
        pub const DBLP: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_DBLP;
        pub const S64: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S64;
        pub const S64P: AVSampleFormat = AVSampleFormat_AV_SAMPLE_FMT_S64P;

        pub fn bytes_per_sample(_sample_fmt: AVSampleFormat) -> i32 {
            0
        }
        pub fn is_planar(_sample_fmt: AVSampleFormat) -> bool {
            false
        }
    }
}

/// Stub `swscale` wrapper module.
pub mod swscale {
    use std::os::raw::c_int;

    use super::{AVPixelFormat, SwsContext};

    pub unsafe fn get_context(
        _src_w: c_int,
        _src_h: c_int,
        _src_fmt: AVPixelFormat,
        _dst_w: c_int,
        _dst_h: c_int,
        _dst_fmt: AVPixelFormat,
        _flags: c_int,
    ) -> Result<*mut SwsContext, c_int> {
        Err(-1)
    }

    pub unsafe fn scale(
        _ctx: *mut SwsContext,
        _src: *const *const u8,
        _src_stride: *const c_int,
        _src_slice_y: c_int,
        _src_slice_h: c_int,
        _dst: *const *mut u8,
        _dst_stride: *const c_int,
    ) -> Result<c_int, c_int> {
        Err(-1)
    }

    pub unsafe fn is_supported_input(_pix_fmt: AVPixelFormat) -> bool {
        false
    }

    pub unsafe fn is_supported_output(_pix_fmt: AVPixelFormat) -> bool {
        false
    }

    pub unsafe fn is_supported_endianness_conversion(_pix_fmt: AVPixelFormat) -> bool {
        false
    }

    pub mod scale_flags {
        pub const FAST_BILINEAR: i32 = 1;
        pub const BILINEAR: i32 = 2;
        pub const BICUBIC: i32 = 4;
        pub const X: i32 = 8;
        pub const POINT: i32 = 16;
        pub const AREA: i32 = 32;
        pub const BICUBLIN: i32 = 64;
        pub const GAUSS: i32 = 128;
        pub const SINC: i32 = 256;
        pub const LANCZOS: i32 = 512;
        pub const SPLINE: i32 = 1024;
    }
}

// RAII owner stub (mirrors crate::codec_context::CodecContext)
// Under DOCS_RS the real `codec_context` module is cfg'd out (it depends on the
// docsrs-gated `avcodec` wrapper); this shape-compatible stub keeps
// `ff_sys::CodecContext` available so ff-decode compiles for docs.rs.

/// Stub mirror of `crate::codec_context::ReceiveOutcome`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReceiveOutcome {
    Frame,
    NeedInput,
    Drained,
}

#[derive(Debug)]
pub struct CodecContext {
    _ptr: std::ptr::NonNull<AVCodecContext>,
}

impl CodecContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new(_codec: Option<Codec>) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    pub fn set_thread_count(&mut self, _thread_count: c_int) {}

    pub fn set_width(&mut self, _width: c_int) {}
    pub fn set_height(&mut self, _height: c_int) {}
    pub fn set_pix_fmt(&mut self, _pix_fmt: AVPixelFormat) {}
    pub fn set_time_base(&mut self, _time_base: AVRational) {}

    #[must_use]
    pub fn pix_fmt(&self) -> AVPixelFormat {
        0
    }
    #[must_use]
    pub fn sample_fmt(&self) -> AVSampleFormat {
        0
    }
    #[must_use]
    pub fn width(&self) -> c_int {
        0
    }
    #[must_use]
    pub fn height(&self) -> c_int {
        0
    }

    pub fn set_codec_id(&mut self, _codec_id: AVCodecID) {}
    pub fn set_framerate(&mut self, _framerate: AVRational) {}
    pub fn set_bit_rate(&mut self, _bit_rate: i64) {}
    #[must_use]
    pub fn bit_rate(&self) -> i64 {
        0
    }
    pub fn set_rc_max_rate(&mut self, _rc_max_rate: i64) {}
    pub fn set_rc_buffer_size(&mut self, _rc_buffer_size: c_int) {}
    pub fn set_color_primaries(&mut self, _color_primaries: AVColorPrimaries) {}
    pub fn set_color_trc(&mut self, _color_trc: AVColorTransferCharacteristic) {}
    pub fn set_colorspace(&mut self, _colorspace: AVColorSpace) {}
    pub fn set_color_range(&mut self, _color_range: AVColorRange) {}
    pub fn set_sample_rate(&mut self, _sample_rate: c_int) {}
    pub fn set_sample_fmt(&mut self, _sample_fmt: AVSampleFormat) {}
    pub fn set_max_b_frames(&mut self, _max_b_frames: c_int) {}
    pub fn set_gop_size(&mut self, _gop_size: c_int) {}
    pub fn set_refs(&mut self, _refs: c_int) {}
    pub fn set_qmin(&mut self, _qmin: c_int) {}
    pub fn set_qmax(&mut self, _qmax: c_int) {}
    pub fn set_ch_layout_default(&mut self, _nb_channels: c_int) {}
    pub fn set_flags(&mut self, _flags: c_int) {}

    #[must_use]
    pub fn flags(&self) -> c_int {
        0
    }
    #[must_use]
    pub fn time_base(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }
    #[must_use]
    pub fn codec_id(&self) -> AVCodecID {
        0
    }
    #[must_use]
    pub fn frame_size(&self) -> c_int {
        0
    }
    #[must_use]
    pub fn sample_rate(&self) -> c_int {
        0
    }
    #[must_use]
    pub fn channels(&self) -> c_int {
        0
    }
    #[must_use]
    pub fn ch_layout(&self) -> &AVChannelLayout {
        Box::leak(Box::new(AVChannelLayout::default()))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_opt(&mut self, _key: &str, _value: &str) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_opt_cstr(
        &mut self,
        _key: &str,
        _value: &core::ffi::CStr,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_opt_search_children(
        &mut self,
        _key: &str,
        _value: &str,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    pub fn set_stats_in(&mut self, _stats: &std::ffi::CStr) {}

    pub fn clear_stats_in(&mut self) {}

    #[must_use]
    pub fn stats_out(&self) -> Option<std::ffi::CString> {
        None
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn apply_parameters(
        &mut self,
        _params: &CodecParameters<'_>,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open_codec(&mut self, _codec: Codec) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn send_packet(&mut self, _pkt: &Packet) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn send_eof(&mut self) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn receive_frame(&mut self, _frame: &mut Frame) -> Result<ReceiveOutcome, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn flush_buffers(&mut self) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn send_frame(&mut self, _frame: Option<&Frame>) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_hw_device_ctx(
        &mut self,
        _device: &HwDeviceContext,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn receive_packet(
        &mut self,
        _pkt: &mut Packet,
    ) -> Result<ReceiveOutcome, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Safety
    /// Stub; never executed on docs.rs.
    pub(crate) unsafe fn parameters_from_context(
        &self,
        _par: *mut AVCodecParameters,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for CodecContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for CodecContext {}

// RAII owner stub (mirrors crate::format_context::InputFormatContext)
// Under DOCS_RS the real `format_context` module is cfg'd out (it depends on the
// docsrs-gated `avformat` wrapper); this shape-compatible stub keeps
// `ff_sys::InputFormatContext` available so ff-decode compiles for docs.rs.

#[derive(Debug)]
pub struct InputFormatContext {
    _ptr: std::ptr::NonNull<AVFormatContext>,
}

impl InputFormatContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open(_path: &std::path::Path) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open_url(
        _url: &str,
        _connect_timeout: std::time::Duration,
        _read_timeout: std::time::Duration,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open_image_sequence(
        _path: &std::path::Path,
        _framerate: u32,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open_custom(
        _source: impl crate::IoSource + 'static,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub fn nb_streams(&self) -> u32 {
        0
    }

    #[must_use]
    pub fn duration(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn iformat_flags(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn bit_rate(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn iformat_name(&self) -> Option<String> {
        None
    }

    #[must_use]
    pub fn iformat_long_name(&self) -> Option<String> {
        None
    }

    #[must_use]
    pub fn metadata(&self) -> std::collections::HashMap<String, String> {
        std::collections::HashMap::new()
    }

    #[must_use]
    pub fn nb_chapters(&self) -> u32 {
        0
    }

    #[must_use]
    pub fn chapter(&self, _index: usize) -> Option<ChapterRef<'_>> {
        None
    }

    pub fn chapters(&self) -> impl Iterator<Item = ChapterRef<'_>> + '_ {
        std::iter::empty()
    }

    #[must_use]
    pub fn stream(&self, _index: usize) -> Option<StreamRef<'_>> {
        None
    }

    pub fn streams(&self) -> impl Iterator<Item = StreamRef<'_>> + '_ {
        std::iter::empty()
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn find_stream_info(&mut self) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn seek_frame(
        &mut self,
        _stream_index: c_int,
        _timestamp: i64,
        _flags: c_int,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn seek_file(
        &mut self,
        _stream_index: c_int,
        _min_ts: i64,
        _ts: i64,
        _max_ts: i64,
        _flags: c_int,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn read_frame(&mut self, _pkt: &mut Packet) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for InputFormatContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for InputFormatContext {}

// RAII owner stub (mirrors crate::format_context::OutputFormatContext)
// Keeps `ff_sys::OutputFormatContext` available so the mux consumers compile for
// docs.rs while the real `format_context` module is cfg'd out.

#[derive(Debug)]
pub struct OutputFormatContext {
    _ptr: std::ptr::NonNull<AVFormatContext>,
}

impl OutputFormatContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new(
        _format_name: Option<&str>,
        _filename: &std::path::Path,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub fn nb_streams(&self) -> u32 {
        0
    }

    #[must_use]
    pub fn oformat_flags(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn is_nofile(&self) -> bool {
        false
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open_io(&mut self, _path: &std::path::Path) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_custom_io(
        &mut self,
        _sink: impl crate::IoSink + 'static,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn write_header(&mut self) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn write_trailer(&mut self) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    pub fn close_io(&mut self) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new_stream(&mut self, _codec: Option<&Codec>) -> Result<usize, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub fn stream_time_base(&self, _idx: usize) -> AVRational {
        AVRational { num: 0, den: 0 }
    }

    pub fn set_stream_time_base(&mut self, _idx: usize, _time_base: AVRational) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn apply_stream_params_from_context(
        &mut self,
        _idx: usize,
        _ctx: &CodecContext,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn copy_stream_params(
        &mut self,
        _idx: usize,
        _src: CodecParameters<'_>,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_opt(
        &mut self,
        _key: &std::ffi::CStr,
        _value: &std::ffi::CStr,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn write_interleaved(&mut self, _pkt: &mut Packet) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_metadata(&mut self, _key: &str, _value: &str) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn add_attachment_stream(
        &mut self,
        _data: &[u8],
        _mime_type: &str,
        _filename: &str,
    ) -> Result<usize, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_chapters(&mut self, _chapters: &[ChapterSpec<'_>]) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for OutputFormatContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for OutputFormatContext {}

#[derive(Clone, Copy, Debug)]
pub struct ChapterSpec<'a> {
    pub id: i64,
    pub start_us: i64,
    pub end_us: i64,
    pub title: Option<&'a str>,
}

// Borrowed stream / params stubs (mirror crate::format_context)

#[derive(Clone, Copy, Debug)]
pub struct StreamRef<'a> {
    _ptr: std::ptr::NonNull<AVStream>,
    _marker: std::marker::PhantomData<&'a InputFormatContext>,
}

impl<'a> StreamRef<'a> {
    #[must_use]
    pub fn index(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn time_base(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }

    #[must_use]
    pub fn avg_frame_rate(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }

    #[must_use]
    pub fn r_frame_rate(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }

    #[must_use]
    pub fn nb_frames(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn codecpar(&self) -> CodecParameters<'a> {
        // SAFETY: stub; never executed on docs.rs.
        unsafe {
            CodecParameters {
                _ptr: std::ptr::NonNull::new_unchecked(ptr::null_mut()),
                _marker: std::marker::PhantomData,
            }
        }
    }

    #[must_use]
    pub fn duration(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn disposition(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn metadata(&self) -> std::collections::HashMap<String, String> {
        std::collections::HashMap::new()
    }
}

#[derive(Clone, Copy, Debug)]
pub struct CodecParameters<'a> {
    _ptr: std::ptr::NonNull<AVCodecParameters>,
    _marker: std::marker::PhantomData<&'a ()>,
}

impl CodecParameters<'_> {
    #[must_use]
    pub fn codec_type(&self) -> AVMediaType {
        0
    }

    #[must_use]
    pub fn codec_id(&self) -> AVCodecID {
        0
    }

    #[must_use]
    pub fn width(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn height(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn sample_rate(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn color_space(&self) -> AVColorSpace {
        0
    }

    #[must_use]
    pub fn color_range(&self) -> AVColorRange {
        0
    }

    #[must_use]
    pub fn color_primaries(&self) -> AVColorPrimaries {
        0
    }

    #[must_use]
    pub fn ch_layout(&self) -> AVChannelLayout {
        AVChannelLayout::default()
    }

    #[must_use]
    pub fn format(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn bit_rate(&self) -> i64 {
        0
    }
}

#[derive(Clone, Copy, Debug)]
pub struct ChapterRef<'a> {
    _ptr: std::ptr::NonNull<AVChapter>,
    _marker: std::marker::PhantomData<&'a InputFormatContext>,
}

impl ChapterRef<'_> {
    #[must_use]
    pub fn id(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn time_base(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }

    #[must_use]
    pub fn start(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn end(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn metadata(&self) -> std::collections::HashMap<String, String> {
        std::collections::HashMap::new()
    }
}

// Owned Frame / Packet / Codec stubs (mirror crate::{frame,packet,codec})
// Under DOCS_RS the real modules are cfg'd out; these shape-compatible stubs keep
// `ff_sys::{Frame, Packet, Codec}` available for docs.rs.

#[derive(Debug)]
pub struct Frame {
    _ptr: std::ptr::NonNull<AVFrame>,
}

impl Frame {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new() -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub(crate) const fn as_ptr(&self) -> *const AVFrame {
        self._ptr.as_ptr()
    }

    #[must_use]
    pub(crate) fn as_mut_ptr(&mut self) -> *mut AVFrame {
        self._ptr.as_ptr()
    }

    #[must_use]
    pub fn width(&self) -> c_int {
        0
    }
    pub fn set_width(&mut self, _width: c_int) {}
    #[must_use]
    pub fn height(&self) -> c_int {
        0
    }
    pub fn set_height(&mut self, _height: c_int) {}
    #[must_use]
    pub fn format(&self) -> c_int {
        0
    }
    pub fn set_format(&mut self, _format: c_int) {}
    pub fn set_pict_type(&mut self, _pict_type: AVPictureType) {}

    #[must_use]
    pub fn pict_type(&self) -> AVPictureType {
        0
    }
    #[must_use]
    pub fn pts(&self) -> i64 {
        0
    }
    pub fn set_pts(&mut self, _pts: i64) {}
    #[must_use]
    pub fn pkt_dts(&self) -> i64 {
        0
    }
    pub fn set_pkt_dts(&mut self, _pkt_dts: i64) {}
    #[must_use]
    pub fn duration(&self) -> i64 {
        0
    }
    pub fn set_duration(&mut self, _duration: i64) {}
    #[must_use]
    pub fn time_base(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }
    pub fn set_time_base(&mut self, _time_base: AVRational) {}
    #[must_use]
    pub fn nb_samples(&self) -> c_int {
        0
    }
    pub fn set_nb_samples(&mut self, _nb_samples: c_int) {}
    #[must_use]
    pub fn sample_rate(&self) -> c_int {
        0
    }
    pub fn set_sample_rate(&mut self, _sample_rate: c_int) {}
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn set_ch_layout(&mut self, _layout: &AVChannelLayout) -> Result<(), crate::AvError> {
        Ok(())
    }
    #[must_use]
    pub fn channels(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn video_plane(&self, _i: usize) -> Option<&[u8]> {
        None
    }

    pub fn video_plane_mut(&mut self, _i: usize) -> Option<&mut [u8]> {
        None
    }

    #[must_use]
    pub fn linesize(&self, _i: usize) -> c_int {
        0
    }

    /// # Safety
    ///
    /// Docs.rs stub; never called.
    pub unsafe fn copy_plane_rows(
        &self,
        _i: usize,
        _dst: &mut [u8],
        _dst_stride: usize,
        _rows: usize,
        _row_bytes: usize,
    ) -> Option<()> {
        None
    }

    #[must_use]
    pub fn audio_plane(&self, _i: usize) -> Option<&[u8]> {
        None
    }

    pub fn audio_plane_mut(&mut self, _i: usize) -> Option<&mut [u8]> {
        None
    }

    pub fn unref(&mut self) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn get_buffer(&mut self, _align: c_int) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    pub fn move_ref(&mut self, _src: &mut Frame) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn hwframe_transfer_data(
        &mut self,
        _src: &Frame,
        _flags: c_int,
    ) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn try_clone(&self) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for Frame {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for Frame {}

#[derive(Debug)]
pub struct Packet {
    _ptr: std::ptr::NonNull<AVPacket>,
}

impl Packet {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new() -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub(crate) const fn as_ptr(&self) -> *const AVPacket {
        self._ptr.as_ptr()
    }

    #[must_use]
    pub(crate) fn as_mut_ptr(&mut self) -> *mut AVPacket {
        self._ptr.as_ptr()
    }

    #[must_use]
    pub fn stream_index(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn pts(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn dts(&self) -> i64 {
        0
    }

    #[must_use]
    pub fn size(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn flags(&self) -> c_int {
        0
    }

    #[must_use]
    pub fn duration(&self) -> i64 {
        0
    }

    pub fn set_stream_index(&mut self, _stream_index: c_int) {}

    pub fn set_pts(&mut self, _pts: i64) {}

    pub fn set_dts(&mut self, _dts: i64) {}

    pub fn set_duration(&mut self, _duration: i64) {}

    pub fn rescale_ts(&mut self, _src_tb: AVRational, _dst_tb: AVRational) {}

    pub fn new_side_data(
        &mut self,
        _kind: AVPacketSideDataType,
        _size: usize,
    ) -> Option<&mut [u8]> {
        None
    }

    pub fn unref(&mut self) {}

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn try_clone(&self) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for Packet {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for Packet {}

#[derive(Clone, Copy, Debug)]
pub struct Codec {
    _ptr: std::ptr::NonNull<AVCodec>,
}

impl Codec {
    #[must_use]
    pub fn find_decoder(_codec_id: AVCodecID) -> Option<Self> {
        None
    }

    #[must_use]
    pub fn find_encoder(_codec_id: AVCodecID) -> Option<Self> {
        None
    }

    #[must_use]
    pub fn find_encoder_by_name(_name: &str) -> Option<Self> {
        None
    }

    #[must_use]
    pub const fn as_ptr(&self) -> *const AVCodec {
        self._ptr.as_ptr()
    }
}

// RAII owner stub (mirrors crate::hwdevice::HwDeviceContext)
// Under DOCS_RS the real `hwdevice` module is cfg'd out; this shape-compatible
// stub keeps `ff_sys::HwDeviceContext` available for docs.rs.

#[derive(Debug)]
pub struct HwDeviceContext {
    _ptr: std::ptr::NonNull<AVBufferRef>,
}

impl HwDeviceContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new(_device_type: AVHWDeviceType) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for HwDeviceContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for HwDeviceContext {}

// RAII owner stub (mirrors crate::scale_context::ScaleContext)
// Under DOCS_RS the real `scale_context` module is cfg'd out; this
// shape-compatible stub keeps `ff_sys::ScaleContext` available for docs.rs.

#[derive(Debug)]
pub struct ScaleContext {
    _ptr: std::ptr::NonNull<SwsContext>,
}

impl ScaleContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn new(
        _src_w: c_int,
        _src_h: c_int,
        _src_fmt: AVPixelFormat,
        _dst_w: c_int,
        _dst_h: c_int,
        _dst_fmt: AVPixelFormat,
        _flags: c_int,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn scale_frames(
        &mut self,
        _src: &Frame,
        _dst: &mut Frame,
    ) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn scale_planes(
        &mut self,
        _src: &[&[u8]],
        _src_strides: &[c_int],
        _src_h: c_int,
        _dst: &mut Frame,
    ) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn scale_slices(
        &mut self,
        _src: &[&[u8]],
        _src_strides: &[c_int],
        _src_h: c_int,
        _dst: &mut [&mut [u8]],
        _dst_strides: &[c_int],
    ) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

}

impl Drop for ScaleContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for ScaleContext {}

// RAII owner stub (mirrors crate::resample_context::ResampleContext)
// Under DOCS_RS the real `resample_context` module is cfg'd out; this
// shape-compatible stub keeps `ff_sys::ResampleContext` available for docs.rs.

#[derive(Debug)]
pub struct ResampleContext {
    _ptr: std::ptr::NonNull<SwrContext>,
}

impl ResampleContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn new(
        _out_ch_layout: *const AVChannelLayout,
        _out_sample_fmt: AVSampleFormat,
        _out_sample_rate: c_int,
        _in_ch_layout: *const AVChannelLayout,
        _in_sample_fmt: AVSampleFormat,
        _in_sample_rate: c_int,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn convert_into_planes(
        &mut self,
        _dst: &mut [&mut [u8]],
        _dst_count: c_int,
        _src: &Frame,
    ) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn convert_into_frame(
        &mut self,
        _dst: &mut Frame,
        _in_planes: &[&[u8]],
        _in_count: c_int,
    ) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    /// # Safety
    /// Stub; never executed on docs.rs.
    pub unsafe fn flush_into_frame(&mut self, _dst: &mut Frame) -> Result<c_int, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub fn get_out_samples(&mut self, _in_samples: c_int) -> c_int {
        0
    }
}

impl Drop for ResampleContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for ResampleContext {}

// Free-function stub (mirrors crate::buffersink)
// Under DOCS_RS the real `buffersink` module is cfg'd out; these shape-compatible
// stubs keep `ff_sys::BufferSinkOutcome` / `ff_sys::buffersink_get_frame`
// available for docs.rs.

/// Stub mirror of `crate::buffersink::BufferSinkOutcome`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BufferSinkOutcome {
    Frame,
    NeedMore,
    Drained,
}

/// # Safety
/// Stub; never executed on docs.rs.
pub unsafe fn buffersink_get_frame(
    _sink: *mut AVFilterContext,
    _dst: &mut Frame,
) -> Result<BufferSinkOutcome, crate::AvError> {
    Err(crate::AvError::new(-1))
}

// Under DOCS_RS the real `bsf` module is cfg'd out; this shape-compatible stub keeps
// `ff_sys::BsfContext` available for docs.rs (ff-remux names it).

/// Stub mirror of `crate::bsf::BsfContext`.
#[derive(Debug)]
pub struct BsfContext {
    _ptr: std::ptr::NonNull<AVBSFContext>,
}

impl BsfContext {
    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn open(
        _spec: &str,
        _par_in: Option<CodecParameters<'_>>,
        _time_base_in: AVRational,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn passthrough(
        _par_in: Option<CodecParameters<'_>>,
        _time_base_in: AVRational,
    ) -> Result<Self, crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    #[must_use]
    pub fn output_params(&self) -> CodecParameters<'_> {
        // SAFETY: stub; never executed on docs.rs.
        unsafe {
            CodecParameters {
                _ptr: std::ptr::NonNull::dangling(),
                _marker: std::marker::PhantomData,
            }
        }
    }

    #[must_use]
    pub fn output_time_base(&self) -> AVRational {
        AVRational { num: 0, den: 1 }
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn send_packet(&mut self, _pkt: &mut Packet) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn send_eof(&mut self) -> Result<(), crate::AvError> {
        Err(crate::AvError::new(-1))
    }

    /// # Errors
    /// Stub; never executed on docs.rs.
    pub fn receive_packet(
        &mut self,
        _pkt: &mut Packet,
    ) -> Result<ReceiveOutcome, crate::AvError> {
        Err(crate::AvError::new(-1))
    }
}

impl Drop for BsfContext {
    fn drop(&mut self) {}
}

// SAFETY: stub; never executed on docs.rs.
unsafe impl Send for BsfContext {}