<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVPixelBufferLockBaseAddress(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "c:@F@CVPixelBufferLockBaseAddress"
  },
  "title" : "CVPixelBufferLockBaseAddress(_:_:)"
}
-->

# CVPixelBufferLockBaseAddress(_:_:)

Locks the base address of the pixel buffer.

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

## Parameters

`pixelBuffer`

The pixel buffer whose base address you want to lock.

`lockFlags`

Either [`readOnly`](/documentation/CoreVideo/CVPixelBufferLockFlags/readOnly) or `0`; see [`CVPixelBufferLockFlags`](/documentation/CoreVideo/CVPixelBufferLockFlags) for discussion.

## Return Value

A Core Video result code. See [Core Video Constants](/documentation/CoreVideo/core-video-constants) for possible values.

## Discussion

You must call the [`CVPixelBufferLockBaseAddress(_:_:)`](/documentation/CoreVideo/CVPixelBufferLockBaseAddress(_:_:)) function before accessing pixel data with the CPU, and call the [`CVPixelBufferUnlockBaseAddress(_:_:)`](/documentation/CoreVideo/CVPixelBufferUnlockBaseAddress(_:_:)) function afterward. If you include the [`readOnly`](/documentation/CoreVideo/CVPixelBufferLockFlags/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)