一组用于处理核心视频类型的扩展和实用程序
核心视频工具
一组用于处理核心视频类型的扩展和实用程序。
CVPixelFormat
调试对象时,需要了解对象中使用的像素格式。要使用香草 API 执行此操作,您被迫找到一个数学值,因为如果基本上是一个数字。这个项目使用CVPixelFormat
enum istead的vanilla public vars,这更方便,你可以很容易地获得当前的像素格式。Core Video
OSType
OSType
OSType
description
let cvPixelFormat: CVPixelFormat = cvPixelBuffer.cvPixelFormatlet description = cvPixelFormat.description
迅捷的原料药
在vanilla CVPixelBuffer C风格的API上有很多Swift包装器:
香草原料药:
let width = CVPixelBufferGetWidth(cvPixelBuffer)let height = CVPixelBufferGetHeight(cvPixelBuffer)// ...let bytesPerElement = IOSurfaceGetBytesPerRow(ioSurface)let bytesPerRow = IOSurfaceGetBytesPerRow(ioSurface)
迅捷的API:
let width = cvPixelBuffer.widthlet height = cvPixelBuffer.height// ...let bytesPerElement = ioSurface.bytesPerElementlet bytesPerRow = ioSurface.bytesPerRow
CVReturn Result & CVError
Core Video 中有一些函数会返回一个代码,如果操作成功,这些代码会有所帮助。该项目旨在简化此错误检查。 结果
和 CVError
类型用于用可操作函数包装原版 API。CVReturn
香草原料药:
let returnCode = CVPixelBufferLockBaseAddress(cvPixelBuffer, lockFlags)guard returnCode == kCVReturnSuccess else { // handle the error ...
迅捷的API:
try cvPixelBuffer.lockBaseAddress(lockFlags: lockFlags)