1 /* 2 * Copyright 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 #ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 12 #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 13 14 #include "libyuv/basic_types.h" 15 16 // TODO(fbarchard): Remove the following headers includes. 17 #include "libyuv/convert.h" 18 #include "libyuv/convert_argb.h" 19 20 #ifdef __cplusplus 21 namespace libyuv { 22 extern "C" { 23 #endif 24 25 // TODO(fbarchard): Move cpu macros to row.h 26 #if defined(__pnacl__) || defined(__CLR_VER) || \ 27 (defined(__native_client__) && defined(__x86_64__)) || \ 28 (defined(__i386__) && !defined(__SSE__) && !defined(__clang__)) 29 #define LIBYUV_DISABLE_X86 30 #endif 31 // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 32 #if defined(__has_feature) 33 #if __has_feature(memory_sanitizer) 34 #define LIBYUV_DISABLE_X86 35 #endif 36 #endif 37 // The following are available on all x86 platforms: 38 #if !defined(LIBYUV_DISABLE_X86) && \ 39 (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) 40 #define HAS_ARGBAFFINEROW_SSE2 41 #endif 42 43 // Copy a plane of data. 44 LIBYUV_API 45 void CopyPlane(const uint8_t* src_y, 46 int src_stride_y, 47 uint8_t* dst_y, 48 int dst_stride_y, 49 int width, 50 int height); 51 52 LIBYUV_API 53 void CopyPlane_16(const uint16_t* src_y, 54 int src_stride_y, 55 uint16_t* dst_y, 56 int dst_stride_y, 57 int width, 58 int height); 59 60 LIBYUV_API 61 void Convert16To8Plane(const uint16_t* src_y, 62 int src_stride_y, 63 uint8_t* dst_y, 64 int dst_stride_y, 65 int scale, // 16384 for 10 bits 66 int width, 67 int height); 68 69 LIBYUV_API 70 void Convert8To16Plane(const uint8_t* src_y, 71 int src_stride_y, 72 uint16_t* dst_y, 73 int dst_stride_y, 74 int scale, // 1024 for 10 bits 75 int width, 76 int height); 77 78 // Set a plane of data to a 32 bit value. 79 LIBYUV_API 80 void SetPlane(uint8_t* dst_y, 81 int dst_stride_y, 82 int width, 83 int height, 84 uint32_t value); 85 86 // Convert a plane of tiles of 16 x H to linear. 87 LIBYUV_API 88 void DetilePlane(const uint8_t* src_y, 89 int src_stride_y, 90 uint8_t* dst_y, 91 int dst_stride_y, 92 int width, 93 int height, 94 int tile_height); 95 96 // Convert a UV plane of tiles of 16 x H into linear U and V planes. 97 LIBYUV_API 98 void DetileSplitUVPlane(const uint8_t* src_uv, 99 int src_stride_uv, 100 uint8_t* dst_u, 101 int dst_stride_u, 102 uint8_t* dst_v, 103 int dst_stride_v, 104 int width, 105 int height, 106 int tile_height); 107 108 // Split interleaved UV plane into separate U and V planes. 109 LIBYUV_API 110 void SplitUVPlane(const uint8_t* src_uv, 111 int src_stride_uv, 112 uint8_t* dst_u, 113 int dst_stride_u, 114 uint8_t* dst_v, 115 int dst_stride_v, 116 int width, 117 int height); 118 119 // Merge separate U and V planes into one interleaved UV plane. 120 LIBYUV_API 121 void MergeUVPlane(const uint8_t* src_u, 122 int src_stride_u, 123 const uint8_t* src_v, 124 int src_stride_v, 125 uint8_t* dst_uv, 126 int dst_stride_uv, 127 int width, 128 int height); 129 130 // Split interleaved msb UV plane into separate lsb U and V planes. 131 LIBYUV_API 132 void SplitUVPlane_16(const uint16_t* src_uv, 133 int src_stride_uv, 134 uint16_t* dst_u, 135 int dst_stride_u, 136 uint16_t* dst_v, 137 int dst_stride_v, 138 int width, 139 int height, 140 int depth); 141 142 // Merge separate lsb U and V planes into one interleaved msb UV plane. 143 LIBYUV_API 144 void MergeUVPlane_16(const uint16_t* src_u, 145 int src_stride_u, 146 const uint16_t* src_v, 147 int src_stride_v, 148 uint16_t* dst_uv, 149 int dst_stride_uv, 150 int width, 151 int height, 152 int depth); 153 154 // Convert lsb plane to msb plane 155 LIBYUV_API 156 void ConvertToMSBPlane_16(const uint16_t* src_y, 157 int src_stride_y, 158 uint16_t* dst_y, 159 int dst_stride_y, 160 int width, 161 int height, 162 int depth); 163 164 // Convert msb plane to lsb plane 165 LIBYUV_API 166 void ConvertToLSBPlane_16(const uint16_t* src_y, 167 int src_stride_y, 168 uint16_t* dst_y, 169 int dst_stride_y, 170 int width, 171 int height, 172 int depth); 173 174 // Scale U and V to half width and height and merge into interleaved UV plane. 175 // width and height are source size, allowing odd sizes. 176 // Use for converting I444 or I422 to NV12. 177 LIBYUV_API 178 void HalfMergeUVPlane(const uint8_t* src_u, 179 int src_stride_u, 180 const uint8_t* src_v, 181 int src_stride_v, 182 uint8_t* dst_uv, 183 int dst_stride_uv, 184 int width, 185 int height); 186 187 // Swap U and V channels in interleaved UV plane. 188 LIBYUV_API 189 void SwapUVPlane(const uint8_t* src_uv, 190 int src_stride_uv, 191 uint8_t* dst_vu, 192 int dst_stride_vu, 193 int width, 194 int height); 195 196 // Split interleaved RGB plane into separate R, G and B planes. 197 LIBYUV_API 198 void SplitRGBPlane(const uint8_t* src_rgb, 199 int src_stride_rgb, 200 uint8_t* dst_r, 201 int dst_stride_r, 202 uint8_t* dst_g, 203 int dst_stride_g, 204 uint8_t* dst_b, 205 int dst_stride_b, 206 int width, 207 int height); 208 209 // Merge separate R, G and B planes into one interleaved RGB plane. 210 LIBYUV_API 211 void MergeRGBPlane(const uint8_t* src_r, 212 int src_stride_r, 213 const uint8_t* src_g, 214 int src_stride_g, 215 const uint8_t* src_b, 216 int src_stride_b, 217 uint8_t* dst_rgb, 218 int dst_stride_rgb, 219 int width, 220 int height); 221 222 // Split interleaved ARGB plane into separate R, G, B and A planes. 223 // dst_a can be NULL to discard alpha plane. 224 LIBYUV_API 225 void SplitARGBPlane(const uint8_t* src_argb, 226 int src_stride_argb, 227 uint8_t* dst_r, 228 int dst_stride_r, 229 uint8_t* dst_g, 230 int dst_stride_g, 231 uint8_t* dst_b, 232 int dst_stride_b, 233 uint8_t* dst_a, 234 int dst_stride_a, 235 int width, 236 int height); 237 238 // Merge separate R, G, B and A planes into one interleaved ARGB plane. 239 // src_a can be NULL to fill opaque value to alpha. 240 LIBYUV_API 241 void MergeARGBPlane(const uint8_t* src_r, 242 int src_stride_r, 243 const uint8_t* src_g, 244 int src_stride_g, 245 const uint8_t* src_b, 246 int src_stride_b, 247 const uint8_t* src_a, 248 int src_stride_a, 249 uint8_t* dst_argb, 250 int dst_stride_argb, 251 int width, 252 int height); 253 254 // Merge separate 'depth' bit R, G and B planes stored in lsb 255 // into one interleaved XR30 plane. 256 // depth should in range [10, 16] 257 LIBYUV_API 258 void MergeXR30Plane(const uint16_t* src_r, 259 int src_stride_r, 260 const uint16_t* src_g, 261 int src_stride_g, 262 const uint16_t* src_b, 263 int src_stride_b, 264 uint8_t* dst_ar30, 265 int dst_stride_ar30, 266 int width, 267 int height, 268 int depth); 269 270 // Merge separate 'depth' bit R, G, B and A planes stored in lsb 271 // into one interleaved AR64 plane. 272 // src_a can be NULL to fill opaque value to alpha. 273 // depth should in range [1, 16] 274 LIBYUV_API 275 void MergeAR64Plane(const uint16_t* src_r, 276 int src_stride_r, 277 const uint16_t* src_g, 278 int src_stride_g, 279 const uint16_t* src_b, 280 int src_stride_b, 281 const uint16_t* src_a, 282 int src_stride_a, 283 uint16_t* dst_ar64, 284 int dst_stride_ar64, 285 int width, 286 int height, 287 int depth); 288 289 // Merge separate 'depth' bit R, G, B and A planes stored in lsb 290 // into one interleaved ARGB plane. 291 // src_a can be NULL to fill opaque value to alpha. 292 // depth should in range [8, 16] 293 LIBYUV_API 294 void MergeARGB16To8Plane(const uint16_t* src_r, 295 int src_stride_r, 296 const uint16_t* src_g, 297 int src_stride_g, 298 const uint16_t* src_b, 299 int src_stride_b, 300 const uint16_t* src_a, 301 int src_stride_a, 302 uint8_t* dst_argb, 303 int dst_stride_argb, 304 int width, 305 int height, 306 int depth); 307 308 // Copy I400. Supports inverting. 309 LIBYUV_API 310 int I400ToI400(const uint8_t* src_y, 311 int src_stride_y, 312 uint8_t* dst_y, 313 int dst_stride_y, 314 int width, 315 int height); 316 317 #define J400ToJ400 I400ToI400 318 319 // Copy I422 to I422. 320 #define I422ToI422 I422Copy 321 LIBYUV_API 322 int I422Copy(const uint8_t* src_y, 323 int src_stride_y, 324 const uint8_t* src_u, 325 int src_stride_u, 326 const uint8_t* src_v, 327 int src_stride_v, 328 uint8_t* dst_y, 329 int dst_stride_y, 330 uint8_t* dst_u, 331 int dst_stride_u, 332 uint8_t* dst_v, 333 int dst_stride_v, 334 int width, 335 int height); 336 337 // Copy I444 to I444. 338 #define I444ToI444 I444Copy 339 LIBYUV_API 340 int I444Copy(const uint8_t* src_y, 341 int src_stride_y, 342 const uint8_t* src_u, 343 int src_stride_u, 344 const uint8_t* src_v, 345 int src_stride_v, 346 uint8_t* dst_y, 347 int dst_stride_y, 348 uint8_t* dst_u, 349 int dst_stride_u, 350 uint8_t* dst_v, 351 int dst_stride_v, 352 int width, 353 int height); 354 355 // Copy I210 to I210. 356 #define I210ToI210 I210Copy 357 LIBYUV_API 358 int I210Copy(const uint16_t* src_y, 359 int src_stride_y, 360 const uint16_t* src_u, 361 int src_stride_u, 362 const uint16_t* src_v, 363 int src_stride_v, 364 uint16_t* dst_y, 365 int dst_stride_y, 366 uint16_t* dst_u, 367 int dst_stride_u, 368 uint16_t* dst_v, 369 int dst_stride_v, 370 int width, 371 int height); 372 373 // Copy NV12. Supports inverting. 374 int NV12Copy(const uint8_t* src_y, 375 int src_stride_y, 376 const uint8_t* src_uv, 377 int src_stride_uv, 378 uint8_t* dst_y, 379 int dst_stride_y, 380 uint8_t* dst_uv, 381 int dst_stride_uv, 382 int width, 383 int height); 384 385 // Copy NV21. Supports inverting. 386 int NV21Copy(const uint8_t* src_y, 387 int src_stride_y, 388 const uint8_t* src_vu, 389 int src_stride_vu, 390 uint8_t* dst_y, 391 int dst_stride_y, 392 uint8_t* dst_vu, 393 int dst_stride_vu, 394 int width, 395 int height); 396 397 // Convert YUY2 to I422. 398 LIBYUV_API 399 int YUY2ToI422(const uint8_t* src_yuy2, 400 int src_stride_yuy2, 401 uint8_t* dst_y, 402 int dst_stride_y, 403 uint8_t* dst_u, 404 int dst_stride_u, 405 uint8_t* dst_v, 406 int dst_stride_v, 407 int width, 408 int height); 409 410 // Convert UYVY to I422. 411 LIBYUV_API 412 int UYVYToI422(const uint8_t* src_uyvy, 413 int src_stride_uyvy, 414 uint8_t* dst_y, 415 int dst_stride_y, 416 uint8_t* dst_u, 417 int dst_stride_u, 418 uint8_t* dst_v, 419 int dst_stride_v, 420 int width, 421 int height); 422 423 LIBYUV_API 424 int YUY2ToNV12(const uint8_t* src_yuy2, 425 int src_stride_yuy2, 426 uint8_t* dst_y, 427 int dst_stride_y, 428 uint8_t* dst_uv, 429 int dst_stride_uv, 430 int width, 431 int height); 432 433 LIBYUV_API 434 int UYVYToNV12(const uint8_t* src_uyvy, 435 int src_stride_uyvy, 436 uint8_t* dst_y, 437 int dst_stride_y, 438 uint8_t* dst_uv, 439 int dst_stride_uv, 440 int width, 441 int height); 442 443 // Convert NV21 to NV12. 444 LIBYUV_API 445 int NV21ToNV12(const uint8_t* src_y, 446 int src_stride_y, 447 const uint8_t* src_vu, 448 int src_stride_vu, 449 uint8_t* dst_y, 450 int dst_stride_y, 451 uint8_t* dst_uv, 452 int dst_stride_uv, 453 int width, 454 int height); 455 456 LIBYUV_API 457 int YUY2ToY(const uint8_t* src_yuy2, 458 int src_stride_yuy2, 459 uint8_t* dst_y, 460 int dst_stride_y, 461 int width, 462 int height); 463 464 LIBYUV_API 465 int UYVYToY(const uint8_t* src_uyvy, 466 int src_stride_uyvy, 467 uint8_t* dst_y, 468 int dst_stride_y, 469 int width, 470 int height); 471 472 // Convert I420 to I400. (calls CopyPlane ignoring u/v). 473 LIBYUV_API 474 int I420ToI400(const uint8_t* src_y, 475 int src_stride_y, 476 const uint8_t* src_u, 477 int src_stride_u, 478 const uint8_t* src_v, 479 int src_stride_v, 480 uint8_t* dst_y, 481 int dst_stride_y, 482 int width, 483 int height); 484 485 // Alias 486 #define J420ToJ400 I420ToI400 487 #define I420ToI420Mirror I420Mirror 488 489 // I420 mirror. 490 LIBYUV_API 491 int I420Mirror(const uint8_t* src_y, 492 int src_stride_y, 493 const uint8_t* src_u, 494 int src_stride_u, 495 const uint8_t* src_v, 496 int src_stride_v, 497 uint8_t* dst_y, 498 int dst_stride_y, 499 uint8_t* dst_u, 500 int dst_stride_u, 501 uint8_t* dst_v, 502 int dst_stride_v, 503 int width, 504 int height); 505 506 // Alias 507 #define I400ToI400Mirror I400Mirror 508 509 // I400 mirror. A single plane is mirrored horizontally. 510 // Pass negative height to achieve 180 degree rotation. 511 LIBYUV_API 512 int I400Mirror(const uint8_t* src_y, 513 int src_stride_y, 514 uint8_t* dst_y, 515 int dst_stride_y, 516 int width, 517 int height); 518 519 // Alias 520 #define NV12ToNV12Mirror NV12Mirror 521 522 // NV12 mirror. 523 LIBYUV_API 524 int NV12Mirror(const uint8_t* src_y, 525 int src_stride_y, 526 const uint8_t* src_uv, 527 int src_stride_uv, 528 uint8_t* dst_y, 529 int dst_stride_y, 530 uint8_t* dst_uv, 531 int dst_stride_uv, 532 int width, 533 int height); 534 535 // Alias 536 #define ARGBToARGBMirror ARGBMirror 537 538 // ARGB mirror. 539 LIBYUV_API 540 int ARGBMirror(const uint8_t* src_argb, 541 int src_stride_argb, 542 uint8_t* dst_argb, 543 int dst_stride_argb, 544 int width, 545 int height); 546 547 // Alias 548 #define RGB24ToRGB24Mirror RGB24Mirror 549 550 // RGB24 mirror. 551 LIBYUV_API 552 int RGB24Mirror(const uint8_t* src_rgb24, 553 int src_stride_rgb24, 554 uint8_t* dst_rgb24, 555 int dst_stride_rgb24, 556 int width, 557 int height); 558 559 // Mirror a plane of data. 560 LIBYUV_API 561 void MirrorPlane(const uint8_t* src_y, 562 int src_stride_y, 563 uint8_t* dst_y, 564 int dst_stride_y, 565 int width, 566 int height); 567 568 // Mirror a plane of UV data. 569 LIBYUV_API 570 void MirrorUVPlane(const uint8_t* src_uv, 571 int src_stride_uv, 572 uint8_t* dst_uv, 573 int dst_stride_uv, 574 int width, 575 int height); 576 577 // Alias 578 #define RGB24ToRAW RAWToRGB24 579 580 LIBYUV_API 581 int RAWToRGB24(const uint8_t* src_raw, 582 int src_stride_raw, 583 uint8_t* dst_rgb24, 584 int dst_stride_rgb24, 585 int width, 586 int height); 587 588 // Draw a rectangle into I420. 589 LIBYUV_API 590 int I420Rect(uint8_t* dst_y, 591 int dst_stride_y, 592 uint8_t* dst_u, 593 int dst_stride_u, 594 uint8_t* dst_v, 595 int dst_stride_v, 596 int x, 597 int y, 598 int width, 599 int height, 600 int value_y, 601 int value_u, 602 int value_v); 603 604 // Draw a rectangle into ARGB. 605 LIBYUV_API 606 int ARGBRect(uint8_t* dst_argb, 607 int dst_stride_argb, 608 int dst_x, 609 int dst_y, 610 int width, 611 int height, 612 uint32_t value); 613 614 // Convert ARGB to gray scale ARGB. 615 LIBYUV_API 616 int ARGBGrayTo(const uint8_t* src_argb, 617 int src_stride_argb, 618 uint8_t* dst_argb, 619 int dst_stride_argb, 620 int width, 621 int height); 622 623 // Make a rectangle of ARGB gray scale. 624 LIBYUV_API 625 int ARGBGray(uint8_t* dst_argb, 626 int dst_stride_argb, 627 int dst_x, 628 int dst_y, 629 int width, 630 int height); 631 632 // Make a rectangle of ARGB Sepia tone. 633 LIBYUV_API 634 int ARGBSepia(uint8_t* dst_argb, 635 int dst_stride_argb, 636 int dst_x, 637 int dst_y, 638 int width, 639 int height); 640 641 // Apply a matrix rotation to each ARGB pixel. 642 // matrix_argb is 4 signed ARGB values. -128 to 127 representing -2 to 2. 643 // The first 4 coefficients apply to B, G, R, A and produce B of the output. 644 // The next 4 coefficients apply to B, G, R, A and produce G of the output. 645 // The next 4 coefficients apply to B, G, R, A and produce R of the output. 646 // The last 4 coefficients apply to B, G, R, A and produce A of the output. 647 LIBYUV_API 648 int ARGBColorMatrix(const uint8_t* src_argb, 649 int src_stride_argb, 650 uint8_t* dst_argb, 651 int dst_stride_argb, 652 const int8_t* matrix_argb, 653 int width, 654 int height); 655 656 // Deprecated. Use ARGBColorMatrix instead. 657 // Apply a matrix rotation to each ARGB pixel. 658 // matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1. 659 // The first 4 coefficients apply to B, G, R, A and produce B of the output. 660 // The next 4 coefficients apply to B, G, R, A and produce G of the output. 661 // The last 4 coefficients apply to B, G, R, A and produce R of the output. 662 LIBYUV_API 663 int RGBColorMatrix(uint8_t* dst_argb, 664 int dst_stride_argb, 665 const int8_t* matrix_rgb, 666 int dst_x, 667 int dst_y, 668 int width, 669 int height); 670 671 // Apply a color table each ARGB pixel. 672 // Table contains 256 ARGB values. 673 LIBYUV_API 674 int ARGBColorTable(uint8_t* dst_argb, 675 int dst_stride_argb, 676 const uint8_t* table_argb, 677 int dst_x, 678 int dst_y, 679 int width, 680 int height); 681 682 // Apply a color table each ARGB pixel but preserve destination alpha. 683 // Table contains 256 ARGB values. 684 LIBYUV_API 685 int RGBColorTable(uint8_t* dst_argb, 686 int dst_stride_argb, 687 const uint8_t* table_argb, 688 int dst_x, 689 int dst_y, 690 int width, 691 int height); 692 693 // Apply a luma/color table each ARGB pixel but preserve destination alpha. 694 // Table contains 32768 values indexed by [Y][C] where 7 it 7 bit luma from 695 // RGB (YJ style) and C is an 8 bit color component (R, G or B). 696 LIBYUV_API 697 int ARGBLumaColorTable(const uint8_t* src_argb, 698 int src_stride_argb, 699 uint8_t* dst_argb, 700 int dst_stride_argb, 701 const uint8_t* luma, 702 int width, 703 int height); 704 705 // Apply a 3 term polynomial to ARGB values. 706 // poly points to a 4x4 matrix. The first row is constants. The 2nd row is 707 // coefficients for b, g, r and a. The 3rd row is coefficients for b squared, 708 // g squared, r squared and a squared. The 4rd row is coefficients for b to 709 // the 3, g to the 3, r to the 3 and a to the 3. The values are summed and 710 // result clamped to 0 to 255. 711 // A polynomial approximation can be dirived using software such as 'R'. 712 713 LIBYUV_API 714 int ARGBPolynomial(const uint8_t* src_argb, 715 int src_stride_argb, 716 uint8_t* dst_argb, 717 int dst_stride_argb, 718 const float* poly, 719 int width, 720 int height); 721 722 // Convert plane of 16 bit shorts to half floats. 723 // Source values are multiplied by scale before storing as half float. 724 LIBYUV_API 725 int HalfFloatPlane(const uint16_t* src_y, 726 int src_stride_y, 727 uint16_t* dst_y, 728 int dst_stride_y, 729 float scale, 730 int width, 731 int height); 732 733 // Convert a buffer of bytes to floats, scale the values and store as floats. 734 LIBYUV_API 735 int ByteToFloat(const uint8_t* src_y, float* dst_y, float scale, int width); 736 737 // Quantize a rectangle of ARGB. Alpha unaffected. 738 // scale is a 16 bit fractional fixed point scaler between 0 and 65535. 739 // interval_size should be a value between 1 and 255. 740 // interval_offset should be a value between 0 and 255. 741 LIBYUV_API 742 int ARGBQuantize(uint8_t* dst_argb, 743 int dst_stride_argb, 744 int scale, 745 int interval_size, 746 int interval_offset, 747 int dst_x, 748 int dst_y, 749 int width, 750 int height); 751 752 // Copy ARGB to ARGB. 753 LIBYUV_API 754 int ARGBCopy(const uint8_t* src_argb, 755 int src_stride_argb, 756 uint8_t* dst_argb, 757 int dst_stride_argb, 758 int width, 759 int height); 760 761 // Copy Alpha channel of ARGB to alpha of ARGB. 762 LIBYUV_API 763 int ARGBCopyAlpha(const uint8_t* src_argb, 764 int src_stride_argb, 765 uint8_t* dst_argb, 766 int dst_stride_argb, 767 int width, 768 int height); 769 770 // Extract the alpha channel from ARGB. 771 LIBYUV_API 772 int ARGBExtractAlpha(const uint8_t* src_argb, 773 int src_stride_argb, 774 uint8_t* dst_a, 775 int dst_stride_a, 776 int width, 777 int height); 778 779 // Copy Y channel to Alpha of ARGB. 780 LIBYUV_API 781 int ARGBCopyYToAlpha(const uint8_t* src_y, 782 int src_stride_y, 783 uint8_t* dst_argb, 784 int dst_stride_argb, 785 int width, 786 int height); 787 788 typedef void (*ARGBBlendRow)(const uint8_t* src_argb0, 789 const uint8_t* src_argb1, 790 uint8_t* dst_argb, 791 int width); 792 793 // Get function to Alpha Blend ARGB pixels and store to destination. 794 LIBYUV_API 795 ARGBBlendRow GetARGBBlend(); 796 797 // Alpha Blend ARGB images and store to destination. 798 // Source is pre-multiplied by alpha using ARGBAttenuate. 799 // Alpha of destination is set to 255. 800 LIBYUV_API 801 int ARGBBlend(const uint8_t* src_argb0, 802 int src_stride_argb0, 803 const uint8_t* src_argb1, 804 int src_stride_argb1, 805 uint8_t* dst_argb, 806 int dst_stride_argb, 807 int width, 808 int height); 809 810 // Alpha Blend plane and store to destination. 811 // Source is not pre-multiplied by alpha. 812 LIBYUV_API 813 int BlendPlane(const uint8_t* src_y0, 814 int src_stride_y0, 815 const uint8_t* src_y1, 816 int src_stride_y1, 817 const uint8_t* alpha, 818 int alpha_stride, 819 uint8_t* dst_y, 820 int dst_stride_y, 821 int width, 822 int height); 823 824 // Alpha Blend YUV images and store to destination. 825 // Source is not pre-multiplied by alpha. 826 // Alpha is full width x height and subsampled to half size to apply to UV. 827 LIBYUV_API 828 int I420Blend(const uint8_t* src_y0, 829 int src_stride_y0, 830 const uint8_t* src_u0, 831 int src_stride_u0, 832 const uint8_t* src_v0, 833 int src_stride_v0, 834 const uint8_t* src_y1, 835 int src_stride_y1, 836 const uint8_t* src_u1, 837 int src_stride_u1, 838 const uint8_t* src_v1, 839 int src_stride_v1, 840 const uint8_t* alpha, 841 int alpha_stride, 842 uint8_t* dst_y, 843 int dst_stride_y, 844 uint8_t* dst_u, 845 int dst_stride_u, 846 uint8_t* dst_v, 847 int dst_stride_v, 848 int width, 849 int height); 850 851 // Multiply ARGB image by ARGB image. Shifted down by 8. Saturates to 255. 852 LIBYUV_API 853 int ARGBMultiply(const uint8_t* src_argb0, 854 int src_stride_argb0, 855 const uint8_t* src_argb1, 856 int src_stride_argb1, 857 uint8_t* dst_argb, 858 int dst_stride_argb, 859 int width, 860 int height); 861 862 // Add ARGB image with ARGB image. Saturates to 255. 863 LIBYUV_API 864 int ARGBAdd(const uint8_t* src_argb0, 865 int src_stride_argb0, 866 const uint8_t* src_argb1, 867 int src_stride_argb1, 868 uint8_t* dst_argb, 869 int dst_stride_argb, 870 int width, 871 int height); 872 873 // Subtract ARGB image (argb1) from ARGB image (argb0). Saturates to 0. 874 LIBYUV_API 875 int ARGBSubtract(const uint8_t* src_argb0, 876 int src_stride_argb0, 877 const uint8_t* src_argb1, 878 int src_stride_argb1, 879 uint8_t* dst_argb, 880 int dst_stride_argb, 881 int width, 882 int height); 883 884 // Convert I422 to YUY2. 885 LIBYUV_API 886 int I422ToYUY2(const uint8_t* src_y, 887 int src_stride_y, 888 const uint8_t* src_u, 889 int src_stride_u, 890 const uint8_t* src_v, 891 int src_stride_v, 892 uint8_t* dst_yuy2, 893 int dst_stride_yuy2, 894 int width, 895 int height); 896 897 // Convert I422 to UYVY. 898 LIBYUV_API 899 int I422ToUYVY(const uint8_t* src_y, 900 int src_stride_y, 901 const uint8_t* src_u, 902 int src_stride_u, 903 const uint8_t* src_v, 904 int src_stride_v, 905 uint8_t* dst_uyvy, 906 int dst_stride_uyvy, 907 int width, 908 int height); 909 910 // Convert unattentuated ARGB to preattenuated ARGB. 911 LIBYUV_API 912 int ARGBAttenuate(const uint8_t* src_argb, 913 int src_stride_argb, 914 uint8_t* dst_argb, 915 int dst_stride_argb, 916 int width, 917 int height); 918 919 // Convert preattentuated ARGB to unattenuated ARGB. 920 LIBYUV_API 921 int ARGBUnattenuate(const uint8_t* src_argb, 922 int src_stride_argb, 923 uint8_t* dst_argb, 924 int dst_stride_argb, 925 int width, 926 int height); 927 928 // Internal function - do not call directly. 929 // Computes table of cumulative sum for image where the value is the sum 930 // of all values above and to the left of the entry. Used by ARGBBlur. 931 LIBYUV_API 932 int ARGBComputeCumulativeSum(const uint8_t* src_argb, 933 int src_stride_argb, 934 int32_t* dst_cumsum, 935 int dst_stride32_cumsum, 936 int width, 937 int height); 938 939 // Blur ARGB image. 940 // dst_cumsum table of width * (height + 1) * 16 bytes aligned to 941 // 16 byte boundary. 942 // dst_stride32_cumsum is number of ints in a row (width * 4). 943 // radius is number of pixels around the center. e.g. 1 = 3x3. 2=5x5. 944 // Blur is optimized for radius of 5 (11x11) or less. 945 LIBYUV_API 946 int ARGBBlur(const uint8_t* src_argb, 947 int src_stride_argb, 948 uint8_t* dst_argb, 949 int dst_stride_argb, 950 int32_t* dst_cumsum, 951 int dst_stride32_cumsum, 952 int width, 953 int height, 954 int radius); 955 956 // Gaussian 5x5 blur a float plane. 957 // Coefficients of 1, 4, 6, 4, 1. 958 // Each destination pixel is a blur of the 5x5 959 // pixels from the source. 960 // Source edges are clamped. 961 LIBYUV_API 962 int GaussPlane_F32(const float* src, 963 int src_stride, 964 float* dst, 965 int dst_stride, 966 int width, 967 int height); 968 969 // Multiply ARGB image by ARGB value. 970 LIBYUV_API 971 int ARGBShade(const uint8_t* src_argb, 972 int src_stride_argb, 973 uint8_t* dst_argb, 974 int dst_stride_argb, 975 int width, 976 int height, 977 uint32_t value); 978 979 // Interpolate between two images using specified amount of interpolation 980 // (0 to 255) and store to destination. 981 // 'interpolation' is specified as 8 bit fraction where 0 means 100% src0 982 // and 255 means 1% src0 and 99% src1. 983 LIBYUV_API 984 int InterpolatePlane(const uint8_t* src0, 985 int src_stride0, 986 const uint8_t* src1, 987 int src_stride1, 988 uint8_t* dst, 989 int dst_stride, 990 int width, 991 int height, 992 int interpolation); 993 994 // Interpolate between two images using specified amount of interpolation 995 // (0 to 255) and store to destination. 996 // 'interpolation' is specified as 8 bit fraction where 0 means 100% src0 997 // and 255 means 1% src0 and 99% src1. 998 LIBYUV_API 999 int InterpolatePlane_16(const uint16_t* src0, 1000 int src_stride0, // measured in 16 bit pixels 1001 const uint16_t* src1, 1002 int src_stride1, 1003 uint16_t* dst, 1004 int dst_stride, 1005 int width, 1006 int height, 1007 int interpolation); 1008 1009 // Interpolate between two ARGB images using specified amount of interpolation 1010 // Internally calls InterpolatePlane with width * 4 (bpp). 1011 LIBYUV_API 1012 int ARGBInterpolate(const uint8_t* src_argb0, 1013 int src_stride_argb0, 1014 const uint8_t* src_argb1, 1015 int src_stride_argb1, 1016 uint8_t* dst_argb, 1017 int dst_stride_argb, 1018 int width, 1019 int height, 1020 int interpolation); 1021 1022 // Interpolate between two YUV images using specified amount of interpolation 1023 // Internally calls InterpolatePlane on each plane where the U and V planes 1024 // are half width and half height. 1025 LIBYUV_API 1026 int I420Interpolate(const uint8_t* src0_y, 1027 int src0_stride_y, 1028 const uint8_t* src0_u, 1029 int src0_stride_u, 1030 const uint8_t* src0_v, 1031 int src0_stride_v, 1032 const uint8_t* src1_y, 1033 int src1_stride_y, 1034 const uint8_t* src1_u, 1035 int src1_stride_u, 1036 const uint8_t* src1_v, 1037 int src1_stride_v, 1038 uint8_t* dst_y, 1039 int dst_stride_y, 1040 uint8_t* dst_u, 1041 int dst_stride_u, 1042 uint8_t* dst_v, 1043 int dst_stride_v, 1044 int width, 1045 int height, 1046 int interpolation); 1047 1048 // Row function for copying pixels from a source with a slope to a row 1049 // of destination. Useful for scaling, rotation, mirror, texture mapping. 1050 LIBYUV_API 1051 void ARGBAffineRow_C(const uint8_t* src_argb, 1052 int src_argb_stride, 1053 uint8_t* dst_argb, 1054 const float* uv_dudv, 1055 int width); 1056 // TODO(fbarchard): Move ARGBAffineRow_SSE2 to row.h 1057 LIBYUV_API 1058 void ARGBAffineRow_SSE2(const uint8_t* src_argb, 1059 int src_argb_stride, 1060 uint8_t* dst_argb, 1061 const float* uv_dudv, 1062 int width); 1063 1064 // Shuffle ARGB channel order. e.g. BGRA to ARGB. 1065 // shuffler is 16 bytes. 1066 LIBYUV_API 1067 int ARGBShuffle(const uint8_t* src_bgra, 1068 int src_stride_bgra, 1069 uint8_t* dst_argb, 1070 int dst_stride_argb, 1071 const uint8_t* shuffler, 1072 int width, 1073 int height); 1074 1075 // Shuffle AR64 channel order. e.g. AR64 to AB64. 1076 // shuffler is 16 bytes. 1077 LIBYUV_API 1078 int AR64Shuffle(const uint16_t* src_ar64, 1079 int src_stride_ar64, 1080 uint16_t* dst_ar64, 1081 int dst_stride_ar64, 1082 const uint8_t* shuffler, 1083 int width, 1084 int height); 1085 1086 // Sobel ARGB effect with planar output. 1087 LIBYUV_API 1088 int ARGBSobelToPlane(const uint8_t* src_argb, 1089 int src_stride_argb, 1090 uint8_t* dst_y, 1091 int dst_stride_y, 1092 int width, 1093 int height); 1094 1095 // Sobel ARGB effect. 1096 LIBYUV_API 1097 int ARGBSobel(const uint8_t* src_argb, 1098 int src_stride_argb, 1099 uint8_t* dst_argb, 1100 int dst_stride_argb, 1101 int width, 1102 int height); 1103 1104 // Sobel ARGB effect w/ Sobel X, Sobel, Sobel Y in ARGB. 1105 LIBYUV_API 1106 int ARGBSobelXY(const uint8_t* src_argb, 1107 int src_stride_argb, 1108 uint8_t* dst_argb, 1109 int dst_stride_argb, 1110 int width, 1111 int height); 1112 1113 #ifdef __cplusplus 1114 } // extern "C" 1115 } // namespace libyuv 1116 #endif 1117 1118 #endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 1119