2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
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.
11 // Common definitions for video, including fourcc and VideoFormat.
13 #ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_ // NOLINT
14 #define INCLUDE_LIBYUV_VIDEO_COMMON_H_
16 #include "libyuv/basic_types.h"
23 //////////////////////////////////////////////////////////////////////////////
24 // Definition of FourCC codes
25 //////////////////////////////////////////////////////////////////////////////
27 // Convert four characters to a FourCC code.
28 // Needs to be a macro otherwise the OS X compiler complains when the kFormat*
29 // constants are used in a switch.
31 #define FOURCC(a, b, c, d) ( \
32 (static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
33 (static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
35 #define FOURCC(a, b, c, d) ( \
36 ((uint32)(a)) | ((uint32)(b) << 8) | /* NOLINT */ \
37 ((uint32)(c) << 16) | ((uint32)(d) << 24)) /* NOLINT */
40 // Some pages discussing FourCC codes:
41 // http://www.fourcc.org/yuv.php
42 // http://v4l2spec.bytesex.org/spec/book1.htm
43 // http://developer.apple.com/quicktime/icefloe/dispatch020.html
44 // http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12
45 // http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt
47 // FourCC codes grouped according to implementation efficiency.
48 // Primary formats should convert in 1 efficient step.
49 // Secondary formats are converted in 2 steps.
50 // Auxilliary formats call primary converters.
52 // 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
53 FOURCC_I420 = FOURCC('I', '4', '2', '0'),
54 FOURCC_I422 = FOURCC('I', '4', '2', '2'),
55 FOURCC_I444 = FOURCC('I', '4', '4', '4'),
56 FOURCC_I411 = FOURCC('I', '4', '1', '1'),
57 FOURCC_I400 = FOURCC('I', '4', '0', '0'),
58 FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
59 FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
60 FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
61 FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
63 // 2 Secondary YUV formats: row biplanar.
64 FOURCC_M420 = FOURCC('M', '4', '2', '0'),
65 FOURCC_Q420 = FOURCC('Q', '4', '2', '0'),
67 // 9 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp.
68 FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
69 FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
70 FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
71 FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
72 FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
73 FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
74 FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
75 FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE.
76 FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE.
78 // 4 Secondary RGB formats: 4 Bayer Patterns.
79 FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
80 FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'),
81 FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'),
82 FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'),
84 // 1 Primary Compressed YUV format.
85 FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
87 // 5 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
88 FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
89 FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
90 FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
91 FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
92 FOURCC_J420 = FOURCC('J', '4', '2', '0'),
93 FOURCC_J400 = FOURCC('J', '4', '0', '0'),
95 // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
96 FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
97 FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422.
98 FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444.
99 FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2.
100 FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac.
101 FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY.
102 FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY on Mac.
103 FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG.
104 FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'), // Alias for MJPG on Mac.
105 FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR.
106 FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW.
107 FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG.
108 FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB
109 FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB
110 FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO.
111 FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP.
112 FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO.
114 // 1 Auxiliary compressed YUV format set aside for capturer.
115 FOURCC_H264 = FOURCC('H', '2', '6', '4'),
122 // Canonical fourcc codes used in our code.
123 FOURCC_BPP_I420 = 12,
124 FOURCC_BPP_I422 = 16,
125 FOURCC_BPP_I444 = 24,
126 FOURCC_BPP_I411 = 12,
128 FOURCC_BPP_NV21 = 12,
129 FOURCC_BPP_NV12 = 12,
130 FOURCC_BPP_YUY2 = 16,
131 FOURCC_BPP_UYVY = 16,
132 FOURCC_BPP_M420 = 12,
133 FOURCC_BPP_Q420 = 12,
134 FOURCC_BPP_ARGB = 32,
135 FOURCC_BPP_BGRA = 32,
136 FOURCC_BPP_ABGR = 32,
137 FOURCC_BPP_RGBA = 32,
138 FOURCC_BPP_24BG = 24,
140 FOURCC_BPP_RGBP = 16,
141 FOURCC_BPP_RGBO = 16,
142 FOURCC_BPP_R444 = 16,
147 FOURCC_BPP_YV12 = 12,
148 FOURCC_BPP_YV16 = 16,
149 FOURCC_BPP_YV24 = 24,
150 FOURCC_BPP_YU12 = 12,
151 FOURCC_BPP_J420 = 12,
153 FOURCC_BPP_MJPG = 0, // 0 means unknown.
155 FOURCC_BPP_IYUV = 12,
156 FOURCC_BPP_YU16 = 16,
157 FOURCC_BPP_YU24 = 24,
158 FOURCC_BPP_YUYV = 16,
159 FOURCC_BPP_YUVS = 16,
160 FOURCC_BPP_HDYC = 16,
161 FOURCC_BPP_2VUY = 16,
165 FOURCC_BPP_RGB3 = 24,
166 FOURCC_BPP_BGR3 = 24,
167 FOURCC_BPP_CM32 = 32,
168 FOURCC_BPP_CM24 = 24,
171 FOURCC_BPP_ANY = 0, // 0 means unknown.
174 // Converts fourcc aliases into canonical ones.
175 LIBYUV_API uint32 CanonicalFourCC(uint32 fourcc);
179 } // namespace libyuv
182 #endif // INCLUDE_LIBYUV_VIDEO_COMMON_H_ NOLINT