1/* 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 12#include "libyuv/video_common.h" 13 14#ifdef __cplusplus 15namespace libyuv { 16extern "C" { 17#endif 18 19#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) 20 21struct FourCCAliasEntry { 22 uint32 alias; 23 uint32 canonical; 24}; 25 26static const struct FourCCAliasEntry kFourCCAliases[] = { 27 {FOURCC_IYUV, FOURCC_I420}, 28 {FOURCC_YU12, FOURCC_I420}, 29 {FOURCC_YU16, FOURCC_I422}, 30 {FOURCC_YU24, FOURCC_I444}, 31 {FOURCC_YUYV, FOURCC_YUY2}, 32 {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs 33 {FOURCC_HDYC, FOURCC_UYVY}, 34 {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 35 {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 36 {FOURCC_DMB1, FOURCC_MJPG}, 37 {FOURCC_BA81, FOURCC_BGGR}, // deprecated. 38 {FOURCC_RGB3, FOURCC_RAW }, 39 {FOURCC_BGR3, FOURCC_24BG}, 40 {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB 41 {FOURCC_CM24, FOURCC_RAW }, // kCMPixelFormat_24RGB 42 {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 43 {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 44 {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 45}; 46// TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. 47// {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA 48 49LIBYUV_API 50uint32 CanonicalFourCC(uint32 fourcc) { 51 int i; 52 for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { 53 if (kFourCCAliases[i].alias == fourcc) { 54 return kFourCCAliases[i].canonical; 55 } 56 } 57 // Not an alias, so return it as-is. 58 return fourcc; 59} 60 61#ifdef __cplusplus 62} // extern "C" 63} // namespace libyuv 64#endif 65 66