Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With my research in these day, I find why <code>CVOpenGLESTextureCacheCreateTextureFromImage</code> cost much time, when the data is big, here is 3M, the <strong>allocation, copy and move operation</strong> which cost is considerable, especially Copy operation. Then with <strong>pixel buffer pool</strong> greatly improve performance of <code>CVOpenGLESTextureCacheCreateTextureFromImage</code> from 30ms to 5ms, the same level with glTexImage2D(). My solution as following:</p> <pre><code>NSMutableDictionary* attributes; attributes = [NSMutableDictionary dictionary]; [attributes setObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; [attributes setObject:[NSNumber numberWithInt:videoWidth] forKey: (NSString*)kCVPixelBufferWidthKey]; [attributes setObject:[NSNumber numberWithInt:videoHeight] forKey: (NSString*)kCVPixelBufferHeightKey]; CVPixelBufferPoolCreate(kCFAllocatorDefault, NULL, (CFDictionaryRef) attributes, &amp;bufferPool); CVPixelBufferPoolCreatePixelBuffer (NULL,bufferPool,&amp;pixelBuffer); CVPixelBufferLockBaseAddress(pixelBuffer,0); UInt8 * baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer); memcpy(baseAddress, bgraData, bytesByRow * videoHeight); CVPixelBufferUnlockBaseAddress(pixelBuffer,0); </code></pre> <p>with this new created <strong>pixelBuffer</strong> you can make it fast.</p> <p>Add following configures to <strong>attribtes</strong> can make its performance to the best, less than 1ms.</p> <pre><code> NSDictionary *IOSurfaceProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], @"IOSurfaceOpenGLESFBOCompatibility",[NSNumber numberWithBool:YES], @"IOSurfaceOpenGLESTextureCompatibility",nil]; [attributes setObject:IOSurfaceProperties forKey:(NSString*)kCVPixelBufferIOSurfacePropertiesKey]; </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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