1 /* 2 * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 /* 12 * Common definitions for video, including fourcc and VideoFormat 13 */ 14 15 16 #ifndef LIBYUV_SOURCE_VIDEO_COMMON_H_ 17 #define LIBYUV_SOURCE_VIDEO_COMMON_H_ 18 19 #include <string> 20 21 #include "libyuv/basic_types.h" 22 23 namespace libyuv { 24 25 ////////////////////////////////////////////////////////////////////////////// 26 // Definition of fourcc. 27 ////////////////////////////////////////////////////////////////////////////// 28 // Convert four characters to a fourcc code. 29 // Needs to be a macro otherwise the OS X compiler complains when the kFormat* 30 // 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)) 34 35 // Some good pages discussing FourCC codes: 36 // http://developer.apple.com/quicktime/icefloe/dispatch020.html 37 // http://www.fourcc.org/yuv.php 38 enum FourCC { 39 // Canonical fourcc codes used in our code. 40 FOURCC_I420 = FOURCC('I', '4', '2', '0'), 41 FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'), 42 FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'), 43 FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'), 44 FOURCC_M420 = FOURCC('M', '4', '2', '0'), 45 FOURCC_24BG = FOURCC('2', '4', 'B', 'G'), 46 FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'), 47 FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'), 48 FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'), 49 FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), 50 FOURCC_RAW = FOURCC('r', 'a', 'w', ' '), 51 FOURCC_NV21 = FOURCC('N', 'V', '2', '1'), 52 FOURCC_NV12 = FOURCC('N', 'V', '1', '2'), 53 // Next four are Bayer RGB formats. The four characters define the order of 54 // the colours in each 2x2 pixel grid, going left-to-right and top-to-bottom. 55 FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'), 56 FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'), 57 FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'), 58 FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'), 59 60 // Aliases for canonical fourcc codes, replaced with their canonical 61 // equivalents by CanonicalFourCC(). 62 FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420 63 FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Alias for I420 64 FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2 65 FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac 66 FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY 67 FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY 68 FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG 69 FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR 70 FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW 71 FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG 72 73 // Match any fourcc. 74 FOURCC_ANY = 0xFFFFFFFF, 75 }; 76 77 // Converts fourcc aliases into canonical ones. 78 uint32 CanonicalFourCC(uint32 fourcc); 79 80 } // namespace libyuv 81 82 #endif // LIBYUV_SOURCE_VIDEO_COMMON_H_ 83