rs / SDAVAssetExportSession

AVAssetExportSession drop-in replacement with customizable audio&video settings
MIT License
805 stars 212 forks source link

CVPixelBufferLockBaseAddress and CVPixelBufferUnlockBaseAddress should not be called. #32

Open marcvanolmen opened 9 years ago

marcvanolmen commented 9 years ago

hi,

I'm not sure why CVPixelBufferLockBaseAddress is called here:

CVPixelBufferLockBaseAddress(renderBuffer, 0); [self.delegate exportSession:self renderFrame:pixelBuffer withPresentationTime:lastSamplePresentationTime toBuffer:renderBuffer]; CVPixelBufferUnlockBaseAddress(renderBuffer, 0);

in our case we use the buffer only the GPU in that scenario there is no need to call, Apple doc has even an important warning against that. I feel it should not done by default by the library.

Here is the information from official apple doc:

https://developer.apple.com/library/prerelease/ios/documentation/QuartzCore/Reference/CVPixelBufferRef/index.html#//apple_ref/c/func/CVPixelBufferLockBaseAddress

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.

IMPORTANT

When accessing pixel data with the GPU, locking is not necessary and can impair performance.