相关疑难解决方法(0)

CVOpenGLESTextureCacheCreateTextureFromImage无法创建IOSurface

对于我目前的项目,我正在阅读iPhone的主摄像头输出.然后我通过以下方法将pixelbuffer转换为缓存的OpenGL纹理:CVOpenGLESTextureCacheCreateTextureFromImage.这在处理用于预览的相机帧时非常有用.使用iPhone 3GS,4,4S,iPod Touch(第4代)和IOS5,IOS6进行不同组合测试.

但是,对于具有非常高分辨率的实际最终图像,这仅适用于以下组合:

  • iPhone 3GS + IOS 5.1.1
  • iPhone 4 + IOS 5.1.1
  • iPhone 4S + IOS 6.0
  • iPod Touch(第4代)+ IOS 5.0

这不适用于:iPhone 4 + IOS6.

控制台中的确切错误消息:

Failed to create IOSurface image (texture)
2012-10-01 16:24:30.663 GLCameraRipple[676:907] Error at CVOpenGLESTextureCacheCreateTextureFromImage -6683
Run Code Online (Sandbox Code Playgroud)

我通过改变Apple的GLCameraRipple项目来解决这个问题.你可以在这里查看我的版本:http://lab.bitshiftcop.com/iosurface.zip

以下是我将stilloutput添加到当前会话的方法:

- (void)setupAVCapture
{
    //-- Create CVOpenGLESTextureCacheRef for optimal CVImageBufferRef to GLES texture conversion.
    CVReturn err = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, NULL, [EAGLContext currentContext], NULL, &_videoTextureCache);
    if (err) 
    {
        NSLog(@"Error at CVOpenGLESTextureCacheCreate %d", err);
        return;
    } …
Run Code Online (Sandbox Code Playgroud)

opengl-es ios

17
推荐指数
1
解决办法
4005
查看次数

C中最快的交错操作?

我有一个指针的字节数组mixed,包含两个不同的阵列的交错字节array1array2.说mixed看起来像这样:

a1b2c3d4...
Run Code Online (Sandbox Code Playgroud)

我需要做的是解交织字节,所以我得到array1 = abcd...array2 = 1234....我知道mixed提前的长度,长度array1array2等价,都等于mixed / 2.

这是我目前的执行(array1array2已经被分配):

int i, j;
int mixedLength_2 = mixedLength / 2;
for (i = 0, j = 0; i < mixedLength_2; i++, j += 2)
{
    array1[i] = mixed[j];
    array2[i] = mixed[j+1];
}
Run Code Online (Sandbox Code Playgroud)

这避免了任何昂贵的乘法或除法运算,但仍然运行得不够快.我希望有类似的东西memcpy需要一个可以使用低级块复制操作来加速该过程的索引器.是否有比我现有的更快的实施?

编辑

目标平台是针对iOS和Mac的Objective-C.对于iOS设备而言,快速操作更为重要,因此针对iOS的解决方案将比没有更好.

更新

感谢大家的回应,尤其是Stephen Canon,Graham Lee和Mecki.这是我的"主"功能,使用Stephen的NEON内在函数(如果可用)和Graham的联合游标,Mecki建议的迭代次数减少.

void interleave(const uint8_t *srcA, const uint8_t …
Run Code Online (Sandbox Code Playgroud)

c arrays performance extract memcpy

12
推荐指数
1
解决办法
5635
查看次数

从YUV创建CVPixelBuffer并支持IOSurface

所以我从网络回调(voip app)获得3个独立阵列中的原始YUV数据.根据我的理解,你不能CVPixelBufferCreateWithPlanarBytes根据这里创建IOSurface支持的像素缓冲区

重要提示:您不能将CVPixelBufferCreateWithBytes()或CVPixelBufferCreateWithPlanarBytes()与kCVPixelBufferIOSurfacePropertiesKey一起使用.调用CVPixelBufferCreateWithBytes()或CVPixelBufferCreateWithPlanarBytes()将导致CVPixelBuffers不是IOSurface支持的

因此,您必须创建它CVPixelBufferCreate,但是如何将数据从回调传输回CVPixelBufferRef您创建的?

- (void)videoCallBack(uint8_t *yPlane, uint8_t *uPlane, uint8_t *vPlane, size_t width, size_t height, size_t stride yStride,
                      size_t uStride, size_t vStride)
    NSDictionary *pixelAttributes = @{(id)kCVPixelBufferIOSurfacePropertiesKey : @{}};
    CVPixelBufferRef pixelBuffer = NULL;
    CVReturn result = CVPixelBufferCreate(kCFAllocatorDefault,
                                          width,
                                          height,
                                          kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
                                          (__bridge CFDictionaryRef)(pixelAttributes),
                                          &pixelBuffer);
Run Code Online (Sandbox Code Playgroud)

我不确定之后该做什么?最终我想把它变成一个CIImage,然后我可以使用我的GLKView来渲染视频.人们如何在创建数据时将数据"放入"缓冲区?

video opengl-es objective-c ios glkit

8
推荐指数
1
解决办法
6997
查看次数

标签 统计

ios ×2

opengl-es ×2

arrays ×1

c ×1

extract ×1

glkit ×1

memcpy ×1

objective-c ×1

performance ×1

video ×1