Contents

CVPixelBufferLockBaseAddress(_:_:)

Locks the base address of the pixel buffer.

Declaration

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

Parameters

  • pixelBuffer:

    The pixel buffer whose base address you want to lock.

  • lockFlags:

    An option that indicates whether you modify the buffer’s data while you hold the lock. Pass Readonly to lock the buffer for reading only, or pass no flags to lock it for both reading and writing.

Return Value

A Core Video result code. See Core Video Constants 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 readOnly value in the lockFlags parameter when locking the buffer, you must also include it when unlocking the buffer. Using the flag asymmetrically results in undefined behavior.

See Also

Modifying Pixel Buffers