1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libyuv/source/video_common.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* 1.5 + * Copyright 2011 The LibYuv Project Authors. All rights reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 + 1.15 +#include "libyuv/video_common.h" 1.16 + 1.17 +#ifdef __cplusplus 1.18 +namespace libyuv { 1.19 +extern "C" { 1.20 +#endif 1.21 + 1.22 +#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) 1.23 + 1.24 +struct FourCCAliasEntry { 1.25 + uint32 alias; 1.26 + uint32 canonical; 1.27 +}; 1.28 + 1.29 +static const struct FourCCAliasEntry kFourCCAliases[] = { 1.30 + {FOURCC_IYUV, FOURCC_I420}, 1.31 + {FOURCC_YU16, FOURCC_I422}, 1.32 + {FOURCC_YU24, FOURCC_I444}, 1.33 + {FOURCC_YUYV, FOURCC_YUY2}, 1.34 + {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs 1.35 + {FOURCC_HDYC, FOURCC_UYVY}, 1.36 + {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 1.37 + {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 1.38 + {FOURCC_DMB1, FOURCC_MJPG}, 1.39 + {FOURCC_BA81, FOURCC_BGGR}, 1.40 + {FOURCC_RGB3, FOURCC_RAW }, 1.41 + {FOURCC_BGR3, FOURCC_24BG}, 1.42 + {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB 1.43 + {FOURCC_CM24, FOURCC_RAW }, // kCMPixelFormat_24RGB 1.44 + {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 1.45 + {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 1.46 + {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 1.47 +}; 1.48 +// TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. 1.49 +// {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA 1.50 + 1.51 +LIBYUV_API 1.52 +uint32 CanonicalFourCC(uint32 fourcc) { 1.53 + int i; 1.54 + for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { 1.55 + if (kFourCCAliases[i].alias == fourcc) { 1.56 + return kFourCCAliases[i].canonical; 1.57 + } 1.58 + } 1.59 + // Not an alias, so return it as-is. 1.60 + return fourcc; 1.61 +} 1.62 + 1.63 +#ifdef __cplusplus 1.64 +} // extern "C" 1.65 +} // namespace libyuv 1.66 +#endif 1.67 +