1 /* 2 * Copyright 2012 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 #ifndef INCLUDE_LIBYUV_CONVERT_ARGB_H_ // NOLINT 12 #define INCLUDE_LIBYUV_CONVERT_ARGB_H_ 13 14 #include "libyuv/basic_types.h" 15 // TODO(fbarchard): Remove the following headers includes 16 #include "libyuv/convert_from.h" 17 #include "libyuv/planar_functions.h" 18 #include "libyuv/rotate.h" 19 20 // TODO(fbarchard): This set of functions should exactly match convert.h 21 // Add missing Q420. 22 // TODO(fbarchard): Add tests. Create random content of right size and convert 23 // with C vs Opt and or to I420 and compare. 24 // TODO(fbarchard): Some of these functions lack parameter setting. 25 26 #ifdef __cplusplus 27 namespace libyuv { 28 extern "C" { 29 #endif 30 31 // Alias. 32 #define ARGBToARGB ARGBCopy 33 34 // Copy ARGB to ARGB. 35 LIBYUV_API 36 int ARGBCopy(const uint8* src_argb, int src_stride_argb, 37 uint8* dst_argb, int dst_stride_argb, 38 int width, int height); 39 40 // Convert I420 to ARGB. 41 LIBYUV_API 42 int I420ToARGB(const uint8* src_y, int src_stride_y, 43 const uint8* src_u, int src_stride_u, 44 const uint8* src_v, int src_stride_v, 45 uint8* dst_argb, int dst_stride_argb, 46 int width, int height); 47 48 // Convert I422 to ARGB. 49 LIBYUV_API 50 int I422ToARGB(const uint8* src_y, int src_stride_y, 51 const uint8* src_u, int src_stride_u, 52 const uint8* src_v, int src_stride_v, 53 uint8* dst_argb, int dst_stride_argb, 54 int width, int height); 55 56 // Convert I444 to ARGB. 57 LIBYUV_API 58 int I444ToARGB(const uint8* src_y, int src_stride_y, 59 const uint8* src_u, int src_stride_u, 60 const uint8* src_v, int src_stride_v, 61 uint8* dst_argb, int dst_stride_argb, 62 int width, int height); 63 64 // Convert I411 to ARGB. 65 LIBYUV_API 66 int I411ToARGB(const uint8* src_y, int src_stride_y, 67 const uint8* src_u, int src_stride_u, 68 const uint8* src_v, int src_stride_v, 69 uint8* dst_argb, int dst_stride_argb, 70 int width, int height); 71 72 // Convert I400 (grey) to ARGB. 73 LIBYUV_API 74 int I400ToARGB(const uint8* src_y, int src_stride_y, 75 uint8* dst_argb, int dst_stride_argb, 76 int width, int height); 77 78 // Alias. 79 #define YToARGB I400ToARGB_Reference 80 81 // Convert I400 to ARGB. Reverse of ARGBToI400. 82 LIBYUV_API 83 int I400ToARGB_Reference(const uint8* src_y, int src_stride_y, 84 uint8* dst_argb, int dst_stride_argb, 85 int width, int height); 86 87 // Convert NV12 to ARGB. 88 LIBYUV_API 89 int NV12ToARGB(const uint8* src_y, int src_stride_y, 90 const uint8* src_uv, int src_stride_uv, 91 uint8* dst_argb, int dst_stride_argb, 92 int width, int height); 93 94 // Convert NV21 to ARGB. 95 LIBYUV_API 96 int NV21ToARGB(const uint8* src_y, int src_stride_y, 97 const uint8* src_vu, int src_stride_vu, 98 uint8* dst_argb, int dst_stride_argb, 99 int width, int height); 100 101 // Convert M420 to ARGB. 102 LIBYUV_API 103 int M420ToARGB(const uint8* src_m420, int src_stride_m420, 104 uint8* dst_argb, int dst_stride_argb, 105 int width, int height); 106 107 // TODO(fbarchard): Convert Q420 to ARGB. 108 // LIBYUV_API 109 // int Q420ToARGB(const uint8* src_y, int src_stride_y, 110 // const uint8* src_yuy2, int src_stride_yuy2, 111 // uint8* dst_argb, int dst_stride_argb, 112 // int width, int height); 113 114 // Convert YUY2 to ARGB. 115 LIBYUV_API 116 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, 117 uint8* dst_argb, int dst_stride_argb, 118 int width, int height); 119 120 // Convert UYVY to ARGB. 121 LIBYUV_API 122 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy, 123 uint8* dst_argb, int dst_stride_argb, 124 int width, int height); 125 126 // BGRA little endian (argb in memory) to ARGB. 127 LIBYUV_API 128 int BGRAToARGB(const uint8* src_frame, int src_stride_frame, 129 uint8* dst_argb, int dst_stride_argb, 130 int width, int height); 131 132 // ABGR little endian (rgba in memory) to ARGB. 133 LIBYUV_API 134 int ABGRToARGB(const uint8* src_frame, int src_stride_frame, 135 uint8* dst_argb, int dst_stride_argb, 136 int width, int height); 137 138 // RGBA little endian (abgr in memory) to ARGB. 139 LIBYUV_API 140 int RGBAToARGB(const uint8* src_frame, int src_stride_frame, 141 uint8* dst_argb, int dst_stride_argb, 142 int width, int height); 143 144 // Deprecated function name. 145 #define BG24ToARGB RGB24ToARGB 146 147 // RGB little endian (bgr in memory) to ARGB. 148 LIBYUV_API 149 int RGB24ToARGB(const uint8* src_frame, int src_stride_frame, 150 uint8* dst_argb, int dst_stride_argb, 151 int width, int height); 152 153 // RGB big endian (rgb in memory) to ARGB. 154 LIBYUV_API 155 int RAWToARGB(const uint8* src_frame, int src_stride_frame, 156 uint8* dst_argb, int dst_stride_argb, 157 int width, int height); 158 159 // RGB16 (RGBP fourcc) little endian to ARGB. 160 LIBYUV_API 161 int RGB565ToARGB(const uint8* src_frame, int src_stride_frame, 162 uint8* dst_argb, int dst_stride_argb, 163 int width, int height); 164 165 // RGB15 (RGBO fourcc) little endian to ARGB. 166 LIBYUV_API 167 int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame, 168 uint8* dst_argb, int dst_stride_argb, 169 int width, int height); 170 171 // RGB12 (R444 fourcc) little endian to ARGB. 172 LIBYUV_API 173 int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame, 174 uint8* dst_argb, int dst_stride_argb, 175 int width, int height); 176 177 #ifdef HAVE_JPEG 178 // src_width/height provided by capture 179 // dst_width/height for clipping determine final size. 180 LIBYUV_API 181 int MJPGToARGB(const uint8* sample, size_t sample_size, 182 uint8* dst_argb, int dst_stride_argb, 183 int src_width, int src_height, 184 int dst_width, int dst_height); 185 #endif 186 187 // Note Bayer formats (BGGR) to ARGB are in format_conversion.h. 188 189 // Convert camera sample to ARGB with cropping, rotation and vertical flip. 190 // "src_size" is needed to parse MJPG. 191 // "dst_stride_argb" number of bytes in a row of the dst_argb plane. 192 // Normally this would be the same as dst_width, with recommended alignment 193 // to 16 bytes for better efficiency. 194 // If rotation of 90 or 270 is used, stride is affected. The caller should 195 // allocate the I420 buffer according to rotation. 196 // "dst_stride_u" number of bytes in a row of the dst_u plane. 197 // Normally this would be the same as (dst_width + 1) / 2, with 198 // recommended alignment to 16 bytes for better efficiency. 199 // If rotation of 90 or 270 is used, stride is affected. 200 // "crop_x" and "crop_y" are starting position for cropping. 201 // To center, crop_x = (src_width - dst_width) / 2 202 // crop_y = (src_height - dst_height) / 2 203 // "src_width" / "src_height" is size of src_frame in pixels. 204 // "src_height" can be negative indicating a vertically flipped image source. 205 // "crop_width" / "crop_height" is the size to crop the src to. 206 // Must be less than or equal to src_width/src_height 207 // Cropping parameters are pre-rotation. 208 // "rotation" can be 0, 90, 180 or 270. 209 // "format" is a fourcc. ie 'I420', 'YUY2' 210 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 211 LIBYUV_API 212 int ConvertToARGB(const uint8* src_frame, size_t src_size, 213 uint8* dst_argb, int dst_stride_argb, 214 int crop_x, int crop_y, 215 int src_width, int src_height, 216 int crop_width, int crop_height, 217 enum RotationMode rotation, 218 uint32 format); 219 220 #ifdef __cplusplus 221 } // extern "C" 222 } // namespace libyuv 223 #endif 224 225 #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT 226