| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 assert(dx == 65536 * 2); // Test scale factor of 2. | 46 assert(dx == 65536 * 2); // Test scale factor of 2. |
| 47 assert((dy & 0x1ffff) == 0); // Test vertical scale is multiple of 2. | 47 assert((dy & 0x1ffff) == 0); // Test vertical scale is multiple of 2. |
| 48 // Advance to odd row, even column. | 48 // Advance to odd row, even column. |
| 49 if (filtering == kFilterBilinear) { | 49 if (filtering == kFilterBilinear) { |
| 50 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; | 50 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; |
| 51 } else { | 51 } else { |
| 52 src_argb += (y >> 16) * src_stride + ((x >> 16) - 1) * 4; | 52 src_argb += (y >> 16) * src_stride + ((x >> 16) - 1) * 4; |
| 53 } | 53 } |
| 54 | 54 |
| 55 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) | 55 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) |
| 56 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 4)) { | 56 if (TestCpuFlag(kCpuHasSSE2)) { |
| 57 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_SSE2 : | 57 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_SSE2 : |
| 58 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_SSE2 : | 58 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_SSE2 : |
| 59 ScaleARGBRowDown2Box_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); |
| 64 } |
| 60 } | 65 } |
| 61 #endif | 66 #endif |
| 62 #if defined(HAS_SCALEARGBROWDOWN2_NEON) | 67 #if defined(HAS_SCALEARGBROWDOWN2_NEON) |
| 63 if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 8)) { | 68 if (TestCpuFlag(kCpuHasNEON)) { |
| 64 ScaleARGBRowDown2 = filtering ? ScaleARGBRowDown2Box_NEON : | 69 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_Any_NEON : |
| 65 ScaleARGBRowDown2_NEON; | 70 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_Any_NEON : |
| 71 ScaleARGBRowDown2Box_Any_NEON); |
| 72 if (IS_ALIGNED(dst_width, 8)) { |
| 73 ScaleARGBRowDown2 = filtering == kFilterNone ? ScaleARGBRowDown2_NEON : |
| 74 (filtering == kFilterLinear ? ScaleARGBRowDown2Linear_NEON : |
| 75 ScaleARGBRowDown2Box_NEON); |
| 76 } |
| 66 } | 77 } |
| 67 #endif | 78 #endif |
| 68 | 79 |
| 69 if (filtering == kFilterLinear) { | 80 if (filtering == kFilterLinear) { |
| 70 src_stride = 0; | 81 src_stride = 0; |
| 71 } | 82 } |
| 72 for (j = 0; j < dst_height; ++j) { | 83 for (j = 0; j < dst_height; ++j) { |
| 73 ScaleARGBRowDown2(src_argb, src_stride, dst_argb, dst_width); | 84 ScaleARGBRowDown2(src_argb, src_stride, dst_argb, dst_width); |
| 74 src_argb += row_stride; | 85 src_argb += row_stride; |
| 75 dst_argb += dst_stride; | 86 dst_argb += dst_stride; |
| 76 } | 87 } |
| 77 } | 88 } |
| 78 | 89 |
| 79 // ScaleARGB ARGB, 1/4 | 90 // ScaleARGB ARGB, 1/4 |
| 80 // This is an optimized version for scaling down a ARGB to 1/4 of | 91 // This is an optimized version for scaling down a ARGB to 1/4 of |
| 81 // its original size. | 92 // its original size. |
| 82 static void ScaleARGBDown4Box(int src_width, int src_height, | 93 static void ScaleARGBDown4Box(int src_width, int src_height, |
| 83 int dst_width, int dst_height, | 94 int dst_width, int dst_height, |
| 84 int src_stride, int dst_stride, | 95 int src_stride, int dst_stride, |
| 85 const uint8* src_argb, uint8* dst_argb, | 96 const uint8* src_argb, uint8* dst_argb, |
| 86 int x, int dx, int y, int dy) { | 97 int x, int dx, int y, int dy) { |
| 87 int j; | 98 int j; |
| 88 // Allocate 2 rows of ARGB. | 99 // Allocate 2 rows of ARGB. |
| 89 const int kRowSize = (dst_width * 2 * 4 + 15) & ~15; | 100 const int kRowSize = (dst_width * 2 * 4 + 31) & ~31; |
| 90 align_buffer_64(row, kRowSize * 2); | 101 align_buffer_64(row, kRowSize * 2); |
| 91 int row_stride = src_stride * (dy >> 16); | 102 int row_stride = src_stride * (dy >> 16); |
| 92 void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, | 103 void (*ScaleARGBRowDown2)(const uint8* src_argb, ptrdiff_t src_stride, |
| 93 uint8* dst_argb, int dst_width) = ScaleARGBRowDown2Box_C; | 104 uint8* dst_argb, int dst_width) = ScaleARGBRowDown2Box_C; |
| 94 // Advance to odd row, even column. | 105 // Advance to odd row, even column. |
| 95 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; | 106 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; |
| 96 assert(dx == 65536 * 4); // Test scale factor of 4. | 107 assert(dx == 65536 * 4); // Test scale factor of 4. |
| 97 assert((dy & 0x3ffff) == 0); // Test vertical scale is multiple of 4. | 108 assert((dy & 0x3ffff) == 0); // Test vertical scale is multiple of 4. |
| 98 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) | 109 #if defined(HAS_SCALEARGBROWDOWN2_SSE2) |
| 99 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 4)) { | 110 if (TestCpuFlag(kCpuHasSSE2)) { |
| 100 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_SSE2; | 111 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_Any_SSE2; |
| 112 if (IS_ALIGNED(dst_width, 4)) { |
| 113 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_SSE2; |
| 114 } |
| 101 } | 115 } |
| 102 #endif | 116 #endif |
| 103 #if defined(HAS_SCALEARGBROWDOWN2_NEON) | 117 #if defined(HAS_SCALEARGBROWDOWN2_NEON) |
| 104 if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 8)) { | 118 if (TestCpuFlag(kCpuHasNEON)) { |
| 105 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_NEON; | 119 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_Any_NEON; |
| 120 if (IS_ALIGNED(dst_width, 8)) { |
| 121 ScaleARGBRowDown2 = ScaleARGBRowDown2Box_NEON; |
| 122 } |
| 106 } | 123 } |
| 107 #endif | 124 #endif |
| 125 |
| 108 for (j = 0; j < dst_height; ++j) { | 126 for (j = 0; j < dst_height; ++j) { |
| 109 ScaleARGBRowDown2(src_argb, src_stride, row, dst_width * 2); | 127 ScaleARGBRowDown2(src_argb, src_stride, row, dst_width * 2); |
| 110 ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, | 128 ScaleARGBRowDown2(src_argb + src_stride * 2, src_stride, |
| 111 row + kRowSize, dst_width * 2); | 129 row + kRowSize, dst_width * 2); |
| 112 ScaleARGBRowDown2(row, kRowSize, dst_argb, dst_width); | 130 ScaleARGBRowDown2(row, kRowSize, dst_argb, dst_width); |
| 113 src_argb += row_stride; | 131 src_argb += row_stride; |
| 114 dst_argb += dst_stride; | 132 dst_argb += dst_stride; |
| 115 } | 133 } |
| 116 free_aligned_buffer_64(row); | 134 free_aligned_buffer_64(row); |
| 117 } | 135 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 128 int j; | 146 int j; |
| 129 int col_step = dx >> 16; | 147 int col_step = dx >> 16; |
| 130 int row_stride = (dy >> 16) * src_stride; | 148 int row_stride = (dy >> 16) * src_stride; |
| 131 void (*ScaleARGBRowDownEven)(const uint8* src_argb, ptrdiff_t src_stride, | 149 void (*ScaleARGBRowDownEven)(const uint8* src_argb, ptrdiff_t src_stride, |
| 132 int src_step, uint8* dst_argb, int dst_width) = | 150 int src_step, uint8* dst_argb, int dst_width) = |
| 133 filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C; | 151 filtering ? ScaleARGBRowDownEvenBox_C : ScaleARGBRowDownEven_C; |
| 134 assert(IS_ALIGNED(src_width, 2)); | 152 assert(IS_ALIGNED(src_width, 2)); |
| 135 assert(IS_ALIGNED(src_height, 2)); | 153 assert(IS_ALIGNED(src_height, 2)); |
| 136 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; | 154 src_argb += (y >> 16) * src_stride + (x >> 16) * 4; |
| 137 #if defined(HAS_SCALEARGBROWDOWNEVEN_SSE2) | 155 #if defined(HAS_SCALEARGBROWDOWNEVEN_SSE2) |
| 138 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 4)) { | 156 if (TestCpuFlag(kCpuHasSSE2)) { |
| 139 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_SSE2 : | 157 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_SSE2 : |
| 140 ScaleARGBRowDownEven_SSE2; | 158 ScaleARGBRowDownEven_Any_SSE2; |
| 159 if (IS_ALIGNED(dst_width, 4)) { |
| 160 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_SSE2 : |
| 161 ScaleARGBRowDownEven_SSE2; |
| 162 } |
| 141 } | 163 } |
| 142 #endif | 164 #endif |
| 143 #if defined(HAS_SCALEARGBROWDOWNEVEN_NEON) | 165 #if defined(HAS_SCALEARGBROWDOWNEVEN_NEON) |
| 144 if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(dst_width, 4)) { | 166 if (TestCpuFlag(kCpuHasNEON)) { |
| 145 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_NEON : | 167 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_Any_NEON : |
| 146 ScaleARGBRowDownEven_NEON; | 168 ScaleARGBRowDownEven_Any_NEON; |
| 169 if (IS_ALIGNED(dst_width, 4)) { |
| 170 ScaleARGBRowDownEven = filtering ? ScaleARGBRowDownEvenBox_NEON : |
| 171 ScaleARGBRowDownEven_NEON; |
| 172 } |
| 147 } | 173 } |
| 148 #endif | 174 #endif |
| 149 | 175 |
| 150 if (filtering == kFilterLinear) { | 176 if (filtering == kFilterLinear) { |
| 151 src_stride = 0; | 177 src_stride = 0; |
| 152 } | 178 } |
| 153 for (j = 0; j < dst_height; ++j) { | 179 for (j = 0; j < dst_height; ++j) { |
| 154 ScaleARGBRowDownEven(src_argb, src_stride, col_step, dst_argb, dst_width); | 180 ScaleARGBRowDownEven(src_argb, src_stride, col_step, dst_argb, dst_width); |
| 155 src_argb += row_stride; | 181 src_argb += row_stride; |
| 156 dst_argb += dst_stride; | 182 dst_argb += dst_stride; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if (IS_ALIGNED(clip_src_width, 4)) { | 249 if (IS_ALIGNED(clip_src_width, 4)) { |
| 224 InterpolateRow = InterpolateRow_MIPS_DSPR2; | 250 InterpolateRow = InterpolateRow_MIPS_DSPR2; |
| 225 } | 251 } |
| 226 } | 252 } |
| 227 #endif | 253 #endif |
| 228 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) | 254 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) |
| 229 if (TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { | 255 if (TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { |
| 230 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; | 256 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; |
| 231 } | 257 } |
| 232 #endif | 258 #endif |
| 259 #if defined(HAS_SCALEARGBFILTERCOLS_NEON) |
| 260 if (TestCpuFlag(kCpuHasNEON)) { |
| 261 ScaleARGBFilterCols = ScaleARGBFilterCols_Any_NEON; |
| 262 if (IS_ALIGNED(dst_width, 4)) { |
| 263 ScaleARGBFilterCols = ScaleARGBFilterCols_NEON; |
| 264 } |
| 265 } |
| 266 #endif |
| 233 // TODO(fbarchard): Consider not allocating row buffer for kFilterLinear. | 267 // TODO(fbarchard): Consider not allocating row buffer for kFilterLinear. |
| 234 // Allocate a row of ARGB. | 268 // Allocate a row of ARGB. |
| 235 { | 269 { |
| 236 align_buffer_64(row, clip_src_width * 4); | 270 align_buffer_64(row, clip_src_width * 4); |
| 237 | 271 |
| 238 const int max_y = (src_height - 1) << 16; | 272 const int max_y = (src_height - 1) << 16; |
| 239 if (y > max_y) { | 273 if (y > max_y) { |
| 240 y = max_y; | 274 y = max_y; |
| 241 } | 275 } |
| 242 for (j = 0; j < dst_height; ++j) { | 276 for (j = 0; j < dst_height; ++j) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 #endif | 348 #endif |
| 315 if (src_width >= 32768) { | 349 if (src_width >= 32768) { |
| 316 ScaleARGBFilterCols = filtering ? | 350 ScaleARGBFilterCols = filtering ? |
| 317 ScaleARGBFilterCols64_C : ScaleARGBCols64_C; | 351 ScaleARGBFilterCols64_C : ScaleARGBCols64_C; |
| 318 } | 352 } |
| 319 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) | 353 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) |
| 320 if (filtering && TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { | 354 if (filtering && TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { |
| 321 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; | 355 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; |
| 322 } | 356 } |
| 323 #endif | 357 #endif |
| 358 #if defined(HAS_SCALEARGBFILTERCOLS_NEON) |
| 359 if (filtering && TestCpuFlag(kCpuHasNEON)) { |
| 360 ScaleARGBFilterCols = ScaleARGBFilterCols_Any_NEON; |
| 361 if (IS_ALIGNED(dst_width, 4)) { |
| 362 ScaleARGBFilterCols = ScaleARGBFilterCols_NEON; |
| 363 } |
| 364 } |
| 365 #endif |
| 324 #if defined(HAS_SCALEARGBCOLS_SSE2) | 366 #if defined(HAS_SCALEARGBCOLS_SSE2) |
| 325 if (!filtering && TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { | 367 if (!filtering && TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { |
| 326 ScaleARGBFilterCols = ScaleARGBCols_SSE2; | 368 ScaleARGBFilterCols = ScaleARGBCols_SSE2; |
| 327 } | 369 } |
| 328 #endif | 370 #endif |
| 371 #if defined(HAS_SCALEARGBCOLS_NEON) |
| 372 if (!filtering && TestCpuFlag(kCpuHasNEON)) { |
| 373 ScaleARGBFilterCols = ScaleARGBCols_Any_NEON; |
| 374 if (IS_ALIGNED(dst_width, 8)) { |
| 375 ScaleARGBFilterCols = ScaleARGBCols_NEON; |
| 376 } |
| 377 } |
| 378 #endif |
| 329 if (!filtering && src_width * 2 == dst_width && x < 0x8000) { | 379 if (!filtering && src_width * 2 == dst_width && x < 0x8000) { |
| 330 ScaleARGBFilterCols = ScaleARGBColsUp2_C; | 380 ScaleARGBFilterCols = ScaleARGBColsUp2_C; |
| 331 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) | 381 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) |
| 332 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { | 382 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { |
| 333 ScaleARGBFilterCols = ScaleARGBColsUp2_SSE2; | 383 ScaleARGBFilterCols = ScaleARGBColsUp2_SSE2; |
| 334 } | 384 } |
| 335 #endif | 385 #endif |
| 336 } | 386 } |
| 337 | 387 |
| 338 if (y > max_y) { | 388 if (y > max_y) { |
| 339 y = max_y; | 389 y = max_y; |
| 340 } | 390 } |
| 341 | 391 |
| 342 { | 392 { |
| 343 int yi = y >> 16; | 393 int yi = y >> 16; |
| 344 const uint8* src = src_argb + yi * src_stride; | 394 const uint8* src = src_argb + yi * src_stride; |
| 345 | 395 |
| 346 // Allocate 2 rows of ARGB. | 396 // Allocate 2 rows of ARGB. |
| 347 const int kRowSize = (dst_width * 4 + 15) & ~15; | 397 const int kRowSize = (dst_width * 4 + 31) & ~31; |
| 348 align_buffer_64(row, kRowSize * 2); | 398 align_buffer_64(row, kRowSize * 2); |
| 349 | 399 |
| 350 uint8* rowptr = row; | 400 uint8* rowptr = row; |
| 351 int rowstride = kRowSize; | 401 int rowstride = kRowSize; |
| 352 int lasty = yi; | 402 int lasty = yi; |
| 353 | 403 |
| 354 ScaleARGBFilterCols(rowptr, src, dst_width, x, dx); | 404 ScaleARGBFilterCols(rowptr, src, dst_width, x, dx); |
| 355 if (src_height > 1) { | 405 if (src_height > 1) { |
| 356 src += src_stride; | 406 src += src_stride; |
| 357 } | 407 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; | 538 filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C; |
| 489 if (src_width >= 32768) { | 539 if (src_width >= 32768) { |
| 490 ScaleARGBFilterCols = filtering ? | 540 ScaleARGBFilterCols = filtering ? |
| 491 ScaleARGBFilterCols64_C : ScaleARGBCols64_C; | 541 ScaleARGBFilterCols64_C : ScaleARGBCols64_C; |
| 492 } | 542 } |
| 493 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) | 543 #if defined(HAS_SCALEARGBFILTERCOLS_SSSE3) |
| 494 if (filtering && TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { | 544 if (filtering && TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { |
| 495 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; | 545 ScaleARGBFilterCols = ScaleARGBFilterCols_SSSE3; |
| 496 } | 546 } |
| 497 #endif | 547 #endif |
| 548 #if defined(HAS_SCALEARGBFILTERCOLS_NEON) |
| 549 if (filtering && TestCpuFlag(kCpuHasNEON)) { |
| 550 ScaleARGBFilterCols = ScaleARGBFilterCols_Any_NEON; |
| 551 if (IS_ALIGNED(dst_width, 4)) { |
| 552 ScaleARGBFilterCols = ScaleARGBFilterCols_NEON; |
| 553 } |
| 554 } |
| 555 #endif |
| 498 #if defined(HAS_SCALEARGBCOLS_SSE2) | 556 #if defined(HAS_SCALEARGBCOLS_SSE2) |
| 499 if (!filtering && TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { | 557 if (!filtering && TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { |
| 500 ScaleARGBFilterCols = ScaleARGBCols_SSE2; | 558 ScaleARGBFilterCols = ScaleARGBCols_SSE2; |
| 501 } | 559 } |
| 502 #endif | 560 #endif |
| 561 #if defined(HAS_SCALEARGBCOLS_NEON) |
| 562 if (!filtering && TestCpuFlag(kCpuHasNEON)) { |
| 563 ScaleARGBFilterCols = ScaleARGBCols_Any_NEON; |
| 564 if (IS_ALIGNED(dst_width, 8)) { |
| 565 ScaleARGBFilterCols = ScaleARGBCols_NEON; |
| 566 } |
| 567 } |
| 568 #endif |
| 503 if (!filtering && src_width * 2 == dst_width && x < 0x8000) { | 569 if (!filtering && src_width * 2 == dst_width && x < 0x8000) { |
| 504 ScaleARGBFilterCols = ScaleARGBColsUp2_C; | 570 ScaleARGBFilterCols = ScaleARGBColsUp2_C; |
| 505 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) | 571 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) |
| 506 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { | 572 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { |
| 507 ScaleARGBFilterCols = ScaleARGBColsUp2_SSE2; | 573 ScaleARGBFilterCols = ScaleARGBColsUp2_SSE2; |
| 508 } | 574 } |
| 509 #endif | 575 #endif |
| 510 } | 576 } |
| 511 | 577 |
| 512 const int max_y = (src_height - 1) << 16; | 578 const int max_y = (src_height - 1) << 16; |
| 513 if (y > max_y) { | 579 if (y > max_y) { |
| 514 y = max_y; | 580 y = max_y; |
| 515 } | 581 } |
| 516 const int kYShift = 1; // Shift Y by 1 to convert Y plane to UV coordinate. | 582 const int kYShift = 1; // Shift Y by 1 to convert Y plane to UV coordinate. |
| 517 int yi = y >> 16; | 583 int yi = y >> 16; |
| 518 int uv_yi = yi >> kYShift; | 584 int uv_yi = yi >> kYShift; |
| 519 const uint8* src_row_y = src_y + yi * src_stride_y; | 585 const uint8* src_row_y = src_y + yi * src_stride_y; |
| 520 const uint8* src_row_u = src_u + uv_yi * src_stride_u; | 586 const uint8* src_row_u = src_u + uv_yi * src_stride_u; |
| 521 const uint8* src_row_v = src_v + uv_yi * src_stride_v; | 587 const uint8* src_row_v = src_v + uv_yi * src_stride_v; |
| 522 | 588 |
| 523 // Allocate 2 rows of ARGB. | 589 // Allocate 2 rows of ARGB. |
| 524 const int kRowSize = (dst_width * 4 + 15) & ~15; | 590 const int kRowSize = (dst_width * 4 + 31) & ~31; |
| 525 align_buffer_64(row, kRowSize * 2); | 591 align_buffer_64(row, kRowSize * 2); |
| 526 | 592 |
| 527 // Allocate 1 row of ARGB for source conversion. | 593 // Allocate 1 row of ARGB for source conversion. |
| 528 align_buffer_64(argb_row, src_width * 4); | 594 align_buffer_64(argb_row, src_width * 4); |
| 529 | 595 |
| 530 uint8* rowptr = row; | 596 uint8* rowptr = row; |
| 531 int rowstride = kRowSize; | 597 int rowstride = kRowSize; |
| 532 int lasty = yi; | 598 int lasty = yi; |
| 533 | 599 |
| 534 // TODO(fbarchard): Convert first 2 rows of YUV to ARGB. | 600 // TODO(fbarchard): Convert first 2 rows of YUV to ARGB. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 int x, int dx, int y, int dy) { | 666 int x, int dx, int y, int dy) { |
| 601 int j; | 667 int j; |
| 602 void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb, | 668 void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb, |
| 603 int dst_width, int x, int dx) = | 669 int dst_width, int x, int dx) = |
| 604 (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C; | 670 (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C; |
| 605 #if defined(HAS_SCALEARGBCOLS_SSE2) | 671 #if defined(HAS_SCALEARGBCOLS_SSE2) |
| 606 if (TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { | 672 if (TestCpuFlag(kCpuHasSSE2) && src_width < 32768) { |
| 607 ScaleARGBCols = ScaleARGBCols_SSE2; | 673 ScaleARGBCols = ScaleARGBCols_SSE2; |
| 608 } | 674 } |
| 609 #endif | 675 #endif |
| 676 #if defined(HAS_SCALEARGBCOLS_NEON) |
| 677 if (TestCpuFlag(kCpuHasNEON)) { |
| 678 ScaleARGBCols = ScaleARGBCols_Any_NEON; |
| 679 if (IS_ALIGNED(dst_width, 8)) { |
| 680 ScaleARGBCols = ScaleARGBCols_NEON; |
| 681 } |
| 682 } |
| 683 #endif |
| 610 if (src_width * 2 == dst_width && x < 0x8000) { | 684 if (src_width * 2 == dst_width && x < 0x8000) { |
| 611 ScaleARGBCols = ScaleARGBColsUp2_C; | 685 ScaleARGBCols = ScaleARGBColsUp2_C; |
| 612 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) | 686 #if defined(HAS_SCALEARGBCOLSUP2_SSE2) |
| 613 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { | 687 if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(dst_width, 8)) { |
| 614 ScaleARGBCols = ScaleARGBColsUp2_SSE2; | 688 ScaleARGBCols = ScaleARGBColsUp2_SSE2; |
| 615 } | 689 } |
| 616 #endif | 690 #endif |
| 617 } | 691 } |
| 618 | 692 |
| 619 for (j = 0; j < dst_height; ++j) { | 693 for (j = 0; j < dst_height; ++j) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 LIBYUV_API | 811 LIBYUV_API |
| 738 int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, | 812 int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, |
| 739 int src_width, int src_height, | 813 int src_width, int src_height, |
| 740 uint8* dst_argb, int dst_stride_argb, | 814 uint8* dst_argb, int dst_stride_argb, |
| 741 int dst_width, int dst_height, | 815 int dst_width, int dst_height, |
| 742 int clip_x, int clip_y, int clip_width, int clip_height, | 816 int clip_x, int clip_y, int clip_width, int clip_height, |
| 743 enum FilterMode filtering) { | 817 enum FilterMode filtering) { |
| 744 if (!src_argb || src_width == 0 || src_height == 0 || | 818 if (!src_argb || src_width == 0 || src_height == 0 || |
| 745 !dst_argb || dst_width <= 0 || dst_height <= 0 || | 819 !dst_argb || dst_width <= 0 || dst_height <= 0 || |
| 746 clip_x < 0 || clip_y < 0 || | 820 clip_x < 0 || clip_y < 0 || |
| 821 clip_width > 32768 || clip_height > 32768 || |
| 747 (clip_x + clip_width) > dst_width || | 822 (clip_x + clip_width) > dst_width || |
| 748 (clip_y + clip_height) > dst_height) { | 823 (clip_y + clip_height) > dst_height) { |
| 749 return -1; | 824 return -1; |
| 750 } | 825 } |
| 751 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, | 826 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, |
| 752 dst_argb, dst_stride_argb, dst_width, dst_height, | 827 dst_argb, dst_stride_argb, dst_width, dst_height, |
| 753 clip_x, clip_y, clip_width, clip_height, filtering); | 828 clip_x, clip_y, clip_width, clip_height, filtering); |
| 754 return 0; | 829 return 0; |
| 755 } | 830 } |
| 756 | 831 |
| 757 // Scale an ARGB image. | 832 // Scale an ARGB image. |
| 758 LIBYUV_API | 833 LIBYUV_API |
| 759 int ARGBScale(const uint8* src_argb, int src_stride_argb, | 834 int ARGBScale(const uint8* src_argb, int src_stride_argb, |
| 760 int src_width, int src_height, | 835 int src_width, int src_height, |
| 761 uint8* dst_argb, int dst_stride_argb, | 836 uint8* dst_argb, int dst_stride_argb, |
| 762 int dst_width, int dst_height, | 837 int dst_width, int dst_height, |
| 763 enum FilterMode filtering) { | 838 enum FilterMode filtering) { |
| 764 if (!src_argb || src_width == 0 || src_height == 0 || | 839 if (!src_argb || src_width == 0 || src_height == 0 || |
| 840 src_width > 32768 || src_height > 32768 || |
| 765 !dst_argb || dst_width <= 0 || dst_height <= 0) { | 841 !dst_argb || dst_width <= 0 || dst_height <= 0) { |
| 766 return -1; | 842 return -1; |
| 767 } | 843 } |
| 768 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, | 844 ScaleARGB(src_argb, src_stride_argb, src_width, src_height, |
| 769 dst_argb, dst_stride_argb, dst_width, dst_height, | 845 dst_argb, dst_stride_argb, dst_width, dst_height, |
| 770 0, 0, dst_width, dst_height, filtering); | 846 0, 0, dst_width, dst_height, filtering); |
| 771 return 0; | 847 return 0; |
| 772 } | 848 } |
| 773 | 849 |
| 774 #ifdef __cplusplus | 850 #ifdef __cplusplus |
| 775 } // extern "C" | 851 } // extern "C" |
| 776 } // namespace libyuv | 852 } // namespace libyuv |
| 777 #endif | 853 #endif |
| OLD | NEW |