---
title: "CVPixelBufferLockBaseAddress(_:_:)"
framework: corevideo
role: symbol
role_heading: Function
path: "corevideo/cvpixelbufferlockbaseaddress(_:_:)"
---

# CVPixelBufferLockBaseAddress(_:_:)

Locks the base address of the pixel buffer.

## Declaration

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

## Parameters

- `pixelBuffer`: The pixel buffer whose base address you want to lock.
- `lockFlags`: Either doc://com.apple.corevideo/documentation/CoreVideo/CVPixelBufferLockFlags/readOnly or 0; see doc://com.apple.corevideo/documentation/CoreVideo/CVPixelBufferLockFlags for discussion.

## Return Value

Return Value A Core Video result code. See Core Video Constants for possible values.

## Discussion

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. important: When accessing pixel data with the GPU, locking is not necessary and can impair performance.

## See Also

### Modifying Pixel Buffers

- [CVPixelBufferFillExtendedPixels(_:)](corevideo/cvpixelbufferfillextendedpixels(_:).md)
- [CVPixelBufferUnlockBaseAddress(_:_:)](corevideo/cvpixelbufferunlockbaseaddress(_:_:).md)
