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_CONVERT_H_ 12 #define INCLUDE_LIBYUV_CONVERT_H_ 13 14 #include "libyuv/basic_types.h" 15 16 #include "libyuv/rotate.h" // For enum RotationMode. 17 18 // TODO(fbarchard): fix WebRTC source to include following libyuv headers: 19 #include "libyuv/convert_argb.h" // For WebRTC I420ToARGB. b/620 20 #include "libyuv/convert_from.h" // For WebRTC ConvertFromI420. b/620 21 #include "libyuv/planar_functions.h" // For WebRTC I420Rect, CopyPlane. b/618 22 23 #ifdef __cplusplus 24 namespace libyuv { 25 extern "C" { 26 #endif 27 28 // Convert I444 to I420. 29 LIBYUV_API 30 int I444ToI420(const uint8_t* src_y, 31 int src_stride_y, 32 const uint8_t* src_u, 33 int src_stride_u, 34 const uint8_t* src_v, 35 int src_stride_v, 36 uint8_t* dst_y, 37 int dst_stride_y, 38 uint8_t* dst_u, 39 int dst_stride_u, 40 uint8_t* dst_v, 41 int dst_stride_v, 42 int width, 43 int height); 44 45 // Convert I444 to NV12. 46 LIBYUV_API 47 int I444ToNV12(const uint8_t* src_y, 48 int src_stride_y, 49 const uint8_t* src_u, 50 int src_stride_u, 51 const uint8_t* src_v, 52 int src_stride_v, 53 uint8_t* dst_y, 54 int dst_stride_y, 55 uint8_t* dst_uv, 56 int dst_stride_uv, 57 int width, 58 int height); 59 60 // Convert I444 to NV21. 61 LIBYUV_API 62 int I444ToNV21(const uint8_t* src_y, 63 int src_stride_y, 64 const uint8_t* src_u, 65 int src_stride_u, 66 const uint8_t* src_v, 67 int src_stride_v, 68 uint8_t* dst_y, 69 int dst_stride_y, 70 uint8_t* dst_vu, 71 int dst_stride_vu, 72 int width, 73 int height); 74 75 // Convert I422 to I420. 76 LIBYUV_API 77 int I422ToI420(const uint8_t* src_y, 78 int src_stride_y, 79 const uint8_t* src_u, 80 int src_stride_u, 81 const uint8_t* src_v, 82 int src_stride_v, 83 uint8_t* dst_y, 84 int dst_stride_y, 85 uint8_t* dst_u, 86 int dst_stride_u, 87 uint8_t* dst_v, 88 int dst_stride_v, 89 int width, 90 int height); 91 92 // Convert I422 to I444. 93 LIBYUV_API 94 int I422ToI444(const uint8_t* src_y, 95 int src_stride_y, 96 const uint8_t* src_u, 97 int src_stride_u, 98 const uint8_t* src_v, 99 int src_stride_v, 100 uint8_t* dst_y, 101 int dst_stride_y, 102 uint8_t* dst_u, 103 int dst_stride_u, 104 uint8_t* dst_v, 105 int dst_stride_v, 106 int width, 107 int height); 108 109 // Convert I422 to I210. 110 LIBYUV_API 111 int I422ToI210(const uint8_t* src_y, 112 int src_stride_y, 113 const uint8_t* src_u, 114 int src_stride_u, 115 const uint8_t* src_v, 116 int src_stride_v, 117 uint16_t* dst_y, 118 int dst_stride_y, 119 uint16_t* dst_u, 120 int dst_stride_u, 121 uint16_t* dst_v, 122 int dst_stride_v, 123 int width, 124 int height); 125 126 // Convert MM21 to NV12. 127 LIBYUV_API 128 int MM21ToNV12(const uint8_t* src_y, 129 int src_stride_y, 130 const uint8_t* src_uv, 131 int src_stride_uv, 132 uint8_t* dst_y, 133 int dst_stride_y, 134 uint8_t* dst_uv, 135 int dst_stride_uv, 136 int width, 137 int height); 138 139 // Convert MM21 to I420. 140 LIBYUV_API 141 int MM21ToI420(const uint8_t* src_y, 142 int src_stride_y, 143 const uint8_t* src_uv, 144 int src_stride_uv, 145 uint8_t* dst_y, 146 int dst_stride_y, 147 uint8_t* dst_u, 148 int dst_stride_u, 149 uint8_t* dst_v, 150 int dst_stride_v, 151 int width, 152 int height); 153 154 // Convert I422 to NV21. 155 LIBYUV_API 156 int I422ToNV21(const uint8_t* src_y, 157 int src_stride_y, 158 const uint8_t* src_u, 159 int src_stride_u, 160 const uint8_t* src_v, 161 int src_stride_v, 162 uint8_t* dst_y, 163 int dst_stride_y, 164 uint8_t* dst_vu, 165 int dst_stride_vu, 166 int width, 167 int height); 168 169 // Copy I420 to I420. 170 #define I420ToI420 I420Copy 171 LIBYUV_API 172 int I420Copy(const uint8_t* src_y, 173 int src_stride_y, 174 const uint8_t* src_u, 175 int src_stride_u, 176 const uint8_t* src_v, 177 int src_stride_v, 178 uint8_t* dst_y, 179 int dst_stride_y, 180 uint8_t* dst_u, 181 int dst_stride_u, 182 uint8_t* dst_v, 183 int dst_stride_v, 184 int width, 185 int height); 186 187 // Convert I420 to I444. 188 LIBYUV_API 189 int I420ToI444(const uint8_t* src_y, 190 int src_stride_y, 191 const uint8_t* src_u, 192 int src_stride_u, 193 const uint8_t* src_v, 194 int src_stride_v, 195 uint8_t* dst_y, 196 int dst_stride_y, 197 uint8_t* dst_u, 198 int dst_stride_u, 199 uint8_t* dst_v, 200 int dst_stride_v, 201 int width, 202 int height); 203 204 // Copy I010 to I010 205 #define I010ToI010 I010Copy 206 #define H010ToH010 I010Copy 207 LIBYUV_API 208 int I010Copy(const uint16_t* src_y, 209 int src_stride_y, 210 const uint16_t* src_u, 211 int src_stride_u, 212 const uint16_t* src_v, 213 int src_stride_v, 214 uint16_t* dst_y, 215 int dst_stride_y, 216 uint16_t* dst_u, 217 int dst_stride_u, 218 uint16_t* dst_v, 219 int dst_stride_v, 220 int width, 221 int height); 222 223 // Convert 10 bit YUV to 8 bit 224 #define H010ToH420 I010ToI420 225 LIBYUV_API 226 int I010ToI420(const uint16_t* src_y, 227 int src_stride_y, 228 const uint16_t* src_u, 229 int src_stride_u, 230 const uint16_t* src_v, 231 int src_stride_v, 232 uint8_t* dst_y, 233 int dst_stride_y, 234 uint8_t* dst_u, 235 int dst_stride_u, 236 uint8_t* dst_v, 237 int dst_stride_v, 238 int width, 239 int height); 240 241 #define H210ToH420 I210ToI420 242 LIBYUV_API 243 int I210ToI420(const uint16_t* src_y, 244 int src_stride_y, 245 const uint16_t* src_u, 246 int src_stride_u, 247 const uint16_t* src_v, 248 int src_stride_v, 249 uint8_t* dst_y, 250 int dst_stride_y, 251 uint8_t* dst_u, 252 int dst_stride_u, 253 uint8_t* dst_v, 254 int dst_stride_v, 255 int width, 256 int height); 257 258 #define H210ToH422 I210ToI422 259 LIBYUV_API 260 int I210ToI422(const uint16_t* src_y, 261 int src_stride_y, 262 const uint16_t* src_u, 263 int src_stride_u, 264 const uint16_t* src_v, 265 int src_stride_v, 266 uint8_t* dst_y, 267 int dst_stride_y, 268 uint8_t* dst_u, 269 int dst_stride_u, 270 uint8_t* dst_v, 271 int dst_stride_v, 272 int width, 273 int height); 274 275 #define H410ToH444 I410ToI444 276 LIBYUV_API 277 int I410ToI444(const uint16_t* src_y, 278 int src_stride_y, 279 const uint16_t* src_u, 280 int src_stride_u, 281 const uint16_t* src_v, 282 int src_stride_v, 283 uint8_t* dst_y, 284 int dst_stride_y, 285 uint8_t* dst_u, 286 int dst_stride_u, 287 uint8_t* dst_v, 288 int dst_stride_v, 289 int width, 290 int height); 291 292 #define H012ToH420 I012ToI420 293 LIBYUV_API 294 int I012ToI420(const uint16_t* src_y, 295 int src_stride_y, 296 const uint16_t* src_u, 297 int src_stride_u, 298 const uint16_t* src_v, 299 int src_stride_v, 300 uint8_t* dst_y, 301 int dst_stride_y, 302 uint8_t* dst_u, 303 int dst_stride_u, 304 uint8_t* dst_v, 305 int dst_stride_v, 306 int width, 307 int height); 308 309 #define H212ToH422 I212ToI422 310 LIBYUV_API 311 int I212ToI422(const uint16_t* src_y, 312 int src_stride_y, 313 const uint16_t* src_u, 314 int src_stride_u, 315 const uint16_t* src_v, 316 int src_stride_v, 317 uint8_t* dst_y, 318 int dst_stride_y, 319 uint8_t* dst_u, 320 int dst_stride_u, 321 uint8_t* dst_v, 322 int dst_stride_v, 323 int width, 324 int height); 325 326 #define H412ToH444 I412ToI444 327 LIBYUV_API 328 int I412ToI444(const uint16_t* src_y, 329 int src_stride_y, 330 const uint16_t* src_u, 331 int src_stride_u, 332 const uint16_t* src_v, 333 int src_stride_v, 334 uint8_t* dst_y, 335 int dst_stride_y, 336 uint8_t* dst_u, 337 int dst_stride_u, 338 uint8_t* dst_v, 339 int dst_stride_v, 340 int width, 341 int height); 342 343 #define I412ToI012 I410ToI010 344 #define H410ToH010 I410ToI010 345 #define H412ToH012 I410ToI010 346 LIBYUV_API 347 int I410ToI010(const uint16_t* src_y, 348 int src_stride_y, 349 const uint16_t* src_u, 350 int src_stride_u, 351 const uint16_t* src_v, 352 int src_stride_v, 353 uint16_t* dst_y, 354 int dst_stride_y, 355 uint16_t* dst_u, 356 int dst_stride_u, 357 uint16_t* dst_v, 358 int dst_stride_v, 359 int width, 360 int height); 361 362 #define I212ToI012 I210ToI010 363 #define H210ToH010 I210ToI010 364 #define H212ToH012 I210ToI010 365 LIBYUV_API 366 int I210ToI010(const uint16_t* src_y, 367 int src_stride_y, 368 const uint16_t* src_u, 369 int src_stride_u, 370 const uint16_t* src_v, 371 int src_stride_v, 372 uint16_t* dst_y, 373 int dst_stride_y, 374 uint16_t* dst_u, 375 int dst_stride_u, 376 uint16_t* dst_v, 377 int dst_stride_v, 378 int width, 379 int height); 380 381 // Convert I010 to I410 382 LIBYUV_API 383 int I010ToI410(const uint16_t* src_y, 384 int src_stride_y, 385 const uint16_t* src_u, 386 int src_stride_u, 387 const uint16_t* src_v, 388 int src_stride_v, 389 uint16_t* dst_y, 390 int dst_stride_y, 391 uint16_t* dst_u, 392 int dst_stride_u, 393 uint16_t* dst_v, 394 int dst_stride_v, 395 int width, 396 int height); 397 398 // Convert I012 to I412 399 #define I012ToI412 I010ToI410 400 401 // Convert I210 to I410 402 LIBYUV_API 403 int I210ToI410(const uint16_t* src_y, 404 int src_stride_y, 405 const uint16_t* src_u, 406 int src_stride_u, 407 const uint16_t* src_v, 408 int src_stride_v, 409 uint16_t* dst_y, 410 int dst_stride_y, 411 uint16_t* dst_u, 412 int dst_stride_u, 413 uint16_t* dst_v, 414 int dst_stride_v, 415 int width, 416 int height); 417 418 // Convert I212 to I412 419 #define I212ToI412 I210ToI410 420 421 // Convert I010 to P010 422 LIBYUV_API 423 int I010ToP010(const uint16_t* src_y, 424 int src_stride_y, 425 const uint16_t* src_u, 426 int src_stride_u, 427 const uint16_t* src_v, 428 int src_stride_v, 429 uint16_t* dst_y, 430 int dst_stride_y, 431 uint16_t* dst_uv, 432 int dst_stride_uv, 433 int width, 434 int height); 435 436 // Convert I210 to P210 437 LIBYUV_API 438 int I210ToP210(const uint16_t* src_y, 439 int src_stride_y, 440 const uint16_t* src_u, 441 int src_stride_u, 442 const uint16_t* src_v, 443 int src_stride_v, 444 uint16_t* dst_y, 445 int dst_stride_y, 446 uint16_t* dst_uv, 447 int dst_stride_uv, 448 int width, 449 int height); 450 451 // Convert I012 to P012 452 LIBYUV_API 453 int I012ToP012(const uint16_t* src_y, 454 int src_stride_y, 455 const uint16_t* src_u, 456 int src_stride_u, 457 const uint16_t* src_v, 458 int src_stride_v, 459 uint16_t* dst_y, 460 int dst_stride_y, 461 uint16_t* dst_uv, 462 int dst_stride_uv, 463 int width, 464 int height); 465 466 // Convert I212 to P212 467 LIBYUV_API 468 int I212ToP212(const uint16_t* src_y, 469 int src_stride_y, 470 const uint16_t* src_u, 471 int src_stride_u, 472 const uint16_t* src_v, 473 int src_stride_v, 474 uint16_t* dst_y, 475 int dst_stride_y, 476 uint16_t* dst_uv, 477 int dst_stride_uv, 478 int width, 479 int height); 480 481 // Convert I400 (grey) to I420. 482 LIBYUV_API 483 int I400ToI420(const uint8_t* src_y, 484 int src_stride_y, 485 uint8_t* dst_y, 486 int dst_stride_y, 487 uint8_t* dst_u, 488 int dst_stride_u, 489 uint8_t* dst_v, 490 int dst_stride_v, 491 int width, 492 int height); 493 494 // Convert I400 (grey) to NV21. 495 LIBYUV_API 496 int I400ToNV21(const uint8_t* src_y, 497 int src_stride_y, 498 uint8_t* dst_y, 499 int dst_stride_y, 500 uint8_t* dst_vu, 501 int dst_stride_vu, 502 int width, 503 int height); 504 505 #define J400ToJ420 I400ToI420 506 507 // Convert NV12 to I420. 508 LIBYUV_API 509 int NV12ToI420(const uint8_t* src_y, 510 int src_stride_y, 511 const uint8_t* src_uv, 512 int src_stride_uv, 513 uint8_t* dst_y, 514 int dst_stride_y, 515 uint8_t* dst_u, 516 int dst_stride_u, 517 uint8_t* dst_v, 518 int dst_stride_v, 519 int width, 520 int height); 521 522 // Convert NV21 to I420. 523 LIBYUV_API 524 int NV21ToI420(const uint8_t* src_y, 525 int src_stride_y, 526 const uint8_t* src_vu, 527 int src_stride_vu, 528 uint8_t* dst_y, 529 int dst_stride_y, 530 uint8_t* dst_u, 531 int dst_stride_u, 532 uint8_t* dst_v, 533 int dst_stride_v, 534 int width, 535 int height); 536 537 // Convert NV12 to NV24. 538 LIBYUV_API 539 int NV12ToNV24(const uint8_t* src_y, 540 int src_stride_y, 541 const uint8_t* src_uv, 542 int src_stride_uv, 543 uint8_t* dst_y, 544 int dst_stride_y, 545 uint8_t* dst_uv, 546 int dst_stride_uv, 547 int width, 548 int height); 549 550 // Convert NV16 to NV24. 551 LIBYUV_API 552 int NV16ToNV24(const uint8_t* src_y, 553 int src_stride_y, 554 const uint8_t* src_uv, 555 int src_stride_uv, 556 uint8_t* dst_y, 557 int dst_stride_y, 558 uint8_t* dst_uv, 559 int dst_stride_uv, 560 int width, 561 int height); 562 563 // Convert P010 to P410. 564 LIBYUV_API 565 int P010ToP410(const uint16_t* src_y, 566 int src_stride_y, 567 const uint16_t* src_uv, 568 int src_stride_uv, 569 uint16_t* dst_y, 570 int dst_stride_y, 571 uint16_t* dst_uv, 572 int dst_stride_uv, 573 int width, 574 int height); 575 576 // Convert P012 to P412. 577 #define P012ToP412 P010ToP410 578 579 // Convert P016 to P416. 580 #define P016ToP416 P010ToP410 581 582 // Convert P210 to P410. 583 LIBYUV_API 584 int P210ToP410(const uint16_t* src_y, 585 int src_stride_y, 586 const uint16_t* src_uv, 587 int src_stride_uv, 588 uint16_t* dst_y, 589 int dst_stride_y, 590 uint16_t* dst_uv, 591 int dst_stride_uv, 592 int width, 593 int height); 594 595 // Convert P212 to P412. 596 #define P212ToP412 P210ToP410 597 598 // Convert P216 to P416. 599 #define P216ToP416 P210ToP410 600 601 // Convert YUY2 to I420. 602 LIBYUV_API 603 int YUY2ToI420(const uint8_t* src_yuy2, 604 int src_stride_yuy2, 605 uint8_t* dst_y, 606 int dst_stride_y, 607 uint8_t* dst_u, 608 int dst_stride_u, 609 uint8_t* dst_v, 610 int dst_stride_v, 611 int width, 612 int height); 613 614 // Convert UYVY to I420. 615 LIBYUV_API 616 int UYVYToI420(const uint8_t* src_uyvy, 617 int src_stride_uyvy, 618 uint8_t* dst_y, 619 int dst_stride_y, 620 uint8_t* dst_u, 621 int dst_stride_u, 622 uint8_t* dst_v, 623 int dst_stride_v, 624 int width, 625 int height); 626 627 // Convert AYUV to NV12. 628 LIBYUV_API 629 int AYUVToNV12(const uint8_t* src_ayuv, 630 int src_stride_ayuv, 631 uint8_t* dst_y, 632 int dst_stride_y, 633 uint8_t* dst_uv, 634 int dst_stride_uv, 635 int width, 636 int height); 637 638 // Convert AYUV to NV21. 639 LIBYUV_API 640 int AYUVToNV21(const uint8_t* src_ayuv, 641 int src_stride_ayuv, 642 uint8_t* dst_y, 643 int dst_stride_y, 644 uint8_t* dst_vu, 645 int dst_stride_vu, 646 int width, 647 int height); 648 649 // Convert Android420 to I420. 650 LIBYUV_API 651 int Android420ToI420(const uint8_t* src_y, 652 int src_stride_y, 653 const uint8_t* src_u, 654 int src_stride_u, 655 const uint8_t* src_v, 656 int src_stride_v, 657 int src_pixel_stride_uv, 658 uint8_t* dst_y, 659 int dst_stride_y, 660 uint8_t* dst_u, 661 int dst_stride_u, 662 uint8_t* dst_v, 663 int dst_stride_v, 664 int width, 665 int height); 666 667 // ARGB little endian (bgra in memory) to I420. 668 LIBYUV_API 669 int ARGBToI420(const uint8_t* src_argb, 670 int src_stride_argb, 671 uint8_t* dst_y, 672 int dst_stride_y, 673 uint8_t* dst_u, 674 int dst_stride_u, 675 uint8_t* dst_v, 676 int dst_stride_v, 677 int width, 678 int height); 679 680 // BGRA little endian (argb in memory) to I420. 681 LIBYUV_API 682 int BGRAToI420(const uint8_t* src_bgra, 683 int src_stride_bgra, 684 uint8_t* dst_y, 685 int dst_stride_y, 686 uint8_t* dst_u, 687 int dst_stride_u, 688 uint8_t* dst_v, 689 int dst_stride_v, 690 int width, 691 int height); 692 693 // ABGR little endian (rgba in memory) to I420. 694 LIBYUV_API 695 int ABGRToI420(const uint8_t* src_abgr, 696 int src_stride_abgr, 697 uint8_t* dst_y, 698 int dst_stride_y, 699 uint8_t* dst_u, 700 int dst_stride_u, 701 uint8_t* dst_v, 702 int dst_stride_v, 703 int width, 704 int height); 705 706 // RGBA little endian (abgr in memory) to I420. 707 LIBYUV_API 708 int RGBAToI420(const uint8_t* src_rgba, 709 int src_stride_rgba, 710 uint8_t* dst_y, 711 int dst_stride_y, 712 uint8_t* dst_u, 713 int dst_stride_u, 714 uint8_t* dst_v, 715 int dst_stride_v, 716 int width, 717 int height); 718 719 // RGB little endian (bgr in memory) to I420. 720 LIBYUV_API 721 int RGB24ToI420(const uint8_t* src_rgb24, 722 int src_stride_rgb24, 723 uint8_t* dst_y, 724 int dst_stride_y, 725 uint8_t* dst_u, 726 int dst_stride_u, 727 uint8_t* dst_v, 728 int dst_stride_v, 729 int width, 730 int height); 731 732 // RGB little endian (bgr in memory) to J420. 733 LIBYUV_API 734 int RGB24ToJ420(const uint8_t* src_rgb24, 735 int src_stride_rgb24, 736 uint8_t* dst_y, 737 int dst_stride_y, 738 uint8_t* dst_u, 739 int dst_stride_u, 740 uint8_t* dst_v, 741 int dst_stride_v, 742 int width, 743 int height); 744 745 // RGB big endian (rgb in memory) to I420. 746 LIBYUV_API 747 int RAWToI420(const uint8_t* src_raw, 748 int src_stride_raw, 749 uint8_t* dst_y, 750 int dst_stride_y, 751 uint8_t* dst_u, 752 int dst_stride_u, 753 uint8_t* dst_v, 754 int dst_stride_v, 755 int width, 756 int height); 757 758 // RGB big endian (rgb in memory) to J420. 759 LIBYUV_API 760 int RAWToJ420(const uint8_t* src_raw, 761 int src_stride_raw, 762 uint8_t* dst_y, 763 int dst_stride_y, 764 uint8_t* dst_u, 765 int dst_stride_u, 766 uint8_t* dst_v, 767 int dst_stride_v, 768 int width, 769 int height); 770 771 // RGB16 (RGBP fourcc) little endian to I420. 772 LIBYUV_API 773 int RGB565ToI420(const uint8_t* src_rgb565, 774 int src_stride_rgb565, 775 uint8_t* dst_y, 776 int dst_stride_y, 777 uint8_t* dst_u, 778 int dst_stride_u, 779 uint8_t* dst_v, 780 int dst_stride_v, 781 int width, 782 int height); 783 784 // RGB15 (RGBO fourcc) little endian to I420. 785 LIBYUV_API 786 int ARGB1555ToI420(const uint8_t* src_argb1555, 787 int src_stride_argb1555, 788 uint8_t* dst_y, 789 int dst_stride_y, 790 uint8_t* dst_u, 791 int dst_stride_u, 792 uint8_t* dst_v, 793 int dst_stride_v, 794 int width, 795 int height); 796 797 // RGB12 (R444 fourcc) little endian to I420. 798 LIBYUV_API 799 int ARGB4444ToI420(const uint8_t* src_argb4444, 800 int src_stride_argb4444, 801 uint8_t* dst_y, 802 int dst_stride_y, 803 uint8_t* dst_u, 804 int dst_stride_u, 805 uint8_t* dst_v, 806 int dst_stride_v, 807 int width, 808 int height); 809 810 // RGB little endian (bgr in memory) to J400. 811 LIBYUV_API 812 int RGB24ToJ400(const uint8_t* src_rgb24, 813 int src_stride_rgb24, 814 uint8_t* dst_yj, 815 int dst_stride_yj, 816 int width, 817 int height); 818 819 // RGB big endian (rgb in memory) to J400. 820 LIBYUV_API 821 int RAWToJ400(const uint8_t* src_raw, 822 int src_stride_raw, 823 uint8_t* dst_yj, 824 int dst_stride_yj, 825 int width, 826 int height); 827 828 // src_width/height provided by capture. 829 // dst_width/height for clipping determine final size. 830 LIBYUV_API 831 int MJPGToI420(const uint8_t* sample, 832 size_t sample_size, 833 uint8_t* dst_y, 834 int dst_stride_y, 835 uint8_t* dst_u, 836 int dst_stride_u, 837 uint8_t* dst_v, 838 int dst_stride_v, 839 int src_width, 840 int src_height, 841 int dst_width, 842 int dst_height); 843 844 // JPEG to NV21 845 LIBYUV_API 846 int MJPGToNV21(const uint8_t* sample, 847 size_t sample_size, 848 uint8_t* dst_y, 849 int dst_stride_y, 850 uint8_t* dst_vu, 851 int dst_stride_vu, 852 int src_width, 853 int src_height, 854 int dst_width, 855 int dst_height); 856 857 // JPEG to NV12 858 LIBYUV_API 859 int MJPGToNV12(const uint8_t* sample, 860 size_t sample_size, 861 uint8_t* dst_y, 862 int dst_stride_y, 863 uint8_t* dst_uv, 864 int dst_stride_uv, 865 int src_width, 866 int src_height, 867 int dst_width, 868 int dst_height); 869 870 // Query size of MJPG in pixels. 871 LIBYUV_API 872 int MJPGSize(const uint8_t* sample, 873 size_t sample_size, 874 int* width, 875 int* height); 876 877 // Convert camera sample to I420 with cropping, rotation and vertical flip. 878 // "src_size" is needed to parse MJPG. 879 // "dst_stride_y" number of bytes in a row of the dst_y plane. 880 // Normally this would be the same as dst_width, with recommended alignment 881 // to 16 bytes for better efficiency. 882 // If rotation of 90 or 270 is used, stride is affected. The caller should 883 // allocate the I420 buffer according to rotation. 884 // "dst_stride_u" number of bytes in a row of the dst_u plane. 885 // Normally this would be the same as (dst_width + 1) / 2, with 886 // recommended alignment to 16 bytes for better efficiency. 887 // If rotation of 90 or 270 is used, stride is affected. 888 // "crop_x" and "crop_y" are starting position for cropping. 889 // To center, crop_x = (src_width - dst_width) / 2 890 // crop_y = (src_height - dst_height) / 2 891 // "src_width" / "src_height" is size of src_frame in pixels. 892 // "src_height" can be negative indicating a vertically flipped image source. 893 // "crop_width" / "crop_height" is the size to crop the src to. 894 // Must be less than or equal to src_width/src_height 895 // Cropping parameters are pre-rotation. 896 // "rotation" can be 0, 90, 180 or 270. 897 // "fourcc" is a fourcc. ie 'I420', 'YUY2' 898 // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 899 LIBYUV_API 900 int ConvertToI420(const uint8_t* sample, 901 size_t sample_size, 902 uint8_t* dst_y, 903 int dst_stride_y, 904 uint8_t* dst_u, 905 int dst_stride_u, 906 uint8_t* dst_v, 907 int dst_stride_v, 908 int crop_x, 909 int crop_y, 910 int src_width, 911 int src_height, 912 int crop_width, 913 int crop_height, 914 enum RotationMode rotation, 915 uint32_t fourcc); 916 917 #ifdef __cplusplus 918 } // extern "C" 919 } // namespace libyuv 920 #endif 921 922 #endif // INCLUDE_LIBYUV_CONVERT_H_ 923