scale_argb_test.cc 28.7 KB
Newer Older
1
/*
2
 *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 4 5 6
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS. All contributing project authors may
8 9 10 11 12 13 14 15
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <stdlib.h>
#include <time.h>

#include "libyuv/cpu_id.h"
#include "libyuv/scale_argb.h"
16
#include "../unit_test/unit_test.h"
17 18 19

namespace libyuv {

20 21 22 23
static __inline int Abs(int v) {
  return v >= 0 ? v : -v;
}

24
static int ARGBTestFilter(int src_width, int src_height,
25
                          int dst_width, int dst_height,
26
                          FilterMode f, int benchmark_iterations) {
fbarchard@google.com's avatar
fbarchard@google.com committed
27
  const int b = 128;
28 29
  int src_argb_plane_size = (Abs(src_width) + b * 2) *
      (Abs(src_height) + b * 2) * 4;
30
  int src_stride_argb = (b * 2 + Abs(src_width)) * 4;
31

32
  align_buffer_64(src_argb, src_argb_plane_size)
fbarchard@google.com's avatar
fbarchard@google.com committed
33
  memset(src_argb, 1, src_argb_plane_size);
34

35 36
  int dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4;
  int dst_stride_argb = (b * 2 + dst_width) * 4;
37 38 39 40

  srandom(time(NULL));

  int i, j;
41 42
  for (i = b; i < (Abs(src_height) + b); ++i) {
    for (j = b; j < (Abs(src_width) + b) * 4; ++j) {
fbarchard@google.com's avatar
fbarchard@google.com committed
43
      src_argb[(i * src_stride_argb) + j] = (random() & 0xff);
44 45 46
    }
  }

47 48
  align_buffer_64(dst_argb_c, dst_argb_plane_size)
  align_buffer_64(dst_argb_opt, dst_argb_plane_size)
fbarchard@google.com's avatar
fbarchard@google.com committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  memset(dst_argb_c, 2, dst_argb_plane_size);
  memset(dst_argb_opt, 3, dst_argb_plane_size);

  // Warm up both versions for consistent benchmarks.
  MaskCpuFlags(0);  // Disable all CPU optimization.
  ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
            src_width, src_height,
            dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
            dst_width, dst_height, f);
  MaskCpuFlags(-1);  // Enable all CPU optimization.
  ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
            src_width, src_height,
            dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
            dst_width, dst_height, f);

  MaskCpuFlags(0);  // Disable all CPU optimization.
65
  double c_time = get_time();
66 67 68 69 70 71
  ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
            src_width, src_height,
            dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
            dst_width, dst_height, f);

  c_time = (get_time() - c_time);
72

fbarchard@google.com's avatar
fbarchard@google.com committed
73
  MaskCpuFlags(-1);  // Enable all CPU optimization.
74
  double opt_time = get_time();
75
  for (i = 0; i < benchmark_iterations; ++i) {
fbarchard@google.com's avatar
fbarchard@google.com committed
76
    ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
77
              src_width, src_height,
fbarchard@google.com's avatar
fbarchard@google.com committed
78
              dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
79
              dst_width, dst_height, f);
fbarchard@google.com's avatar
fbarchard@google.com committed
80
  }
81
  opt_time = (get_time() - opt_time) / benchmark_iterations;
82

fbarchard@google.com's avatar
fbarchard@google.com committed
83 84
  // Report performance of C vs OPT
  printf("filter %d - %8d us C - %8d us OPT\n",
85
         f, static_cast<int>(c_time * 1e6), static_cast<int>(opt_time * 1e6));
86

87 88
  // C version may be a little off from the optimized. Order of
  //  operations may introduce rounding somewhere. So do a difference
89 90 91 92 93
  //  of the buffers and look to see that the max difference isn't
  //  over 2.
  int max_diff = 0;
  for (i = b; i < (dst_height + b); ++i) {
    for (j = b * 4; j < (dst_width + b) * 4; ++j) {
fbarchard@google.com's avatar
fbarchard@google.com committed
94 95
      int abs_diff = abs(dst_argb_c[(i * dst_stride_argb) + j] -
                         dst_argb_opt[(i * dst_stride_argb) + j]);
96
      if (abs_diff > max_diff) {
97
        max_diff = abs_diff;
98
      }
99 100 101
    }
  }

102 103 104
  free_aligned_buffer_64(dst_argb_c)
  free_aligned_buffer_64(dst_argb_opt)
  free_aligned_buffer_64(src_argb)
fbarchard@google.com's avatar
fbarchard@google.com committed
105
  return max_diff;
106 107
}

fbarchard@google.com's avatar
fbarchard@google.com committed
108 109
// TODO(fbarchard): Consider TEST_P to iterate through test cases.

110
TEST_F(libyuvTest, ARGBScaleDownBy2_None) {
111 112
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
113 114
  const int dst_width = Abs(src_width) / 2;
  const int dst_height = Abs(src_height) / 2;
115

116 117 118 119 120
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
121 122
}

123 124 125
TEST_F(libyuvTest, ARGBScaleDownBy2_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
126 127
  const int dst_width = Abs(src_width) / 2;
  const int dst_height = Abs(src_height) / 2;
128 129 130 131 132

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
133
  EXPECT_LE(max_diff, 2);
134 135
}

fbarchard@google.com's avatar
fbarchard@google.com committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
TEST_F(libyuvTest, ARGBScaleDownBy1_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width);
  const int dst_height = Abs(src_height);

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 0);
}

TEST_F(libyuvTest, ARGBScaleDownBy1_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width);
  const int dst_height = Abs(src_height);

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 0);
}

162
TEST_F(libyuvTest, ARGBScaleDownBy4_None) {
163 164
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
165 166
  const int dst_width = Abs(src_width) / 4;
  const int dst_height = Abs(src_height) / 4;
167

168 169 170 171
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
172
  EXPECT_LE(max_diff, 1);
173 174 175 176 177
}

TEST_F(libyuvTest, ARGBScaleDownBy4_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
178 179
  const int dst_width = Abs(src_width) / 4;
  const int dst_height = Abs(src_height) / 4;
180 181 182 183 184

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
185
  EXPECT_LE(max_diff, 2);
fbarchard@google.com's avatar
fbarchard@google.com committed
186 187
}

188
TEST_F(libyuvTest, ARGBScaleDownBy5_None) {
189 190
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
191 192
  const int dst_width = Abs(src_width) / 5;
  const int dst_height = Abs(src_height) / 5;
fbarchard@google.com's avatar
fbarchard@google.com committed
193

194 195 196 197 198 199 200 201 202 203
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
}

TEST_F(libyuvTest, ARGBScaleDownBy5_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
204 205
  const int dst_width = Abs(src_width) / 5;
  const int dst_height = Abs(src_height) / 5;
206 207 208 209 210

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
211
  EXPECT_LE(max_diff, 2);
212 213 214
}

TEST_F(libyuvTest, ARGBScaleDownBy8_None) {
215 216
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
217 218
  const int dst_width = Abs(src_width) / 8;
  const int dst_height = Abs(src_height) / 8;
219

220 221 222 223 224 225 226 227 228 229
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
}

TEST_F(libyuvTest, ARGBScaleDownBy8_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
230 231
  const int dst_width = Abs(src_width) / 8;
  const int dst_height = Abs(src_height) / 8;
232 233 234 235 236

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
237
  EXPECT_LE(max_diff, 2);
238 239 240
}

TEST_F(libyuvTest, ARGBScaleDownBy16_None) {
241 242
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
243 244
  const int dst_width = Abs(src_width) / 16;
  const int dst_height = Abs(src_height) / 16;
fbarchard@google.com's avatar
fbarchard@google.com committed
245

246 247 248 249 250
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
fbarchard@google.com's avatar
fbarchard@google.com committed
251
}
252

253 254 255
TEST_F(libyuvTest, ARGBScaleDownBy16_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
256 257
  const int dst_width = Abs(src_width) / 16;
  const int dst_height = Abs(src_height) / 16;
258 259 260 261 262

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
263
  EXPECT_LE(max_diff, 2);
264 265 266
}

TEST_F(libyuvTest, ARGBScaleDownBy34_None) {
267 268
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
269 270
  const int dst_width = Abs(src_width) * 3 / 4;
  const int dst_height = Abs(src_height) * 3 / 4;
271

272 273 274 275 276 277 278 279 280 281
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
}

TEST_F(libyuvTest, ARGBScaleDownBy34_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
282 283
  const int dst_width = Abs(src_width) * 3 / 4;
  const int dst_height = Abs(src_height) * 3 / 4;
284 285 286 287 288

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
289
  EXPECT_LE(max_diff, 2);
290 291
}

292
TEST_F(libyuvTest, ARGBScaleDownBy38_None) {
293 294
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
295 296
  int dst_width = Abs(src_width) * 3 / 8;
  int dst_height = Abs(src_height) * 3 / 8;
297

298 299 300 301 302
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
303 304
}

305 306 307
TEST_F(libyuvTest, ARGBScaleDownBy38_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
308 309
  int dst_width = Abs(src_width) * 3 / 8;
  int dst_height = Abs(src_height) * 3 / 8;
310 311 312 313 314

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
315
  EXPECT_LE(max_diff, 2);
316 317 318
}

TEST_F(libyuvTest, ARGBScaleTo1366x768_None) {
319 320
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
321 322 323
  int dst_width = 1366;
  int dst_height = 768;

324 325 326 327 328
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
329 330
}

331 332 333 334 335 336
TEST_F(libyuvTest, ARGBScaleTo1366x768_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1366;
  int dst_height = 768;

337 338 339 340
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
341
  EXPECT_LE(max_diff, 2);
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
}


TEST_F(libyuvTest, ARGBScaleTo1280x720_None) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1280;
  int dst_height = 720;

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
}

TEST_F(libyuvTest, ARGBScaleTo1280x720_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1280;
  int dst_height = 720;

364 365 366 367
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
368
  EXPECT_LE(max_diff, 2);
369 370 371
}

TEST_F(libyuvTest, ARGBScaleTo853x480_None) {
372 373
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
374 375 376
  int dst_width = 853;
  int dst_height = 480;

377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
  EXPECT_LE(max_diff, 1);
}

TEST_F(libyuvTest, ARGBScaleTo853x480_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 853;
  int dst_height = 480;

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
394
  EXPECT_LE(max_diff, 2);
395 396
}

397 398 399
TEST_F(libyuvTest, ARGBScaleFrom640x360_None) {
  int src_width = 640;
  int src_height = 360;
400 401
  int dst_width = Abs(benchmark_width_);
  int dst_height = Abs(benchmark_height_);
402 403 404 405 406

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterNone,
                                benchmark_iterations_);
407
  EXPECT_LE(max_diff, 1);
408 409 410 411 412
}

TEST_F(libyuvTest, ARGBScaleFrom640x360_Bilinear) {
  int src_width = 640;
  int src_height = 360;
413 414
  int dst_width = Abs(benchmark_width_);
  int dst_height = Abs(benchmark_height_);
415 416 417 418 419

  int max_diff = ARGBTestFilter(src_width, src_height,
                                dst_width, dst_height,
                                kFilterBilinear,
                                benchmark_iterations_);
fbarchard@google.com's avatar
fbarchard@google.com committed
420
  EXPECT_LE(max_diff, 2);
421 422
}

fbarchard@google.com's avatar
fbarchard@google.com committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
static const int kTileX = 16;
static const int kTileY = 16;

static int TileARGBScale(const uint8* src_argb, int src_stride_argb,
                         int src_width, int src_height,
                         uint8* dst_argb, int dst_stride_argb,
                         int dst_width, int dst_height,
                         FilterMode filtering) {
  for (int y = 0; y < dst_height; y += kTileY) {
    for (int x = 0; x < dst_width; x += kTileX) {
      int clip_width = kTileX;
      if (x + clip_width > dst_width) {
        clip_width = dst_width - x;
      }
      int clip_height = kTileY;
      if (y + clip_height > dst_height) {
        clip_height = dst_height - y;
      }
      int r = ARGBScaleClip(src_argb, src_stride_argb,
                            src_width, src_height,
                            dst_argb, dst_stride_argb,
                            dst_width, dst_height,
                            x, y, clip_width, clip_height, filtering);
      if (r) {
        return r;
      }
    }
  }
  return 0;
}

static int ARGBClipTestFilter(int src_width, int src_height,
                              int dst_width, int dst_height,
                              FilterMode f, int benchmark_iterations) {
  const int b = 128;
  int src_argb_plane_size = (Abs(src_width) + b * 2) *
      (Abs(src_height) + b * 2) * 4;
  int src_stride_argb = (b * 2 + Abs(src_width)) * 4;

  align_buffer_64(src_argb, src_argb_plane_size)
  memset(src_argb, 1, src_argb_plane_size);

  int dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4;
  int dst_stride_argb = (b * 2 + dst_width) * 4;

  srandom(time(NULL));

  int i, j;
  for (i = b; i < (Abs(src_height) + b); ++i) {
    for (j = b; j < (Abs(src_width) + b) * 4; ++j) {
      src_argb[(i * src_stride_argb) + j] = (random() & 0xff);
    }
  }

  align_buffer_64(dst_argb_c, dst_argb_plane_size)
  align_buffer_64(dst_argb_opt, dst_argb_plane_size)
  memset(dst_argb_c, 2, dst_argb_plane_size);
  memset(dst_argb_opt, 3, dst_argb_plane_size);

  // Do full image, no clipping.
  double c_time = get_time();
  ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
            src_width, src_height,
            dst_argb_c + (dst_stride_argb * b) + b * 4, dst_stride_argb,
            dst_width, dst_height, f);
  c_time = (get_time() - c_time);

  // Do tiled image, clipping scale to a tile at a time.
  double opt_time = get_time();
  for (i = 0; i < benchmark_iterations; ++i) {
    TileARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
                  src_width, src_height,
                  dst_argb_opt + (dst_stride_argb * b) + b * 4, dst_stride_argb,
                  dst_width, dst_height, f);
  }
  opt_time = (get_time() - opt_time) / benchmark_iterations;

  // Report performance of Full vs Tiled.
  printf("filter %d - %8d us Full - %8d us Tiled\n",
         f, static_cast<int>(c_time * 1e6), static_cast<int>(opt_time * 1e6));

  // Compare full scaled image vs tiled image.
  int max_diff = 0;
  for (i = b; i < (dst_height + b); ++i) {
    for (j = b * 4; j < (dst_width + b) * 4; ++j) {
      int abs_diff = abs(dst_argb_c[(i * dst_stride_argb) + j] -
                         dst_argb_opt[(i * dst_stride_argb) + j]);
      if (abs_diff > max_diff) {
        max_diff = abs_diff;
      }
    }
  }

  free_aligned_buffer_64(dst_argb_c)
  free_aligned_buffer_64(dst_argb_opt)
  free_aligned_buffer_64(src_argb)
  return max_diff;
}

TEST_F(libyuvTest, ARGBScaleClipDownBy1_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width);
  const int dst_height = Abs(src_height);

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy1_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width);
  const int dst_height = Abs(src_height);

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy2_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 2;
  const int dst_height = Abs(src_height) / 2;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy2_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 2;
  const int dst_height = Abs(src_height) / 2;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy4_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 4;
  const int dst_height = Abs(src_height) / 4;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy4_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 4;
  const int dst_height = Abs(src_height) / 4;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy5_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 5;
  const int dst_height = Abs(src_height) / 5;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy5_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 5;
  const int dst_height = Abs(src_height) / 5;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy8_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 8;
  const int dst_height = Abs(src_height) / 8;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy8_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 8;
  const int dst_height = Abs(src_height) / 8;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy16_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 16;
  const int dst_height = Abs(src_height) / 16;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy16_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) / 16;
  const int dst_height = Abs(src_height) / 16;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy34_None) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) * 3 / 4;
  const int dst_height = Abs(src_height) * 3 / 4;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy34_Bilinear) {
  const int src_width = benchmark_width_;
  const int src_height = benchmark_height_;
  const int dst_width = Abs(src_width) * 3 / 4;
  const int dst_height = Abs(src_height) * 3 / 4;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy38_None) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = Abs(src_width) * 3 / 8;
  int dst_height = Abs(src_height) * 3 / 8;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipDownBy38_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = Abs(src_width) * 3 / 8;
  int dst_height = Abs(src_height) * 3 / 8;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipTo1366x768_None) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1366;
  int dst_height = 768;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipTo1366x768_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1366;
  int dst_height = 768;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}


TEST_F(libyuvTest, ARGBScaleClipTo1280x720_None) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1280;
  int dst_height = 720;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipTo1280x720_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 1280;
  int dst_height = 720;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipTo853x480_None) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 853;
  int dst_height = 480;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipTo853x480_Bilinear) {
  int src_width = benchmark_width_;
  int src_height = benchmark_height_;
  int dst_width = 853;
  int dst_height = 480;

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipFrom640x360_None) {
  int src_width = 640;
  int src_height = 360;
  int dst_width = Abs(benchmark_width_);
  int dst_height = Abs(benchmark_height_);

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterNone,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

TEST_F(libyuvTest, ARGBScaleClipFrom640x360_Bilinear) {
  int src_width = 640;
  int src_height = 360;
  int dst_width = Abs(benchmark_width_);
  int dst_height = Abs(benchmark_height_);

  int max_diff = ARGBClipTestFilter(src_width, src_height,
                                    dst_width, dst_height,
                                    kFilterBilinear,
                                    benchmark_iterations_);
  EXPECT_EQ(0, max_diff);
}

835
}  // namespace libyuv