michael@0: /* michael@0: * Copyright 2011 The LibYuv Project Authors. All rights reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include "libyuv/video_common.h" michael@0: michael@0: #ifdef __cplusplus michael@0: namespace libyuv { michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) michael@0: michael@0: struct FourCCAliasEntry { michael@0: uint32 alias; michael@0: uint32 canonical; michael@0: }; michael@0: michael@0: static const struct FourCCAliasEntry kFourCCAliases[] = { michael@0: {FOURCC_IYUV, FOURCC_I420}, michael@0: {FOURCC_YU16, FOURCC_I422}, michael@0: {FOURCC_YU24, FOURCC_I444}, michael@0: {FOURCC_YUYV, FOURCC_YUY2}, michael@0: {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs michael@0: {FOURCC_HDYC, FOURCC_UYVY}, michael@0: {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 michael@0: {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. michael@0: {FOURCC_DMB1, FOURCC_MJPG}, michael@0: {FOURCC_BA81, FOURCC_BGGR}, michael@0: {FOURCC_RGB3, FOURCC_RAW }, michael@0: {FOURCC_BGR3, FOURCC_24BG}, michael@0: {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB michael@0: {FOURCC_CM24, FOURCC_RAW }, // kCMPixelFormat_24RGB michael@0: {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 michael@0: {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 michael@0: {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 michael@0: }; michael@0: // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. michael@0: // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA michael@0: michael@0: LIBYUV_API michael@0: uint32 CanonicalFourCC(uint32 fourcc) { michael@0: int i; michael@0: for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { michael@0: if (kFourCCAliases[i].alias == fourcc) { michael@0: return kFourCCAliases[i].canonical; michael@0: } michael@0: } michael@0: // Not an alias, so return it as-is. michael@0: return fourcc; michael@0: } michael@0: michael@0: #ifdef __cplusplus michael@0: } // extern "C" michael@0: } // namespace libyuv michael@0: #endif michael@0: