Mac Developer Library

Developer

System Framework Reference CVPixelBuffer Reference

Options
Deployment Target:

On This Page
Language:

CVPixelBuffer Reference

A Core Video pixel buffer is an image buffer that holds pixels in main memory. Applications generating frames, compressing or decompressing video, or using Core Image can all make use of Core Video pixel buffers.

Functions

  • Creates a single pixel buffer for a given size and pixel format.

    Declaration

    Swift

    func CVPixelBufferCreate(_ allocator: CFAllocator!, _ width: UInt, _ height: UInt, _ pixelFormatType: OSType, _ pixelBufferAttributes: CFDictionary!, _ pixelBufferOut: UnsafeMutablePointer<Unmanaged<CVPixelBuffer>?>) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferCreate ( CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut );

    Parameters

    allocator

    The allocator to use to create the pixel buffer. Pass NULL to specify the default allocator.

    width

    Width of the pixel buffer, in pixels.

    height

    Height of the pixel buffer, in pixels.

    pixelFormatType

    The pixel format identified by its respective four-character code (type OSType).

    pixelBufferAttributes

    A dictionary with additional attributes for a pixel buffer. This parameter is optional. See Pixel Buffer Attribute Keys for more details.

    pixelBufferOut

    On output, the newly created pixel buffer. Ownership follows the The Create Rule.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    This function allocates the necessary memory based on the pixel dimensions, format, and extended pixels described in the pixel buffer’s attributes.

    Some of the parameters specified in this call override equivalent pixel buffer attributes. For example, if you define the kCVPixelBufferWidth and kCVPixelBufferHeight keys in the pixel buffer attributes parameter (pixelBufferAttributes), these values are overridden by the width and height parameters.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Resolves an array of CFDictionary objects describing various pixel buffer attributes into a single dictionary.

    Declaration

    Swift

    func CVPixelBufferCreateResolvedAttributesDictionary(_ allocator: CFAllocator!, _ attributes: CFArray!, _ resolvedDictionaryOut: UnsafeMutablePointer<Unmanaged<CFDictionary>?>) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferCreateResolvedAttributesDictionary ( CFAllocatorRef allocator, CFArrayRef attributes, CFDictionaryRef *resolvedDictionaryOut );

    Parameters

    allocator

    The allocator to use to create the pixel buffer. Pass NULL to specify the default allocator.

    attributes

    An array of Core Foundation dictionaries containing pixel buffer attribute key-value pairs.

    resolvedDictionaryOut

    On output, the consolidated dictionary. Ownership follows the The Create Rule.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    This call is useful when you need to resolve requirements between several potential clients of a buffer.

    If two or more dictionaries contain the same key but different values, this function adjusts values where possible so that the output dictionary contains a mutually compatible set of values. For example, if the attributes parameter contains dictionaries whose bytes-per-row attributes differ, the rowBytes value in the output dictionary is the least common multiple of the input values.

    Some mismatched attributes cannot be resolved. Calling this function results in an error if the widths, heights, pixel format allocators, or callbacks in the input dictionaries do not match.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Creates a pixel buffer for a given size and pixel format containing data specified by a memory location.

    Declaration

    Swift

    func CVPixelBufferCreateWithBytes(_ allocator: CFAllocator!, _ width: UInt, _ height: UInt, _ pixelFormatType: OSType, _ baseAddress: UnsafeMutablePointer<Void>, _ bytesPerRow: UInt, _ releaseCallback: CVPixelBufferReleaseBytesCallback, _ releaseRefCon: UnsafeMutablePointer<Void>, _ pixelBufferAttributes: CFDictionary!, _ pixelBufferOut: UnsafeMutablePointer<Unmanaged<CVPixelBuffer>?>) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferCreateWithBytes ( CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void *baseAddress, size_t bytesPerRow, CVPixelBufferReleaseBytesCallback releaseCallback, void *releaseRefCon, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut );

    Parameters

    allocator

    The allocator to use to create this buffer. Pass NULL to specify the default allocator.

    width

    The width of the pixel buffer, in pixels.

    height

    The height of the pixel buffer, in pixels.

    pixelFormatType

    The pixel format identified by its respective four character code (type OSType).

    baseAddress

    A pointer to the base address of the memory storing the pixels.

    bytesPerRow

    The row bytes of the pixel storage memory.

    releaseCallback

    The callback function to be called when the pixel buffer is destroyed. This callback allows the owner of the pixels to free the memory. See CVPixelBufferReleaseBytesCallback for more information.

    releaseRefCon

    The user data identifying the pixel buffer. This value is passed to your pixel buffer release callback.

    pixelBufferAttributes

    A Core Foundation dictionary with additional attributes for a a pixel buffer. This parameter is optional. See Pixel Buffer Attribute Keys for more details.

    pixelBufferOut

    On output, the newly created pixel buffer. Ownership follows the The Create Rule.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    Some of the parameters specified in this call override equivalent pixel buffer attributes. For example, if you define the kCVPixelBufferWidth and kCVPixelBufferHeight keys in the pixel buffer attributes parameter (pixelBufferAttributes), these values are overridden by the width and height parameters.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Creates a single pixel buffer in planar format for a given size and pixel format containing data specified by a memory location.

    Declaration

    Swift

    func CVPixelBufferCreateWithPlanarBytes(_ allocator: CFAllocator!, _ width: UInt, _ height: UInt, _ pixelFormatType: OSType, _ dataPtr: UnsafeMutablePointer<Void>, _ dataSize: UInt, _ numberOfPlanes: UInt, _ planeBaseAddress: UnsafeMutablePointer<UnsafeMutablePointer<Void>>, _ planeWidth: UnsafeMutablePointer<UInt>, _ planeHeight: UnsafeMutablePointer<UInt>, _ planeBytesPerRow: UnsafeMutablePointer<UInt>, _ releaseCallback: CVPixelBufferReleasePlanarBytesCallback, _ releaseRefCon: UnsafeMutablePointer<Void>, _ pixelBufferAttributes: CFDictionary!, _ pixelBufferOut: UnsafeMutablePointer<Unmanaged<CVPixelBuffer>?>) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferCreateWithPlanarBytes ( CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void *dataPtr, size_t dataSize, size_t numberOfPlanes, void *planeBaseAddress[], size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], CVPixelBufferReleasePlanarBytesCallback releaseCallback, void *releaseRefCon, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut );

    Parameters

    allocator

    The allocator to use to create this buffer. Pass NULL to specify the default allocator.

    width

    The width of the pixel buffer, in pixels.

    height

    The height of the pixel buffer, in pixels.

    pixelFormatType

    The pixel format identified by its respective four-character code (type OSType).

    dataPtr

    A pointer to a plane descriptor block if applicable, or NULL if it is not.

    dataSize

    The size of the memory if the planes are contiguous, or NULL if it is not.

    numberOfPlanes

    The number of planes.

    planeBaseAddress

    The array of base addresses for the planes.

    planeWidth

    The array of plane widths.

    planeHeight

    The array of plane heights.

    planeBytesPerRow

    The array of plane bytes-per-row values.

    releaseCallback

    The callback function that gets called when the pixel buffer is destroyed. This callback allows the owner of the pixels to free the memory. See CVPixelBufferReleaseBytesCallback for more information.

    releaseRefCon

    A pointer to user data identifying the pixel buffer. This value is passed to your pixel buffer release callback.

    pixelBufferAttributes

    A dictionary with additional attributes for a a pixel buffer. This parameter is optional. See Pixel Buffer Attribute Keys for more details.

    pixelBufferOut

    On output, the newly created pixel buffer. Ownership follows the The Create Rule.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    Some of the parameters specified in this call override equivalent pixel buffer attributes. For example, if you define the kCVPixelBufferWidth and kCVPixelBufferHeight keys in the pixel buffer attributes parameter (pixelBufferAttributes), these values are overridden by the width and height parameters.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Fills the extended pixels of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferFillExtendedPixels(_ pixelBuffer: CVPixelBuffer!) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferFillExtendedPixels ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose extended pixels you want to fill.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    This function replicates edge pixels to fill the entire extended region of the image.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the base address of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetBaseAddress(_ pixelBuffer: CVPixelBuffer!) -> UnsafeMutablePointer<Void>

    Objective-C

    void * CVPixelBufferGetBaseAddress ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose base address you want to obtain.

    Return Value

    The base address of the pixel buffer.

    Discussion

    The pointer returned by this function depends on the type of buffer and the conditions under which it was created.

    • For chunky buffers, returns a pointer to the pixel at (0,0) in the buffer.

    • For planar buffers, returns a pointer to a CVPlanarComponentInfo structure, or NULL if no such structure is present.

    Because this function returns NULL for some planar buffers, you should call CVPixelBufferGetBaseAddressOfPlane and CVPixelBufferGetBytesPerRowOfPlane to get information about a planar buffer.

    Retrieving the base address for a pixel buffer requires that the buffer base address be locked using the CVPixelBufferLockBaseAddress function.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the base address of the plane at the specified plane index.

    Declaration

    Swift

    func CVPixelBufferGetBaseAddressOfPlane(_ pixelBuffer: CVPixelBuffer!, _ planeIndex: UInt) -> UnsafeMutablePointer<Void>

    Objective-C

    void * CVPixelBufferGetBaseAddressOfPlane ( CVPixelBufferRef pixelBuffer, size_t planeIndex );

    Parameters

    pixelBuffer

    The pixel buffer containing the plane whose base address you want to obtain.

    planeIndex

    The index of the plane.

    Return Value

    The base address of the plane, or NULL for nonplanar pixel buffers.

    Discussion

    Retrieving the base address for a pixel buffer requires that the buffer base address be locked using the CVPixelBufferLockBaseAddress function.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the number of bytes per row of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetBytesPerRow(_ pixelBuffer: CVPixelBuffer!) -> UInt

    Objective-C

    size_t CVPixelBufferGetBytesPerRow ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose bytes-per-row value you want to obtain.

    Return Value

    The number of bytes per row of the image data. For planar buffers, this function returns a rowBytes value such that bytesPerRow * height covers the entire image, including all planes.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the number of bytes per row for a plane at the specified index in the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetBytesPerRowOfPlane(_ pixelBuffer: CVPixelBuffer!, _ planeIndex: UInt) -> UInt

    Objective-C

    size_t CVPixelBufferGetBytesPerRowOfPlane ( CVPixelBufferRef pixelBuffer, size_t planeIndex );

    Parameters

    pixelBuffer

    The pixel buffer containing the plane.

    planeIndex

    The index of the plane whose bytes-per-row value you want to obtain.

    Return Value

    The number of bytes per row for the plane, or NULL for nonplanar pixel buffers.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the data size for contiguous planes of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetDataSize(_ pixelBuffer: CVPixelBuffer!) -> UInt

    Objective-C

    size_t CVPixelBufferGetDataSize ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose data size you want to obtain.

    Return Value

    The size of the memory if the planes are contiguous, or NULL if it is not.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the amount of extended pixel padding in the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetExtendedPixels(_ pixelBuffer: CVPixelBuffer!, _ extraColumnsOnLeft: UnsafeMutablePointer<UInt>, _ extraColumnsOnRight: UnsafeMutablePointer<UInt>, _ extraRowsOnTop: UnsafeMutablePointer<UInt>, _ extraRowsOnBottom: UnsafeMutablePointer<UInt>)

    Objective-C

    void CVPixelBufferGetExtendedPixels ( CVPixelBufferRef pixelBuffer, size_t *extraColumnsOnLeft, size_t *extraColumnsOnRight, size_t *extraRowsOnTop, size_t *extraRowsOnBottom );

    Parameters

    pixelBuffer

    The pixel buffer whose extended pixel size you want to obtain.

    extraColumnsOnLeft

    On output, the pixel row padding to the left. Pass NULL if you do not want this information.

    extraColumnsOnRight

    On output, the pixel row padding to the right. Pass NULL if you do not want this information.

    extraRowsOnTop

    On output, the pixel row padding to the top. Pass NULL if you do not want this information.

    extraRowsOnBottom

    On output, the pixel row padding to the bottom. Pass NULL if you do not want this information.

    Discussion

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the height of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetHeight(_ pixelBuffer: CVPixelBuffer!) -> UInt

    Objective-C

    size_t CVPixelBufferGetHeight ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose height you want to obtain.

    Return Value

    The buffer height, in pixels.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the height of the plane at planeIndex in the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetHeightOfPlane(_ pixelBuffer: CVPixelBuffer!, _ planeIndex: UInt) -> UInt

    Objective-C

    size_t CVPixelBufferGetHeightOfPlane ( CVPixelBufferRef pixelBuffer, size_t planeIndex );

    Parameters

    pixelBuffer

    The pixel buffer whose plane height you want to obtain.

    planeIndex

    The index of the plane.

    Return Value

    The height of the buffer, in pixels, or 0 for nonplanar pixel buffers.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the pixel format type of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetPixelFormatType(_ pixelBuffer: CVPixelBuffer!) -> OSType

    Objective-C

    OSType CVPixelBufferGetPixelFormatType ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose format type you want to obtain.

    Return Value

    A four-character code OSType identifier for the pixel format.

    Discussion

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns number of planes of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetPlaneCount(_ pixelBuffer: CVPixelBuffer!) -> UInt

    Objective-C

    size_t CVPixelBufferGetPlaneCount ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose plane count you want to obtain.

    Return Value

    The number of planes. Returns 0 for nonplanar pixel buffers.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the Core Foundation type identifier of the pixel buffer type.

    Declaration

    Swift

    func CVPixelBufferGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CVPixelBufferGetTypeID ( void );

    Return Value

    The Core Foundation type identifier for this type.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the width of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetWidth(_ pixelBuffer: CVPixelBuffer!) -> UInt

    Objective-C

    size_t CVPixelBufferGetWidth ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer whose width you want to obtain.

    Return Value

    The width of the buffer, in pixels.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Returns the width of the plane at a given index in the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferGetWidthOfPlane(_ pixelBuffer: CVPixelBuffer!, _ planeIndex: UInt) -> UInt

    Objective-C

    size_t CVPixelBufferGetWidthOfPlane ( CVPixelBufferRef pixelBuffer, size_t planeIndex );

    Parameters

    pixelBuffer

    The pixel buffer whose plane width you want to obtain.

    planeIndex

    The plane index that contains the plane’s width value.

    Return Value

    The width of the plane, in pixels, or 0 for nonplanar pixel buffers.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Determines whether the pixel buffer is planar.

    Declaration

    Swift

    func CVPixelBufferIsPlanar(_ pixelBuffer: CVPixelBuffer!) -> Boolean

    Objective-C

    Boolean CVPixelBufferIsPlanar ( CVPixelBufferRef pixelBuffer );

    Parameters

    pixelBuffer

    The pixel buffer to check.

    Return Value

    true if the pixel buffer is planar; otherwise, false.

    Discussion

    Planar buffers can be created using the CVPixelBufferCreateWithPlanarBytes function.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Locks the base address of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferLockBaseAddress(_ pixelBuffer: CVPixelBuffer!, _ lockFlags: CVOptionFlags) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferLockBaseAddress ( CVPixelBufferRef pixelBuffer, CVOptionFlags lockFlags );

    Parameters

    pixelBuffer

    The pixel buffer whose base address you want to lock.

    lockFlags

    Either kCVPixelBufferLock_ReadOnly or 0; see Pixel Buffer Locking Flags for discussion.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    You must call the CVPixelBufferLockBaseAddress function before accessing pixel data with the CPU, and call the CVPixelBufferUnlockBaseAddress function afterward. If you include the kCVPixelBufferLock_ReadOnly value in the lockFlags parameter when locking the buffer, you must also include it when unlocking the buffer.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

  • Releases a pixel buffer.

    Declaration

    Objective-C

    void CVPixelBufferRelease ( CVPixelBufferRef texture );

    Parameters

    buffer

    The pixel buffer that you want to release.

    Discussion

    This function is equivalent to CFRelease, but is NULL safe.

    Import Statement

    Objective-C

    @import CoreVideo;

    Availability

    Available in OS X v10.4 and later.

  • Retains a pixel buffer.

    Declaration

    Objective-C

    CVPixelBufferRef CVPixelBufferRetain ( CVPixelBufferRef texture );

    Parameters

    buffer

    The pixel buffer that you want to retain.

    Return Value

    For convenience, the same pixel buffer you want to retain.

    Discussion

    This function is equivalent to CFRetain, but is NULL safe.

    Import Statement

    Objective-C

    @import CoreVideo;

    Availability

    Available in OS X v10.4 and later.

  • Unlocks the base address of the pixel buffer.

    Declaration

    Swift

    func CVPixelBufferUnlockBaseAddress(_ pixelBuffer: CVPixelBuffer!, _ unlockFlags: CVOptionFlags) -> CVReturn

    Objective-C

    CVReturn CVPixelBufferUnlockBaseAddress ( CVPixelBufferRef pixelBuffer, CVOptionFlags unlockFlags );

    Parameters

    pixelBuffer

    The pixel buffer whose base address you want to unlock.

    unlockFlags

    Either kCVPixelBufferLock_ReadOnly or 0; see Pixel Buffer Locking Flags for discussion.

    Return Value

    A Core Video result code. See Core Video Constants Reference for possible values.

    Discussion

    You must call the CVPixelBufferLockBaseAddress function before accessing pixel data with the CPU, and call the CVPixelBufferUnlockBaseAddress function afterward. If you include the kCVPixelBufferLock_ReadOnly value in the lockFlags parameter when locking the buffer, you must also include it when unlocking the buffer.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.4 and later.

