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 16 #include "libyuv/rotate.h" // For enum RotationMode. 17 18 // TODO(fbarchard): This set of functions should exactly match convert.h 19 // TODO(fbarchard): Add tests. Create random content of right size and convert 20 // with C vs Opt and or to I420 and compare. 21 // TODO(fbarchard): Some of these functions lack parameter setting. 22 23 #ifdef __cplusplus 24 namespace libyuv { 25 extern "C" { 26 #endif 27 28 // Alias. 29 #define ARGBToARGB ARGBCopy 30 31 // Copy ARGB to ARGB. 32 LIBYUV_API 33 int ARGBCopy(const uint8* src_argb, int src_stride_argb, 34 uint8* dst_argb, int dst_stride_argb, 35 int width, int height); 36 37 // Convert I420 to ARGB. 38 LIBYUV_API 39 int I420ToARGB(const uint8* src_y, int src_stride_y, 40 const uint8* src_u, int src_stride_u, 41 const uint8* src_v, int src_stride_v, 42 uint8* dst_argb, int dst_stride_argb, 43 int width, int height); 44 45 // Duplicate prototype for function in convert_from.h for remoting. 46 LIBYUV_API 47 int I420ToABGR(const uint8* src_y, int src_stride_y, 48 const uint8* src_u, int src_stride_u, 49 const uint8* src_v, int src_stride_v, 50 uint8* dst_argb, int dst_stride_argb, 51 int width, int height); 52 53 // Convert I422 to ARGB. 54 LIBYUV_API 55 int I422ToARGB(const uint8* src_y, int src_stride_y, 56 const uint8* src_u, int src_stride_u, 57 const uint8* src_v, int src_stride_v, 58 uint8* dst_argb, int dst_stride_argb, 59 int width, int height); 60 61 // Convert I444 to ARGB. 62 LIBYUV_API 63 int I444ToARGB(const uint8* src_y, int src_stride_y, 64 const uint8* src_u, int src_stride_u, 65 const uint8* src_v, int src_stride_v, 66 uint8* dst_argb, int dst_stride_argb, 67 int width, int height); 68 69 // Convert J444 to ARGB. 70 LIBYUV_API 71 int J444ToARGB(const uint8* src_y, int src_stride_y, 72 const uint8* src_u, int src_stride_u, 73 const uint8* src_v, int src_stride_v, 74 uint8* dst_argb, int dst_stride_argb, 75 int width, int height); 76 77 // Convert I444 to ABGR. 78 LIBYUV_API 79 int I444ToABGR(const uint8* src_y, int src_stride_y, 80 const uint8* src_u, int src_stride_u, 81 const uint8* src_v, int src_stride_v, 82 uint8* dst_abgr, int dst_stride_abgr, 83 int width, int height); 84 85 // Convert I411 to ARGB. 86 LIBYUV_API 87 int I411ToARGB(const uint8* src_y, int src_stride_y, 88 const uint8* src_u, int src_stride_u, 89 const uint8* src_v, int src_stride_v, 90 uint8* dst_argb, int dst_stride_argb, 91 int width, int height); 92 93 // Convert I420 with Alpha to preattenuated ARGB. 94 LIBYUV_API 95 int I420AlphaToARGB(const uint8* src_y, int src_stride_y, 96 const uint8* src_u, int src_stride_u, 97 const uint8* src_v, int src_stride_v, 98 const uint8* src_a, int src_stride_a, 99 uint8* dst_argb, int dst_stride_argb, 100 int width, int height, int attenuate); 101 102 // Convert I420 with Alpha to preattenuated ABGR. 103 LIBYUV_API 104 int I420AlphaToABGR(const uint8* src_y, int src_stride_y, 105 const uint8* src_u, int src_stride_u, 106 const uint8* src_v, int src_stride_v, 107 const uint8* src_a, int src_stride_a, 108 uint8* dst_abgr, int dst_stride_abgr, 109 int width, int height, int attenuate); 110 111 // Convert I400 (grey) to ARGB. Reverse of ARGBToI400. 112 LIBYUV_API 113 int I400ToARGB(const uint8* src_y, int src_stride_y, 114 uint8* dst_argb, int dst_stride_argb, 115 int width, int height); 116 117 // Convert J400 (jpeg grey) to ARGB. 118 LIBYUV_API 119 int J400ToARGB(const uint8* src_y, int src_stride_y, 120 uint8* dst_argb, int dst_stride_argb, 121 int width, int height); 122 123 // Alias. 124 #define YToARGB I400ToARGB 125 126 // Convert NV12 to ARGB. 127 LIBYUV_API 128 int NV12ToARGB(const uint8* src_y, int src_stride_y, 129 const uint8* src_uv, int src_stride_uv, 130 uint8* dst_argb, int dst_stride_argb, 131 int width, int height); 132 133 // Convert NV21 to ARGB. 134 LIBYUV_API 135 int NV21ToARGB(const uint8* src_y, int src_stride_y, 136 const uint8* src_vu, int src_stride_vu, 137 uint8* dst_argb, int dst_stride_argb, 138 int width, int height); 139 140 // Convert M420 to ARGB. 141 LIBYUV_API 142 int M420ToARGB(const uint8* src_m420, int src_stride_m420, 143 uint8* dst_argb, int dst_stride_argb, 144 int width, int height); 145 146 // Convert YUY2 to ARGB. 147 LIBYUV_API 148 int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, 149 uint8* dst_argb, int dst_stride_argb, 150 int width, int height); 151 152 // Convert UYVY to ARGB. 153 LIBYUV_API 154 int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy, 155 uint8* dst_argb, int dst_stride_argb, 156 int width, int height); 157 158 // Convert J420 to ARGB. 159 LIBYUV_API 160 int J420ToARGB(const uint8* src_y, int src_stride_y, 161 const uint8* src_u, int src_stride_u, 162 const uint8* src_v, int src_stride_v, 163 uint8* dst_argb, int dst_stride_argb, 164 int width, int height); 165 166 // Convert J422 to ARGB. 167 LIBYUV_API 168 int J422ToARGB(const uint8* src_y, int src_stride_y, 169 const uint8* src_u, int src_stride_u, 170 const uint8* src_v, int src_stride_v, 171 uint8* dst_argb, int dst_stride_argb, 172 int width, int height); 173 174 // Convert J420 to ABGR. 175 LIBYUV_API 176 int J420ToABGR(const uint8* src_y, int src_stride_y, 177 const uint8* src_u, int src_stride_u, 178 const uint8* src_v, int src_stride_v, 179 uint8* dst_abgr, int dst_stride_abgr, 180 int width, int height); 181 182 // Convert J422 to ABGR. 183 LIBYUV_API 184 int J422ToABGR(const uint8* src_y, int src_stride_y, 185 const uint8* src_u, int src_stride_u, 186 const uint8* src_v, int src_stride_v, 187 uint8* dst_abgr, int dst_stride_abgr, 188 int width, int height); 189 190 // Convert H420 to ARGB. 191 LIBYUV_API 192 int H420ToARGB(const uint8* src_y, int src_stride_y, 193 const uint8* src_u, int src_stride_u, 194 const uint8* src_v, int src_stride_v, 195 uint8* dst_argb, int dst_stride_argb, 196 int width, int height); 197 198 // Convert H422 to ARGB. 199 LIBYUV_API 200 int H422ToARGB(const uint8* src_y, int src_stride_y, 201 const uint8* src_u, int src_stride_u, 202 const uint8* src_v, int src_stride_v, 203 uint8* dst_argb, int dst_stride_argb, 204 int width, int height); 205 206 // Convert H420 to ABGR. 207 LIBYUV_API 208 int H420ToABGR(const uint8* src_y, int src_stride_y, 209 const uint8* src_u, int src_stride_u, 210 const uint8* src_v, int src_stride_v, 211 uint8* dst_abgr, int dst_stride_abgr, 212 int width, int height); 213 214 // Convert H422 to ABGR. 215 LIBYUV_API 216 int H422ToABGR(const uint8* src_y, int src_stride_y, 217 const uint8* src_u, int src_stride_u, 218 const uint8* src_v, int src_stride_v, 219 uint8* dst_abgr, int dst_stride_abgr, 220 int width, int height); 221 222 // BGRA little endian (argb in memory) to ARGB. 223 LIBYUV_API 224 int BGRAToARGB(const uint8* src_frame, int src_stride_frame, 225 uint8* dst_argb, int dst_stride_argb, 226 int width, int height); 227 228 // ABGR little endian (rgba in memory) to ARGB. 229 LIBYUV_API 230 int ABGRToARGB(const uint8* src_frame, int src_stride_frame, 231 uint8* dst_argb, int dst_stride_argb, 232 int width, int height); 233 234 // RGBA little endian (abgr in memory) to ARGB. 235 LIBYUV_API 236 int RGBAToARGB(const uint8* src_frame, int src_stride_frame, 237 uint8* dst_argb, int dst_stride_argb, 238 int width, int height); 239 240 // Deprecated function name. 241 #define BG24ToARGB RGB24ToARGB 242 243 // RGB little endian (bgr in memory) to ARGB. 244 LIBYUV_API 245 int RGB24ToARGB(const uint8* src_frame, int src_stride_frame, 246 uint8* dst_argb, int dst_stride_argb, 247 int width, int height); 248 249 // RGB big endian (rgb in memory) to ARGB. 250 LIBYUV_API 251 int RAWToARGB(const uint8* src_frame, int src_stride_frame, 252 uint8* dst_argb, int dst_stride_argb, 253 int width, int height); 254 255 // RGB16 (RGBP fourcc) little endian to ARGB. 256 LIBYUV_API 257 int RGB565ToARGB(const uint8* src_frame, int src_stride_frame, 258 uint8* dst_argb, int dst_stride_argb, 259 int width, int height); 260 261 // RGB15 (RGBO fourcc) little endian to ARGB. 262 LIBYUV_API 263 int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame, 264 uint8* dst_argb, int dst_stride_argb, 265 int width, int height); 266 267 // RGB12 (R444 fourcc) little endian to ARGB. 268 LIBYUV_API 269 int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame, 270 uint8* dst_argb, int dst_stride_argb, 271 int width, int height); 272 273 #ifdef HAVE_JPEG 274 // src_width/height provided by capture 275 // dst_width/height for clipping determine final size. 276 LIBYUV_API 277 int MJPGToARGB(const uint8* sample, size_t sample_size, 278 uint8* dst_argb, int dst_stride_argb, 279 int src_width, int src_height, 280 int dst_width, int dst_height); 281 #endif 282 283 // Convert camera sample to ARGB with cropping, rotation and vertical flip. 284 // "src_size" is needed to parse MJPG. 285 // "dst_stride_argb" number of bytes in a row of the dst_argb plane. 286 // Normally this would be the same as dst_width, with recommended alignment 287 // to 16 bytes for better efficiency. 288 // If rotation of 90 or 270 is used, stride is affected. The caller should 289 // allocate the I420 buffer according to rotation. 290 // "dst_stride_u" number of bytes in a row of the dst_u plane. 291 // Normally this would be the same as (dst_width + 1) / 2, with 292 // recommended alignment to 16 bytes for better efficiency. 293 // If rotation of 90 or 270 is used, stride is affected. 294 // "crop_x" and "crop_y" are starting position for cropping. 295 // To center, crop_x = (src_width - dst_width) / 2 296 // crop_y = (src_height - dst_height) / 2 297 // "src_width" / "src_height" is size of src_frame in pixels. 298 // "src_height" can be negative indicating a vertically flipped image source. 299 // "crop_width" / "crop_height" is the size to crop the src to. 300 // Must be less than or equal to src_width/src_height 301 // Cropping parameters are pre-rotation. 302 // "rotation" can be 0, 90, 180 or 270. 303 // "format" is a fourcc. ie 'I420', 'YUY2' 304 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 305 LIBYUV_API 306 int ConvertToARGB(const uint8* src_frame, size_t src_size, 307 uint8* dst_argb, int dst_stride_argb, 308 int crop_x, int crop_y, 309 int src_width, int src_height, 310 int crop_width, int crop_height, 311 enum RotationMode rotation, 312 uint32 format); 313 314 #ifdef __cplusplus 315 } // extern "C" 316 } // namespace libyuv 317 #endif 318 319 #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ NOLINT 320