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