diff options
author | Riza Sulistyo <riza@teluu.com> | 2016-06-28 06:04:19 +0000 |
---|---|---|
committer | Riza Sulistyo <riza@teluu.com> | 2016-06-28 06:04:19 +0000 |
commit | c2b4b93619393241204ced09a16caf5f9c5f97b1 (patch) | |
tree | 3c2f2bef0dc7642dee6895e3e1c1ce94496902ef /third_party/yuv/source/video_common.cc | |
parent | a0021d168c110589e37fb8ef1bc7589b239ba8d6 (diff) |
Re #1937: Change project and folder name for consistency with existing third party library.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5358 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/yuv/source/video_common.cc')
-rw-r--r-- | third_party/yuv/source/video_common.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/third_party/yuv/source/video_common.cc b/third_party/yuv/source/video_common.cc new file mode 100644 index 00000000..00fb71e1 --- /dev/null +++ b/third_party/yuv/source/video_common.cc @@ -0,0 +1,65 @@ +/* + * Copyright 2011 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#include "libyuv/video_common.h" + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) + +struct FourCCAliasEntry { + uint32 alias; + uint32 canonical; +}; + +static const struct FourCCAliasEntry kFourCCAliases[] = { + {FOURCC_IYUV, FOURCC_I420}, + {FOURCC_YU12, FOURCC_I420}, + {FOURCC_YU16, FOURCC_I422}, + {FOURCC_YU24, FOURCC_I444}, + {FOURCC_YUYV, FOURCC_YUY2}, + {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs + {FOURCC_HDYC, FOURCC_UYVY}, + {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 + {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. + {FOURCC_DMB1, FOURCC_MJPG}, + {FOURCC_BA81, FOURCC_BGGR}, // deprecated. + {FOURCC_RGB3, FOURCC_RAW }, + {FOURCC_BGR3, FOURCC_24BG}, + {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB + {FOURCC_CM24, FOURCC_RAW }, // kCMPixelFormat_24RGB + {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 + {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 + {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 +}; +// TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. +// {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA + +LIBYUV_API +uint32 CanonicalFourCC(uint32 fourcc) { + int i; + for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { + if (kFourCCAliases[i].alias == fourcc) { + return kFourCCAliases[i].canonical; + } + } + // Not an alias, so return it as-is. + return fourcc; +} + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif + |