|
Q: What pixel formats does Core Video currently support, and is there an API that can be used to retrieve this information programatically?A: A Core Video Pixel Buffer (represented by the opaque type Individual pixel buffers can be created and managed using APIs such as At the time of this writing (Mac OS X 10.4.8 w/QuickTime 7.1.3), Core Video supports the pixel formats shown in Table 1. Note that new pixel formats may be added over time: Table 1: Core Video supported pixel formats.
Note: For information regarding the memory/file layout of pixel data defined by these pixel format types, see Ice Floe Dispatch 20 QuickTime Pixel Format FourCCs There are two APIs that can be used to dynamically retrieve all the pixel format OSTypes and Pixel Format Descriptions known to Core Video: Use CFArrayRef CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes(CFAllocatorRef allocator) Description: Returns a CFArrayRef containing a list of all supported pixel format types. allocator - The allocator used to allocate memory for the array and its storage for values. Pass kCFAllocatorDefault to specify the default allocator. Use CFDictionaryRef CVPixelFormatDescriptionCreateWithPixelFormatType(CFAllocatorRef allocator, OSType pixelFormat) Description: Returns a CFDictionaryRef containing the pixel format description for the passed in pixel format type. allocator - The allocator to use when creating the description. Pass kCFAllocatorDefault to specify the default allocator. pixelFormat - A four-character code that identifies the pixel format description you want to obtain. Notes: The returned Core Foundation dictionary contains the pixel format description. See “Pixel Format Description Keys” for more detailed information regarding the keys relevant to the format description. Pixel Format Description Dictionary Keys: kCVPixelFormatName - The name of the pixel format (type CFString). kCVPixelFormatConstant - The pixel format constant for QuickTime. kCVPixelFormatCodecType - The codec type (type CFString). For example, '2vuy' or k422YpCbCr8CodecType. kCVPixelFormatFourCC - The Microsoft FourCC equivalent code for this pixel format (type CFString). kCVPixelFormatPlanes - The number of image planes associated with this format (type CFNumber). kCVPixelFormatBlockWidth - The width, in pixels, of the smallest byte-addressable group of pixels (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatBlockHeight - The height, in pixels, of the smallest byte-addressable group of pixels (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatBitsPerBlock - The number of bits per block (type CFNumber). For simple pixel formats, this value is the same as the traditional bits-per-pixel value. This key is mandatory in pixel format descriptions. kCVPixelFormatBlockHorizontalAlignment - The horizontal alignment requirements of this format (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatBlockVerticalAlignment - The vertical alignment requirements of this format (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatHorizontalSubsampling - Horizontal subsampling information for this plane (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatVerticalSubsampling - Vertical subsampling information for this plane (type CFNumber). Assumed to be 1 if this key is not present. kCVPixelFormatOpenGLFormat - The OpenGL format used to describe this image plane (if applicable) (type CFNumber). See the OpenGL specification for possible values. kCVPixelFormatOpenGLType - The OpenGL type to describe this image plane (if applicable) (type CFNumber). See the OpenGL specification for possible values. kCVPixelFormatOpenGLInternalFormat - The OpenGL internal format for this pixel format (if applicable). (type CFNumber). See the OpenGL specification for possible values. kCVPixelFormatCGBitmapInfo - The Core Graphics bitmap information for this pixel format (if applicable). kCVPixelFormatQDCompatibility - Indicates whether this format is compatible with QuickDraw (type CFBoolean). kCVPixelFormatCGBitmapContextCompatibility - Indicates whether this format is compatible with Core Graphics bitmap contexts(type CFBoolean). kCVPixelFormatCGImageCompatibility - Indicates whether this format is compatible with the CGImage type (type CFBoolean). kCVPixelFormatOpenGLCompatibility - Indicates whether this format is compatible with OpenGL (type CFBoolean). kCVPixelFormatFillExtendedPixelsCallback - Specifies a custom extended pixel fill algorithm (type CFData). Listing 1 demonstrates how to retrieve a list of supported Core Video pixel format types with the output produced shown in Listing 2. Listing 1: Retrieving pixel format types known to Core Video. { CFArrayRef pixelFormatDescriptionsArray = NULL; CFIndex i; pixelFormatDescriptionsArray = CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes(kCFAllocatorDefault); printf("Core Video Supported Pixel Format Types:\n\n"); for (i = 0; i < CFArrayGetCount(pixelFormatDescriptionsArray); i++) { CFStringRef pixelFormat = NULL; CFNumberRef pixelFormatFourCC = (CFNumberRef)CFArrayGetValueAtIndex(pixelFormatDescriptionsArray, i); if (pixelFormatFourCC != NULL) { UInt32 value; CFNumberGetValue(pixelFormatFourCC, kCFNumberSInt32Type, &value); if (value <= 0x28) { pixelFormat = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("Core Video Pixel Format Type: %d\n"), value); } else { pixelFormat = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("Core Video Pixel Format Type (FourCC): %c%c%c%c\n"), (char)(value >> 24), (char)(value >> 16), (char)(value >> 8), (char)value); } CFShow(pixelFormat); CFRelease(pixelFormat); } } } Listing 2: Output produced by Listing 1. Core Video Pixel Format Type: 32 Core Video Pixel Format Type: 24 Core Video Pixel Format Type: 16 Core Video Pixel Format Type (FourCC): 2vuy Core Video Pixel Format Type (FourCC): yuvs Core Video Pixel Format Type (FourCC): r408 Core Video Pixel Format Type (FourCC): v408 Core Video Pixel Format Type (FourCC): BGRA Core Video Pixel Format Type (FourCC): b64a Core Video Pixel Format Type (FourCC): b48r Core Video Pixel Format Type (FourCC): b32a Core Video Pixel Format Type (FourCC): b16g Core Video Pixel Format Type (FourCC): v308 Core Video Pixel Format Type (FourCC): v216 Core Video Pixel Format Type (FourCC): v210 Core Video Pixel Format Type (FourCC): v410 Core Video Pixel Format Type (FourCC): r4fl Listing 3 shows an example of the Pixel Format Description dictionary values returned by calling Listing 3: Pixel Format Description values for k32ARGBPixelFormat. kCVPixelFormatConstant - 32 kCVPixelFormatBitsPerBlock - 32 kCVPixelFormatQDCompatibility - true kCVPixelFormatCGBitmapContextCompatibility - true kCVPixelFormatCGImageCompatibility - true kCVPixelFormatCGBitmapInfo - kCGImageAlphaFirst | kCGBitmapByteOrder32Big kCVPixelFormatFillExtendedPixelsCallback - Extended fill procedure for this pixel format Mac OS X: kCVPixelFormatOpenGLFormat - GL_BGRA kCVPixelFormatOpenGLInternalFormat - GL_RGBA8 PPC Based Mac (Big Endian): kCVPixelFormatOpenGLCompatibility - true kCVPixelFormatOpenGLType - GL_UNSIGNED_INT_8_8_8_8_REV Intel Based Mac (Little Endian): kCVPixelFormatOpenGLType - GL_UNSIGNED_INT_8_8_8_8 Listing 4: Pixel Format Description values for k422YpCbCr8PixelFormat. kCVPixelFormatConstant - k422YpCbCr8PixelFormat kCVPixelFormatBlockWidth - 2 kCVPixelFormatBitsPerBlock - 32 kCVPixelFormatFillExtendedPixelsCallback - Extended fill procedure for this pixel format Mac OS X: kCVPixelFormatOpenGLCompatibility - true kCVPixelFormatOpenGLFormat - GL_YCBCR_422_APPLE kCVPixelFormatOpenGLInternalFormat - GL_RGB PPC Based Mac (Big Endian): kCVPixelFormatOpenGLType - GL_UNSIGNED_SHORT_8_8_REV_APPLE Intel Based Mac (Little Endian): kCVPixelFormatOpenGLType - GL_UNSIGNED_SHORT_8_8_APPLE Windows (if Direct3D supports the format): kCVPixelFormatDirect3DCompatibility - true kCVPixelFormatDirect3DFormat - D3DFMT_UYVY kCVPixelFormatDirect3DType - D3DFMT_UYVY kCVPixelFormatDirect3DInternalFormat - D3DFMT_UYVY Note: Rendering to a Pixel Buffer Visual Context is currently not available in QuickTime for Windows. ReferencesDocument Revision History
Posted: 2007-01-23 |
|