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. 8 All YUV formats can be converted to/from I420. 9 All RGB formats can be converted to/from ARGB. 10 11Filtering functions such as scaling and planar functions work on I420 and/or ARGB. 12 13# OSX Core Media Pixel Formats 14 15This is how OSX formats map to libyuv 16 17 enum { 18 kCMPixelFormat_32ARGB = 32, FOURCC_BGRA 19 kCMPixelFormat_32BGRA = 'BGRA', FOURCC_ARGB 20 kCMPixelFormat_24RGB = 24, FOURCC_RAW 21 kCMPixelFormat_16BE555 = 16, Not supported. 22 kCMPixelFormat_16BE565 = 'B565', Not supported. 23 kCMPixelFormat_16LE555 = 'L555', FOURCC_RGBO 24 kCMPixelFormat_16LE565 = 'L565', FOURCC_RGBP 25 kCMPixelFormat_16LE5551 = '5551', FOURCC_RGBO 26 kCMPixelFormat_422YpCbCr8 = '2vuy', FOURCC_UYVY 27 kCMPixelFormat_422YpCbCr8_yuvs = 'yuvs', FOURCC_YUY2 28 kCMPixelFormat_444YpCbCr8 = 'v308', FOURCC_I444 ? 29 kCMPixelFormat_4444YpCbCrA8 = 'v408', Not supported. 30 kCMPixelFormat_422YpCbCr16 = 'v216', Not supported. 31 kCMPixelFormat_422YpCbCr10 = 'v210', FOURCC_V210 previously. Removed now. 32 kCMPixelFormat_444YpCbCr10 = 'v410', Not supported. 33 kCMPixelFormat_8IndexedGray_WhiteIsZero = 0x00000028, Not supported. 34 }; 35 36 37# FOURCC (Four Charactacter Code) List 38 39The following is extracted from video_common.h as a complete list of formats supported by libyuv. 40 enum FourCC { 41 // 10 Primary YUV formats: 5 planar, 2 biplanar, 2 packed. 42 FOURCC_I420 = FOURCC('I', '4', '2', '0'), 43 FOURCC_I422 = FOURCC('I', '4', '2', '2'), 44 FOURCC_I444 = FOURCC('I', '4', '4', '4'), 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 FOURCC_H010 = FOURCC('H', '0', '1', '0'), // unofficial fourcc. 10 bit lsb 51 FOURCC_U010 = FOURCC('U', '0', '1', '0'), // bt.2020, unofficial fourcc. 52 // 10 bit lsb 53 54 // 1 Secondary YUV format: row biplanar. 55 FOURCC_M420 = FOURCC('M', '4', '2', '0'), // deprecated. 56 57 // 13 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc, 2 64 bpp 58 FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'), 59 FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'), 60 FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'), 61 FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010. 62 FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit 63 FOURCC_AR64 = FOURCC('A', 'R', '6', '4'), // 16 bit per channel. 64 FOURCC_AB64 = FOURCC('A', 'B', '6', '4'), // ABGR version of 16 bit 65 FOURCC_24BG = FOURCC('2', '4', 'B', 'G'), 66 FOURCC_RAW = FOURCC('r', 'a', 'w', ' '), 67 FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'), 68 FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE. 69 FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE. 70 FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE. 71 72 // 1 Primary Compressed YUV format. 73 FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), 74 75 // 11 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'), // unofficial fourcc 82 FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc 83 FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc 84 FOURCC_U420 = FOURCC('U', '4', '2', '0'), // bt.2020, unofficial fourcc 85 FOURCC_U422 = FOURCC('U', '4', '2', '2'), // bt.2020, unofficial fourcc 86 FOURCC_U444 = FOURCC('U', '4', '4', '4'), // bt.2020, unofficial fourcc 87 88 // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc. 89 FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420. 90 FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422. 91 FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444. 92 FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2. 93 FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac. 94 FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY. 95 FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY on Mac. 96 FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG. 97 FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'), // Alias for MJPG on Mac. 98 FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR. 99 FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW. 100 FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG. 101 FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB 102 FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB 103 FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO. 104 FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP. 105 FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO. 106 107# Planar YUV 108 The following formats contains a full size Y plane followed by 1 or 2 109 planes for UV: I420, I422, I444, I400, NV21, NV12, I400 110 The size (subsampling) of the UV varies. 111 I420, NV12 and NV21 are half width, half height 112 I422, NV16 and NV61 are half width, full height 113 I444, NV24 and NV42 are full width, full height 114 I400 and J400 have no chroma channel. 115 116# Color space 117 The YUV formats start with a letter to specify the color space. e.g. I420 118 I = BT.601 limited range 119 J = BT.601 full range (J = JPEG that uses this) 120 H = BT.709 limited range (H for HD) 121 F = BT.709 full range (F for Full range) 122 U = BT.2020 limited range (U for UHD) 123 V = BT.2020 full range 124 For YUV to RGB conversions, a matrix can be passed. See also convert_argh.h 125 126# HDR formats 127 Planar formats with 10 or 12 bits use the following fourcc: 128 I010, I012, P010, P012 are half width, half height 129 I210, I212, P210, P212 are half width, full height 130 I410, I412, P410, P412 are full width, full height 131 where 132 I is the color space (see above) and 3 planes: Y, U and V. 133 P is a biplanar format, similar to NV12 but 16 bits, with the valid bits in the high bits. There is a Y plane and a UV plane. 134 0, 2 or 4 is the last digit of subsampling: 4:2:0, 4:2:2, or 4:4:4 135 10 or 12 is the bits per channel. The bits are in the low bits of a 16 bit channel. 136 137# The ARGB FOURCC 138 139There are 4 ARGB layouts - ARGB, BGRA, ABGR and RGBA. ARGB is most common by far, used for screen formats, and windows webcam drivers. 140 141The fourcc describes the order of channels in a ***register***. 142 143A fourcc provided by capturer, can be thought of string, e.g. "ARGB". 144 145On little endian machines, as an int, this would have 'A' in the lowest byte. The FOURCC macro reverses the order: 146 147 #define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24)) 148 149So the "ARGB" string, read as an uint32, is 150 151 FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B') 152 153If 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. 154 155When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB(). 156 157All formats can be converted to/from ARGB. 158 159Most 'planar_functions' work on ARGB (e.g. ARGBBlend). 160 161Some are channel order agnostic (e.g. ARGBScale). 162 163Some functions are symmetric (e.g. ARGBToBGRA is the same as BGRAToARGB, so its a macro). 164 165ARGBBlend expects preattenuated ARGB. The R,G,B are premultiplied by alpha. Other functions don't care. 166 167# RGB24 and RAW 168 169There are 2 RGB layouts - RGB24 (aka 24BG) and RAW 170 171RGB24 is B,G,R in memory 172RAW is R,G,B in memory 173 174# AR30 and XR30 175 176AR30 is 2 10 10 10 ARGB stored in little endian order. 177The 2 bit alpha has 4 values. Here are the comparable 8 bit alpha values. 1780 - 0. 00000000b = 0x00 = 0 1791 - 33%. 01010101b = 0x55 = 85 1802 - 66%. 10101010b = 0xaa = 170 1813 - 100%. 11111111b = 0xff = 255 182The 10 bit RGB values range from 0 to 1023. 183XR30 is the same as AR30 but with no alpha channel. 184 185# AB64 and AR64 186 187AB64 is similar to ABGR, with 16 bit (2 bytes) per channel. Each channel stores an unsigned short. 188In memory R is the lowest and A is the highest. 189Each channel has value ranges from 0 to 65535. 190AR64 is similar to ARGB. 191 192# NV12 and NV21 193 194NV12 is a biplanar format with a full sized Y plane followed by a single 195chroma plane with weaved U and V values. 196NV21 is the same but with weaved V and U values. 197The 12 in NV12 refers to 12 bits per pixel. NV12 has a half width and half 198height chroma channel, and therefore is a 420 subsampling. 199NV16 is 16 bits per pixel, with half width and full height. aka 422. 200NV24 is 24 bits per pixel with full sized chroma channel. aka 444. 201Most NV12 functions allow the destination Y pointer to be NULL. 202 203# YUY2 and UYVY 204 205YUY2 is a packed YUV format with half width, full height. 206 207YUY2 is YUYV in memory 208UYVY is UYVY in memory 209