1/* 2 * Copyright (c) 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 "video_common.h" 13 14#include <sstream> 15 16namespace libyuv { 17 18#define ARRAY_SIZE(x) (static_cast<int>((sizeof(x)/sizeof(x[0])))) 19 20struct FourCCAliasEntry { 21 uint32 alias; 22 uint32 canonical; 23}; 24 25static const FourCCAliasEntry kFourCCAliases[] = { 26 {FOURCC_IYUV, FOURCC_I420}, 27 {FOURCC_YU12, FOURCC_I420}, 28 {FOURCC_YUYV, FOURCC_YUY2}, 29 {FOURCC_YUVS, FOURCC_YUY2}, 30 {FOURCC_HDYC, FOURCC_UYVY}, 31 {FOURCC_2VUY, FOURCC_UYVY}, 32 {FOURCC_BA81, FOURCC_BGGR}, 33 {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 34 {FOURCC_RGB3, FOURCC_RAW}, 35 {FOURCC_BGR3, FOURCC_24BG}, 36}; 37 38uint32 CanonicalFourCC(uint32 fourcc) { 39 for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { 40 if (kFourCCAliases[i].alias == fourcc) { 41 return kFourCCAliases[i].canonical; 42 } 43 } 44 // Not an alias, so return it as-is. 45 return fourcc; 46} 47 48} // namespace libyuv 49