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_ 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, 34 int src_stride_argb, 35 uint8* dst_argb, 36 int dst_stride_argb, 37 int width, 38 int height); 39 40 // Convert I420 to ARGB. 41 LIBYUV_API 42 int I420ToARGB(const uint8* src_y, 43 int src_stride_y, 44 const uint8* src_u, 45 int src_stride_u, 46 const uint8* src_v, 47 int src_stride_v, 48 uint8* dst_argb, 49 int dst_stride_argb, 50 int width, 51 int height); 52 53 // Duplicate prototype for function in convert_from.h for remoting. 54 LIBYUV_API 55 int I420ToABGR(const uint8* src_y, 56 int src_stride_y, 57 const uint8* src_u, 58 int src_stride_u, 59 const uint8* src_v, 60 int src_stride_v, 61 uint8* dst_argb, 62 int dst_stride_argb, 63 int width, 64 int height); 65 66 // Convert I422 to ARGB. 67 LIBYUV_API 68 int I422ToARGB(const uint8* src_y, 69 int src_stride_y, 70 const uint8* src_u, 71 int src_stride_u, 72 const uint8* src_v, 73 int src_stride_v, 74 uint8* dst_argb, 75 int dst_stride_argb, 76 int width, 77 int height); 78 79 // Convert I444 to ARGB. 80 LIBYUV_API 81 int I444ToARGB(const uint8* src_y, 82 int src_stride_y, 83 const uint8* src_u, 84 int src_stride_u, 85 const uint8* src_v, 86 int src_stride_v, 87 uint8* dst_argb, 88 int dst_stride_argb, 89 int width, 90 int height); 91 92 // Convert J444 to ARGB. 93 LIBYUV_API 94 int J444ToARGB(const uint8* src_y, 95 int src_stride_y, 96 const uint8* src_u, 97 int src_stride_u, 98 const uint8* src_v, 99 int src_stride_v, 100 uint8* dst_argb, 101 int dst_stride_argb, 102 int width, 103 int height); 104 105 // Convert I444 to ABGR. 106 LIBYUV_API 107 int I444ToABGR(const uint8* src_y, 108 int src_stride_y, 109 const uint8* src_u, 110 int src_stride_u, 111 const uint8* src_v, 112 int src_stride_v, 113 uint8* dst_abgr, 114 int dst_stride_abgr, 115 int width, 116 int height); 117 118 // Convert I420 with Alpha to preattenuated ARGB. 119 LIBYUV_API 120 int I420AlphaToARGB(const uint8* src_y, 121 int src_stride_y, 122 const uint8* src_u, 123 int src_stride_u, 124 const uint8* src_v, 125 int src_stride_v, 126 const uint8* src_a, 127 int src_stride_a, 128 uint8* dst_argb, 129 int dst_stride_argb, 130 int width, 131 int height, 132 int attenuate); 133 134 // Convert I420 with Alpha to preattenuated ABGR. 135 LIBYUV_API 136 int I420AlphaToABGR(const uint8* src_y, 137 int src_stride_y, 138 const uint8* src_u, 139 int src_stride_u, 140 const uint8* src_v, 141 int src_stride_v, 142 const uint8* src_a, 143 int src_stride_a, 144 uint8* dst_abgr, 145 int dst_stride_abgr, 146 int width, 147 int height, 148 int attenuate); 149 150 // Convert I400 (grey) to ARGB. Reverse of ARGBToI400. 151 LIBYUV_API 152 int I400ToARGB(const uint8* src_y, 153 int src_stride_y, 154 uint8* dst_argb, 155 int dst_stride_argb, 156 int width, 157 int height); 158 159 // Convert J400 (jpeg grey) to ARGB. 160 LIBYUV_API 161 int J400ToARGB(const uint8* src_y, 162 int src_stride_y, 163 uint8* dst_argb, 164 int dst_stride_argb, 165 int width, 166 int height); 167 168 // Alias. 169 #define YToARGB I400ToARGB 170 171 // Convert NV12 to ARGB. 172 LIBYUV_API 173 int NV12ToARGB(const uint8* src_y, 174 int src_stride_y, 175 const uint8* src_uv, 176 int src_stride_uv, 177 uint8* dst_argb, 178 int dst_stride_argb, 179 int width, 180 int height); 181 182 // Convert NV21 to ARGB. 183 LIBYUV_API 184 int NV21ToARGB(const uint8* src_y, 185 int src_stride_y, 186 const uint8* src_vu, 187 int src_stride_vu, 188 uint8* dst_argb, 189 int dst_stride_argb, 190 int width, 191 int height); 192 193 // Convert M420 to ARGB. 194 LIBYUV_API 195 int M420ToARGB(const uint8* src_m420, 196 int src_stride_m420, 197 uint8* dst_argb, 198 int dst_stride_argb, 199 int width, 200 int height); 201 202 // Convert YUY2 to ARGB. 203 LIBYUV_API 204 int YUY2ToARGB(const uint8* src_yuy2, 205 int src_stride_yuy2, 206 uint8* dst_argb, 207 int dst_stride_argb, 208 int width, 209 int height); 210 211 // Convert UYVY to ARGB. 212 LIBYUV_API 213 int UYVYToARGB(const uint8* src_uyvy, 214 int src_stride_uyvy, 215 uint8* dst_argb, 216 int dst_stride_argb, 217 int width, 218 int height); 219 220 // Convert J420 to ARGB. 221 LIBYUV_API 222 int J420ToARGB(const uint8* src_y, 223 int src_stride_y, 224 const uint8* src_u, 225 int src_stride_u, 226 const uint8* src_v, 227 int src_stride_v, 228 uint8* dst_argb, 229 int dst_stride_argb, 230 int width, 231 int height); 232 233 // Convert J422 to ARGB. 234 LIBYUV_API 235 int J422ToARGB(const uint8* src_y, 236 int src_stride_y, 237 const uint8* src_u, 238 int src_stride_u, 239 const uint8* src_v, 240 int src_stride_v, 241 uint8* dst_argb, 242 int dst_stride_argb, 243 int width, 244 int height); 245 246 // Convert J420 to ABGR. 247 LIBYUV_API 248 int J420ToABGR(const uint8* src_y, 249 int src_stride_y, 250 const uint8* src_u, 251 int src_stride_u, 252 const uint8* src_v, 253 int src_stride_v, 254 uint8* dst_abgr, 255 int dst_stride_abgr, 256 int width, 257 int height); 258 259 // Convert J422 to ABGR. 260 LIBYUV_API 261 int J422ToABGR(const uint8* src_y, 262 int src_stride_y, 263 const uint8* src_u, 264 int src_stride_u, 265 const uint8* src_v, 266 int src_stride_v, 267 uint8* dst_abgr, 268 int dst_stride_abgr, 269 int width, 270 int height); 271 272 // Convert H420 to ARGB. 273 LIBYUV_API 274 int H420ToARGB(const uint8* src_y, 275 int src_stride_y, 276 const uint8* src_u, 277 int src_stride_u, 278 const uint8* src_v, 279 int src_stride_v, 280 uint8* dst_argb, 281 int dst_stride_argb, 282 int width, 283 int height); 284 285 // Convert H422 to ARGB. 286 LIBYUV_API 287 int H422ToARGB(const uint8* src_y, 288 int src_stride_y, 289 const uint8* src_u, 290 int src_stride_u, 291 const uint8* src_v, 292 int src_stride_v, 293 uint8* dst_argb, 294 int dst_stride_argb, 295 int width, 296 int height); 297 298 // Convert H420 to ABGR. 299 LIBYUV_API 300 int H420ToABGR(const uint8* src_y, 301 int src_stride_y, 302 const uint8* src_u, 303 int src_stride_u, 304 const uint8* src_v, 305 int src_stride_v, 306 uint8* dst_abgr, 307 int dst_stride_abgr, 308 int width, 309 int height); 310 311 // Convert H422 to ABGR. 312 LIBYUV_API 313 int H422ToABGR(const uint8* src_y, 314 int src_stride_y, 315 const uint8* src_u, 316 int src_stride_u, 317 const uint8* src_v, 318 int src_stride_v, 319 uint8* dst_abgr, 320 int dst_stride_abgr, 321 int width, 322 int height); 323 324 // BGRA little endian (argb in memory) to ARGB. 325 LIBYUV_API 326 int BGRAToARGB(const uint8* src_frame, 327 int src_stride_frame, 328 uint8* dst_argb, 329 int dst_stride_argb, 330 int width, 331 int height); 332 333 // ABGR little endian (rgba in memory) to ARGB. 334 LIBYUV_API 335 int ABGRToARGB(const uint8* src_frame, 336 int src_stride_frame, 337 uint8* dst_argb, 338 int dst_stride_argb, 339 int width, 340 int height); 341 342 // RGBA little endian (abgr in memory) to ARGB. 343 LIBYUV_API 344 int RGBAToARGB(const uint8* src_frame, 345 int src_stride_frame, 346 uint8* dst_argb, 347 int dst_stride_argb, 348 int width, 349 int height); 350 351 // Deprecated function name. 352 #define BG24ToARGB RGB24ToARGB 353 354 // RGB little endian (bgr in memory) to ARGB. 355 LIBYUV_API 356 int RGB24ToARGB(const uint8* src_frame, 357 int src_stride_frame, 358 uint8* dst_argb, 359 int dst_stride_argb, 360 int width, 361 int height); 362 363 // RGB big endian (rgb in memory) to ARGB. 364 LIBYUV_API 365 int RAWToARGB(const uint8* src_frame, 366 int src_stride_frame, 367 uint8* dst_argb, 368 int dst_stride_argb, 369 int width, 370 int height); 371 372 // RGB16 (RGBP fourcc) little endian to ARGB. 373 LIBYUV_API 374 int RGB565ToARGB(const uint8* src_frame, 375 int src_stride_frame, 376 uint8* dst_argb, 377 int dst_stride_argb, 378 int width, 379 int height); 380 381 // RGB15 (RGBO fourcc) little endian to ARGB. 382 LIBYUV_API 383 int ARGB1555ToARGB(const uint8* src_frame, 384 int src_stride_frame, 385 uint8* dst_argb, 386 int dst_stride_argb, 387 int width, 388 int height); 389 390 // RGB12 (R444 fourcc) little endian to ARGB. 391 LIBYUV_API 392 int ARGB4444ToARGB(const uint8* src_frame, 393 int src_stride_frame, 394 uint8* dst_argb, 395 int dst_stride_argb, 396 int width, 397 int height); 398 399 #ifdef HAVE_JPEG 400 // src_width/height provided by capture 401 // dst_width/height for clipping determine final size. 402 LIBYUV_API 403 int MJPGToARGB(const uint8* sample, 404 size_t sample_size, 405 uint8* dst_argb, 406 int dst_stride_argb, 407 int src_width, 408 int src_height, 409 int dst_width, 410 int dst_height); 411 #endif 412 413 // Convert camera sample to ARGB with cropping, rotation and vertical flip. 414 // "src_size" is needed to parse MJPG. 415 // "dst_stride_argb" number of bytes in a row of the dst_argb plane. 416 // Normally this would be the same as dst_width, with recommended alignment 417 // to 16 bytes for better efficiency. 418 // If rotation of 90 or 270 is used, stride is affected. The caller should 419 // allocate the I420 buffer according to rotation. 420 // "dst_stride_u" number of bytes in a row of the dst_u plane. 421 // Normally this would be the same as (dst_width + 1) / 2, with 422 // recommended alignment to 16 bytes for better efficiency. 423 // If rotation of 90 or 270 is used, stride is affected. 424 // "crop_x" and "crop_y" are starting position for cropping. 425 // To center, crop_x = (src_width - dst_width) / 2 426 // crop_y = (src_height - dst_height) / 2 427 // "src_width" / "src_height" is size of src_frame in pixels. 428 // "src_height" can be negative indicating a vertically flipped image source. 429 // "crop_width" / "crop_height" is the size to crop the src to. 430 // Must be less than or equal to src_width/src_height 431 // Cropping parameters are pre-rotation. 432 // "rotation" can be 0, 90, 180 or 270. 433 // "format" is a fourcc. ie 'I420', 'YUY2' 434 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 435 LIBYUV_API 436 int ConvertToARGB(const uint8* src_frame, 437 size_t src_size, 438 uint8* dst_argb, 439 int dst_stride_argb, 440 int crop_x, 441 int crop_y, 442 int src_width, 443 int src_height, 444 int crop_width, 445 int crop_height, 446 enum RotationMode rotation, 447 uint32 format); 448 449 #ifdef __cplusplus 450 } // extern "C" 451 } // namespace libyuv 452 #endif 453 454 #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ 455