【发布时间】:2015-04-23 02:57:38
【问题描述】:
我正在实现一个裁剪视频帧的自定义视频合成器。目前我使用 Core Graphics 来做到这一点:
-(void)renderImage:(CGImageRef)image inBuffer:(CVPixelBufferRef)destination {
CGRect cropRect = // some rect ...
CGImageRef currentRectImage = CGImageCreateWithImageInRect(photoFullImage, cropRect);
size_t width = CVPixelBufferGetWidth(destination);
size_t height = CVPixelBufferGetHeight(destination);
CGContextRef context = CGBitmapContextCreate(CVPixelBufferGetBaseAddress(destination), // data
width,
height,
8, // bpp
CVPixelBufferGetBytesPerRow(destination),
CGImageGetColorSpace(backImage),
CGImageGetBitmapInfo(backImage));
CGRect frame = CGRectMake(0, 0, width, height);
CGContextDrawImage(context, frame, currentRectImage);
CGContextRelease(context);
}
如何使用 Metal API 来执行此操作?它应该快得多,对吧? 使用 Accelerate 框架(特别是 vImage)怎么样?那会更简单吗?
【问题讨论】:
标签: ios core-graphics accelerate-framework metal vimage