Home | History | Annotate | Download | only in docs
      1 # Introduction
      2 
      3 Formats (FOURCC) supported by libyuv are detailed here.
      4 
      5 # Core Formats
      6 
      7 There 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 
      9 Filtering functions such as scaling and planar functions work on I420 and/or ARGB.
     10 
     11 # OSX Core Media Pixel Formats
     12 
     13 This 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 
     37 The following is extracted from video_common.h as a complete list of formats supported by libyuv.
     38 
     39     enum FourCC {
     40       // 8 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_I400 = FOURCC('I', '4', '0', '0'),
     45       FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
     46       FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
     47       FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
     48       FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
     49 
     50       // 1 Secondary YUV formats: row biplanar.
     51       FOURCC_M420 = FOURCC('M', '4', '2', '0'),
     52 
     53       // 9 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp.
     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_24BG = FOURCC('2', '4', 'B', 'G'),
     58       FOURCC_RAW  = FOURCC('r', 'a', 'w', ' '),
     59       FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
     60       FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'),  // rgb565 LE.
     61       FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'),  // argb1555 LE.
     62       FOURCC_R444 = FOURCC('R', '4', '4', '4'),  // argb4444 LE.
     63 
     64       // 4 Secondary RGB formats: 4 Bayer Patterns.
     65       FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
     66       FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'),
     67       FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'),
     68       FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'),
     69 
     70       // 1 Primary Compressed YUV format.
     71       FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
     72 
     73       // 5 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
     74       FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
     75       FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
     76       FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
     77       FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'),  // Linux version of I420.
     78       FOURCC_J420 = FOURCC('J', '4', '2', '0'),
     79       FOURCC_J400 = FOURCC('J', '4', '0', '0'),
     80 
     81       // 14 Auxiliary aliases.  CanonicalFourCC() maps these to canonical fourcc.
     82       FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'),  // Alias for I420.
     83       FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'),  // Alias for I422.
     84       FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'),  // Alias for I444.
     85       FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'),  // Alias for YUY2.
     86       FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'),  // Alias for YUY2 on Mac.
     87       FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'),  // Alias for UYVY.
     88       FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'),  // Alias for UYVY on Mac.
     89       FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'),  // Alias for MJPG.
     90       FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'),  // Alias for MJPG on Mac.
     91       FOURCC_BA81 = FOURCC('B', 'A', '8', '1'),  // Alias for BGGR.
     92       FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'),  // Alias for RAW.
     93       FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'),  // Alias for 24BG.
     94       FOURCC_CM32 = FOURCC(0, 0, 0, 32),  // Alias for BGRA kCMPixelFormat_32ARGB
     95       FOURCC_CM24 = FOURCC(0, 0, 0, 24),  // Alias for RAW kCMPixelFormat_24RGB
     96       FOURCC_L555 = FOURCC('L', '5', '5', '5'),  // Alias for RGBO.
     97       FOURCC_L565 = FOURCC('L', '5', '6', '5'),  // Alias for RGBP.
     98       FOURCC_5551 = FOURCC('5', '5', '5', '1'),  // Alias for RGBO.
     99 
    100       // 1 Auxiliary compressed YUV format set aside for capturer.
    101       FOURCC_H264 = FOURCC('H', '2', '6', '4'),
    102 
    103 # Planar YUV
    104       The following formats contains a full size Y plane followed by 1 or 2
    105         planes for UV: I420, I422, I444, I400, NV21, NV12, I400
    106       The size (subsampling) of the UV varies.
    107         I420, NV12 and NV21 are half width, half height
    108         I422, NV16 and NV61 are half width, full height
    109         I444, NV24 and NV42 are full width, full height
    110         I400 and J400 have no chroma channel.
    111 
    112 # The ARGB FOURCC
    113 
    114 There are 4 ARGB layouts - ARGB, BGRA, ABGR and RGBA.  ARGB is most common by far, used for screen formats, and windows webcam drivers.
    115 
    116 The fourcc describes the order of channels in a ***register***.
    117 
    118 A fourcc provided by capturer, can be thought of string, e.g. "ARGB".
    119 
    120 On little endian machines, as an int, this would have 'A' in the lowest byte.  The FOURCC macro reverses the order:
    121 
    122     #define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24))
    123 
    124 So the "ARGB" string, read as an uint32, is
    125 
    126     FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B')
    127 
    128 If 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.
    129 
    130 When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB().
    131 
    132 All formats can be converted to/from ARGB.
    133 
    134 Most 'planar_functions' work on ARGB (e.g. ARGBBlend).
    135 
    136 Some are channel order agnostic (e.g. ARGBScale).
    137 
    138 Some functions are symmetric (e.g. ARGBToBGRA is the same as BGRAToARGB, so its a macro).
    139 
    140 ARGBBlend expects preattenuated ARGB. The R,G,B are premultiplied by alpha.  Other functions don't care.
    141