How to list all OpenGL ES compatible PixelBuffer formats

Is there a way to list all CVPixelBuffer formats for CVPixelBufferCreate() that will not generate -6683: kCVReturnPixelBufferNotOpenGLCompatible error -6683: kCVReturnPixelBufferNotOpenGLCompatible when used with CVOpenGLESTextureCacheCreateTextureFromImage() ?

This lists all supported CVPixelBuffer formats for CVPixelBufferCreate() , but does not guarantee that CVOpenGLESTextureCacheCreateTextureFromImage() will not return the error above, I assume that my desired list should be a subset of this.

0
ios core-video
Nov 26 '14 at 12:33
source share
2 answers

Based on the answer from Adi Shavit above , here is the full code snippet (Objective-C) that you can use to print all current OpenGL ES compatible pixel formats

 + (void)load { @autoreleasepool { printf("Core Video Supported Pixel Format Types:\n"); CFArrayRef pixelFormatDescriptionsArray = CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes(kCFAllocatorDefault); for (CFIndex i = 0; i < CFArrayGetCount(pixelFormatDescriptionsArray); i++) { CFNumberRef pixelFormatFourCC = (CFNumberRef)CFArrayGetValueAtIndex(pixelFormatDescriptionsArray, i); if (pixelFormatFourCC != NULL) { UInt32 value; CFNumberGetValue(pixelFormatFourCC, kCFNumberSInt32Type, &value); NSString * pixelFormat; if (value <= 0x28) { pixelFormat = [NSString stringWithFormat:@"Core Video Pixel Format Type 0x%02x", (unsigned int)value]; } else { pixelFormat = [NSString stringWithFormat:@"Core Video Pixel Format Type (FourCC) %c%c%c%c", (char)(value >> 24), (char)(value >> 16), (char)(value >> 8), (char)value]; } CFDictionaryRef desc = CVPixelFormatDescriptionCreateWithPixelFormatType(kCFAllocatorDefault, (OSType)value); CFBooleanRef OpenGLESCompatibility = (CFBooleanRef)CFDictionaryGetValue(desc, kCVPixelFormatOpenGLESCompatibility); printf("%s: Compatible with OpenGL ES: %s\n", pixelFormat.UTF8String, (OpenGLESCompatibility != nil && CFBooleanGetValue(OpenGLESCompatibility)) ? "YES" : "NO"); } } printf("End Core Video Supported Pixel Format Types.\n"); } } 

You can place this snippet anywhere in the Objective-C category or class to print which pixel format is compatible and which are not. For completeness, all pixel formats that are compatible with OpenGL ES with iOS 10.2.1 are presented here:

  • L565
  • 5551
  • L555
  • 2vuy
  • yuvs
  • yuvf
  • L008
  • L016
  • 2C08
  • 2C16
  • BGRA
  • 420v
  • 420f
  • 420e
  • 411v
  • 411f
  • 422v
  • 422f
  • 444v
  • 444f
  • L00h
  • L00f
  • 2C0h
  • 2C0f
  • RGhA
  • RGfA
+2
Feb 14 '17 at 11:45
source share

Answering a question ... after further study of this link.
The CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes() function provides all supported formats on a specific device (and OS). Once the fourCC value is found, as shown in the link , you can use CVPixelFormatDescriptionCreateWithPixelFormatType() to get a dictionary with various fields describing each format.

It looks something like this:

 UInt32 value; CFNumberGetValue(pixelFormatFourCC, kCFNumberSInt32Type, &value); auto desc = CVPixelFormatDescriptionCreateWithPixelFormatType(kCFAllocatorDefault, (OSType)value); auto OpenGLCompatibility = (CFBooleanRef)CFDictionaryGetValue(desc, kCVPixelFormatOpenGLCompatibility); auto OpenGLESCompatibility = (CFBooleanRef)CFDictionaryGetValue(desc, kCVPixelFormatOpenGLESCompatibility); 

If OpenGLESCompatibility true, then this format is compatible with OpenGL ES.

0
Nov 26 '14 at 15:02
source share



All Articles