Changeset 5633 for pjproject/trunk/third_party/yuv/source/scale_argb.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_argb.cc
r5358 r5633 31 31 // This is an optimized version for scaling down a ARGB to 1/2 of 32 32 // its original size. 33 static void ScaleARGBDown2(int src_width, int src_height, 34 int dst_width, int dst_height, 35 int src_stride, int dst_stride, 36 const uint8* src_argb, uint8* dst_argb, 37 int x, int dx, int y, int dy, 33 static void ScaleARGBDown2(int src_width, 34 int src_height, 35 int dst_width, 36 int dst_height, 37 int src_stride, 38 int dst_stride, 39 const uint8* src_argb, 40 uint8* dst_argb, 41 int x, 42 int dx, 43 int y, 44 int dy, 38 45 enum FilterMode filtering) { 39 46 int j; … … 41 48 void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, 42 49 uint8* dst_argb, int dst_width) = 43 filtering == kFilterNone ? ScaleARGBRowDown2_C : 44 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C : 45 ScaleARGBRowDown2Box_C); 46 assert(dx == 65536 * 2); // Test scale factor of 2. 50 filtering == kFilterNone 51 ? ScaleARGBRowDown2_C 52 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_C 53 : ScaleARGBRowDown2Box_C); 54 (void)src_width; 55 (void)src_height; 56 (void)dx; 57 assert(dx == 65536 * 2); // Test scale factor of 2. 47 58 assert((dy & 0x1ffff) == 0); // Test vertical scale is multiple of 2. 48 59 // Advance to odd row, even column. … … 55 66 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) 56 67 if (TestCpuFlag(kCpuHasSSE2)) { 57 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_SSE2 : 58 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_SSE2 : 59 ScaleARGBRowDown2Box_Any_SSE2); 60 if (IS_ALIGNED(dst_width, 4)) { 61 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_SSE2 : 62 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_SSE2 : 63 ScaleARGBRowDown2Box_SSE2); 68 ScaleARGBRowDown2 = 69 filtering == kFilterNone 70 ? ScaleARGBRowDown2_Any_SSE2 71 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_SSE2 72 : ScaleARGBRowDown2Box_Any_SSE2); 73 if (IS_ALIGNED(dst_width, 4)) { 74 ScaleARGBRowDown2 = 75 filtering == kFilterNone 76 ? ScaleARGBRowDown2_SSE2 77 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_SSE2 78 : ScaleARGBRowDown2Box_SSE2); 64 79 } 65 80 } … … 67 82 #if defined(HAS_SCALEARGBROWDOWN2_NEON) 68 83 if (TestCpuFlag(kCpuHasNEON)) { 69 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_NEON : 70 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_NEON : 71 ScaleARGBRowDown2Box_Any_NEON); 84 ScaleARGBRowDown2 = 85 filtering == kFilterNone 86 ? ScaleARGBRowDown2_Any_NEON 87 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_NEON 88 : ScaleARGBRowDown2Box_Any_NEON); 72 89 if (IS_ALIGNED(dst_width, 8)) { 73 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_NEON : 74 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_NEON : 75 ScaleARGBRowDown2Box_NEON); 90 ScaleARGBRowDown2 = 91 filtering == kFilterNone 92 ? ScaleARGBRowDown2_NEON 93 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_NEON 94 : ScaleARGBRowDown2Box_NEON); 95 } 96 } 97 #endif 98 #if defined(HAS_SCALEARGBROWDOWN2_MSA) 99 if (TestCpuFlag(kCpuHasMSA)) { 100 ScaleARGBRowDown2 = 101 filtering == kFilterNone 102 ? ScaleARGBRowDown2_Any_MSA 103 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_MSA 104 : ScaleARGBRowDown2Box_Any_MSA); 105 if (IS_ALIGNED(dst_width, 4)) { 106 ScaleARGBRowDown2 = 107 filtering == kFilterNone 108 ? ScaleARGBRowDown2_MSA 109 : (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_MSA 110 : ScaleARGBRowDown2Box_MSA); 76 111 } 77 112 } … … 91 126 // This is an optimized version for scaling down a ARGB to 1/4 of 92 127 // its original size. 93 static void ScaleARGBDown4Box(int src_width, int src_height, 94 int dst_width, int dst_height, 95 int src_stride, int dst_stride, 96 const uint8* src_argb, uint8* dst_argb, 97 int x, int dx, int y, int dy) { 128 static void ScaleARGBDown4Box(int src_width, 129 int src_height, 130 int dst_width, 131 int dst_height, 132 int src_stride, 133 int dst_stride, 134 const uint8* src_argb, 135 uint8* dst_argb, 136 int x, 137 int dx, 138 int y, 139 int dy) { 98 140 int j; 99 141 // Allocate 2 rows of ARGB. … … 102 144 int row_stride = src_stride * (dy >> 16); 103 145 void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, 104 uint8* dst_argb, int dst_width) = ScaleARGBRowDown2Box_C; 146 uint8* dst_argb, int dst_width) = 147 ScaleARGBRowDown2Box_C; 105 148 // Advance to odd row, even column. 106 149 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; 107 assert(dx == 65536 * 4); // Test scale factor of 4. 150 (void)src_width; 151 (void)src_height; 152 (void)dx; 153 assert(dx == 65536 * 4); // Test scale factor of 4. 108 154 assert((dy & 0x3ffff) == 0); // Test vertical scale is multiple of 4. 109 155 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) … … 126 172 for (j = 0; j < dst_height; ++j) { 127 173 ScaleARGBRowDown2(src_argb, src_stride, row, dst_width * 2); 128 ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, 129 row + kRowSize,dst_width * 2);174 ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, row + kRowSize, 175 dst_width * 2); 130 176 ScaleARGBRowDown2(row, kRowSize, dst_argb, dst_width); 131 177 src_argb += row_stride; … … 138 184 // This is an optimized version for scaling down a ARGB to even 139 185 // multiple of its original size. 140 static void ScaleARGBDownEven(int src_width, int src_height, 141 int dst_width, int dst_height, 142 int src_stride, int dst_stride, 143 const uint8* src_argb, uint8* dst_argb, 144 int x, int dx, int y, int dy, 186 static void ScaleARGBDownEven(int src_width, 187 int src_height, 188 int dst_width, 189 int dst_height, 190 int src_stride, 191 int dst_stride, 192 const uint8* src_argb, 193 uint8* dst_argb, 194 int x, 195 int dx, 196 int y, 197 int dy, 145 198 enum FilterMode filtering) { 146 199 int j; … … 150 203 int src_step, uint8* dst_argb, int dst_width) = 151 204 filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C; 205 (void)src_width; 206 (void)src_height; 152 207 assert(IS_ALIGNED(src_width, 2)); 153 208 assert(IS_ALIGNED(src_height, 2)); … … 155 210 #if defined(HAS_SCALEARGBROWDOWNEVEN_SSE2) 156 211 if (TestCpuFlag(kCpuHasSSE2)) { 157 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_SSE2 :158 ScaleARGBRowDownEven_Any_SSE2;159 if (IS_ALIGNED(dst_width, 4)) { 160 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_SSE2 :161 ScaleARGBRowDownEven_SSE2;212 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_SSE2 213 : ScaleARGBRowDownEven_Any_SSE2; 214 if (IS_ALIGNED(dst_width, 4)) { 215 ScaleARGBRowDownEven = 216 filtering ? ScaleARGBRowDownEvenBox_SSE2 : ScaleARGBRowDownEven_SSE2; 162 217 } 163 218 } … … 165 220 #if defined(HAS_SCALEARGBROWDOWNEVEN_NEON) 166 221 if (TestCpuFlag(kCpuHasNEON)) { 167 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_NEON : 168 ScaleARGBRowDownEven_Any_NEON; 169 if (IS_ALIGNED(dst_width, 4)) { 170 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_NEON : 171 ScaleARGBRowDownEven_NEON; 222 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_NEON 223 : ScaleARGBRowDownEven_Any_NEON; 224 if (IS_ALIGNED(dst_width, 4)) { 225 ScaleARGBRowDownEven = 226 filtering ? ScaleARGBRowDownEvenBox_NEON : ScaleARGBRowDownEven_NEON; 227 } 228 } 229 #endif 230 #if defined(HAS_SCALEARGBROWDOWNEVEN_MSA) 231 if (TestCpuFlag(kCpuHasMSA)) { 232 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_MSA 233 : ScaleARGBRowDownEven_Any_MSA; 234 if (IS_ALIGNED(dst_width, 4)) { 235 ScaleARGBRowDownEven = 236 filtering ? ScaleARGBRowDownEvenBox_MSA : ScaleARGBRowDownEven_MSA; 172 237 } 173 238 } … … 185 250 186 251 // Scale ARGB down with bilinear interpolation. 187 static void ScaleARGBBilinearDown(int src_width, int src_height, 188 int dst_width, int dst_height, 189 int src_stride, int dst_stride, 190 const uint8* src_argb, uint8* dst_argb, 191 int x, int dx, int y, int dy, 252 static void ScaleARGBBilinearDown(int src_width, 253 int src_height, 254 int dst_width, 255 int dst_height, 256 int src_stride, 257 int dst_stride, 258 const uint8* src_argb, 259 uint8* dst_argb, 260 int x, 261 int dx, 262 int y, 263 int dy, 192 264 enum FilterMode filtering) { 193 265 int j; 194 void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb,195 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =196 InterpolateRow_C;197 void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb,198 int dst_width, int x, int dx) =266 void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 267 ptrdiff_t src_stride, int dst_width, 268 int source_y_fraction) = InterpolateRow_C; 269 void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 270 int dst_width, int x, int dx) = 199 271 (src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C; 200 272 int64 xlast = x + (int64)(dst_width - 1) * dx; … … 202 274 int64 xr = (dx >= 0) ? xlast : x; 203 275 int clip_src_width; 204 xl = (xl >> 16) & ~3; // Left edge aligned.205 xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels.276 xl = (xl >> 16) & ~3; // Left edge aligned. 277 xr = (xr >> 16) + 1; // Right most pixel used. Bilinear uses 2 pixels. 206 278 xr = (xr + 1 + 3) & ~3; // 1 beyond 4 pixel aligned right most pixel. 207 279 if (xr > src_width) { … … 236 308 #endif 237 309 #if defined(HAS_INTERPOLATEROW_DSPR2) 238 if (TestCpuFlag(kCpuHasDSPR2) && 239 IS_ALIGNED(src_ argb, 4) && IS_ALIGNED(src_stride, 4)) {310 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src_argb, 4) && 311 IS_ALIGNED(src_stride, 4)) { 240 312 InterpolateRow = InterpolateRow_Any_DSPR2; 241 313 if (IS_ALIGNED(clip_src_width, 4)) { 242 314 InterpolateRow = InterpolateRow_DSPR2; 315 } 316 } 317 #endif 318 #if defined(HAS_INTERPOLATEROW_MSA) 319 if (TestCpuFlag(kCpuHasMSA)) { 320 InterpolateRow = InterpolateRow_Any_MSA; 321 if (IS_ALIGNED(clip_src_width, 32)) { 322 InterpolateRow = InterpolateRow_MSA; 243 323 } 244 324 } … … 287 367 288 368 // Scale ARGB up with bilinear interpolation. 289 static void ScaleARGBBilinearUp(int src_width, int src_height, 290 int dst_width, int dst_height, 291 int src_stride, int dst_stride, 292 const uint8* src_argb, uint8* dst_argb, 293 int x, int dx, int y, int dy, 369 static void ScaleARGBBilinearUp(int src_width, 370 int src_height, 371 int dst_width, 372 int dst_height, 373 int src_stride, 374 int dst_stride, 375 const uint8* src_argb, 376 uint8* dst_argb, 377 int x, 378 int dx, 379 int y, 380 int dy, 294 381 enum FilterMode filtering) { 295 382 int j; 296 void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb,297 ptrdiff_t src_stride, int dst_width, int source_y_fraction) =298 InterpolateRow_C;299 void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb,300 int dst_width, int x, int dx) =383 void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 384 ptrdiff_t src_stride, int dst_width, 385 int source_y_fraction) = InterpolateRow_C; 386 void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 387 int dst_width, int x, int dx) = 301 388 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; 302 389 const int max_y = (src_height - 1) << 16; … … 326 413 #endif 327 414 #if defined(HAS_INTERPOLATEROW_DSPR2) 328 if (TestCpuFlag(kCpuHasDSPR2) && 329 IS_ALIGNED(dst_ argb, 4) && IS_ALIGNED(dst_stride, 4)) {415 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(dst_argb, 4) && 416 IS_ALIGNED(dst_stride, 4)) { 330 417 InterpolateRow = InterpolateRow_DSPR2; 331 418 } 332 419 #endif 420 #if defined(HAS_INTERPOLATEROW_MSA) 421 if (TestCpuFlag(kCpuHasMSA)) { 422 InterpolateRow = InterpolateRow_Any_MSA; 423 if (IS_ALIGNED(dst_width, 8)) { 424 InterpolateRow = InterpolateRow_MSA; 425 } 426 } 427 #endif 333 428 if (src_width >= 32768) { 334 ScaleARGBFilterCols = filtering ?335 ScaleARGBFilterCols64_C : ScaleARGBCols64_C;429 ScaleARGBFilterCols = 430 filtering ? ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 336 431 } 337 432 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) … … 424 519 #ifdef YUVSCALEUP 425 520 // Scale YUV to ARGB up with bilinear interpolation. 426 static void ScaleYUVToARGBBilinearUp(int src_width, int src_height, 427 int dst_width, int dst_height, 521 static void ScaleYUVToARGBBilinearUp(int src_width, 522 int src_height, 523 int dst_width, 524 int dst_height, 428 525 int src_stride_y, 429 526 int src_stride_u, … … 434 531 const uint8* src_v, 435 532 uint8* dst_argb, 436 int x, int dx, int y, int dy, 533 int x, 534 int dx, 535 int y, 536 int dy, 437 537 enum FilterMode filtering) { 438 538 int j; 439 void (*I422ToARGBRow)(const uint8* y_buf, 440 const uint8* u_buf, 441 const uint8* v_buf, 442 uint8* rgb_buf, 443 int width) = I422ToARGBRow_C; 539 void (*I422ToARGBRow)(const uint8* y_buf, const uint8* u_buf, 540 const uint8* v_buf, uint8* rgb_buf, int width) = 541 I422ToARGBRow_C; 444 542 #if defined(HAS_I422TOARGBROW_SSSE3) 445 543 if (TestCpuFlag(kCpuHasSSSE3)) { … … 475 573 } 476 574 #endif 477 478 void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, 479 ptrdiff_t src_stride, int dst_width, int source_y_fraction) = 480 InterpolateRow_C; 575 #if defined(HAS_I422TOARGBROW_MSA) 576 if (TestCpuFlag(kCpuHasMSA)) { 577 I422ToARGBRow = I422ToARGBRow_Any_MSA; 578 if (IS_ALIGNED(src_width, 8)) { 579 I422ToARGBRow = I422ToARGBRow_MSA; 580 } 581 } 582 #endif 583 584 void (*InterpolateRow)(uint8 * dst_argb, const uint8* src_argb, 585 ptrdiff_t src_stride, int dst_width, 586 int source_y_fraction) = InterpolateRow_C; 481 587 #if defined(HAS_INTERPOLATEROW_SSSE3) 482 588 if (TestCpuFlag(kCpuHasSSSE3)) { … … 504 610 #endif 505 611 #if defined(HAS_INTERPOLATEROW_DSPR2) 506 if (TestCpuFlag(kCpuHasDSPR2) && 507 IS_ALIGNED(dst_ argb, 4) && IS_ALIGNED(dst_stride_argb, 4)) {612 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(dst_argb, 4) && 613 IS_ALIGNED(dst_stride_argb, 4)) { 508 614 InterpolateRow = InterpolateRow_DSPR2; 509 615 } 510 616 #endif 511 512 void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb, 513 int dst_width, int x, int dx) = 617 #if defined(HAS_INTERPOLATEROW_MSA) 618 if (TestCpuFlag(kCpuHasMSA)) { 619 InterpolateRow = InterpolateRow_Any_MSA; 620 if (IS_ALIGNED(dst_width, 8)) { 621 InterpolateRow = InterpolateRow_MSA; 622 } 623 } 624 #endif 625 626 void (*ScaleARGBFilterCols)(uint8 * dst_argb, const uint8* src_argb, 627 int dst_width, int x, int dx) = 514 628 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; 515 629 if (src_width >= 32768) { 516 ScaleARGBFilterCols = filtering ?517 ScaleARGBFilterCols64_C : ScaleARGBCols64_C;630 ScaleARGBFilterCols = 631 filtering ? ScaleARGBFilterCols64_C : ScaleARGBCols64_C; 518 632 } 519 633 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) … … 636 750 // the lower 16 bits are the fixed decimal part. 637 751 638 static void ScaleARGBSimple(int src_width, int src_height, 639 int dst_width, int dst_height, 640 int src_stride, int dst_stride, 641 const uint8* src_argb, uint8* dst_argb, 642 int x, int dx, int y, int dy) { 752 static void ScaleARGBSimple(int src_width, 753 int src_height, 754 int dst_width, 755 int dst_height, 756 int src_stride, 757 int dst_stride, 758 const uint8* src_argb, 759 uint8* dst_argb, 760 int x, 761 int dx, 762 int y, 763 int dy) { 643 764 int j; 644 void (*ScaleARGBCols)(uint8 * dst_argb, const uint8* src_argb,645 int dst_width,int x, int dx) =765 void (*ScaleARGBCols)(uint8 * dst_argb, const uint8* src_argb, int dst_width, 766 int x, int dx) = 646 767 (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C; 768 (void)src_height; 647 769 #if defined(HAS_SCALEARGBCOLS_SSE2) 648 770 if (TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { … … 668 790 669 791 for (j = 0; j < dst_height; ++j) { 670 ScaleARGBCols(dst_argb, src_argb + (y >> 16) * src_stride, 671 d st_width, x, dx);792 ScaleARGBCols(dst_argb, src_argb + (y >> 16) * src_stride, dst_width, x, 793 dx); 672 794 dst_argb += dst_stride; 673 795 y += dy; … … 678 800 // This function in turn calls a scaling function 679 801 // suitable for handling the desired resolutions. 680 static void ScaleARGB(const uint8* src, int src_stride, 681 int src_width, int src_height, 682 uint8* dst, int dst_stride, 683 int dst_width, int dst_height, 684 int clip_x, int clip_y, int clip_width, int clip_height, 802 static void ScaleARGB(const uint8* src, 803 int src_stride, 804 int src_width, 805 int src_height, 806 uint8* dst, 807 int dst_stride, 808 int dst_width, 809 int dst_height, 810 int clip_x, 811 int clip_y, 812 int clip_width, 813 int clip_height, 685 814 enum FilterMode filtering) { 686 815 // Initial source x/y coordinate and step values as 16.16 fixed point. … … 691 820 // ARGB does not support box filter yet, but allow the user to pass it. 692 821 // Simplify filtering when possible. 693 filtering = ScaleFilterReduce(src_width, src_height, 694 dst_width, dst_height, 822 filtering = ScaleFilterReduce(src_width, src_height, dst_width, dst_height, 695 823 filtering); 696 824 … … 701 829 src_stride = -src_stride; 702 830 } 703 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, 704 & x, &y, &dx, &dy);831 ScaleSlope(src_width, src_height, dst_width, dst_height, filtering, &x, &y, 832 &dx, &dy); 705 833 src_width = Abs(src_width); 706 834 if (clip_x) { 707 int64 clipf = (int64)(clip_x) *dx;835 int64 clipf = (int64)(clip_x)*dx; 708 836 x += (clipf & 0xffff); 709 837 src += (clipf >> 16) * 4; … … 711 839 } 712 840 if (clip_y) { 713 int64 clipf = (int64)(clip_y) *dy;841 int64 clipf = (int64)(clip_y)*dy; 714 842 y += (clipf & 0xffff); 715 843 src += (clipf >> 16) * src_stride; … … 726 854 if (dx == 0x20000) { 727 855 // Optimized 1/2 downsample. 728 ScaleARGBDown2(src_width, src_height, 729 clip_width, clip_height, 730 src_stride, dst_stride, src, dst, 731 x, dx, y, dy, filtering); 856 ScaleARGBDown2(src_width, src_height, clip_width, clip_height, 857 src_stride, dst_stride, src, dst, x, dx, y, dy, 858 filtering); 732 859 return; 733 860 } 734 861 if (dx == 0x40000 && filtering == kFilterBox) { 735 862 // Optimized 1/4 box downsample. 736 ScaleARGBDown4Box(src_width, src_height, 737 clip_width, clip_height, 738 src_stride, dst_stride, src, dst, 739 x, dx, y, dy); 863 ScaleARGBDown4Box(src_width, src_height, clip_width, clip_height, 864 src_stride, dst_stride, src, dst, x, dx, y, dy); 740 865 return; 741 866 } 742 ScaleARGBDownEven(src_width, src_height, 743 clip_width, clip_height, 744 src_stride, dst_stride, src, dst, 745 x, dx, y, dy, filtering); 867 ScaleARGBDownEven(src_width, src_height, clip_width, clip_height, 868 src_stride, dst_stride, src, dst, x, dx, y, dy, 869 filtering); 746 870 return; 747 871 } … … 760 884 if (dx == 0x10000 && (x & 0xffff) == 0) { 761 885 // Arbitrary scale vertically, but unscaled vertically. 762 ScalePlaneVertical(src_height, 763 clip_width, clip_height, 764 src_stride, dst_stride, src, dst, 765 x, y, dy, 4, filtering); 886 ScalePlaneVertical(src_height, clip_width, clip_height, src_stride, 887 dst_stride, src, dst, x, y, dy, 4, filtering); 766 888 return; 767 889 } 768 890 if (filtering && dy < 65536) { 769 ScaleARGBBilinearUp(src_width, src_height, 770 clip_width, clip_height, 771 src_stride, dst_stride, src, dst, 772 x, dx, y, dy, filtering); 891 ScaleARGBBilinearUp(src_width, src_height, clip_width, clip_height, 892 src_stride, dst_stride, src, dst, x, dx, y, dy, 893 filtering); 773 894 return; 774 895 } 775 896 if (filtering) { 776 ScaleARGBBilinearDown(src_width, src_height, 777 clip_width, clip_height, 778 src_stride, dst_stride, src, dst, 779 x, dx, y, dy, filtering); 897 ScaleARGBBilinearDown(src_width, src_height, clip_width, clip_height, 898 src_stride, dst_stride, src, dst, x, dx, y, dy, 899 filtering); 780 900 return; 781 901 } 782 ScaleARGBSimple(src_width, src_height, clip_width, clip_height, 783 src_stride, dst_stride, src, dst, 784 x, dx, y, dy); 902 ScaleARGBSimple(src_width, src_height, clip_width, clip_height, src_stride, 903 dst_stride, src, dst, x, dx, y, dy); 785 904 } 786 905 787 906 LIBYUV_API 788 int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 789 int src_width, int src_height, 790 uint8* dst_argb, int dst_stride_argb, 791 int dst_width, int dst_height, 792 int clip_x, int clip_y, int clip_width, int clip_height, 907 int ARGBScaleClip(const uint8* src_argb, 908 int src_stride_argb, 909 int src_width, 910 int src_height, 911 uint8* dst_argb, 912 int dst_stride_argb, 913 int dst_width, 914 int dst_height, 915 int clip_x, 916 int clip_y, 917 int clip_width, 918 int clip_height, 793 919 enum FilterMode filtering) { 794 if (!src_argb || src_width == 0 || src_height == 0 || 795 !dst_argb || dst_width <= 0 || dst_height <= 0 || 796 clip_x < 0 || clip_y < 0 || 920 if (!src_argb || src_width == 0 || src_height == 0 || !dst_argb || 921 dst_width <= 0 || dst_height <= 0 || clip_x < 0 || clip_y < 0 || 797 922 clip_width > 32768 || clip_height > 32768 || 798 923 (clip_x + clip_width) > dst_width || … … 800 925 return -1; 801 926 } 802 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, 803 dst_ argb, dst_stride_argb, dst_width, dst_height,804 clip_ x, clip_y, clip_width, clip_height, filtering);927 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb, 928 dst_stride_argb, dst_width, dst_height, clip_x, clip_y, clip_width, 929 clip_height, filtering); 805 930 return 0; 806 931 } … … 808 933 // Scale an ARGB image. 809 934 LIBYUV_API 810 int ARGBScale(const uint8* src_argb, int src_stride_argb, 811 int src_width, int src_height, 812 uint8* dst_argb, int dst_stride_argb, 813 int dst_width, int dst_height, 935 int ARGBScale(const uint8* src_argb, 936 int src_stride_argb, 937 int src_width, 938 int src_height, 939 uint8* dst_argb, 940 int dst_stride_argb, 941 int dst_width, 942 int dst_height, 814 943 enum FilterMode filtering) { 815 if (!src_argb || src_width == 0 || src_height == 0 || 816 src_width > 32768 || src_height > 32768 || 817 !dst_argb || dst_width <= 0 || dst_height <= 0) { 944 if (!src_argb || src_width == 0 || src_height == 0 || src_width > 32768 || 945 src_height > 32768 || !dst_argb || dst_width <= 0 || dst_height <= 0) { 818 946 return -1; 819 947 } 820 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, 821 dst_ argb, dst_stride_argb, dst_width, dst_height,822 0, 0, dst_width, dst_height,filtering);948 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, dst_argb, 949 dst_stride_argb, dst_width, dst_height, 0, 0, dst_width, dst_height, 950 filtering); 823 951 return 0; 824 952 } … … 826 954 // Scale with YUV conversion to ARGB and clipping. 827 955 LIBYUV_API 828 int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 829 const uint8* src_u, int src_stride_u, 830 const uint8* src_v, int src_stride_v, 956 int YUVToARGBScaleClip(const uint8* src_y, 957 int src_stride_y, 958 const uint8* src_u, 959 int src_stride_u, 960 const uint8* src_v, 961 int src_stride_v, 831 962 uint32 src_fourcc, 832 int src_width, int src_height, 833 uint8* dst_argb, int dst_stride_argb, 963 int src_width, 964 int src_height, 965 uint8* dst_argb, 966 int dst_stride_argb, 834 967 uint32 dst_fourcc, 835 int dst_width, int dst_height, 836 int clip_x, int clip_y, int clip_width, int clip_height, 968 int dst_width, 969 int dst_height, 970 int clip_x, 971 int clip_y, 972 int clip_width, 973 int clip_height, 837 974 enum FilterMode filtering) { 838 975 uint8* argb_buffer = (uint8*)malloc(src_width * src_height * 4); 839 976 int r; 840 I420ToARGB(src_y, src_stride_y, 841 src_u, src_stride_u, 842 src_v, src_stride_v, 843 argb_buffer, src_width * 4, 844 src_width, src_height); 845 846 r = ARGBScaleClip(argb_buffer, src_width * 4, 847 src_width, src_height, 848 dst_argb, dst_stride_argb, 849 dst_width, dst_height, 850 clip_x, clip_y, clip_width, clip_height, 851 filtering); 977 (void)src_fourcc; // TODO(fbarchard): implement and/or assert. 978 (void)dst_fourcc; 979 I420ToARGB(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, 980 argb_buffer, src_width * 4, src_width, src_height); 981 982 r = ARGBScaleClip(argb_buffer, src_width * 4, src_width, src_height, dst_argb, 983 dst_stride_argb, dst_width, dst_height, clip_x, clip_y, 984 clip_width, clip_height, filtering); 852 985 free(argb_buffer); 853 986 return r;
Note: See TracChangeset
for help on using the changeset viewer.