Skip to main content

core_video_sys/
pixel_format_description.rs

1use core_foundation_sys::{
2    array::CFArrayRef,
3    base::{Boolean, CFAllocatorRef, CFIndex},
4    dictionary::CFDictionaryRef,
5    string::CFStringRef,
6};
7use libc::c_void;
8
9use crate::{pixel_buffer::CVPixelBufferRef, OSType};
10
11pub type CVFillExtendedPixelsCallBack =
12    extern "C" fn(pixelBuffer: CVPixelBufferRef, refCon: *mut c_void) -> Boolean;
13
14#[repr(C)]
15#[derive(Debug, Clone, Copy)]
16pub struct CVFillExtendedPixelsCallBackData {
17    pub version: CFIndex,
18    pub fillCallBack: CVFillExtendedPixelsCallBack,
19    pub refCon: *mut c_void,
20}
21
22extern "C" {
23    pub static kCVPixelFormatName: CFStringRef;
24
25    /// QuickTime/QuickDraw Pixel Format Type constant (OSType)
26    pub static kCVPixelFormatConstant: CFStringRef;
27
28    /// This is the codec type constant, i.e. '2vuy' or k422YpCbCr8CodecType
29    pub static kCVPixelFormatCodecType: CFStringRef;
30
31    /// This is the equivalent Microsoft FourCC code for this pixel format
32    pub static kCVPixelFormatFourCC: CFStringRef;
33
34    /// kCFBooleanTrue indicates that the format contains alpha and some images may be considered transparent
35    /// kCFBooleanFalse indicates that there is no alpha and images are always opaque.
36    pub static kCVPixelFormatContainsAlpha: CFStringRef;
37
38    /// kCFBooleanTrue indicates that the format contains YCbCr data
39    pub static kCVPixelFormatContainsYCbCr: CFStringRef;
40
41    /// kCFBooleanTrue indicates that the format contains RGB data
42    pub static kCVPixelFormatContainsRGB: CFStringRef;
43
44    pub static kCVPixelFormatComponentRange: CFStringRef;
45
46    pub static kCVPixelFormatComponentRange_VideoRange: CFStringRef;
47
48    pub static kCVPixelFormatComponentRange_FullRange: CFStringRef;
49
50    pub static kCVPixelFormatComponentRange_WideRange: CFStringRef;
51
52    /// All buffers have one or more image planes.
53    /// Each plane may contain a single or an interleaved set of components
54    /// For simplicity sake,
55    /// pixel formats that are not planar may place the required format keys at the top level dictionary.
56    pub static kCVPixelFormatPlanes: CFStringRef;
57
58    pub static kCVPixelFormatBlockWidth: CFStringRef;
59    pub static kCVPixelFormatBlockHeight: CFStringRef;
60
61    /// This value must be present.
62    /// For simple pixel formats this will be equivalent to the traditional bitsPerPixel value.
63    pub static kCVPixelFormatBitsPerBlock: CFStringRef;
64
65    /// Used to state requirements on block multiples.  v210 would be '8' here for the horizontal case,
66    /// to match the standard v210 row alignment value of 48.
67    /// These may be assumed as 1 if not present.
68    pub static kCVPixelFormatBlockHorizontalAlignment: CFStringRef;
69    pub static kCVPixelFormatBlockVerticalAlignment: CFStringRef;
70
71    /// CFData containing the bit pattern for a block of black pixels.  If absent, black is assumed to be all zeros.
72    /// If present, this should be bitsPerPixel bits long -- if bitsPerPixel is less than a byte, repeat the bit pattern
73    /// for the full byte.
74    pub static kCVPixelFormatBlackBlock: CFStringRef;
75
76    /// Subsampling information for this plane.  Assumed to be '1' if not present.
77    pub static kCVPixelFormatHorizontalSubsampling: CFStringRef;
78    pub static kCVPixelFormatVerticalSubsampling: CFStringRef;
79
80    /// If present, these two keys describe the OpenGL format and type enums you would use to describe this
81    /// image plane to OpenGL
82    pub static kCVPixelFormatOpenGLFormat: CFStringRef;
83    pub static kCVPixelFormatOpenGLType: CFStringRef;
84    pub static kCVPixelFormatOpenGLInternalFormat: CFStringRef;
85
86    /// CGBitmapInfo value, if required
87    pub static kCVPixelFormatCGBitmapInfo: CFStringRef;
88
89    /// Pixel format compatibility flags
90    pub static kCVPixelFormatQDCompatibility: CFStringRef;
91    pub static kCVPixelFormatCGBitmapContextCompatibility: CFStringRef;
92    pub static kCVPixelFormatCGImageCompatibility: CFStringRef;
93    pub static kCVPixelFormatOpenGLCompatibility: CFStringRef;
94    pub static kCVPixelFormatOpenGLESCompatibility: CFStringRef;
95
96    pub static kCVPixelFormatFillExtendedPixelsCallback: CFStringRef;
97
98    pub fn CVPixelFormatDescriptionCreateWithPixelFormatType(
99        allocator: CFAllocatorRef,
100        pixelFormat: OSType,
101    ) -> CFDictionaryRef;
102    pub fn CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes(
103        allocator: CFAllocatorRef,
104    ) -> CFArrayRef;
105    pub fn CVPixelFormatDescriptionRegisterDescriptionWithPixelFormatType(
106        description: CFDictionaryRef,
107        pixelFormat: OSType,
108    );
109}
110
111#[cfg(feature = "direct3d")]
112extern "C" {
113    pub static kCVPixelFormatDirect3DFormat: CFStringRef;
114    pub static kCVPixelFormatDirect3DType: CFStringRef;
115    pub static kCVPixelFormatDirect3DInternalFormat: CFStringRef;
116    pub static kCVPixelFormatDirect3DCompatibility: CFStringRef;
117}