Changeset 5633 for pjproject/trunk/third_party/yuv/source/scale.cc
- Timestamp:
- Jul 28, 2017 2:51:44 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/third_party/yuv/source/scale.cc
r5358 r5633 34 34 // its original size. 35 35 36 static void ScalePlaneDown2(int src_width, int src_height, 37 int dst_width, int dst_height, 38 int src_stride, int dst_stride, 39 const uint8* src_ptr, uint8* dst_ptr, 36 static void ScalePlaneDown2(int src_width, 37 int src_height, 38 int dst_width, 39 int dst_height, 40 int src_stride, 41 int dst_stride, 42 const uint8* src_ptr, 43 uint8* dst_ptr, 40 44 enum FilterMode filtering) { 41 45 int y; 42 46 void (*ScaleRowDown2)(const uint8* src_ptr, ptrdiff_t src_stride, 43 47 uint8* dst_ptr, int dst_width) = 44 filtering == kFilterNone ? ScaleRowDown2_C : 45 (filtering == kFilterLinear ? ScaleRowDown2Linear_C : ScaleRowDown2Box_C); 48 filtering == kFilterNone 49 ? ScaleRowDown2_C 50 : (filtering == kFilterLinear ? ScaleRowDown2Linear_C 51 : ScaleRowDown2Box_C); 46 52 int row_stride = src_stride << 1; 53 (void)src_width; 54 (void)src_height; 47 55 if (!filtering) { 48 56 src_ptr += src_stride; // Point to odd rows. … … 52 60 #if defined(HAS_SCALEROWDOWN2_NEON) 53 61 if (TestCpuFlag(kCpuHasNEON)) { 54 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_NEON : 55 (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_NEON : 56 ScaleRowDown2Box_Any_NEON); 62 ScaleRowDown2 = 63 filtering == kFilterNone 64 ? ScaleRowDown2_Any_NEON 65 : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_NEON 66 : ScaleRowDown2Box_Any_NEON); 57 67 if (IS_ALIGNED(dst_width, 16)) { 58 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_NEON : 59 (filtering == kFilterLinear ? ScaleRowDown2Linear_NEON : 60 ScaleRowDown2Box_NEON); 68 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_NEON 69 : (filtering == kFilterLinear 70 ? ScaleRowDown2Linear_NEON 71 : ScaleRowDown2Box_NEON); 61 72 } 62 73 } … … 64 75 #if defined(HAS_SCALEROWDOWN2_SSSE3) 65 76 if (TestCpuFlag(kCpuHasSSSE3)) { 66 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_SSSE3 : 67 (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_SSSE3 : 68 ScaleRowDown2Box_Any_SSSE3); 77 ScaleRowDown2 = 78 filtering == kFilterNone 79 ? ScaleRowDown2_Any_SSSE3 80 : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_SSSE3 81 : ScaleRowDown2Box_Any_SSSE3); 69 82 if (IS_ALIGNED(dst_width, 16)) { 70 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_SSSE3 : 71 (filtering == kFilterLinear ? ScaleRowDown2Linear_SSSE3 : 72 ScaleRowDown2Box_SSSE3); 83 ScaleRowDown2 = 84 filtering == kFilterNone 85 ? ScaleRowDown2_SSSE3 86 : (filtering == kFilterLinear ? ScaleRowDown2Linear_SSSE3 87 : ScaleRowDown2Box_SSSE3); 73 88 } 74 89 } … … 76 91 #if defined(HAS_SCALEROWDOWN2_AVX2) 77 92 if (TestCpuFlag(kCpuHasAVX2)) { 78 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_Any_AVX2 : 79 (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_AVX2 : 80 ScaleRowDown2Box_Any_AVX2); 93 ScaleRowDown2 = 94 filtering == kFilterNone 95 ? ScaleRowDown2_Any_AVX2 96 : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_AVX2 97 : ScaleRowDown2Box_Any_AVX2); 81 98 if (IS_ALIGNED(dst_width, 32)) { 82 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_AVX2 : 83 (filtering == kFilterLinear ? ScaleRowDown2Linear_AVX2 : 84 ScaleRowDown2Box_AVX2); 99 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_AVX2 100 : (filtering == kFilterLinear 101 ? ScaleRowDown2Linear_AVX2 102 : ScaleRowDown2Box_AVX2); 85 103 } 86 104 } … … 90 108 IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) && 91 109 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 92 ScaleRowDown2 = filtering ? 93 ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2; 110 ScaleRowDown2 = filtering ? ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2; 111 } 112 #endif 113 #if defined(HAS_SCALEROWDOWN2_MSA) 114 if (TestCpuFlag(kCpuHasMSA)) { 115 ScaleRowDown2 = 116 filtering == kFilterNone 117 ? ScaleRowDown2_Any_MSA 118 : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_MSA 119 : ScaleRowDown2Box_Any_MSA); 120 if (IS_ALIGNED(dst_width, 32)) { 121 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_MSA 122 : (filtering == kFilterLinear 123 ? ScaleRowDown2Linear_MSA 124 : ScaleRowDown2Box_MSA); 125 } 94 126 } 95 127 #endif … … 106 138 } 107 139 108 static void ScalePlaneDown2_16(int src_width, int src_height, 109 int dst_width, int dst_height, 110 int src_stride, int dst_stride, 111 const uint16* src_ptr, uint16* dst_ptr, 140 static void ScalePlaneDown2_16(int src_width, 141 int src_height, 142 int dst_width, 143 int dst_height, 144 int src_stride, 145 int dst_stride, 146 const uint16* src_ptr, 147 uint16* dst_ptr, 112 148 enum FilterMode filtering) { 113 149 int y; 114 150 void (*ScaleRowDown2)(const uint16* src_ptr, ptrdiff_t src_stride, 115 151 uint16* dst_ptr, int dst_width) = 116 filtering == kFilterNone ? ScaleRowDown2_16_C : 117 (filtering == kFilterLinear ? ScaleRowDown2Linear_16_C : 118 ScaleRowDown2Box_16_C); 152 filtering == kFilterNone 153 ? ScaleRowDown2_16_C 154 : (filtering == kFilterLinear ? ScaleRowDown2Linear_16_C 155 : ScaleRowDown2Box_16_C); 119 156 int row_stride = src_stride << 1; 157 (void)src_width; 158 (void)src_height; 120 159 if (!filtering) { 121 160 src_ptr += src_stride; // Point to odd rows. … … 125 164 #if defined(HAS_SCALEROWDOWN2_16_NEON) 126 165 if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 16)) { 127 ScaleRowDown2 = filtering ? ScaleRowDown2Box_16_NEON :128 ScaleRowDown2_16_NEON;166 ScaleRowDown2 = 167 filtering ? ScaleRowDown2Box_16_NEON : ScaleRowDown2_16_NEON; 129 168 } 130 169 #endif 131 170 #if defined(HAS_SCALEROWDOWN2_16_SSE2) 132 171 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 16)) { 133 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_16_SSE2 : 134 (filtering == kFilterLinear ? ScaleRowDown2Linear_16_SSE2 : 135 ScaleRowDown2Box_16_SSE2); 172 ScaleRowDown2 = 173 filtering == kFilterNone 174 ? ScaleRowDown2_16_SSE2 175 : (filtering == kFilterLinear ? ScaleRowDown2Linear_16_SSE2 176 : ScaleRowDown2Box_16_SSE2); 136 177 } 137 178 #endif … … 140 181 IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) && 141 182 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 142 ScaleRowDown2 = filtering ?143 ScaleRowDown2Box_16_DSPR2 : ScaleRowDown2_16_DSPR2;183 ScaleRowDown2 = 184 filtering ? ScaleRowDown2Box_16_DSPR2 : ScaleRowDown2_16_DSPR2; 144 185 } 145 186 #endif … … 160 201 // its original size. 161 202 162 static void ScalePlaneDown4(int src_width, int src_height, 163 int dst_width, int dst_height, 164 int src_stride, int dst_stride, 165 const uint8* src_ptr, uint8* dst_ptr, 203 static void ScalePlaneDown4(int src_width, 204 int src_height, 205 int dst_width, 206 int dst_height, 207 int src_stride, 208 int dst_stride, 209 const uint8* src_ptr, 210 uint8* dst_ptr, 166 211 enum FilterMode filtering) { 167 212 int y; … … 170 215 filtering ? ScaleRowDown4Box_C : ScaleRowDown4_C; 171 216 int row_stride = src_stride << 2; 217 (void)src_width; 218 (void)src_height; 172 219 if (!filtering) { 173 220 src_ptr += src_stride * 2; // Point to row 2. … … 176 223 #if defined(HAS_SCALEROWDOWN4_NEON) 177 224 if (TestCpuFlag(kCpuHasNEON)) { 178 ScaleRowDown4 = filtering ?179 ScaleRowDown4Box_Any_NEON : ScaleRowDown4_Any_NEON;225 ScaleRowDown4 = 226 filtering ? ScaleRowDown4Box_Any_NEON : ScaleRowDown4_Any_NEON; 180 227 if (IS_ALIGNED(dst_width, 8)) { 181 228 ScaleRowDown4 = filtering ? ScaleRowDown4Box_NEON : ScaleRowDown4_NEON; … … 185 232 #if defined(HAS_SCALEROWDOWN4_SSSE3) 186 233 if (TestCpuFlag(kCpuHasSSSE3)) { 187 ScaleRowDown4 = filtering ?188 ScaleRowDown4Box_Any_SSSE3 : ScaleRowDown4_Any_SSSE3;234 ScaleRowDown4 = 235 filtering ? ScaleRowDown4Box_Any_SSSE3 : ScaleRowDown4_Any_SSSE3; 189 236 if (IS_ALIGNED(dst_width, 8)) { 190 237 ScaleRowDown4 = filtering ? ScaleRowDown4Box_SSSE3 : ScaleRowDown4_SSSE3; … … 194 241 #if defined(HAS_SCALEROWDOWN4_AVX2) 195 242 if (TestCpuFlag(kCpuHasAVX2)) { 196 ScaleRowDown4 = filtering ?197 ScaleRowDown4Box_Any_AVX2 : ScaleRowDown4_Any_AVX2;243 ScaleRowDown4 = 244 filtering ? ScaleRowDown4Box_Any_AVX2 : ScaleRowDown4_Any_AVX2; 198 245 if (IS_ALIGNED(dst_width, 16)) { 199 246 ScaleRowDown4 = filtering ? ScaleRowDown4Box_AVX2 : ScaleRowDown4_AVX2; … … 205 252 IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) && 206 253 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 207 ScaleRowDown4 = filtering ? 208 ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2; 254 ScaleRowDown4 = filtering ? ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2; 255 } 256 #endif 257 #if defined(HAS_SCALEROWDOWN4_MSA) 258 if (TestCpuFlag(kCpuHasMSA)) { 259 ScaleRowDown4 = 260 filtering ? ScaleRowDown4Box_Any_MSA : ScaleRowDown4_Any_MSA; 261 if (IS_ALIGNED(dst_width, 16)) { 262 ScaleRowDown4 = filtering ? ScaleRowDown4Box_MSA : ScaleRowDown4_MSA; 263 } 209 264 } 210 265 #endif … … 220 275 } 221 276 222 static void ScalePlaneDown4_16(int src_width, int src_height, 223 int dst_width, int dst_height, 224 int src_stride, int dst_stride, 225 const uint16* src_ptr, uint16* dst_ptr, 277 static void ScalePlaneDown4_16(int src_width, 278 int src_height, 279 int dst_width, 280 int dst_height, 281 int src_stride, 282 int dst_stride, 283 const uint16* src_ptr, 284 uint16* dst_ptr, 226 285 enum FilterMode filtering) { 227 286 int y; … … 230 289 filtering ? ScaleRowDown4Box_16_C : ScaleRowDown4_16_C; 231 290 int row_stride = src_stride << 2; 291 (void)src_width; 292 (void)src_height; 232 293 if (!filtering) { 233 294 src_ptr += src_stride * 2; // Point to row 2. … … 236 297 #if defined(HAS_SCALEROWDOWN4_16_NEON) 237 298 if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 8)) { 238 ScaleRowDown4 = filtering ? ScaleRowDown4Box_16_NEON :239 ScaleRowDown4_16_NEON;299 ScaleRowDown4 = 300 filtering ? ScaleRowDown4Box_16_NEON : ScaleRowDown4_16_NEON; 240 301 } 241 302 #endif 242 303 #if defined(HAS_SCALEROWDOWN4_16_SSE2) 243 304 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { 244 ScaleRowDown4 = filtering ? ScaleRowDown4Box_16_SSE2 :245 ScaleRowDown4_16_SSE2;305 ScaleRowDown4 = 306 filtering ? ScaleRowDown4Box_16_SSE2 : ScaleRowDown4_16_SSE2; 246 307 } 247 308 #endif … … 250 311 IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) && 251 312 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 252 ScaleRowDown4 = filtering ?253 ScaleRowDown4Box_16_DSPR2 : ScaleRowDown4_16_DSPR2;313 ScaleRowDown4 = 314 filtering ? ScaleRowDown4Box_16_DSPR2 : ScaleRowDown4_16_DSPR2; 254 315 } 255 316 #endif … … 266 327 267 328 // Scale plane down, 3/4 268 269 static void ScalePlaneDown34(int src_width, int src_height, 270 int dst_width, int dst_height, 271 int src_stride, int dst_stride, 272 const uint8* src_ptr, uint8* dst_ptr, 329 static void ScalePlaneDown34(int src_width, 330 int src_height, 331 int dst_width, 332 int dst_height, 333 int src_stride, 334 int dst_stride, 335 const uint8* src_ptr, 336 uint8* dst_ptr, 273 337 enum FilterMode filtering) { 274 338 int y; … … 278 342 uint8* dst_ptr, int dst_width); 279 343 const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 344 (void)src_width; 345 (void)src_height; 280 346 assert(dst_width % 3 == 0); 281 347 if (!filtering) { … … 347 413 src_ptr += src_stride; 348 414 dst_ptr += dst_stride; 349 ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, 350 dst_ptr, dst_width); 415 ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, dst_ptr, dst_width); 351 416 src_ptr += src_stride * 2; 352 417 dst_ptr += dst_stride; … … 364 429 } 365 430 366 static void ScalePlaneDown34_16(int src_width, int src_height, 367 int dst_width, int dst_height, 368 int src_stride, int dst_stride, 369 const uint16* src_ptr, uint16* dst_ptr, 431 static void ScalePlaneDown34_16(int src_width, 432 int src_height, 433 int dst_width, 434 int dst_height, 435 int src_stride, 436 int dst_stride, 437 const uint16* src_ptr, 438 uint16* dst_ptr, 370 439 enum FilterMode filtering) { 371 440 int y; … … 375 444 uint16* dst_ptr, int dst_width); 376 445 const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 446 (void)src_width; 447 (void)src_height; 377 448 assert(dst_width % 3 == 0); 378 449 if (!filtering) { … … 426 497 src_ptr += src_stride; 427 498 dst_ptr += dst_stride; 428 ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, 429 dst_ptr, dst_width); 499 ScaleRowDown34_0(src_ptr + src_stride, -filter_stride, dst_ptr, dst_width); 430 500 src_ptr += src_stride * 2; 431 501 dst_ptr += dst_stride; … … 442 512 } 443 513 } 444 445 514 446 515 // Scale plane, 3/8 … … 459 528 // Boxes are 3x3, 2x3, 3x2 and 2x2 460 529 461 static void ScalePlaneDown38(int src_width, int src_height, 462 int dst_width, int dst_height, 463 int src_stride, int dst_stride, 464 const uint8* src_ptr, uint8* dst_ptr, 530 static void ScalePlaneDown38(int src_width, 531 int src_height, 532 int dst_width, 533 int dst_height, 534 int src_stride, 535 int dst_stride, 536 const uint8* src_ptr, 537 uint8* dst_ptr, 465 538 enum FilterMode filtering) { 466 539 int y; … … 471 544 const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 472 545 assert(dst_width % 3 == 0); 546 (void)src_width; 547 (void)src_height; 473 548 if (!filtering) { 474 549 ScaleRowDown38_3 = ScaleRowDown38_C; … … 531 606 } 532 607 #endif 608 #if defined(HAS_SCALEROWDOWN38_MSA) 609 if (TestCpuFlag(kCpuHasMSA)) { 610 if (!filtering) { 611 ScaleRowDown38_3 = ScaleRowDown38_Any_MSA; 612 ScaleRowDown38_2 = ScaleRowDown38_Any_MSA; 613 } else { 614 ScaleRowDown38_3 = ScaleRowDown38_3_Box_Any_MSA; 615 ScaleRowDown38_2 = ScaleRowDown38_2_Box_Any_MSA; 616 } 617 if (dst_width % 12 == 0) { 618 if (!filtering) { 619 ScaleRowDown38_3 = ScaleRowDown38_MSA; 620 ScaleRowDown38_2 = ScaleRowDown38_MSA; 621 } else { 622 ScaleRowDown38_3 = ScaleRowDown38_3_Box_MSA; 623 ScaleRowDown38_2 = ScaleRowDown38_2_Box_MSA; 624 } 625 } 626 } 627 #endif 533 628 534 629 for (y = 0; y < dst_height - 2; y += 3) { … … 555 650 } 556 651 557 static void ScalePlaneDown38_16(int src_width, int src_height, 558 int dst_width, int dst_height, 559 int src_stride, int dst_stride, 560 const uint16* src_ptr, uint16* dst_ptr, 652 static void ScalePlaneDown38_16(int src_width, 653 int src_height, 654 int dst_width, 655 int dst_height, 656 int src_stride, 657 int dst_stride, 658 const uint16* src_ptr, 659 uint16* dst_ptr, 561 660 enum FilterMode filtering) { 562 661 int y; … … 566 665 uint16* dst_ptr, int dst_width); 567 666 const int filter_stride = (filtering == kFilterLinear) ? 0 : src_stride; 667 (void)src_width; 668 (void)src_height; 568 669 assert(dst_width % 3 == 0); 569 670 if (!filtering) { … … 655 756 } 656 757 657 static void ScaleAddCols2_C(int dst_width, int boxheight, int x, int dx, 658 const uint16* src_ptr, uint8* dst_ptr) { 758 static void ScaleAddCols2_C(int dst_width, 759 int boxheight, 760 int x, 761 int dx, 762 const uint16* src_ptr, 763 uint8* dst_ptr) { 659 764 int i; 660 765 int scaletbl[2]; … … 667 772 x += dx; 668 773 boxwidth = MIN1((x >> 16) - ix); 669 *dst_ptr++ = SumPixels(boxwidth, src_ptr + ix) * 670 scaletbl[boxwidth - minboxwidth] >> 16; 671 } 672 } 673 674 static void ScaleAddCols2_16_C(int dst_width, int boxheight, int x, int dx, 675 const uint32* src_ptr, uint16* dst_ptr) { 774 *dst_ptr++ = 775 SumPixels(boxwidth, src_ptr + ix) * scaletbl[boxwidth - minboxwidth] >> 776 16; 777 } 778 } 779 780 static void ScaleAddCols2_16_C(int dst_width, 781 int boxheight, 782 int x, 783 int dx, 784 const uint32* src_ptr, 785 uint16* dst_ptr) { 676 786 int i; 677 787 int scaletbl[2]; … … 685 795 boxwidth = MIN1((x >> 16) - ix); 686 796 *dst_ptr++ = SumPixels_16(boxwidth, src_ptr + ix) * 687 scaletbl[boxwidth - minboxwidth] >> 16; 688 } 689 } 690 691 static void ScaleAddCols0_C(int dst_width, int boxheight, int x, int, 692 const uint16* src_ptr, uint8* dst_ptr) { 797 scaletbl[boxwidth - minboxwidth] >> 798 16; 799 } 800 } 801 802 static void ScaleAddCols0_C(int dst_width, 803 int boxheight, 804 int x, 805 int, 806 const uint16* src_ptr, 807 uint8* dst_ptr) { 693 808 int scaleval = 65536 / boxheight; 694 809 int i; … … 699 814 } 700 815 701 static void ScaleAddCols1_C(int dst_width, int boxheight, int x, int dx, 702 const uint16* src_ptr, uint8* dst_ptr) { 816 static void ScaleAddCols1_C(int dst_width, 817 int boxheight, 818 int x, 819 int dx, 820 const uint16* src_ptr, 821 uint8* dst_ptr) { 703 822 int boxwidth = MIN1(dx >> 16); 704 823 int scaleval = 65536 / (boxwidth * boxheight); … … 711 830 } 712 831 713 static void ScaleAddCols1_16_C(int dst_width, int boxheight, int x, int dx, 714 const uint32* src_ptr, uint16* dst_ptr) { 832 static void ScaleAddCols1_16_C(int dst_width, 833 int boxheight, 834 int x, 835 int dx, 836 const uint32* src_ptr, 837 uint16* dst_ptr) { 715 838 int boxwidth = MIN1(dx >> 16); 716 839 int scaleval = 65536 / (boxwidth * boxheight); … … 729 852 // through source, sampling a box of pixel with simple 730 853 // averaging. 731 static void ScalePlaneBox(int src_width, int src_height, 732 int dst_width, int dst_height, 733 int src_stride, int dst_stride, 734 const uint8* src_ptr, uint8* dst_ptr) { 854 static void ScalePlaneBox(int src_width, 855 int src_height, 856 int dst_width, 857 int dst_height, 858 int src_stride, 859 int dst_stride, 860 const uint8* src_ptr, 861 uint8* dst_ptr) { 735 862 int j, k; 736 863 // Initial source x/y coordinate and step values as 16.16 fixed point. … … 740 867 int dy = 0; 741 868 const int max_y = (src_height << 16); 742 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, 743 & x, &y, &dx, &dy);869 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, &x, &y, 870 &dx, &dy); 744 871 src_width = Abs(src_width); 745 872 { … … 747 874 align_buffer_64(row16, src_width * 2); 748 875 void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, 749 const uint16* src_ptr, uint8* dst_ptr) =750 (dx & 0xffff) ? ScaleAddCols2_C :751 ((dx != 0x10000) ? ScaleAddCols1_C : ScaleAddCols0_C);876 const uint16* src_ptr, uint8* dst_ptr) = 877 (dx & 0xffff) ? ScaleAddCols2_C 878 : ((dx != 0x10000) ? ScaleAddCols1_C : ScaleAddCols0_C); 752 879 void (*ScaleAddRow)(const uint8* src_ptr, uint16* dst_ptr, int src_width) = 753 880 ScaleAddRow_C; … … 773 900 if (IS_ALIGNED(src_width, 16)) { 774 901 ScaleAddRow = ScaleAddRow_NEON; 902 } 903 } 904 #endif 905 #if defined(HAS_SCALEADDROW_MSA) 906 if (TestCpuFlag(kCpuHasMSA)) { 907 ScaleAddRow = ScaleAddRow_Any_MSA; 908 if (IS_ALIGNED(src_width, 16)) { 909 ScaleAddRow = ScaleAddRow_MSA; 910 } 911 } 912 #endif 913 #if defined(HAS_SCALEADDROW_DSPR2) 914 if (TestCpuFlag(kCpuHasDSPR2)) { 915 ScaleAddRow = ScaleAddRow_Any_DSPR2; 916 if (IS_ALIGNED(src_width, 16)) { 917 ScaleAddRow = ScaleAddRow_DSPR2; 775 918 } 776 919 } … … 788 931 memset(row16, 0, src_width * 2); 789 932 for (k = 0; k < boxheight; ++k) { 790 ScaleAddRow(src, (uint16 933 ScaleAddRow(src, (uint16*)(row16), src_width); 791 934 src += src_stride; 792 935 } … … 798 941 } 799 942 800 static void ScalePlaneBox_16(int src_width, int src_height, 801 int dst_width, int dst_height, 802 int src_stride, int dst_stride, 803 const uint16* src_ptr, uint16* dst_ptr) { 943 static void ScalePlaneBox_16(int src_width, 944 int src_height, 945 int dst_width, 946 int dst_height, 947 int src_stride, 948 int dst_stride, 949 const uint16* src_ptr, 950 uint16* dst_ptr) { 804 951 int j, k; 805 952 // Initial source x/y coordinate and step values as 16.16 fixed point. … … 809 956 int dy = 0; 810 957 const int max_y = (src_height << 16); 811 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, 812 & x, &y, &dx, &dy);958 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterBox, &x, &y, 959 &dx, &dy); 813 960 src_width = Abs(src_width); 814 961 { … … 816 963 align_buffer_64(row32, src_width * 4); 817 964 void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, 818 const uint32* src_ptr, uint16* dst_ptr) =819 (dx & 0xffff) ? ScaleAddCols2_16_C : ScaleAddCols1_16_C;965 const uint32* src_ptr, uint16* dst_ptr) = 966 (dx & 0xffff) ? ScaleAddCols2_16_C : ScaleAddCols1_16_C; 820 967 void (*ScaleAddRow)(const uint16* src_ptr, uint32* dst_ptr, int src_width) = 821 968 ScaleAddRow_16_C; … … 838 985 memset(row32, 0, src_width * 4); 839 986 for (k = 0; k < boxheight; ++k) { 840 ScaleAddRow(src, (uint32 987 ScaleAddRow(src, (uint32*)(row32), src_width); 841 988 src += src_stride; 842 989 } … … 849 996 850 997 // Scale plane down with bilinear interpolation. 851 void ScalePlaneBilinearDown(int src_width, int src_height, 852 int dst_width, int dst_height, 853 int src_stride, int dst_stride, 854 const uint8* src_ptr, uint8* dst_ptr, 998 void ScalePlaneBilinearDown(int src_width, 999 int src_height, 1000 int dst_width, 1001 int dst_height, 1002 int src_stride, 1003 int dst_stride, 1004 const uint8* src_ptr, 1005 uint8* dst_ptr, 855 1006 enum FilterMode filtering) { 856 1007 // Initial source x/y coordinate and step values as 16.16 fixed point. … … 865 1016 const int max_y = (src_height - 1) << 16; 866 1017 int j; 867 void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr,868 int dst_width,int x, int dx) =1018 void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, 1019 int x, int dx) = 869 1020 (src_width >= 32768) ? ScaleFilterCols64_C : ScaleFilterCols_C; 870 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr,871 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =872 InterpolateRow_C;873 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 874 & x, &y, &dx, &dy);1021 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 1022 ptrdiff_t src_stride, int dst_width, 1023 int source_y_fraction) = InterpolateRow_C; 1024 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 1025 &dx, &dy); 875 1026 src_width = Abs(src_width); 876 1027 … … 907 1058 } 908 1059 #endif 909 1060 #if defined(HAS_INTERPOLATEROW_MSA) 1061 if (TestCpuFlag(kCpuHasMSA)) { 1062 InterpolateRow = InterpolateRow_Any_MSA; 1063 if (IS_ALIGNED(src_width, 32)) { 1064 InterpolateRow = InterpolateRow_MSA; 1065 } 1066 } 1067 #endif 910 1068 911 1069 #if defined(HAS_SCALEFILTERCOLS_SSSE3) … … 945 1103 } 946 1104 947 void ScalePlaneBilinearDown_16(int src_width, int src_height, 948 int dst_width, int dst_height, 949 int src_stride, int dst_stride, 950 const uint16* src_ptr, uint16* dst_ptr, 1105 void ScalePlaneBilinearDown_16(int src_width, 1106 int src_height, 1107 int dst_width, 1108 int dst_height, 1109 int src_stride, 1110 int dst_stride, 1111 const uint16* src_ptr, 1112 uint16* dst_ptr, 951 1113 enum FilterMode filtering) { 952 1114 // Initial source x/y coordinate and step values as 16.16 fixed point. … … 961 1123 const int max_y = (src_height - 1) << 16; 962 1124 int j; 963 void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr,964 int dst_width, int x, int dx) =1125 void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr, 1126 int dst_width, int x, int dx) = 965 1127 (src_width >= 32768) ? ScaleFilterCols64_16_C : ScaleFilterCols_16_C; 966 void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr,967 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =968 InterpolateRow_16_C;969 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 970 & x, &y, &dx, &dy);1128 void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr, 1129 ptrdiff_t src_stride, int dst_width, 1130 int source_y_fraction) = InterpolateRow_16_C; 1131 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 1132 &dx, &dy); 971 1133 src_width = Abs(src_width); 972 1134 … … 1011 1173 } 1012 1174 #endif 1013 1014 1175 1015 1176 #if defined(HAS_SCALEFILTERCOLS_16_SSSE3) … … 1042 1203 1043 1204 // Scale up down with bilinear interpolation. 1044 void ScalePlaneBilinearUp(int src_width, int src_height, 1045 int dst_width, int dst_height, 1046 int src_stride, int dst_stride, 1047 const uint8* src_ptr, uint8* dst_ptr, 1205 void ScalePlaneBilinearUp(int src_width, 1206 int src_height, 1207 int dst_width, 1208 int dst_height, 1209 int src_stride, 1210 int dst_stride, 1211 const uint8* src_ptr, 1212 uint8* dst_ptr, 1048 1213 enum FilterMode filtering) { 1049 1214 int j; … … 1054 1219 int dy = 0; 1055 1220 const int max_y = (src_height - 1) << 16; 1056 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr,1057 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =1058 InterpolateRow_C;1059 void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr,1060 int dst_width,int x, int dx) =1221 void (*InterpolateRow)(uint8 * dst_ptr, const uint8* src_ptr, 1222 ptrdiff_t src_stride, int dst_width, 1223 int source_y_fraction) = InterpolateRow_C; 1224 void (*ScaleFilterCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, 1225 int x, int dx) = 1061 1226 filtering ? ScaleFilterCols_C : ScaleCols_C; 1062 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 1063 & x, &y, &dx, &dy);1227 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 1228 &dx, &dy); 1064 1229 src_width = Abs(src_width); 1065 1230 … … 1173 1338 } 1174 1339 1175 void ScalePlaneBilinearUp_16(int src_width, int src_height, 1176 int dst_width, int dst_height, 1177 int src_stride, int dst_stride, 1178 const uint16* src_ptr, uint16* dst_ptr, 1340 void ScalePlaneBilinearUp_16(int src_width, 1341 int src_height, 1342 int dst_width, 1343 int dst_height, 1344 int src_stride, 1345 int dst_stride, 1346 const uint16* src_ptr, 1347 uint16* dst_ptr, 1179 1348 enum FilterMode filtering) { 1180 1349 int j; … … 1185 1354 int dy = 0; 1186 1355 const int max_y = (src_height - 1) << 16; 1187 void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr,1188 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =1189 InterpolateRow_16_C;1190 void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr,1191 int dst_width, int x, int dx) =1356 void (*InterpolateRow)(uint16 * dst_ptr, const uint16* src_ptr, 1357 ptrdiff_t src_stride, int dst_width, 1358 int source_y_fraction) = InterpolateRow_16_C; 1359 void (*ScaleFilterCols)(uint16 * dst_ptr, const uint16* src_ptr, 1360 int dst_width, int x, int dx) = 1192 1361 filtering ? ScaleFilterCols_16_C : ScaleCols_16_C; 1193 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 1194 & x, &y, &dx, &dy);1362 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 1363 &dx, &dy); 1195 1364 src_width = Abs(src_width); 1196 1365 … … 1309 1478 // the lower 16 bits are the fixed decimal part. 1310 1479 1311 static void ScalePlaneSimple(int src_width, int src_height, 1312 int dst_width, int dst_height, 1313 int src_stride, int dst_stride, 1314 const uint8* src_ptr, uint8* dst_ptr) { 1480 static void ScalePlaneSimple(int src_width, 1481 int src_height, 1482 int dst_width, 1483 int dst_height, 1484 int src_stride, 1485 int dst_stride, 1486 const uint8* src_ptr, 1487 uint8* dst_ptr) { 1315 1488 int i; 1316 void (*ScaleCols)(uint8 * dst_ptr, const uint8* src_ptr,1317 int dst_width, int x,int dx) = ScaleCols_C;1489 void (*ScaleCols)(uint8 * dst_ptr, const uint8* src_ptr, int dst_width, int x, 1490 int dx) = ScaleCols_C; 1318 1491 // Initial source x/y coordinate and step values as 16.16 fixed point. 1319 1492 int x = 0; … … 1321 1494 int dx = 0; 1322 1495 int dy = 0; 1323 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, 1324 & x, &y, &dx, &dy);1496 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, &x, &y, 1497 &dx, &dy); 1325 1498 src_width = Abs(src_width); 1326 1499 … … 1341 1514 } 1342 1515 1343 static void ScalePlaneSimple_16(int src_width, int src_height, 1344 int dst_width, int dst_height, 1345 int src_stride, int dst_stride, 1346 const uint16* src_ptr, uint16* dst_ptr) { 1516 static void ScalePlaneSimple_16(int src_width, 1517 int src_height, 1518 int dst_width, 1519 int dst_height, 1520 int src_stride, 1521 int dst_stride, 1522 const uint16* src_ptr, 1523 uint16* dst_ptr) { 1347 1524 int i; 1348 void (*ScaleCols)(uint16 * dst_ptr, const uint16* src_ptr,1349 int dst_width,int x, int dx) = ScaleCols_16_C;1525 void (*ScaleCols)(uint16 * dst_ptr, const uint16* src_ptr, int dst_width, 1526 int x, int dx) = ScaleCols_16_C; 1350 1527 // Initial source x/y coordinate and step values as 16.16 fixed point. 1351 1528 int x = 0; … … 1353 1530 int dx = 0; 1354 1531 int dy = 0; 1355 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, 1356 & x, &y, &dx, &dy);1532 ScaleSlope(src_width, src_height, dst_width, dst_height, kFilterNone, &x, &y, 1533 &dx, &dy); 1357 1534 src_width = Abs(src_width); 1358 1535 … … 1367 1544 1368 1545 for (i = 0; i < dst_height; ++i) { 1369 ScaleCols(dst_ptr, src_ptr + (y >> 16) * src_stride, 1370 dst_width, x, dx); 1546 ScaleCols(dst_ptr, src_ptr + (y >> 16) * src_stride, dst_width, x, dx); 1371 1547 dst_ptr += dst_stride; 1372 1548 y += dy; … … 1378 1554 1379 1555 LIBYUV_API 1380 void ScalePlane(const uint8* src, int src_stride, 1381 int src_width, int src_height, 1382 uint8* dst, int dst_stride, 1383 int dst_width, int dst_height, 1556 void ScalePlane(const uint8* src, 1557 int src_stride, 1558 int src_width, 1559 int src_height, 1560 uint8* dst, 1561 int dst_stride, 1562 int dst_width, 1563 int dst_height, 1384 1564 enum FilterMode filtering) { 1385 1565 // Simplify filtering when possible. 1386 filtering = ScaleFilterReduce(src_width, src_height, 1387 dst_width, dst_height,filtering);1566 filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 1567 filtering); 1388 1568 1389 1569 // Negative height means invert the image. … … 1404 1584 int dy = FixedDiv(src_height, dst_height); 1405 1585 // Arbitrary scale vertically, but unscaled horizontally. 1406 ScalePlaneVertical(src_height, 1407 dst_width, dst_height, 1408 src_stride, dst_stride, src, dst, 1409 0, 0, dy, 1, filtering); 1586 ScalePlaneVertical(src_height, dst_width, dst_height, src_stride, 1587 dst_stride, src, dst, 0, 0, dy, 1, filtering); 1410 1588 return; 1411 1589 } 1412 1590 if (dst_width <= Abs(src_width) && dst_height <= src_height) { 1413 1591 // Scale down. 1414 if (4 * dst_width == 3 * src_width && 1415 4 * dst_height == 3 * src_height) { 1592 if (4 * dst_width == 3 * src_width && 4 * dst_height == 3 * src_height) { 1416 1593 // optimized, 3/4 1417 ScalePlaneDown34(src_width, src_height, dst_width, dst_height, 1418 src_stride,dst_stride, src, dst, filtering);1594 ScalePlaneDown34(src_width, src_height, dst_width, dst_height, src_stride, 1595 dst_stride, src, dst, filtering); 1419 1596 return; 1420 1597 } 1421 1598 if (2 * dst_width == src_width && 2 * dst_height == src_height) { 1422 1599 // optimized, 1/2 1423 ScalePlaneDown2(src_width, src_height, dst_width, dst_height, 1424 src_stride,dst_stride, src, dst, filtering);1600 ScalePlaneDown2(src_width, src_height, dst_width, dst_height, src_stride, 1601 dst_stride, src, dst, filtering); 1425 1602 return; 1426 1603 } 1427 1604 // 3/8 rounded up for odd sized chroma height. 1428 if (8 * dst_width == 3 * src_width && 1429 dst_height == ((src_height * 3 + 7) / 8)) { 1605 if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) { 1430 1606 // optimized, 3/8 1431 ScalePlaneDown38(src_width, src_height, dst_width, dst_height, 1432 src_stride,dst_stride, src, dst, filtering);1607 ScalePlaneDown38(src_width, src_height, dst_width, dst_height, src_stride, 1608 dst_stride, src, dst, filtering); 1433 1609 return; 1434 1610 } … … 1436 1612 (filtering == kFilterBox || filtering == kFilterNone)) { 1437 1613 // optimized, 1/4 1438 ScalePlaneDown4(src_width, src_height, dst_width, dst_height, 1439 src_stride,dst_stride, src, dst, filtering);1614 ScalePlaneDown4(src_width, src_height, dst_width, dst_height, src_stride, 1615 dst_stride, src, dst, filtering); 1440 1616 return; 1441 1617 } 1442 1618 } 1443 1619 if (filtering == kFilterBox && dst_height * 2 < src_height) { 1444 ScalePlaneBox(src_width, src_height, dst_width, dst_height, 1445 src_stride,dst_stride, src, dst);1620 ScalePlaneBox(src_width, src_height, dst_width, dst_height, src_stride, 1621 dst_stride, src, dst); 1446 1622 return; 1447 1623 } … … 1456 1632 return; 1457 1633 } 1458 ScalePlaneSimple(src_width, src_height, dst_width, dst_height, 1459 src_stride,dst_stride, src, dst);1634 ScalePlaneSimple(src_width, src_height, dst_width, dst_height, src_stride, 1635 dst_stride, src, dst); 1460 1636 } 1461 1637 1462 1638 LIBYUV_API 1463 void ScalePlane_16(const uint16* src, int src_stride, 1464 int src_width, int src_height, 1465 uint16* dst, int dst_stride, 1466 int dst_width, int dst_height, 1467 enum FilterMode filtering) { 1639 void ScalePlane_16(const uint16* src, 1640 int src_stride, 1641 int src_width, 1642 int src_height, 1643 uint16* dst, 1644 int dst_stride, 1645 int dst_width, 1646 int dst_height, 1647 enum FilterMode filtering) { 1468 1648 // Simplify filtering when possible. 1469 filtering = ScaleFilterReduce(src_width, src_height, 1470 dst_width, dst_height,filtering);1649 filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 1650 filtering); 1471 1651 1472 1652 // Negative height means invert the image. … … 1487 1667 int dy = FixedDiv(src_height, dst_height); 1488 1668 // Arbitrary scale vertically, but unscaled vertically. 1489 ScalePlaneVertical_16(src_height, 1490 dst_width, dst_height, 1491 src_stride, dst_stride, src, dst, 1492 0, 0, dy, 1, filtering); 1669 ScalePlaneVertical_16(src_height, dst_width, dst_height, src_stride, 1670 dst_stride, src, dst, 0, 0, dy, 1, filtering); 1493 1671 return; 1494 1672 } 1495 1673 if (dst_width <= Abs(src_width) && dst_height <= src_height) { 1496 1674 // Scale down. 1497 if (4 * dst_width == 3 * src_width && 1498 4 * dst_height == 3 * src_height) { 1675 if (4 * dst_width == 3 * src_width && 4 * dst_height == 3 * src_height) { 1499 1676 // optimized, 3/4 1500 1677 ScalePlaneDown34_16(src_width, src_height, dst_width, dst_height, … … 1509 1686 } 1510 1687 // 3/8 rounded up for odd sized chroma height. 1511 if (8 * dst_width == 3 * src_width && 1512 dst_height == ((src_height * 3 + 7) / 8)) { 1688 if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) { 1513 1689 // optimized, 3/8 1514 1690 ScalePlaneDown38_16(src_width, src_height, dst_width, dst_height, … … 1517 1693 } 1518 1694 if (4 * dst_width == src_width && 4 * dst_height == src_height && 1519 1695 filtering != kFilterBilinear) { 1520 1696 // optimized, 1/4 1521 1697 ScalePlaneDown4_16(src_width, src_height, dst_width, dst_height, … … 1525 1701 } 1526 1702 if (filtering == kFilterBox && dst_height * 2 < src_height) { 1527 ScalePlaneBox_16(src_width, src_height, dst_width, dst_height, 1528 src_stride,dst_stride, src, dst);1703 ScalePlaneBox_16(src_width, src_height, dst_width, dst_height, src_stride, 1704 dst_stride, src, dst); 1529 1705 return; 1530 1706 } … … 1539 1715 return; 1540 1716 } 1541 ScalePlaneSimple_16(src_width, src_height, dst_width, dst_height, 1542 src_stride,dst_stride, src, dst);1717 ScalePlaneSimple_16(src_width, src_height, dst_width, dst_height, src_stride, 1718 dst_stride, src, dst); 1543 1719 } 1544 1720 … … 1547 1723 1548 1724 LIBYUV_API 1549 int I420Scale(const uint8* src_y, int src_stride_y, 1550 const uint8* src_u, int src_stride_u, 1551 const uint8* src_v, int src_stride_v, 1552 int src_width, int src_height, 1553 uint8* dst_y, int dst_stride_y, 1554 uint8* dst_u, int dst_stride_u, 1555 uint8* dst_v, int dst_stride_v, 1556 int dst_width, int dst_height, 1725 int I420Scale(const uint8* src_y, 1726 int src_stride_y, 1727 const uint8* src_u, 1728 int src_stride_u, 1729 const uint8* src_v, 1730 int src_stride_v, 1731 int src_width, 1732 int src_height, 1733 uint8* dst_y, 1734 int dst_stride_y, 1735 uint8* dst_u, 1736 int dst_stride_u, 1737 uint8* dst_v, 1738 int dst_stride_v, 1739 int dst_width, 1740 int dst_height, 1557 1741 enum FilterMode filtering) { 1558 1742 int src_halfwidth = SUBSAMPLE(src_width, 1, 1); … … 1561 1745 int dst_halfheight = SUBSAMPLE(dst_height, 1, 1); 1562 1746 if (!src_y || !src_u || !src_v || src_width == 0 || src_height == 0 || 1563 src_width > 32768 || src_height > 32768 || 1564 !dst_y || !dst_u || !dst_v ||dst_width <= 0 || dst_height <= 0) {1747 src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v || 1748 dst_width <= 0 || dst_height <= 0) { 1565 1749 return -1; 1566 1750 } 1567 1751 1568 ScalePlane(src_y, src_stride_y, src_width, src_height, 1569 dst_y, dst_stride_y, dst_width, dst_height, 1570 filtering); 1571 ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight, 1572 dst_u, dst_stride_u, dst_halfwidth, dst_halfheight, 1573 filtering); 1574 ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight, 1575 dst_v, dst_stride_v, dst_halfwidth, dst_halfheight, 1576 filtering); 1752 ScalePlane(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y, 1753 dst_width, dst_height, filtering); 1754 ScalePlane(src_u, src_stride_u, src_halfwidth, src_halfheight, dst_u, 1755 dst_stride_u, dst_halfwidth, dst_halfheight, filtering); 1756 ScalePlane(src_v, src_stride_v, src_halfwidth, src_halfheight, dst_v, 1757 dst_stride_v, dst_halfwidth, dst_halfheight, filtering); 1577 1758 return 0; 1578 1759 } 1579 1760 1580 1761 LIBYUV_API 1581 int I420Scale_16(const uint16* src_y, int src_stride_y, 1582 const uint16* src_u, int src_stride_u, 1583 const uint16* src_v, int src_stride_v, 1584 int src_width, int src_height, 1585 uint16* dst_y, int dst_stride_y, 1586 uint16* dst_u, int dst_stride_u, 1587 uint16* dst_v, int dst_stride_v, 1588 int dst_width, int dst_height, 1762 int I420Scale_16(const uint16* src_y, 1763 int src_stride_y, 1764 const uint16* src_u, 1765 int src_stride_u, 1766 const uint16* src_v, 1767 int src_stride_v, 1768 int src_width, 1769 int src_height, 1770 uint16* dst_y, 1771 int dst_stride_y, 1772 uint16* dst_u, 1773 int dst_stride_u, 1774 uint16* dst_v, 1775 int dst_stride_v, 1776 int dst_width, 1777 int dst_height, 1589 1778 enum FilterMode filtering) { 1590 1779 int src_halfwidth = SUBSAMPLE(src_width, 1, 1); … … 1593 1782 int dst_halfheight = SUBSAMPLE(dst_height, 1, 1); 1594 1783 if (!src_y || !src_u || !src_v || src_width == 0 || src_height == 0 || 1595 src_width > 32768 || src_height > 32768 || 1596 !dst_y || !dst_u || !dst_v ||dst_width <= 0 || dst_height <= 0) {1784 src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v || 1785 dst_width <= 0 || dst_height <= 0) { 1597 1786 return -1; 1598 1787 } 1599 1788 1600 ScalePlane_16(src_y, src_stride_y, src_width, src_height, 1601 dst_y, dst_stride_y, dst_width, dst_height, 1602 filtering); 1603 ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_halfheight, 1604 dst_u, dst_stride_u, dst_halfwidth, dst_halfheight, 1605 filtering); 1606 ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_halfheight, 1607 dst_v, dst_stride_v, dst_halfwidth, dst_halfheight, 1608 filtering); 1789 ScalePlane_16(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y, 1790 dst_width, dst_height, filtering); 1791 ScalePlane_16(src_u, src_stride_u, src_halfwidth, src_halfheight, dst_u, 1792 dst_stride_u, dst_halfwidth, dst_halfheight, filtering); 1793 ScalePlane_16(src_v, src_stride_v, src_halfwidth, src_halfheight, dst_v, 1794 dst_stride_v, dst_halfwidth, dst_halfheight, filtering); 1609 1795 return 0; 1610 1796 } … … 1612 1798 // Deprecated api 1613 1799 LIBYUV_API 1614 int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 1615 int src_stride_y, int src_stride_u, int src_stride_v, 1616 int src_width, int src_height, 1617 uint8* dst_y, uint8* dst_u, uint8* dst_v, 1618 int dst_stride_y, int dst_stride_u, int dst_stride_v, 1619 int dst_width, int dst_height, 1800 int Scale(const uint8* src_y, 1801 const uint8* src_u, 1802 const uint8* src_v, 1803 int src_stride_y, 1804 int src_stride_u, 1805 int src_stride_v, 1806 int src_width, 1807 int src_height, 1808 uint8* dst_y, 1809 uint8* dst_u, 1810 uint8* dst_v, 1811 int dst_stride_y, 1812 int dst_stride_u, 1813 int dst_stride_v, 1814 int dst_width, 1815 int dst_height, 1620 1816 LIBYUV_BOOL interpolate) { 1621 return I420Scale(src_y, src_stride_y, 1622 src_u, src_stride_u, 1623 src_v, src_stride_v, 1624 src_width, src_height, 1625 dst_y, dst_stride_y, 1626 dst_u, dst_stride_u, 1627 dst_v, dst_stride_v, 1628 dst_width, dst_height, 1629 interpolate ? kFilterBox : kFilterNone); 1817 return I420Scale(src_y, src_stride_y, src_u, src_stride_u, src_v, 1818 src_stride_v, src_width, src_height, dst_y, dst_stride_y, 1819 dst_u, dst_stride_u, dst_v, dst_stride_v, dst_width, 1820 dst_height, interpolate ? kFilterBox : kFilterNone); 1630 1821 } 1631 1822 1632 1823 // Deprecated api 1633 1824 LIBYUV_API 1634 int ScaleOffset(const uint8* src, int src_width, int src_height, 1635 uint8* dst, int dst_width, int dst_height, int dst_yoffset, 1825 int ScaleOffset(const uint8* src, 1826 int src_width, 1827 int src_height, 1828 uint8* dst, 1829 int dst_width, 1830 int dst_height, 1831 int dst_yoffset, 1636 1832 LIBYUV_BOOL interpolate) { 1637 1833 // Chroma requires offset to multiple of 2. … … 1644 1840 const uint8* src_y = src; 1645 1841 const uint8* src_u = src + src_width * src_height; 1646 const uint8* src_v = src + src_width * src_height +1647 1842 const uint8* src_v = 1843 src + src_width * src_height + src_halfwidth * src_halfheight; 1648 1844 uint8* dst_y = dst + dst_yoffset_even * dst_width; 1649 uint8* dst_u = dst + dst_width * dst_height +1650 1845 uint8* dst_u = 1846 dst + dst_width * dst_height + (dst_yoffset_even >> 1) * dst_halfwidth; 1651 1847 uint8* dst_v = dst + dst_width * dst_height + dst_halfwidth * dst_halfheight + 1652 1848 (dst_yoffset_even >> 1) * dst_halfwidth; 1653 if (!src || src_width <= 0 || src_height <= 0 || 1654 !dst || dst_width <= 0 ||dst_height <= 0 || dst_yoffset_even < 0 ||1849 if (!src || src_width <= 0 || src_height <= 0 || !dst || dst_width <= 0 || 1850 dst_height <= 0 || dst_yoffset_even < 0 || 1655 1851 dst_yoffset_even >= dst_height) { 1656 1852 return -1; 1657 1853 } 1658 return I420Scale(src_y, src_width, 1659 src_u, src_halfwidth, 1660 src_v, src_halfwidth, 1661 src_width, src_height, 1662 dst_y, dst_width, 1663 dst_u, dst_halfwidth, 1664 dst_v, dst_halfwidth, 1665 dst_width, aheight, 1854 return I420Scale(src_y, src_width, src_u, src_halfwidth, src_v, src_halfwidth, 1855 src_width, src_height, dst_y, dst_width, dst_u, 1856 dst_halfwidth, dst_v, dst_halfwidth, dst_width, aheight, 1666 1857 interpolate ? kFilterBox : kFilterNone); 1667 1858 }
Note: See TracChangeset
for help on using the changeset viewer.