• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Introduction
2
3Formats (FOURCC) supported by libyuv are detailed here.
4
5# Core Formats
6
7There are 2 core formats supported by libyuv - I420 and ARGB.  All YUV formats can be converted to/from I420.  All RGB formats can be converted to/from ARGB.
8
9Filtering functions such as scaling and planar functions work on I420 and/or ARGB.
10
11# OSX Core Media Pixel Formats
12
13This is how OSX formats map to libyuv
14
15    enum {
16      kCMPixelFormat_32ARGB          = 32,      FOURCC_BGRA
17      kCMPixelFormat_32BGRA          = 'BGRA',  FOURCC_ARGB
18      kCMPixelFormat_24RGB           = 24,      FOURCC_RAW
19      kCMPixelFormat_16BE555         = 16,      Not supported.
20      kCMPixelFormat_16BE565         = 'B565',  Not supported.
21      kCMPixelFormat_16LE555         = 'L555',  FOURCC_RGBO
22      kCMPixelFormat_16LE565         = 'L565',  FOURCC_RGBP
23      kCMPixelFormat_16LE5551        = '5551',  FOURCC_RGBO
24      kCMPixelFormat_422YpCbCr8      = '2vuy',  FOURCC_UYVY
25      kCMPixelFormat_422YpCbCr8_yuvs = 'yuvs',  FOURCC_YUY2
26      kCMPixelFormat_444YpCbCr8      = 'v308',  FOURCC_I444 ?
27      kCMPixelFormat_4444YpCbCrA8    = 'v408',  Not supported.
28      kCMPixelFormat_422YpCbCr16     = 'v216',  Not supported.
29      kCMPixelFormat_422YpCbCr10     = 'v210',  FOURCC_V210 previously.  Removed now.
30      kCMPixelFormat_444YpCbCr10     = 'v410',  Not supported.
31      kCMPixelFormat_8IndexedGray_WhiteIsZero = 0x00000028,  Not supported.
32    };
33
34
35# FOURCC (Four Charactacter Code) List
36
37The following is extracted from video_common.h as a complete list of formats supported by libyuv.
38
39    enum FourCC {
40      // 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
41      FOURCC_I420 = FOURCC('I', '4', '2', '0'),
42      FOURCC_I422 = FOURCC('I', '4', '2', '2'),
43      FOURCC_I444 = FOURCC('I', '4', '4', '4'),
44      FOURCC_I411 = FOURCC('I', '4', '1', '1'),
45      FOURCC_I400 = FOURCC('I', '4', '0', '0'),
46      FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
47      FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
48      FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
49      FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
50
51      // 2 Secondary YUV formats: row biplanar.
52      FOURCC_M420 = FOURCC('M', '4', '2', '0'),
53      FOURCC_Q420 = FOURCC('Q', '4', '2', '0'),
54
55      // 9 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp.
56      FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
57      FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
58      FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
59      FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
60      FOURCC_RAW  = FOURCC('r', 'a', 'w', ' '),
61      FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
62      FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'),  // rgb565 LE.
63      FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'),  // argb1555 LE.
64      FOURCC_R444 = FOURCC('R', '4', '4', '4'),  // argb4444 LE.
65
66      // 4 Secondary RGB formats: 4 Bayer Patterns.
67      FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
68      FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'),
69      FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'),
70      FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'),
71
72      // 1 Primary Compressed YUV format.
73      FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
74
75      // 5 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
76      FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
77      FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
78      FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
79      FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'),  // Linux version of I420.
80      FOURCC_J420 = FOURCC('J', '4', '2', '0'),
81      FOURCC_J400 = FOURCC('J', '4', '0', '0'),
82
83      // 14 Auxiliary aliases.  CanonicalFourCC() maps these to canonical fourcc.
84      FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'),  // Alias for I420.
85      FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'),  // Alias for I422.
86      FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'),  // Alias for I444.
87      FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'),  // Alias for YUY2.
88      FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'),  // Alias for YUY2 on Mac.
89      FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'),  // Alias for UYVY.
90      FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'),  // Alias for UYVY on Mac.
91      FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'),  // Alias for MJPG.
92      FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'),  // Alias for MJPG on Mac.
93      FOURCC_BA81 = FOURCC('B', 'A', '8', '1'),  // Alias for BGGR.
94      FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'),  // Alias for RAW.
95      FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'),  // Alias for 24BG.
96      FOURCC_CM32 = FOURCC(0, 0, 0, 32),  // Alias for BGRA kCMPixelFormat_32ARGB
97      FOURCC_CM24 = FOURCC(0, 0, 0, 24),  // Alias for RAW kCMPixelFormat_24RGB
98      FOURCC_L555 = FOURCC('L', '5', '5', '5'),  // Alias for RGBO.
99      FOURCC_L565 = FOURCC('L', '5', '6', '5'),  // Alias for RGBP.
100      FOURCC_5551 = FOURCC('5', '5', '5', '1'),  // Alias for RGBO.
101
102      // 1 Auxiliary compressed YUV format set aside for capturer.
103      FOURCC_H264 = FOURCC('H', '2', '6', '4'),
104
105# The ARGB FOURCC
106
107There are 4 ARGB layouts - ARGB, BGRA, ABGR and RGBA.  ARGB is most common by far, used for screen formats, and windows webcam drivers.
108
109The fourcc describes the order of channels in a ***register***.
110
111A fourcc provided by capturer, can be thought of string, e.g. "ARGB".
112
113On little endian machines, as an int, this would have 'A' in the lowest byte.  The FOURCC macro reverses the order:
114
115    #define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24))
116
117So the "ARGB" string, read as an uint32, is
118
119    FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B')
120
121If you were to read ARGB pixels as uint32's, the alpha would be in the high byte, and the blue in the lowest byte.  In memory, these are stored little endian, so 'B' is first, then 'G', 'R' and 'A' last.
122
123When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB().
124
125All formats can be converted to/from ARGB.
126
127Most 'planar_functions' work on ARGB (e.g. ARGBBlend).
128
129Some are channel order agnostic (e.g. ARGBScale).
130
131Some functions are symmetric (e.g. ARGBToBGRA is the same as BGRAToARGB, so its a macro).
132
133ARGBBlend expects preattenuated ARGB. The R,G,B are premultiplied by alpha.  Other functions don't care.
134