use crate::libc::{ c_void, int32_t, uint32_t, size_t, };
use crate::core_foundation_sys::{
base::{ Boolean, CFAllocatorRef, CFTypeID },
dictionary::CFDictionaryRef,
array::CFArrayRef,
string::CFStringRef,
};
use crate::{
OSType,
base::CVOptionFlags,
image_buffer::CVImageBufferRef,
return_::CVReturn,
};
const fn as_u32_be(array: &[u8; 4]) -> u32 {
((array[0] as u32) << 24) +
((array[1] as u32) << 16) +
((array[2] as u32) << 8) +
((array[3] as u32) << 0)
}
pub type CVPixelBufferLockFlags = u64;
pub type CVPixelBufferRef = CVImageBufferRef;
pub const kCVPixelFormatType_1Monochrome: OSType = 0x00000001;
pub const kCVPixelFormatType_2Indexed: OSType = 0x00000002;
pub const kCVPixelFormatType_4Indexed: OSType = 0x00000004;
pub const kCVPixelFormatType_8Indexed: OSType = 0x00000008;
pub const kCVPixelFormatType_1IndexedGray_WhiteIsZero: OSType = 0x00000021;
pub const kCVPixelFormatType_2IndexedGray_WhiteIsZero: OSType = 0x00000022;
pub const kCVPixelFormatType_4IndexedGray_WhiteIsZero: OSType = 0x00000024;
pub const kCVPixelFormatType_8IndexedGray_WhiteIsZero: OSType = 0x00000028;
pub const kCVPixelFormatType_16BE555: OSType = 0x00000010;
pub const kCVPixelFormatType_16LE555: OSType = as_u32_be(b"L555");
pub const kCVPixelFormatType_16LE5551: OSType = as_u32_be(b"5551");
pub const kCVPixelFormatType_16BE565: OSType = as_u32_be(b"B565");
pub const kCVPixelFormatType_16LE565: OSType = as_u32_be(b"L565");
pub const kCVPixelFormatType_24RGB: OSType = 0x00000018;
pub const kCVPixelFormatType_24BGR: OSType = as_u32_be(b"24BG");
pub const kCVPixelFormatType_32ARGB: OSType = 0x00000020;
pub const kCVPixelFormatType_32BGRA: OSType = as_u32_be(b"BGRA");
pub const kCVPixelFormatType_32ABGR: OSType = as_u32_be(b"ABGR");
pub const kCVPixelFormatType_32RGBA: OSType = as_u32_be(b"RGBA");
pub const kCVPixelFormatType_64ARGB: OSType = as_u32_be(b"b64a");
pub const kCVPixelFormatType_48RGB: OSType = as_u32_be(b"b48r");
pub const kCVPixelFormatType_32AlphaGray: OSType = as_u32_be(b"b32a");
pub const kCVPixelFormatType_16Gray: OSType = as_u32_be(b"b16g");
pub const kCVPixelFormatType_30RGB: OSType = as_u32_be(b"R10k");
pub const kCVPixelFormatType_422YpCbCr8: OSType = as_u32_be(b"2vuy");
pub const kCVPixelFormatType_4444YpCbCrA8: OSType = as_u32_be(b"v408");
pub const kCVPixelFormatType_4444YpCbCrA8R: OSType = as_u32_be(b"r408");
pub const kCVPixelFormatType_4444AYpCbCr8: OSType = as_u32_be(b"y408");
pub const kCVPixelFormatType_4444AYpCbCr16: OSType = as_u32_be(b"y416");
pub const kCVPixelFormatType_444YpCbCr8: OSType = as_u32_be(b"v308");
pub const kCVPixelFormatType_422YpCbCr16: OSType = as_u32_be(b"v216");
pub const kCVPixelFormatType_422YpCbCr10: OSType = as_u32_be(b"v210");
pub const kCVPixelFormatType_444YpCbCr10: OSType = as_u32_be(b"v410");
pub const kCVPixelFormatType_420YpCbCr8Planar: OSType = as_u32_be(b"y420");
pub const kCVPixelFormatType_420YpCbCr8PlanarFullRange: OSType = as_u32_be(b"f420");
pub const kCVPixelFormatType_422YpCbCr_4A_8BiPlanar: OSType = as_u32_be(b"a2vy");
pub const kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: OSType = as_u32_be(b"420v");
pub const kCVPixelFormatType_420YpCbCr8BiPlanarFullRange: OSType = as_u32_be(b"420f");
pub const kCVPixelFormatType_422YpCbCr8_yuvs: OSType = as_u32_be(b"yuvs");
pub const kCVPixelFormatType_422YpCbCr8FullRange: OSType = as_u32_be(b"yuvf");
pub const kCVPixelFormatType_OneComponent8: OSType = as_u32_be(b"L008");
pub const kCVPixelFormatType_TwoComponent8: OSType = as_u32_be(b"2C08");
pub const kCVPixelFormatType_30RGBLEPackedWideGamut: OSType = as_u32_be(b"w30r");
pub const kCVPixelFormatType_ARGB2101010LEPacked: OSType = as_u32_be(b"l10r");
pub const kCVPixelFormatType_OneComponent16Half: OSType = as_u32_be(b"L00h");
pub const kCVPixelFormatType_OneComponent32Float: OSType = as_u32_be(b"L00f");
pub const kCVPixelFormatType_TwoComponent16Half: OSType = as_u32_be(b"2C0h");
pub const kCVPixelFormatType_TwoComponent32Float: OSType = as_u32_be(b"2C0f");
pub const kCVPixelFormatType_64RGBAHalf: OSType = as_u32_be(b"RGhA");
pub const kCVPixelFormatType_128RGBAFloat: OSType = as_u32_be(b"RGfA");
pub const kCVPixelFormatType_14Bayer_GRBG: OSType = as_u32_be(b"grb4");
pub const kCVPixelFormatType_14Bayer_RGGB: OSType = as_u32_be(b"rgg4");
pub const kCVPixelFormatType_14Bayer_BGGR: OSType = as_u32_be(b"bgg4");
pub const kCVPixelFormatType_14Bayer_GBRG: OSType = as_u32_be(b"gbr4");
pub const kCVPixelFormatType_DisparityFloat16: OSType = as_u32_be(b"hdis");
pub const kCVPixelFormatType_DisparityFloat32: OSType = as_u32_be(b"fdis");
pub const kCVPixelFormatType_DepthFloat16: OSType = as_u32_be(b"hdep");
pub const kCVPixelFormatType_DepthFloat32: OSType = as_u32_be(b"fdep");
pub const kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange: OSType = as_u32_be(b"x420");
pub const kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange: OSType = as_u32_be(b"x422");
pub const kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange: OSType = as_u32_be(b"x444");
pub const kCVPixelFormatType_420YpCbCr10BiPlanarFullRange: OSType = as_u32_be(b"xf20");
pub const kCVPixelFormatType_422YpCbCr10BiPlanarFullRange: OSType = as_u32_be(b"xf22");
pub const kCVPixelFormatType_444YpCbCr10BiPlanarFullRange: OSType = as_u32_be(b"xf44");
pub const kCVPixelBufferLock_ReadOnly: CVPixelBufferLockFlags = 1;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CVPlanarComponentInfo {
pub offset: int32_t,
pub rowBytes: uint32_t,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CVPlanarPixelBufferInfo {
pub componentInfo: [CVPlanarComponentInfo; 1],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CVPlanarPixelBufferInfo_YCbCrPlanar {
pub componentInfoY: CVPlanarComponentInfo,
pub componentInfoCb: CVPlanarComponentInfo,
pub componentInfoCr: CVPlanarComponentInfo,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CVPlanarPixelBufferInfo_YCbCrBiPlanar {
pub componentInfoY: CVPlanarComponentInfo,
pub componentInfoCbCr: CVPlanarComponentInfo,
}
pub type CVPixelBufferReleaseBytesCallback = extern "C" fn (releaseRefCon: *mut c_void,
baseAddress: *const *const c_void);
pub type CVPixelBufferReleasePlanarBytesCallback = extern "C" fn (releaseRefCon: *mut c_void,
dataPtr: *const *const c_void,
dataSize: size_t,
numberOfPlanes: size_t,
planeAddresses: *const *const c_void);
extern "C" {
pub static kCVPixelBufferPixelFormatTypeKey: CFStringRef;
pub static kCVPixelBufferMemoryAllocatorKey: CFStringRef;
pub static kCVPixelBufferWidthKey: CFStringRef;
pub static kCVPixelBufferHeightKey: CFStringRef;
pub static kCVPixelBufferExtendedPixelsLeftKey: CFStringRef;
pub static kCVPixelBufferExtendedPixelsTopKey: CFStringRef;
pub static kCVPixelBufferExtendedPixelsRightKey: CFStringRef;
pub static kCVPixelBufferExtendedPixelsBottomKey: CFStringRef;
pub static kCVPixelBufferBytesPerRowAlignmentKey: CFStringRef;
pub static kCVPixelBufferCGBitmapContextCompatibilityKey: CFStringRef;
pub static kCVPixelBufferCGImageCompatibilityKey: CFStringRef;
pub static kCVPixelBufferOpenGLCompatibilityKey: CFStringRef;
pub static kCVPixelBufferPlaneAlignmentKey: CFStringRef;
pub static kCVPixelBufferIOSurfacePropertiesKey: CFStringRef;
pub static kCVPixelBufferOpenGLESCompatibilityKey: CFStringRef;
pub static kCVPixelBufferMetalCompatibilityKey: CFStringRef;
pub static kCVPixelBufferOpenGLTextureCacheCompatibilityKey: CFStringRef;
pub static kCVPixelBufferOpenGLESTextureCacheCompatibilityKey: CFStringRef;
pub fn CVBufferGetTypeID() -> CFTypeID;
pub fn CVPixelBufferRetain(texture: CVPixelBufferRef) -> CVPixelBufferRef;
pub fn CVPixelBufferRelease(texture: CVPixelBufferRef);
pub fn CVPixelBufferCreateResolvedAttributesDictionary(allocator: CFAllocatorRef,
attributes: CFArrayRef,
resolvedDictionaryOut: *mut CFDictionaryRef) -> CVReturn;
pub fn CVPixelBufferCreate(
allocator: CFAllocatorRef,
width: size_t,
height: size_t,
pixelFormatType: OSType,
pixelBufferAttributes: CFDictionaryRef,
pixelBufferOut: *mut CVPixelBufferRef,
) -> CVReturn;
pub fn CVPixelBufferLockBaseAddress(pixelBuffer: CVPixelBufferRef,
lockFlags: CVOptionFlags) -> CVReturn;
pub fn CVPixelBufferUnlockBaseAddress(pixelBuffer: CVPixelBufferRef,
unlockFlags: CVOptionFlags) -> CVReturn;
pub fn CVPixelBufferGetWidth(pixelBuffer: CVPixelBufferRef) -> size_t;
pub fn CVPixelBufferGetHeight(pixelBuffer: CVPixelBufferRef) -> size_t;
pub fn CVPixelBufferGetPixelFormatType(pixelBuffer: CVPixelBufferRef) -> OSType;
pub fn CVPixelBufferGetBaseAddress(pixelBuffer: CVPixelBufferRef) -> *mut c_void;
pub fn CVPixelBufferGetBytesPerRow(pixelBuffer: CVPixelBufferRef) -> size_t;
pub fn CVPixelBufferIsPlanar(pixelBuffer: CVPixelBufferRef) -> Boolean;
pub fn CVPixelBufferGetPlaneCount(pixelBuffer: CVPixelBufferRef) -> size_t;
pub fn CVPixelBufferGetWidthOfPlane(pixelBuffer: CVPixelBufferRef,
planeIndex: size_t) -> size_t;
pub fn CVPixelBufferGetHeightOfPlane(pixelBuffer: CVPixelBufferRef,
planeIndex: size_t) -> size_t;
pub fn CVPixelBufferGetBaseAddressOfPlane(pixelBuffer: CVPixelBufferRef,
planeIndex: size_t) -> *mut c_void;
pub fn CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer: CVPixelBufferRef,
planeIndex: size_t) -> size_t;
pub fn CVPixelBufferGetExtendedPixels(pixelBuffer: CVPixelBufferRef,
extraColumnsOnLeft: *const size_t,
extraColumnsOnRight: *const size_t,
extraRowsOnTop: *const size_t,
extraRowsOnBottom: *const size_t);
pub fn CVPixelBufferFillExtendedPixels(pixelBuffer: CVPixelBufferRef) -> CVReturn;
}