Note that there are some explanatory texts on larger screens.

plurals
  1. POCVOpenGLESTextureCacheCreateTextureFromImage on iPad2 is too slow ,it needs almost 30 ms, too crazy
    primarykey
    data
    text
    <p>I use opengl es to display bgr24 data on iPad, I am new about opengl es ,so in display video part I use code from RosyWriter one APPLE sample. It works, but the CVOpenGLESTextureCacheCreateTextureFromImage function cost more than 30ms, while in RosyWriter its cost is negligible. what I do is first transform BGR24 to BGRA pixel format, then use CVPixelBufferCreateWithBytes function create a CVPixelBufferRef, and then get a CVOpenGLESTextureRef by CVOpenGLESTextureCacheCreateTextureFromImage. My codes as following,</p> <pre><code>- (void)transformBGRToBGRA:(const UInt8 *)pict width:(int)width height:(int)height { rgb.data = (void *)pict; vImage_Error error = vImageConvert_RGB888toARGB8888(&amp;rgb,NULL,0,&amp;argb,NO,kvImageNoFlags); if (error != kvImageNoError) { NSLog(@"vImageConvert_RGB888toARGB8888 error"); } const uint8_t permuteMap[4] = {1,2,3,0}; error = vImagePermuteChannels_ARGB8888(&amp;argb,&amp;bgra,permuteMap,kvImageNoFlags); if (error != kvImageNoError) { NSLog(@"vImagePermuteChannels_ARGB8888 error"); } free((void *)pict); } </code></pre> <p>and after transform, will generate CVPixelBufferRef, codes as following,</p> <pre><code>[self transformBGRToBGRA:pict width:width height:height]; CVPixelBufferRef pixelBuffer; CVReturn err = CVPixelBufferCreateWithBytes(NULL, width, height, kCVPixelFormatType_32BGRA, (void*)bgraData, bytesByRow, NULL, 0, NULL, &amp;pixelBuffer); if(!pixelBuffer || err) { NSLog(@"CVPixelBufferCreateWithBytes failed (error: %d)", err); return; } CVOpenGLESTextureRef texture = NULL; err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, videoTextureCache, pixelBuffer, NULL, GL_TEXTURE_2D, GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0, &amp;texture); if (!texture || err) { NSLog(@"CVOpenGLESTextureCacheCreateTextureFromImage failed (error: %d)", err); CVPixelBufferRelease(pixelBuffer); return; } </code></pre> <p>The other codes is almost similar RosyWriter sample, include shaders. So I want to know why, how to fix this problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload