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