Callbacks

  • Defines a pointer to a pixel buffer release callback function, which is called when a pixel buffer created by CVPixelBufferCreateWithBytes is released.

    Declaration

    Swift

    typealias CVPixelBufferReleaseBytesCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafePointer<Void>) -> Void)>

    Objective-C

    typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress );

    Parameters

    releaseRefCon

    A pointer to application-defined data. This pointer is the same as that passed in the releaseRefCon parameter of CVPixelBufferCreateWithBytes.

    baseAddress

    A pointer to the base address of the memory holding the pixels. This pointer is the same as that passed in the baseAddress parameter of CVPixelBufferCreateWithBytes.

    Discussion

    You use this callback to release the pixels and perform any other cleanup when a pixel buffer is released.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.3 and later.

  • Defines a pointer to a pixel buffer release callback function, which is called when a pixel buffer created by CVPixelBufferCreateWithPlanarBytes is released.

    Declaration

    Swift

    typealias CVPixelBufferReleasePlanarBytesCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafePointer<Void>, UInt, UInt, UnsafeMutablePointer<UnsafePointer<Void>>) -> Void)>

    Objective-C

    typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] );

    Parameters

    releaseRefCon

    A pointer to application-defined data. This pointer is the same as that passed in the releaseRefCon parameter of CVPixelBufferCreateWithPlanarBytes.

    dataPtr

    A pointer to a plane descriptor block. This is the same pointer you passed to CVPixelBufferCreateWithPlanarBytes in the dataPtr parameter.

    dataSize

    The size value you passed to CVPixelBufferCreateWithPlanarBytes in the dataSize parameter.

    numberOfPlanes

    The number of planes value you passed to CVPixelBufferCreateWithPlanarBytes in the numberOfPlanes parameter.

    planeAddresses

    A pointer to the base plane address you passed to CVPixelBufferCreateWithPlanarBytes in the basePlaneAddress parameter.

    Discussion

    You use this callback to release the pixels and perform any other cleanup when a pixel buffer is released.

    Import Statement

    Objective-C

    @import CoreVideo;

    Swift

    import CoreVideo

    Availability

    Available in OS X v10.3 and later.

Data Types

Constants

  • The attributes associated with a pixel buffer.

    Declaration

    Swift

    let kCVPixelBufferPixelFormatTypeKey: CFString! let kCVPixelBufferMemoryAllocatorKey: CFString! let kCVPixelBufferWidthKey: CFString! let kCVPixelBufferHeightKey: CFString! let kCVPixelBufferExtendedPixelsLeftKey: CFString! let kCVPixelBufferExtendedPixelsTopKey: CFString! let kCVPixelBufferExtendedPixelsRightKey: CFString! let kCVPixelBufferExtendedPixelsBottomKey: CFString! let kCVPixelBufferBytesPerRowAlignmentKey: CFString! let kCVPixelBufferCGBitmapContextCompatibilityKey: CFString! let kCVPixelBufferCGImageCompatibilityKey: CFString! let kCVPixelBufferOpenGLCompatibilityKey: CFString! let kCVPixelBufferPlaneAlignmentKey: CFString! let kCVPixelBufferIOSurfacePropertiesKey: CFString!

    Objective-C

    const CFStringRef kCVPixelBufferPixelFormatTypeKey; const CFStringRef kCVPixelBufferMemoryAllocatorKey; const CFStringRef kCVPixelBufferWidthKey; const CFStringRef kCVPixelBufferHeightKey; const CFStringRef kCVPixelBufferExtendedPixelsLeftKey; const CFStringRef kCVPixelBufferExtendedPixelsTopKey; const CFStringRef kCVPixelBufferExtendedPixelsRightKey; const CFStringRef kCVPixelBufferExtendedPixelsBottomKey; const CFStringRef kCVPixelBufferBytesPerRowAlignmentKey; const CFStringRef kCVPixelBufferCGBitmapContextCompatibilityKey; const CFStringRef kCVPixelBufferCGImageCompatibilityKey; const CFStringRef kCVPixelBufferOpenGLCompatibilityKey; const CFStringRef kCVPixelBufferPlaneAlignmentKey; const CFStringRef kCVPixelBufferIOSurfacePropertiesKey;

    Constants

    • kCVPixelBufferPixelFormatTypeKey

      kCVPixelBufferPixelFormatTypeKey

      One or more pixel format types used for this buffer. The value for this key may be a single CFNumber value or an array (CFArray) containing multiple CFNumber values.

      For a list of common pixel formats, see Pixel Format Types.

      Available in OS X v10.4 and later.

    • kCVPixelBufferMemoryAllocatorKey

      kCVPixelBufferMemoryAllocatorKey

      The allocator used with this buffer (type CFAllocatorRef).

      Available in OS X v10.4 and later.

    • kCVPixelBufferWidthKey

      kCVPixelBufferWidthKey

      The width of the pixel buffer (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferHeightKey

      kCVPixelBufferHeightKey

      The height of the pixel buffer (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferExtendedPixelsLeftKey

      kCVPixelBufferExtendedPixelsLeftKey

      The number of pixels padding the left of the image (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferExtendedPixelsTopKey

      kCVPixelBufferExtendedPixelsTopKey

      The number of pixels padding the top of the image (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferExtendedPixelsRightKey

      kCVPixelBufferExtendedPixelsRightKey

      The number of pixels padding the right of the image (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferExtendedPixelsBottomKey

      kCVPixelBufferExtendedPixelsBottomKey

      The number of pixels padding the bottom of the image (type CFNumber).

      Available in OS X v10.4 and later.

    • kCVPixelBufferBytesPerRowAlignmentKey

      kCVPixelBufferBytesPerRowAlignmentKey

      A number that specifies the alignment of number of bytes per row in the pixel buffer(type CFNumber).

      The pixel buffer’s number of bytes per row must be a multiple of this number.

      Available in OS X v10.4 and later.

    • kCVPixelBufferCGBitmapContextCompatibilityKey

      kCVPixelBufferCGBitmapContextCompatibilityKey

      A Boolean value that indicates whether the pixel buffer is compatible with Core Graphics bitmap contexts (type CFBoolean).

      Available in OS X v10.4 and later.

    • kCVPixelBufferCGImageCompatibilityKey

      kCVPixelBufferCGImageCompatibilityKey

      A Boolean value that indicates whether the pixel buffer is compatible with CGImage types (type CFBoolean).

      Available in OS X v10.4 and later.

    • kCVPixelBufferOpenGLCompatibilityKey

      kCVPixelBufferOpenGLCompatibilityKey

      A Boolean value that indicates whether the pixel buffer is compatible with OpenGL contexts (type CFBoolean).

      Available in OS X v10.4 and later.

    • kCVPixelBufferPlaneAlignmentKey

      kCVPixelBufferPlaneAlignmentKey

      A number that specifies the alignment of the planes in the pixel buffer (type CFNumber).

      Planes start on a byte number which is a multiple of this value.

      Available in OS X v10.6 and later.

    • kCVPixelBufferIOSurfacePropertiesKey

      kCVPixelBufferIOSurfacePropertiesKey

      A dictionary containing optional properties for use by the IOSurface framework (type CFDictionary).

      Provide a value for this key if you want Core Video to use the IOSurface framework to allocate the pixel buffer. (See IOSurface Framework Reference.) Provide an empty dictionary to use default IOSurface options.

      Available in OS X v10.6 and later.

    Discussion

    A pixel buffer attributes dictionary is a Core Foundation dictionary containing zero or more of these keys and appropriate values. Core Video functions such as CVPixelBufferCreate and CVPixelBufferPoolCreate accept pixel buffer attributes dictionaries to describe how to allocate pixel buffers for compatibility with client requirements. Where multiple CoreVideo clients seek to exchange pixel buffers, CVPixelBufferCreateResolvedAttributesDictionary can be used to find a common pixel buffer attributes dictionary that is compatible with all the clients' pixel buffer attributes dictionaries.