libde265-sys2 0.1.0

libde265 bindings
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
// automatically generated by rust-bindgen 0.72.1

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage> {
    storage: Storage,
}
impl<Storage> __BindgenBitfieldUnit<Storage> {
    #[inline]
    pub const fn new(storage: Storage) -> Self {
        Self { storage }
    }
}
impl<Storage> __BindgenBitfieldUnit<Storage>
where
    Storage: AsRef<[u8]> + AsMut<[u8]>,
{
    #[inline]
    fn extract_bit(byte: u8, index: usize) -> bool {
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        byte & mask == mask
    }
    #[inline]
    pub fn get_bit(&self, index: usize) -> bool {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = self.storage.as_ref()[byte_index];
        Self::extract_bit(byte, index)
    }
    #[inline]
    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
        let byte_index = index / 8;
        let byte = unsafe {
            *(core::ptr::addr_of!((*this).storage) as *const u8).offset(byte_index as isize)
        };
        Self::extract_bit(byte, index)
    }
    #[inline]
    fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        if val { byte | mask } else { byte & !mask }
    }
    #[inline]
    pub fn set_bit(&mut self, index: usize, val: bool) {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = &mut self.storage.as_mut()[byte_index];
        *byte = Self::change_bit(*byte, index, val);
    }
    #[inline]
    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
        let byte_index = index / 8;
        let byte = unsafe {
            (core::ptr::addr_of_mut!((*this).storage) as *mut u8).offset(byte_index as isize)
        };
        unsafe { *byte = Self::change_bit(*byte, index, val) };
    }
    #[inline]
    pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),);
        let mut val = 0;
        for i in 0..(bit_width as usize) {
            if self.get_bit(i + bit_offset) {
                let index = if cfg!(target_endian = "big") {
                    bit_width as usize - 1 - i
                } else {
                    i
                };
                val |= 1 << index;
            }
        }
        val
    }
    #[inline]
    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),);
        let mut val = 0;
        for i in 0..(bit_width as usize) {
            if unsafe { Self::raw_get_bit(this, i + bit_offset) } {
                let index = if cfg!(target_endian = "big") {
                    bit_width as usize - 1 - i
                } else {
                    i
                };
                val |= 1 << index;
            }
        }
        val
    }
    #[inline]
    pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len(),);
        for i in 0..(bit_width as usize) {
            let mask = 1 << i;
            let val_bit_is_set = val & mask == mask;
            let index = if cfg!(target_endian = "big") {
                bit_width as usize - 1 - i
            } else {
                i
            };
            self.set_bit(index + bit_offset, val_bit_is_set);
        }
    }
    #[inline]
    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),);
        for i in 0..(bit_width as usize) {
            let mask = 1 << i;
            let val_bit_is_set = val & mask == mask;
            let index = if cfg!(target_endian = "big") {
                bit_width as usize - 1 - i
            } else {
                i
            };
            unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
        }
    }
}
pub const LIBDE265_NUMERIC_VERSION: u32 = 16782848;
pub const LIBDE265_VERSION: &::std::ffi::CStr = c"1.0.16";
unsafe extern "C" {
    /// version of linked libde265 library
    pub fn de265_get_version() -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    /// returns the version number as a BCD number.
    /// 0xAABBCCDD is interpreted as version AA.BB.CC.
    /// For example: 0x02143000 is version 2.14.30
    pub fn de265_get_version_number() -> u32;
}
unsafe extern "C" {
    pub fn de265_get_version_number_major() -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_version_number_minor() -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_version_number_maintenance() -> ::std::os::raw::c_int;
}
pub mod de265_error {
    pub type Type = ::std::os::raw::c_uint;
    pub const DE265_OK: Type = 0;
    pub const DE265_ERROR_NO_SUCH_FILE: Type = 1;
    pub const DE265_ERROR_COEFFICIENT_OUT_OF_IMAGE_BOUNDS: Type = 4;
    pub const DE265_ERROR_CHECKSUM_MISMATCH: Type = 5;
    pub const DE265_ERROR_CTB_OUTSIDE_IMAGE_AREA: Type = 6;
    pub const DE265_ERROR_OUT_OF_MEMORY: Type = 7;
    pub const DE265_ERROR_CODED_PARAMETER_OUT_OF_RANGE: Type = 8;
    pub const DE265_ERROR_IMAGE_BUFFER_FULL: Type = 9;
    pub const DE265_ERROR_CANNOT_START_THREADPOOL: Type = 10;
    pub const DE265_ERROR_LIBRARY_INITIALIZATION_FAILED: Type = 11;
    pub const DE265_ERROR_LIBRARY_NOT_INITIALIZED: Type = 12;
    pub const DE265_ERROR_WAITING_FOR_INPUT_DATA: Type = 13;
    pub const DE265_ERROR_CANNOT_PROCESS_SEI: Type = 14;
    pub const DE265_ERROR_PARAMETER_PARSING: Type = 15;
    pub const DE265_ERROR_NO_INITIAL_SLICE_HEADER: Type = 16;
    pub const DE265_ERROR_PREMATURE_END_OF_SLICE: Type = 17;
    pub const DE265_ERROR_UNSPECIFIED_DECODING_ERROR: Type = 18;
    pub const DE265_ERROR_NOT_IMPLEMENTED_YET: Type = 502;
    pub const DE265_WARNING_NO_WPP_CANNOT_USE_MULTITHREADING: Type = 1000;
    pub const DE265_WARNING_WARNING_BUFFER_FULL: Type = 1001;
    pub const DE265_WARNING_PREMATURE_END_OF_SLICE_SEGMENT: Type = 1002;
    pub const DE265_WARNING_INCORRECT_ENTRY_POINT_OFFSET: Type = 1003;
    pub const DE265_WARNING_CTB_OUTSIDE_IMAGE_AREA: Type = 1004;
    pub const DE265_WARNING_SPS_HEADER_INVALID: Type = 1005;
    pub const DE265_WARNING_PPS_HEADER_INVALID: Type = 1006;
    pub const DE265_WARNING_SLICEHEADER_INVALID: Type = 1007;
    pub const DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING: Type = 1008;
    pub const DE265_WARNING_NONEXISTING_PPS_REFERENCED: Type = 1009;
    pub const DE265_WARNING_NONEXISTING_SPS_REFERENCED: Type = 1010;
    pub const DE265_WARNING_BOTH_PREDFLAGS_ZERO: Type = 1011;
    pub const DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED: Type = 1012;
    pub const DE265_WARNING_NUMMVP_NOT_EQUAL_TO_NUMMVQ: Type = 1013;
    pub const DE265_WARNING_NUMBER_OF_SHORT_TERM_REF_PIC_SETS_OUT_OF_RANGE: Type = 1014;
    pub const DE265_WARNING_SHORT_TERM_REF_PIC_SET_OUT_OF_RANGE: Type = 1015;
    pub const DE265_WARNING_FAULTY_REFERENCE_PICTURE_LIST: Type = 1016;
    pub const DE265_WARNING_EOSS_BIT_NOT_SET: Type = 1017;
    pub const DE265_WARNING_MAX_NUM_REF_PICS_EXCEEDED: Type = 1018;
    pub const DE265_WARNING_INVALID_CHROMA_FORMAT: Type = 1019;
    pub const DE265_WARNING_SLICE_SEGMENT_ADDRESS_INVALID: Type = 1020;
    pub const DE265_WARNING_DEPENDENT_SLICE_WITH_ADDRESS_ZERO: Type = 1021;
    pub const DE265_WARNING_NUMBER_OF_THREADS_LIMITED_TO_MAXIMUM: Type = 1022;
    pub const DE265_NON_EXISTING_LT_REFERENCE_CANDIDATE_IN_SLICE_HEADER: Type = 1023;
    pub const DE265_WARNING_CANNOT_APPLY_SAO_OUT_OF_MEMORY: Type = 1024;
    pub const DE265_WARNING_SPS_MISSING_CANNOT_DECODE_SEI: Type = 1025;
    pub const DE265_WARNING_COLLOCATED_MOTION_VECTOR_OUTSIDE_IMAGE_AREA: Type = 1026;
    pub const DE265_WARNING_PCM_BITDEPTH_TOO_LARGE: Type = 1027;
    pub const DE265_WARNING_REFERENCE_IMAGE_BIT_DEPTH_DOES_NOT_MATCH: Type = 1028;
    pub const DE265_WARNING_REFERENCE_IMAGE_SIZE_DOES_NOT_MATCH_SPS: Type = 1029;
    pub const DE265_WARNING_CHROMA_OF_CURRENT_IMAGE_DOES_NOT_MATCH_SPS: Type = 1030;
    pub const DE265_WARNING_BIT_DEPTH_OF_CURRENT_IMAGE_DOES_NOT_MATCH_SPS: Type = 1031;
    pub const DE265_WARNING_REFERENCE_IMAGE_CHROMA_FORMAT_DOES_NOT_MATCH: Type = 1032;
    pub const DE265_WARNING_INVALID_SLICE_HEADER_INDEX_ACCESS: Type = 1033;
}
unsafe extern "C" {
    pub fn de265_get_error_text(err: de265_error::Type) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    /// Returns true, if 'err' is DE265_OK or a warning.
    pub fn de265_isOK(err: de265_error::Type) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_disable_logging();
}
unsafe extern "C" {
    pub fn de265_set_verbosity(level: ::std::os::raw::c_int);
}
/// The image is currently always 3-channel YCbCr, with 4:2:0 chroma.
/// But you may want to check the chroma format anyway for future compatibility.
#[repr(C)]
#[derive(Debug)]
pub struct de265_image {
    _unused: [u8; 0],
}
pub mod de265_chroma {
    pub type Type = ::std::os::raw::c_uint;
    pub const de265_chroma_mono: Type = 0;
    pub const de265_chroma_420: Type = 1;
    pub const de265_chroma_422: Type = 2;
    pub const de265_chroma_444: Type = 3;
}
pub type de265_PTS = i64;
unsafe extern "C" {
    pub fn de265_get_image_width(
        arg1: *const de265_image,
        channel: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_image_height(
        arg1: *const de265_image,
        channel: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_chroma_format(arg1: *const de265_image) -> de265_chroma::Type;
}
unsafe extern "C" {
    pub fn de265_get_bits_per_pixel(
        arg1: *const de265_image,
        channel: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    /// The |out_stride| is returned as "bytes per line" if a non-NULL parameter is given.
    pub fn de265_get_image_plane(
        arg1: *const de265_image,
        channel: ::std::os::raw::c_int,
        out_stride: *mut ::std::os::raw::c_int,
    ) -> *const u8;
}
unsafe extern "C" {
    pub fn de265_get_image_plane_user_data(
        arg1: *const de265_image,
        channel: ::std::os::raw::c_int,
    ) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    pub fn de265_get_image_PTS(arg1: *const de265_image) -> de265_PTS;
}
unsafe extern "C" {
    pub fn de265_get_image_user_data(arg1: *const de265_image) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    pub fn de265_set_image_user_data(
        arg1: *mut de265_image,
        user_data: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    /// Get NAL-header information of this frame. You can pass in NULL pointers if you
    /// do not need this piece of information.
    pub fn de265_get_image_NAL_header(
        arg1: *const de265_image,
        nal_unit_type: *mut ::std::os::raw::c_int,
        nal_unit_name: *mut *const ::std::os::raw::c_char,
        nuh_layer_id: *mut ::std::os::raw::c_int,
        nuh_temporal_id: *mut ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn de265_get_image_full_range_flag(arg1: *const de265_image) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_image_colour_primaries(arg1: *const de265_image) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_image_transfer_characteristics(
        arg1: *const de265_image,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_image_matrix_coefficients(arg1: *const de265_image) -> ::std::os::raw::c_int;
}
/// === decoder ===
pub type de265_decoder_context = ::std::os::raw::c_void;
unsafe extern "C" {
    /// Get a new decoder context. Must be freed with de265_free_decoder().
    pub fn de265_new_decoder() -> *mut de265_decoder_context;
}
unsafe extern "C" {
    /// Initialize background decoding threads. If this function is not called,
    /// all decoding is done in the main thread (no multi-threading).
    pub fn de265_start_worker_threads(
        arg1: *mut de265_decoder_context,
        number_of_threads: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// Free decoder context. May only be called once on a context.
    pub fn de265_free_decoder(arg1: *mut de265_decoder_context) -> de265_error::Type;
}
unsafe extern "C" {
    /// Push more data into the decoder, must be raw h265.
    /// All complete images in the data will be decoded, hence, do not push
    /// too much data at once to prevent image buffer overflows.
    /// The end of a picture can only be detected when the succeeding start-code
    /// is read from the data.
    /// If you want to flush the data and force decoding of the data so far
    /// (e.g. at the end of a file), call de265_decode_data() with 'length' zero.
    ///
    /// NOTE: This method is deprecated and will be removed in a future version.
    /// You should use "de265_push_data" or "de265_push_NAL" and "de265_decode"
    /// instead.
    pub fn de265_decode_data(
        arg1: *mut de265_decoder_context,
        data: *const ::std::os::raw::c_void,
        length: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// Push more data into the decoder, must be a raw h265 bytestream with startcodes.
    /// The PTS is assigned to all NALs whose start-code 0x000001 is contained in the data.
    /// The bytestream must contain all stuffing-bytes.
    /// This function only pushes data into the decoder, nothing will be decoded.
    pub fn de265_push_data(
        arg1: *mut de265_decoder_context,
        data: *const ::std::os::raw::c_void,
        length: ::std::os::raw::c_int,
        pts: de265_PTS,
        user_data: *mut ::std::os::raw::c_void,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// Indicate that de265_push_data has just received data until the end of a NAL.
    /// The remaining pending input data is put into a NAL package and forwarded to the decoder.
    pub fn de265_push_end_of_NAL(arg1: *mut de265_decoder_context);
}
unsafe extern "C" {
    /// Indicate that de265_push_data has just received data until the end of a frame.
    /// All data pending at the decoder input will be pushed into the decoder and
    /// the decoded picture is pushed to the output queue.
    pub fn de265_push_end_of_frame(arg1: *mut de265_decoder_context);
}
unsafe extern "C" {
    /// Push a complete NAL unit without startcode into the decoder. The data must still
    /// contain all stuffing-bytes.
    /// This function only pushes data into the decoder, nothing will be decoded.
    pub fn de265_push_NAL(
        arg1: *mut de265_decoder_context,
        data: *const ::std::os::raw::c_void,
        length: ::std::os::raw::c_int,
        pts: de265_PTS,
        user_data: *mut ::std::os::raw::c_void,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// Indicate the end-of-stream. All data pending at the decoder input will be
    /// pushed into the decoder and the decoded picture queue will be completely emptied.
    pub fn de265_flush_data(arg1: *mut de265_decoder_context) -> de265_error::Type;
}
unsafe extern "C" {
    /// Return number of bytes pending at the decoder input.
    /// Can be used to avoid overflowing the decoder with too much data.
    pub fn de265_get_number_of_input_bytes_pending(
        arg1: *mut de265_decoder_context,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    /// Return number of NAL units pending at the decoder input.
    /// Can be used to avoid overflowing the decoder with too much data.
    pub fn de265_get_number_of_NAL_units_pending(
        arg1: *mut de265_decoder_context,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    /// Do some decoding. Returns status whether it did perform some decoding or
    /// why it could not do so. If 'more' is non-null, indicates whether de265_decode()
    /// should be called again (possibly after resolving the indicated problem).
    /// DE265_OK - decoding ok
    /// DE265_ERROR_IMAGE_BUFFER_FULL - DPB full, extract some images before continuing
    /// DE265_ERROR_WAITING_FOR_INPUT_DATA - insert more data before continuing
    ///
    /// You have to consider these cases:
    /// - decoding successful   -> err  = DE265_OK, more=true
    /// - decoding stalled      -> err != DE265_OK, more=true
    /// - decoding finished     -> err  = DE265_OK, more=false
    /// - unresolvable error    -> err != DE265_OK, more=false
    pub fn de265_decode(
        arg1: *mut de265_decoder_context,
        more: *mut ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// Clear decoder state. Call this when skipping in the stream.
    pub fn de265_reset(arg1: *mut de265_decoder_context);
}
unsafe extern "C" {
    /// Return next decoded picture, if there is any. If no complete picture has been
    /// decoded yet, NULL is returned. You should call de265_release_next_picture() to
    /// advance to the next picture.
    pub fn de265_peek_next_picture(arg1: *mut de265_decoder_context) -> *const de265_image;
}
unsafe extern "C" {
    /// Get next decoded picture and remove this picture from the decoder output queue.
    /// Returns NULL is there is no decoded picture ready.
    /// You can use the picture only until you call any other de265_* function.
    pub fn de265_get_next_picture(arg1: *mut de265_decoder_context) -> *const de265_image;
}
unsafe extern "C" {
    /// Release the current decoded picture for reuse in the decoder. You should not
    /// use the data anymore after calling this function.
    pub fn de265_release_next_picture(arg1: *mut de265_decoder_context);
}
unsafe extern "C" {
    pub fn de265_get_warning(arg1: *mut de265_decoder_context) -> de265_error::Type;
}
pub mod de265_image_format {
    pub type Type = ::std::os::raw::c_uint;
    pub const de265_image_format_mono8: Type = 1;
    pub const de265_image_format_YUV420P8: Type = 2;
    pub const de265_image_format_YUV422P8: Type = 3;
    pub const de265_image_format_YUV444P8: Type = 4;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct de265_image_spec {
    pub format: de265_image_format::Type,
    pub width: ::std::os::raw::c_int,
    pub height: ::std::os::raw::c_int,
    pub alignment: ::std::os::raw::c_int,
    /// conformance window
    pub crop_left: ::std::os::raw::c_int,
    pub crop_right: ::std::os::raw::c_int,
    pub crop_top: ::std::os::raw::c_int,
    pub crop_bottom: ::std::os::raw::c_int,
    /// convenience, width  - crop_left - crop_right
    pub visible_width: ::std::os::raw::c_int,
    /// convenience, height - crop_top - crop_bottom
    pub visible_height: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct de265_image_allocation {
    /// first parameter deprecated
    pub get_buffer: ::std::option::Option<
        unsafe extern "C" fn(
            ctx: *mut de265_decoder_context,
            spec: *mut de265_image_spec,
            img: *mut de265_image,
            userdata: *mut ::std::os::raw::c_void,
        ) -> ::std::os::raw::c_int,
    >,
    /// first parameter deprecated
    pub release_buffer: ::std::option::Option<
        unsafe extern "C" fn(
            ctx: *mut de265_decoder_context,
            img: *mut de265_image,
            userdata: *mut ::std::os::raw::c_void,
        ),
    >,
}
unsafe extern "C" {
    /// The user data pointer will be given to the get_buffer() and release_buffer() functions
    /// in de265_image_allocation.
    pub fn de265_set_image_allocation_functions(
        arg1: *mut de265_decoder_context,
        arg2: *mut de265_image_allocation,
        userdata: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    pub fn de265_get_default_image_allocation_functions() -> *const de265_image_allocation;
}
unsafe extern "C" {
    pub fn de265_set_image_plane(
        img: *mut de265_image,
        cIdx: ::std::os::raw::c_int,
        mem: *mut ::std::os::raw::c_void,
        stride: ::std::os::raw::c_int,
        userdata: *mut ::std::os::raw::c_void,
    );
}
unsafe extern "C" {
    /// --- frame dropping API ---
    ///
    /// To limit decoding to a maximum temporal layer (TID), use de265_set_limit_TID().
    /// The maximum layer ID in the stream can be queried with de265_get_highest_TID().
    /// Note that the maximum layer ID can change throughout the stream.
    ///
    /// For a fine-grained selection of the frame-rate, use de265_set_framerate_ratio().
    /// A percentage of 100% will decode all frames in all temporal layers. A lower percentage
    /// will drop approximately as many frames. Note that this only accurate if the frames
    /// are distributed evenly among the layers. Otherwise, the mapping is non-linear.
    ///
    /// The limit_TID has a higher precedence than framerate_ratio. Hence, setting a higher
    /// framerate-ratio will decode at limit_TID without dropping.
    ///
    /// With change_framerate(), the output frame-rate can be increased/decreased to some
    /// discrete preferable values. Currently, these are non-dropped decoding at various
    /// TID layers.
    pub fn de265_get_highest_TID(arg1: *mut de265_decoder_context) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_get_current_TID(arg1: *mut de265_decoder_context) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn de265_set_limit_TID(arg1: *mut de265_decoder_context, max_tid: ::std::os::raw::c_int);
}
unsafe extern "C" {
    pub fn de265_set_framerate_ratio(
        arg1: *mut de265_decoder_context,
        percent: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn de265_change_framerate(
        arg1: *mut de265_decoder_context,
        more_vs_less: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
pub mod de265_param {
    /// --- decoding parameters ---
    pub type Type = ::std::os::raw::c_uint;
    /// (bool) Perform SEI hash check on decoded pictures.
    pub const DE265_DECODER_PARAM_BOOL_SEI_CHECK_HASH: Type = 0;
    /// (int)  Dump headers to specified file-descriptor.
    pub const DE265_DECODER_PARAM_DUMP_SPS_HEADERS: Type = 1;
    pub const DE265_DECODER_PARAM_DUMP_VPS_HEADERS: Type = 2;
    pub const DE265_DECODER_PARAM_DUMP_PPS_HEADERS: Type = 3;
    pub const DE265_DECODER_PARAM_DUMP_SLICE_HEADERS: Type = 4;
    /// (int)  enum de265_acceleration, default: AUTO
    pub const DE265_DECODER_PARAM_ACCELERATION_CODE: Type = 5;
    /// (bool)  do not output frames with decoding errors, default: no (output all images)
    pub const DE265_DECODER_PARAM_SUPPRESS_FAULTY_PICTURES: Type = 6;
    /// (bool)  disable deblocking
    pub const DE265_DECODER_PARAM_DISABLE_DEBLOCKING: Type = 7;
    /// (bool)  disable SAO filter
    pub const DE265_DECODER_PARAM_DISABLE_SAO: Type = 8;
}
pub mod de265_acceleration {
    /// sorted such that a large ID includes all optimizations from lower IDs
    pub type Type = ::std::os::raw::c_uint;
    /// only fallback implementation
    pub const de265_acceleration_SCALAR: Type = 0;
    pub const de265_acceleration_MMX: Type = 10;
    pub const de265_acceleration_SSE: Type = 20;
    pub const de265_acceleration_SSE2: Type = 30;
    pub const de265_acceleration_SSE4: Type = 40;
    /// not implemented yet
    pub const de265_acceleration_AVX: Type = 50;
    /// not implemented yet
    pub const de265_acceleration_AVX2: Type = 60;
    pub const de265_acceleration_ARM: Type = 70;
    pub const de265_acceleration_NEON: Type = 80;
    pub const de265_acceleration_AUTO: Type = 10000;
}
unsafe extern "C" {
    /// Set decoding parameters.
    pub fn de265_set_parameter_bool(
        arg1: *mut de265_decoder_context,
        param: de265_param::Type,
        value: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn de265_set_parameter_int(
        arg1: *mut de265_decoder_context,
        param: de265_param::Type,
        value: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    /// Get decoding parameters.
    pub fn de265_get_parameter_bool(
        arg1: *mut de265_decoder_context,
        param: de265_param::Type,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    /// Static library initialization. Must be paired with de265_free().
    /// Initialization is optional, since it will be done implicitly in de265_new_decoder().
    /// Return value is false if initialization failed.
    /// Only call de265_free() when initialization was successful.
    /// Multiple calls to 'init' are allowed, but must be matched with an equal number of 'free' calls.
    pub fn de265_init() -> de265_error::Type;
}
unsafe extern "C" {
    /// Free global library data.
    /// An implicit free call is made in de265_free_decoder().
    /// Returns false if library was not initialized before, or if 'free' was called
    /// more often than 'init'.
    pub fn de265_free() -> de265_error::Type;
}
/// ========== encoder context ==========
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct en265_encoder_context {
    _unused: [u8; 0],
}
unsafe extern "C" {
    /// Get a new encoder context. Must be freed with en265_free_encoder().
    pub fn en265_new_encoder() -> *mut en265_encoder_context;
}
unsafe extern "C" {
    /// Free encoder context. May only be called once on a context.
    pub fn en265_free_encoder(arg1: *mut en265_encoder_context) -> de265_error::Type;
}
unsafe extern "C" {
    /// ========== encoder parameters ==========
    pub fn en265_set_parameter_bool(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
        value: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_set_parameter_int(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
        value: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_set_parameter_string(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
        value: *const ::std::os::raw::c_char,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_set_parameter_choice(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
        value: *const ::std::os::raw::c_char,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_list_parameters(
        arg1: *mut en265_encoder_context,
    ) -> *mut *const ::std::os::raw::c_char;
}
pub mod en265_parameter_type {
    pub type Type = ::std::os::raw::c_uint;
    pub const en265_parameter_bool: Type = 0;
    pub const en265_parameter_int: Type = 1;
    pub const en265_parameter_string: Type = 2;
    pub const en265_parameter_choice: Type = 3;
}
unsafe extern "C" {
    pub fn en265_get_parameter_type(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
    ) -> en265_parameter_type::Type;
}
unsafe extern "C" {
    pub fn en265_list_parameter_choices(
        arg1: *mut en265_encoder_context,
        parametername: *const ::std::os::raw::c_char,
    ) -> *mut *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    /// --- convenience functions for command-line parameters ---
    pub fn en265_parse_command_line_parameters(
        arg1: *mut en265_encoder_context,
        argc: *mut ::std::os::raw::c_int,
        argv: *mut *mut ::std::os::raw::c_char,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_show_parameters(arg1: *mut en265_encoder_context);
}
unsafe extern "C" {
    /// ========== encoding loop ==========
    pub fn en265_start_encoder(
        arg1: *mut en265_encoder_context,
        number_of_threads: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    /// If we have provided our own memory release function, no image memory will be allocated.
    pub fn en265_allocate_image(
        arg1: *mut en265_encoder_context,
        width: ::std::os::raw::c_int,
        height: ::std::os::raw::c_int,
        chroma: de265_chroma::Type,
        pts: de265_PTS,
        image_userdata: *mut ::std::os::raw::c_void,
    ) -> *mut de265_image;
}
unsafe extern "C" {
    pub fn de265_alloc_image_plane(
        img: *mut de265_image,
        cIdx: ::std::os::raw::c_int,
        inputdata: *mut ::std::os::raw::c_void,
        inputstride: ::std::os::raw::c_int,
        userdata: *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    pub fn de265_free_image_plane(img: *mut de265_image, cIdx: ::std::os::raw::c_int);
}
unsafe extern "C" {
    /// Request a specification of the image memory layout for an image of the specified dimensions.
    pub fn en265_get_image_spec(
        arg1: *mut en265_encoder_context,
        width: ::std::os::raw::c_int,
        height: ::std::os::raw::c_int,
        chroma: de265_chroma::Type,
        out_spec: *mut de265_image_spec,
    );
}
unsafe extern "C" {
    /// Image memory layout specification for an image returned by en265_allocate_image().
    /// * TODO: do we need this?
    /// LIBDE265_API void de265_get_image_spec_from_image(de265_image* img, struct de265_image_spec* spec);
    /// */
    pub fn en265_push_image(
        arg1: *mut en265_encoder_context,
        arg2: *mut de265_image,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_push_eof(arg1: *mut en265_encoder_context) -> de265_error::Type;
}
unsafe extern "C" {
    /// block when there are more than max_input_images in the input queue
    pub fn en265_block_on_input_queue_length(
        arg1: *mut en265_encoder_context,
        max_pending_images: ::std::os::raw::c_int,
        timeout_ms: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_trim_input_queue(
        arg1: *mut en265_encoder_context,
        max_pending_images: ::std::os::raw::c_int,
    ) -> de265_error::Type;
}
unsafe extern "C" {
    pub fn en265_current_input_queue_length(
        arg1: *mut en265_encoder_context,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    /// Run encoder in main thread. Only use this when not using background threads.
    pub fn en265_encode(arg1: *mut en265_encoder_context) -> de265_error::Type;
}
pub mod en265_encoder_state {
    pub type Type = ::std::os::raw::c_uint;
    pub const EN265_STATE_IDLE: Type = 0;
    pub const EN265_STATE_WAITING_FOR_INPUT: Type = 1;
    pub const EN265_STATE_WORKING: Type = 2;
    pub const EN265_STATE_OUTPUT_QUEUE_FULL: Type = 3;
    pub const EN265_STATE_EOS: Type = 4;
}
unsafe extern "C" {
    pub fn en265_get_encoder_state(arg1: *mut en265_encoder_context) -> en265_encoder_state::Type;
}
pub mod en265_packet_content_type {
    pub type Type = ::std::os::raw::c_uint;
    pub const EN265_PACKET_VPS: Type = 0;
    pub const EN265_PACKET_SPS: Type = 1;
    pub const EN265_PACKET_PPS: Type = 2;
    pub const EN265_PACKET_SEI: Type = 3;
    pub const EN265_PACKET_SLICE: Type = 4;
    pub const EN265_PACKET_SKIPPED_IMAGE: Type = 5;
}
pub mod en265_nal_unit_type {
    pub type Type = ::std::os::raw::c_uint;
    pub const EN265_NUT_TRAIL_N: Type = 0;
    pub const EN265_NUT_TRAIL_R: Type = 1;
    pub const EN265_NUT_TSA_N: Type = 2;
    pub const EN265_NUT_TSA_R: Type = 3;
    pub const EN265_NUT_STSA_N: Type = 4;
    pub const EN265_NUT_STSA_R: Type = 5;
    pub const EN265_NUT_RADL_N: Type = 6;
    pub const EN265_NUT_RADL_R: Type = 7;
    pub const EN265_NUT_RASL_N: Type = 8;
    pub const EN265_NUT_RASL_R: Type = 9;
    pub const EN265_NUT_BLA_W_LP: Type = 16;
    pub const EN265_NUT_BLA_W_RADL: Type = 17;
    pub const EN265_NUT_BLA_N_LP: Type = 18;
    pub const EN265_NUT_IDR_W_RADL: Type = 19;
    pub const EN265_NUT_IDR_N_LP: Type = 20;
    pub const EN265_NUT_CRA: Type = 21;
    pub const EN265_NUT_VPS: Type = 32;
    pub const EN265_NUT_SPS: Type = 33;
    pub const EN265_NUT_PPS: Type = 34;
    pub const EN265_NUT_AUD: Type = 35;
    pub const EN265_NUT_EOS: Type = 36;
    pub const EN265_NUT_EOB: Type = 37;
    pub const EN265_NUT_FD: Type = 38;
    pub const EN265_NUT_PREFIX_SEI: Type = 39;
    pub const EN265_NUT_SUFFIX_SEI: Type = 40;
}
#[repr(C)]
#[derive(Debug)]
pub struct en265_packet {
    pub version: ::std::os::raw::c_int,
    pub data: *const u8,
    pub length: ::std::os::raw::c_int,
    pub frame_number: ::std::os::raw::c_int,
    pub content_type: en265_packet_content_type::Type,
    pub _bitfield_align_1: [u8; 0],
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
    pub nal_unit_type: en265_nal_unit_type::Type,
    pub nuh_layer_id: ::std::os::raw::c_uchar,
    pub nuh_temporal_id: ::std::os::raw::c_uchar,
    pub encoder_context: *mut en265_encoder_context,
    pub input_image: *const de265_image,
    pub reconstruction: *const de265_image,
}
impl en265_packet {
    #[inline]
    pub fn complete_picture(&self) -> ::std::os::raw::c_char {
        unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_complete_picture(&mut self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub unsafe fn complete_picture_raw(this: *const Self) -> ::std::os::raw::c_char {
        unsafe {
            ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get(
                ::std::ptr::addr_of!((*this)._bitfield_1),
                0usize,
                1u8,
            ) as u8)
        }
    }
    #[inline]
    pub unsafe fn set_complete_picture_raw(this: *mut Self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set(
                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
                0usize,
                1u8,
                val as u64,
            )
        }
    }
    #[inline]
    pub fn final_slice(&self) -> ::std::os::raw::c_char {
        unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_final_slice(&mut self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            self._bitfield_1.set(1usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub unsafe fn final_slice_raw(this: *const Self) -> ::std::os::raw::c_char {
        unsafe {
            ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get(
                ::std::ptr::addr_of!((*this)._bitfield_1),
                1usize,
                1u8,
            ) as u8)
        }
    }
    #[inline]
    pub unsafe fn set_final_slice_raw(this: *mut Self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set(
                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
                1usize,
                1u8,
                val as u64,
            )
        }
    }
    #[inline]
    pub fn dependent_slice(&self) -> ::std::os::raw::c_char {
        unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_dependent_slice(&mut self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            self._bitfield_1.set(2usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub unsafe fn dependent_slice_raw(this: *const Self) -> ::std::os::raw::c_char {
        unsafe {
            ::std::mem::transmute(<__BindgenBitfieldUnit<[u8; 1usize]>>::raw_get(
                ::std::ptr::addr_of!((*this)._bitfield_1),
                2usize,
                1u8,
            ) as u8)
        }
    }
    #[inline]
    pub unsafe fn set_dependent_slice_raw(this: *mut Self, val: ::std::os::raw::c_char) {
        unsafe {
            let val: u8 = ::std::mem::transmute(val);
            <__BindgenBitfieldUnit<[u8; 1usize]>>::raw_set(
                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
                2usize,
                1u8,
                val as u64,
            )
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        complete_picture: ::std::os::raw::c_char,
        final_slice: ::std::os::raw::c_char,
        dependent_slice: ::std::os::raw::c_char,
    ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let complete_picture: u8 = unsafe { ::std::mem::transmute(complete_picture) };
            complete_picture as u64
        });
        __bindgen_bitfield_unit.set(1usize, 1u8, {
            let final_slice: u8 = unsafe { ::std::mem::transmute(final_slice) };
            final_slice as u64
        });
        __bindgen_bitfield_unit.set(2usize, 1u8, {
            let dependent_slice: u8 = unsafe { ::std::mem::transmute(dependent_slice) };
            dependent_slice as u64
        });
        __bindgen_bitfield_unit
    }
}
unsafe extern "C" {
    /// timeout_ms - timeout in milliseconds. 0 - no timeout, -1 - block forever
    pub fn en265_get_packet(
        arg1: *mut en265_encoder_context,
        timeout_ms: ::std::os::raw::c_int,
    ) -> *mut en265_packet;
}
unsafe extern "C" {
    pub fn en265_free_packet(arg1: *mut en265_encoder_context, arg2: *mut en265_packet);
}
unsafe extern "C" {
    pub fn en265_number_of_queued_packets(
        arg1: *mut en265_encoder_context,
    ) -> ::std::os::raw::c_int;
}