• 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    enum FourCC {
39      // 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
40      FOURCC_I420 = FOURCC('I', '4', '2', '0'),
41      FOURCC_I422 = FOURCC('I', '4', '2', '2'),
42      FOURCC_I444 = FOURCC('I', '4', '4', '4'),
43      FOURCC_I400 = FOURCC('I', '4', '0', '0'),
44      FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
45      FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
46      FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
47      FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
48      FOURCC_H010 = FOURCC('H', '0', '1', '0'),  // unofficial fourcc. 10 bit lsb
49
50      // 1 Secondary YUV format: row biplanar.
51      FOURCC_M420 = FOURCC('M', '4', '2', '0'),
52
53      // 11 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc
54      FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
55      FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
56      FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
57      FOURCC_AR30 = FOURCC('A', 'R', '3', '0'),  // 10 bit per channel. 2101010.
58      FOURCC_AB30 = FOURCC('A', 'B', '3', '0'),  // ABGR version of 10 bit
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      // 1 Primary Compressed YUV format.
67      FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
68
69      // 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
70      FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
71      FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
72      FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
73      FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'),  // Linux version of I420.
74      FOURCC_J420 = FOURCC('J', '4', '2', '0'),
75      FOURCC_J400 = FOURCC('J', '4', '0', '0'),  // unofficial fourcc
76      FOURCC_H420 = FOURCC('H', '4', '2', '0'),  // unofficial fourcc
77      FOURCC_H422 = FOURCC('H', '4', '2', '2'),  // unofficial fourcc
78
79      // 14 Auxiliary aliases.  CanonicalFourCC() maps these to canonical fourcc.
80      FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'),  // Alias for I420.
81      FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'),  // Alias for I422.
82      FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'),  // Alias for I444.
83      FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'),  // Alias for YUY2.
84      FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'),  // Alias for YUY2 on Mac.
85      FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'),  // Alias for UYVY.
86      FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'),  // Alias for UYVY on Mac.
87      FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'),  // Alias for MJPG.
88      FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'),  // Alias for MJPG on Mac.
89      FOURCC_BA81 = FOURCC('B', 'A', '8', '1'),  // Alias for BGGR.
90      FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'),  // Alias for RAW.
91      FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'),  // Alias for 24BG.
92      FOURCC_CM32 = FOURCC(0, 0, 0, 32),  // Alias for BGRA kCMPixelFormat_32ARGB
93      FOURCC_CM24 = FOURCC(0, 0, 0, 24),  // Alias for RAW kCMPixelFormat_24RGB
94      FOURCC_L555 = FOURCC('L', '5', '5', '5'),  // Alias for RGBO.
95      FOURCC_L565 = FOURCC('L', '5', '6', '5'),  // Alias for RGBP.
96      FOURCC_5551 = FOURCC('5', '5', '5', '1'),  // Alias for RGBO.
97
98# Planar YUV
99      The following formats contains a full size Y plane followed by 1 or 2
100        planes for UV: I420, I422, I444, I400, NV21, NV12, I400
101      The size (subsampling) of the UV varies.
102        I420, NV12 and NV21 are half width, half height
103        I422, NV16 and NV61 are half width, full height
104        I444, NV24 and NV42 are full width, full height
105        I400 and J400 have no chroma channel.
106
107# The ARGB FOURCC
108
109There are 4 ARGB layouts - ARGB, BGRA, ABGR and RGBA.  ARGB is most common by far, used for screen formats, and windows webcam drivers.
110
111The fourcc describes the order of channels in a ***register***.
112
113A fourcc provided by capturer, can be thought of string, e.g. "ARGB".
114
115On little endian machines, as an int, this would have 'A' in the lowest byte.  The FOURCC macro reverses the order:
116
117    #define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24))
118
119So the "ARGB" string, read as an uint32, is
120
121    FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B')
122
123If 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.
124
125When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB().
126
127All formats can be converted to/from ARGB.
128
129Most 'planar_functions' work on ARGB (e.g. ARGBBlend).
130
131Some are channel order agnostic (e.g. ARGBScale).
132
133Some functions are symmetric (e.g. ARGBToBGRA is the same as BGRAToARGB, so its a macro).
134
135ARGBBlend expects preattenuated ARGB. The R,G,B are premultiplied by alpha.  Other functions don't care.
136
137# RGB24 and RAW
138
139There are 2 RGB layouts - RGB24 (aka 24BG) and RAW
140
141RGB24 is B,G,R in memory
142RAW is R,G,B in memory
143
144# AR30 and XR30
145
146AR30 is 2 10 10 10 ARGB stored in little endian order.
147The 2 bit alpha has 4 values.  Here are the comparable 8 bit alpha values.
1480 - 0.    00000000b = 0x00 = 0
1491 - 33%.  01010101b = 0x55 = 85
1502 - 66%.  10101010b = 0xaa = 170
1513 - 100%. 11111111b = 0xff = 255
152The 10 bit RGB values range from 0 to 1023.
153XR30 is the same as AR30 but with no alpha channel.
154
155# NV12 and NV21
156
157NV12 is a biplanar format with a full sized Y plane followed by a single
158chroma plane with weaved U and V values.
159NV21 is the same but with weaved V and U values.
160The 12 in NV12 refers to 12 bits per pixel.  NV12 has a half width and half
161height chroma channel, and therefore is a 420 subsampling.
162NV16 is 16 bits per pixel, with half width and full height.  aka 422.
163NV24 is 24 bits per pixel with full sized chroma channel. aka 444.
164