| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include <memory> | |
| 12 #include <sstream> | |
| 13 | |
| 14 #include "libyuv/cpu_id.h" | |
| 15 #include "libyuv/scale.h" | |
| 16 #include "webrtc/base/basictypes.h" | |
| 17 #include "webrtc/base/flags.h" | |
| 18 #include "webrtc/base/gunit.h" | |
| 19 #include "webrtc/media/base/testutils.h" | |
| 20 | |
| 21 #if defined(_MSC_VER) | |
| 22 #define ALIGN16(var) __declspec(align(16)) var | |
| 23 #else | |
| 24 #define ALIGN16(var) var __attribute__((aligned(16))) | |
| 25 #endif | |
| 26 | |
| 27 using cricket::LoadPlanarYuvTestImage; | |
| 28 using cricket::DumpPlanarYuvTestImage; | |
| 29 | |
| 30 DEFINE_bool(yuvscaler_dump, false, | |
| 31 "whether to write out scaled images for inspection"); | |
| 32 DEFINE_int(yuvscaler_repeat, 1, | |
| 33 "how many times to perform each scaling operation (for perf testing)"); | |
| 34 | |
| 35 static const int kAlignment = 16; | |
| 36 | |
| 37 // TEST_UNCACHED flushes cache to test real memory performance. | |
| 38 // TEST_RSTSC uses cpu cycles for more accurate benchmark of the scale function. | |
| 39 #ifndef __arm__ | |
| 40 // #define TEST_UNCACHED 1 | |
| 41 // #define TEST_RSTSC 1 | |
| 42 #endif | |
| 43 | |
| 44 #if defined(TEST_UNCACHED) || defined(TEST_RSTSC) | |
| 45 #ifdef _MSC_VER | |
| 46 #include <emmintrin.h> // NOLINT | |
| 47 #endif | |
| 48 | |
| 49 #if defined(__GNUC__) && defined(__i386__) | |
| 50 static inline uint64_t __rdtsc(void) { | |
| 51 uint32_t a, d; | |
| 52 __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); | |
| 53 return (reinterpret_cast<uint64_t>(d) << 32) + a; | |
| 54 } | |
| 55 | |
| 56 static inline void _mm_clflush(volatile void *__p) { | |
| 57 asm volatile("clflush %0" : "+m" (*(volatile char *)__p)); | |
| 58 } | |
| 59 #endif | |
| 60 | |
| 61 static void FlushCache(uint8_t* dst, int count) { | |
| 62 while (count >= 32) { | |
| 63 _mm_clflush(dst); | |
| 64 dst += 32; | |
| 65 count -= 32; | |
| 66 } | |
| 67 } | |
| 68 #endif | |
| 69 | |
| 70 class YuvScalerTest : public testing::Test { | |
| 71 protected: | |
| 72 virtual void SetUp() { | |
| 73 dump_ = *rtc::FlagList::Lookup("yuvscaler_dump")->bool_variable(); | |
| 74 repeat_ = *rtc::FlagList::Lookup("yuvscaler_repeat")->int_variable(); | |
| 75 } | |
| 76 | |
| 77 // Scale an image and compare against a Lanczos-filtered test image. | |
| 78 // Lanczos is considered to be the "ideal" image resampling method, so we try | |
| 79 // to get as close to that as possible, while being as fast as possible. | |
| 80 bool TestScale(int iw, int ih, int ow, int oh, int offset, bool usefile, | |
| 81 bool optimize, int cpuflags, bool interpolate, | |
| 82 int memoffset, double* error) { | |
| 83 *error = 0.; | |
| 84 size_t isize = I420_SIZE(iw, ih); | |
| 85 size_t osize = I420_SIZE(ow, oh); | |
| 86 std::unique_ptr<uint8_t[]> ibuffer( | |
| 87 new uint8_t[isize + kAlignment + memoffset]()); | |
| 88 std::unique_ptr<uint8_t[]> obuffer( | |
| 89 new uint8_t[osize + kAlignment + memoffset]()); | |
| 90 std::unique_ptr<uint8_t[]> xbuffer( | |
| 91 new uint8_t[osize + kAlignment + memoffset]()); | |
| 92 | |
| 93 uint8_t* ibuf = ALIGNP(ibuffer.get(), kAlignment) + memoffset; | |
| 94 uint8_t* obuf = ALIGNP(obuffer.get(), kAlignment) + memoffset; | |
| 95 uint8_t* xbuf = ALIGNP(xbuffer.get(), kAlignment) + memoffset; | |
| 96 | |
| 97 if (usefile) { | |
| 98 if (!LoadPlanarYuvTestImage("faces", iw, ih, ibuf) || | |
| 99 !LoadPlanarYuvTestImage("faces", ow, oh, xbuf)) { | |
| 100 LOG(LS_ERROR) << "Failed to load image"; | |
| 101 return false; | |
| 102 } | |
| 103 } else { | |
| 104 // These are used to test huge images. | |
| 105 memset(ibuf, 213, isize); // Input is constant color. | |
| 106 memset(obuf, 100, osize); // Output set to something wrong for now. | |
| 107 memset(xbuf, 213, osize); // Expected result. | |
| 108 } | |
| 109 | |
| 110 #ifdef TEST_UNCACHED | |
| 111 FlushCache(ibuf, isize); | |
| 112 FlushCache(obuf, osize); | |
| 113 FlushCache(xbuf, osize); | |
| 114 #endif | |
| 115 | |
| 116 // Scale down. | |
| 117 // If cpu true, disable cpu optimizations. Else allow auto detect | |
| 118 // TODO(fbarchard): set flags for libyuv | |
| 119 libyuv::MaskCpuFlags(cpuflags); | |
| 120 #ifdef TEST_RSTSC | |
| 121 uint64_t t = 0; | |
| 122 #endif | |
| 123 for (int i = 0; i < repeat_; ++i) { | |
| 124 #ifdef TEST_UNCACHED | |
| 125 FlushCache(ibuf, isize); | |
| 126 FlushCache(obuf, osize); | |
| 127 #endif | |
| 128 #ifdef TEST_RSTSC | |
| 129 uint64_t t1 = __rdtsc(); | |
| 130 #endif | |
| 131 EXPECT_EQ(0, libyuv::ScaleOffset(ibuf, iw, ih, obuf, ow, oh, | |
| 132 offset, interpolate)); | |
| 133 #ifdef TEST_RSTSC | |
| 134 uint64_t t2 = __rdtsc(); | |
| 135 t += t2 - t1; | |
| 136 #endif | |
| 137 } | |
| 138 | |
| 139 #ifdef TEST_RSTSC | |
| 140 LOG(LS_INFO) << "Time: " << std::setw(9) << t; | |
| 141 #endif | |
| 142 | |
| 143 if (dump_) { | |
| 144 const testing::TestInfo* const test_info = | |
| 145 testing::UnitTest::GetInstance()->current_test_info(); | |
| 146 std::string test_name(test_info->name()); | |
| 147 DumpPlanarYuvTestImage(test_name, obuf, ow, oh); | |
| 148 } | |
| 149 | |
| 150 double sse = cricket::ComputeSumSquareError(obuf, xbuf, osize); | |
| 151 *error = sse / osize; // Mean Squared Error. | |
| 152 double PSNR = cricket::ComputePSNR(sse, osize); | |
| 153 LOG(LS_INFO) << "Image MSE: " << | |
| 154 std::setw(6) << std::setprecision(4) << *error << | |
| 155 " Image PSNR: " << PSNR; | |
| 156 return true; | |
| 157 } | |
| 158 | |
| 159 // Returns the index of the first differing byte. Easier to debug than memcmp. | |
| 160 static int FindDiff(const uint8_t* buf1, const uint8_t* buf2, int len) { | |
| 161 int i = 0; | |
| 162 while (i < len && buf1[i] == buf2[i]) { | |
| 163 i++; | |
| 164 } | |
| 165 return (i < len) ? i : -1; | |
| 166 } | |
| 167 | |
| 168 protected: | |
| 169 bool dump_; | |
| 170 int repeat_; | |
| 171 }; | |
| 172 | |
| 173 // Tests straight copy of data. | |
| 174 TEST_F(YuvScalerTest, TestCopy) { | |
| 175 const int iw = 640, ih = 360; | |
| 176 const int ow = 640, oh = 360; | |
| 177 ALIGN16(uint8_t ibuf[I420_SIZE(iw, ih)]); | |
| 178 ALIGN16(uint8_t obuf[I420_SIZE(ow, oh)]); | |
| 179 | |
| 180 // Load the frame, scale it, check it. | |
| 181 ASSERT_TRUE(LoadPlanarYuvTestImage("faces", iw, ih, ibuf)); | |
| 182 for (int i = 0; i < repeat_; ++i) { | |
| 183 libyuv::ScaleOffset(ibuf, iw, ih, obuf, ow, oh, 0, false); | |
| 184 } | |
| 185 if (dump_) DumpPlanarYuvTestImage("TestCopy", obuf, ow, oh); | |
| 186 EXPECT_EQ(-1, FindDiff(obuf, ibuf, sizeof(ibuf))); | |
| 187 } | |
| 188 | |
| 189 // Tests copy from 4:3 to 16:9. | |
| 190 TEST_F(YuvScalerTest, TestOffset16_10Copy) { | |
| 191 const int iw = 640, ih = 360; | |
| 192 const int ow = 640, oh = 480; | |
| 193 const int offset = (480 - 360) / 2; | |
| 194 std::unique_ptr<uint8_t[]> ibuffer( | |
| 195 new uint8_t[I420_SIZE(iw, ih) + kAlignment]); | |
| 196 std::unique_ptr<uint8_t[]> obuffer( | |
| 197 new uint8_t[I420_SIZE(ow, oh) + kAlignment]); | |
| 198 | |
| 199 uint8_t* ibuf = ALIGNP(ibuffer.get(), kAlignment); | |
| 200 uint8_t* obuf = ALIGNP(obuffer.get(), kAlignment); | |
| 201 | |
| 202 // Load the frame, scale it, check it. | |
| 203 ASSERT_TRUE(LoadPlanarYuvTestImage("faces", iw, ih, ibuf)); | |
| 204 | |
| 205 // Clear to black, which is Y = 0 and U and V = 128 | |
| 206 memset(obuf, 0, ow * oh); | |
| 207 memset(obuf + ow * oh, 128, ow * oh / 2); | |
| 208 for (int i = 0; i < repeat_; ++i) { | |
| 209 libyuv::ScaleOffset(ibuf, iw, ih, obuf, ow, oh, offset, false); | |
| 210 } | |
| 211 if (dump_) DumpPlanarYuvTestImage("TestOffsetCopy16_9", obuf, ow, oh); | |
| 212 EXPECT_EQ(-1, FindDiff(obuf + ow * offset, | |
| 213 ibuf, | |
| 214 iw * ih)); | |
| 215 EXPECT_EQ(-1, FindDiff(obuf + ow * oh + ow * offset / 4, | |
| 216 ibuf + iw * ih, | |
| 217 iw * ih / 4)); | |
| 218 EXPECT_EQ(-1, FindDiff(obuf + ow * oh * 5 / 4 + ow * offset / 4, | |
| 219 ibuf + iw * ih * 5 / 4, | |
| 220 iw * ih / 4)); | |
| 221 } | |
| 222 | |
| 223 // The following are 'cpu' flag values: | |
| 224 // Allow all SIMD optimizations | |
| 225 #define ALLFLAGS -1 | |
| 226 // Disable SSSE3 but allow other forms of SIMD (SSE2) | |
| 227 #define NOSSSE3 ~libyuv::kCpuHasSSSE3 | |
| 228 // Disable SSE2 and SSSE3 | |
| 229 #define NOSSE ~libyuv::kCpuHasSSE2 & ~libyuv::kCpuHasSSSE3 | |
| 230 | |
| 231 // TEST_M scale factor with variations of opt, align, int | |
| 232 #define TEST_M(name, iwidth, iheight, owidth, oheight, mse) \ | |
| 233 TEST_F(YuvScalerTest, name##Ref) { \ | |
| 234 double error; \ | |
| 235 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 236 0, true, false, ALLFLAGS, false, 0, &error)); \ | |
| 237 EXPECT_LE(error, mse); \ | |
| 238 } \ | |
| 239 TEST_F(YuvScalerTest, name##OptAligned) { \ | |
| 240 double error; \ | |
| 241 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 242 0, true, true, ALLFLAGS, false, 0, &error)); \ | |
| 243 EXPECT_LE(error, mse); \ | |
| 244 } \ | |
| 245 TEST_F(YuvScalerTest, name##OptUnaligned) { \ | |
| 246 double error; \ | |
| 247 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 248 0, true, true, ALLFLAGS, false, 1, &error)); \ | |
| 249 EXPECT_LE(error, mse); \ | |
| 250 } \ | |
| 251 TEST_F(YuvScalerTest, name##OptSSE2) { \ | |
| 252 double error; \ | |
| 253 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 254 0, true, true, NOSSSE3, false, 0, &error)); \ | |
| 255 EXPECT_LE(error, mse); \ | |
| 256 } \ | |
| 257 TEST_F(YuvScalerTest, name##OptC) { \ | |
| 258 double error; \ | |
| 259 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 260 0, true, true, NOSSE, false, 0, &error)); \ | |
| 261 EXPECT_LE(error, mse); \ | |
| 262 } \ | |
| 263 TEST_F(YuvScalerTest, name##IntRef) { \ | |
| 264 double error; \ | |
| 265 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 266 0, true, false, ALLFLAGS, true, 0, &error)); \ | |
| 267 EXPECT_LE(error, mse); \ | |
| 268 } \ | |
| 269 TEST_F(YuvScalerTest, name##IntOptAligned) { \ | |
| 270 double error; \ | |
| 271 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 272 0, true, true, ALLFLAGS, true, 0, &error)); \ | |
| 273 EXPECT_LE(error, mse); \ | |
| 274 } \ | |
| 275 TEST_F(YuvScalerTest, name##IntOptUnaligned) { \ | |
| 276 double error; \ | |
| 277 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 278 0, true, true, ALLFLAGS, true, 1, &error)); \ | |
| 279 EXPECT_LE(error, mse); \ | |
| 280 } \ | |
| 281 TEST_F(YuvScalerTest, name##IntOptSSE2) { \ | |
| 282 double error; \ | |
| 283 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 284 0, true, true, NOSSSE3, true, 0, &error)); \ | |
| 285 EXPECT_LE(error, mse); \ | |
| 286 } \ | |
| 287 TEST_F(YuvScalerTest, name##IntOptC) { \ | |
| 288 double error; \ | |
| 289 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 290 0, true, true, NOSSE, true, 0, &error)); \ | |
| 291 EXPECT_LE(error, mse); \ | |
| 292 } | |
| 293 | |
| 294 #define TEST_H(name, iwidth, iheight, owidth, oheight, opt, cpu, intr, mse) \ | |
| 295 TEST_F(YuvScalerTest, name) { \ | |
| 296 double error; \ | |
| 297 EXPECT_TRUE(TestScale(iwidth, iheight, owidth, oheight, \ | |
| 298 0, false, opt, cpu, intr, 0, &error)); \ | |
| 299 EXPECT_LE(error, mse); \ | |
| 300 } | |
| 301 | |
| 302 // Test 4x3 aspect ratio scaling | |
| 303 | |
| 304 // Tests 1/1x scale down. | |
| 305 TEST_M(TestScale4by3Down11, 640, 480, 640, 480, 0) | |
| 306 | |
| 307 // Tests 3/4x scale down. | |
| 308 TEST_M(TestScale4by3Down34, 640, 480, 480, 360, 60) | |
| 309 | |
| 310 // Tests 1/2x scale down. | |
| 311 TEST_M(TestScale4by3Down12, 640, 480, 320, 240, 60) | |
| 312 | |
| 313 // Tests 3/8x scale down. | |
| 314 TEST_M(TestScale4by3Down38, 640, 480, 240, 180, 60) | |
| 315 | |
| 316 // Tests 1/4x scale down.. | |
| 317 TEST_M(TestScale4by3Down14, 640, 480, 160, 120, 60) | |
| 318 | |
| 319 // Tests 3/16x scale down. | |
| 320 TEST_M(TestScale4by3Down316, 640, 480, 120, 90, 120) | |
| 321 | |
| 322 // Tests 1/8x scale down. | |
| 323 TEST_M(TestScale4by3Down18, 640, 480, 80, 60, 150) | |
| 324 | |
| 325 // Tests 2/3x scale down. | |
| 326 TEST_M(TestScale4by3Down23, 480, 360, 320, 240, 60) | |
| 327 | |
| 328 // Tests 4/3x scale up. | |
| 329 TEST_M(TestScale4by3Up43, 480, 360, 640, 480, 60) | |
| 330 | |
| 331 // Tests 2/1x scale up. | |
| 332 TEST_M(TestScale4by3Up21, 320, 240, 640, 480, 60) | |
| 333 | |
| 334 // Tests 4/1x scale up. | |
| 335 TEST_M(TestScale4by3Up41, 160, 120, 640, 480, 80) | |
| 336 | |
| 337 // Test 16x10 aspect ratio scaling | |
| 338 | |
| 339 // Tests 1/1x scale down. | |
| 340 TEST_M(TestScale16by10Down11, 640, 400, 640, 400, 0) | |
| 341 | |
| 342 // Tests 3/4x scale down. | |
| 343 TEST_M(TestScale16by10Down34, 640, 400, 480, 300, 60) | |
| 344 | |
| 345 // Tests 1/2x scale down. | |
| 346 TEST_M(TestScale16by10Down12, 640, 400, 320, 200, 60) | |
| 347 | |
| 348 // Tests 3/8x scale down. | |
| 349 TEST_M(TestScale16by10Down38, 640, 400, 240, 150, 60) | |
| 350 | |
| 351 // Tests 1/4x scale down.. | |
| 352 TEST_M(TestScale16by10Down14, 640, 400, 160, 100, 60) | |
| 353 | |
| 354 // Tests 3/16x scale down. | |
| 355 TEST_M(TestScale16by10Down316, 640, 400, 120, 75, 120) | |
| 356 | |
| 357 // Tests 1/8x scale down. | |
| 358 TEST_M(TestScale16by10Down18, 640, 400, 80, 50, 150) | |
| 359 | |
| 360 // Tests 2/3x scale down. | |
| 361 TEST_M(TestScale16by10Down23, 480, 300, 320, 200, 60) | |
| 362 | |
| 363 // Tests 4/3x scale up. | |
| 364 TEST_M(TestScale16by10Up43, 480, 300, 640, 400, 60) | |
| 365 | |
| 366 // Tests 2/1x scale up. | |
| 367 TEST_M(TestScale16by10Up21, 320, 200, 640, 400, 60) | |
| 368 | |
| 369 // Tests 4/1x scale up. | |
| 370 TEST_M(TestScale16by10Up41, 160, 100, 640, 400, 80) | |
| 371 | |
| 372 // Test 16x9 aspect ratio scaling | |
| 373 | |
| 374 // Tests 1/1x scale down. | |
| 375 TEST_M(TestScaleDown11, 640, 360, 640, 360, 0) | |
| 376 | |
| 377 // Tests 3/4x scale down. | |
| 378 TEST_M(TestScaleDown34, 640, 360, 480, 270, 60) | |
| 379 | |
| 380 // Tests 1/2x scale down. | |
| 381 TEST_M(TestScaleDown12, 640, 360, 320, 180, 60) | |
| 382 | |
| 383 // Tests 3/8x scale down. | |
| 384 TEST_M(TestScaleDown38, 640, 360, 240, 135, 60) | |
| 385 | |
| 386 // Tests 1/4x scale down.. | |
| 387 TEST_M(TestScaleDown14, 640, 360, 160, 90, 60) | |
| 388 | |
| 389 // Tests 3/16x scale down. | |
| 390 TEST_M(TestScaleDown316, 640, 360, 120, 68, 120) | |
| 391 | |
| 392 // Tests 1/8x scale down. | |
| 393 TEST_M(TestScaleDown18, 640, 360, 80, 45, 150) | |
| 394 | |
| 395 // Tests 2/3x scale down. | |
| 396 TEST_M(TestScaleDown23, 480, 270, 320, 180, 60) | |
| 397 | |
| 398 // Tests 4/3x scale up. | |
| 399 TEST_M(TestScaleUp43, 480, 270, 640, 360, 60) | |
| 400 | |
| 401 // Tests 2/1x scale up. | |
| 402 TEST_M(TestScaleUp21, 320, 180, 640, 360, 60) | |
| 403 | |
| 404 // Tests 4/1x scale up. | |
| 405 TEST_M(TestScaleUp41, 160, 90, 640, 360, 80) | |
| 406 | |
| 407 // Test HD 4x3 aspect ratio scaling | |
| 408 | |
| 409 // Tests 1/1x scale down. | |
| 410 TEST_M(TestScaleHD4x3Down11, 1280, 960, 1280, 960, 0) | |
| 411 | |
| 412 // Tests 3/4x scale down. | |
| 413 TEST_M(TestScaleHD4x3Down34, 1280, 960, 960, 720, 60) | |
| 414 | |
| 415 // Tests 1/2x scale down. | |
| 416 TEST_M(TestScaleHD4x3Down12, 1280, 960, 640, 480, 60) | |
| 417 | |
| 418 // Tests 3/8x scale down. | |
| 419 TEST_M(TestScaleHD4x3Down38, 1280, 960, 480, 360, 60) | |
| 420 | |
| 421 // Tests 1/4x scale down.. | |
| 422 TEST_M(TestScaleHD4x3Down14, 1280, 960, 320, 240, 60) | |
| 423 | |
| 424 // Tests 3/16x scale down. | |
| 425 TEST_M(TestScaleHD4x3Down316, 1280, 960, 240, 180, 120) | |
| 426 | |
| 427 // Tests 1/8x scale down. | |
| 428 TEST_M(TestScaleHD4x3Down18, 1280, 960, 160, 120, 150) | |
| 429 | |
| 430 // Tests 2/3x scale down. | |
| 431 TEST_M(TestScaleHD4x3Down23, 960, 720, 640, 480, 60) | |
| 432 | |
| 433 // Tests 4/3x scale up. | |
| 434 TEST_M(TestScaleHD4x3Up43, 960, 720, 1280, 960, 60) | |
| 435 | |
| 436 // Tests 2/1x scale up. | |
| 437 TEST_M(TestScaleHD4x3Up21, 640, 480, 1280, 960, 60) | |
| 438 | |
| 439 // Tests 4/1x scale up. | |
| 440 TEST_M(TestScaleHD4x3Up41, 320, 240, 1280, 960, 80) | |
| 441 | |
| 442 // Test HD 16x10 aspect ratio scaling | |
| 443 | |
| 444 // Tests 1/1x scale down. | |
| 445 TEST_M(TestScaleHD16x10Down11, 1280, 800, 1280, 800, 0) | |
| 446 | |
| 447 // Tests 3/4x scale down. | |
| 448 TEST_M(TestScaleHD16x10Down34, 1280, 800, 960, 600, 60) | |
| 449 | |
| 450 // Tests 1/2x scale down. | |
| 451 TEST_M(TestScaleHD16x10Down12, 1280, 800, 640, 400, 60) | |
| 452 | |
| 453 // Tests 3/8x scale down. | |
| 454 TEST_M(TestScaleHD16x10Down38, 1280, 800, 480, 300, 60) | |
| 455 | |
| 456 // Tests 1/4x scale down.. | |
| 457 TEST_M(TestScaleHD16x10Down14, 1280, 800, 320, 200, 60) | |
| 458 | |
| 459 // Tests 3/16x scale down. | |
| 460 TEST_M(TestScaleHD16x10Down316, 1280, 800, 240, 150, 120) | |
| 461 | |
| 462 // Tests 1/8x scale down. | |
| 463 TEST_M(TestScaleHD16x10Down18, 1280, 800, 160, 100, 150) | |
| 464 | |
| 465 // Tests 2/3x scale down. | |
| 466 TEST_M(TestScaleHD16x10Down23, 960, 600, 640, 400, 60) | |
| 467 | |
| 468 // Tests 4/3x scale up. | |
| 469 TEST_M(TestScaleHD16x10Up43, 960, 600, 1280, 800, 60) | |
| 470 | |
| 471 // Tests 2/1x scale up. | |
| 472 TEST_M(TestScaleHD16x10Up21, 640, 400, 1280, 800, 60) | |
| 473 | |
| 474 // Tests 4/1x scale up. | |
| 475 TEST_M(TestScaleHD16x10Up41, 320, 200, 1280, 800, 80) | |
| 476 | |
| 477 // Test HD 16x9 aspect ratio scaling | |
| 478 | |
| 479 // Tests 1/1x scale down. | |
| 480 TEST_M(TestScaleHDDown11, 1280, 720, 1280, 720, 0) | |
| 481 | |
| 482 // Tests 3/4x scale down. | |
| 483 TEST_M(TestScaleHDDown34, 1280, 720, 960, 540, 60) | |
| 484 | |
| 485 // Tests 1/2x scale down. | |
| 486 TEST_M(TestScaleHDDown12, 1280, 720, 640, 360, 60) | |
| 487 | |
| 488 // Tests 3/8x scale down. | |
| 489 TEST_M(TestScaleHDDown38, 1280, 720, 480, 270, 60) | |
| 490 | |
| 491 // Tests 1/4x scale down.. | |
| 492 TEST_M(TestScaleHDDown14, 1280, 720, 320, 180, 60) | |
| 493 | |
| 494 // Tests 3/16x scale down. | |
| 495 TEST_M(TestScaleHDDown316, 1280, 720, 240, 135, 120) | |
| 496 | |
| 497 // Tests 1/8x scale down. | |
| 498 TEST_M(TestScaleHDDown18, 1280, 720, 160, 90, 150) | |
| 499 | |
| 500 // Tests 2/3x scale down. | |
| 501 TEST_M(TestScaleHDDown23, 960, 540, 640, 360, 60) | |
| 502 | |
| 503 // Tests 4/3x scale up. | |
| 504 TEST_M(TestScaleHDUp43, 960, 540, 1280, 720, 60) | |
| 505 | |
| 506 // Tests 2/1x scale up. | |
| 507 TEST_M(TestScaleHDUp21, 640, 360, 1280, 720, 60) | |
| 508 | |
| 509 // Tests 4/1x scale up. | |
| 510 TEST_M(TestScaleHDUp41, 320, 180, 1280, 720, 80) | |
| 511 | |
| 512 // Tests 1366x768 resolution for comparison to chromium scaler_bench | |
| 513 TEST_M(TestScaleHDUp1366, 1280, 720, 1366, 768, 10) | |
| 514 | |
| 515 // Tests odd source/dest sizes. 3 less to make chroma odd as well. | |
| 516 TEST_M(TestScaleHDUp1363, 1277, 717, 1363, 765, 10) | |
| 517 | |
| 518 // Tests 1/2x scale down, using optimized algorithm. | |
| 519 TEST_M(TestScaleOddDown12, 180, 100, 90, 50, 50) | |
| 520 | |
| 521 // Tests bilinear scale down | |
| 522 TEST_M(TestScaleOddDownBilin, 160, 100, 90, 50, 120) | |
| 523 | |
| 524 // Test huge buffer scales that are expected to use a different code path | |
| 525 // that avoids stack overflow but still work using point sampling. | |
| 526 // Max output size is 640 wide. | |
| 527 | |
| 528 // Tests interpolated 1/8x scale down, using optimized algorithm. | |
| 529 TEST_H(TestScaleDown18HDOptInt, 6144, 48, 768, 6, true, ALLFLAGS, true, 1) | |
| 530 | |
| 531 // Tests interpolated 1/8x scale down, using c_only optimized algorithm. | |
| 532 TEST_H(TestScaleDown18HDCOnlyOptInt, 6144, 48, 768, 6, true, NOSSE, true, 1) | |
| 533 | |
| 534 // Tests interpolated 3/8x scale down, using optimized algorithm. | |
| 535 TEST_H(TestScaleDown38HDOptInt, 2048, 16, 768, 6, true, ALLFLAGS, true, 1) | |
| 536 | |
| 537 // Tests interpolated 3/8x scale down, using no SSSE3 optimized algorithm. | |
| 538 TEST_H(TestScaleDown38HDNoSSSE3OptInt, 2048, 16, 768, 6, true, NOSSSE3, true, 1) | |
| 539 | |
| 540 // Tests interpolated 3/8x scale down, using c_only optimized algorithm. | |
| 541 TEST_H(TestScaleDown38HDCOnlyOptInt, 2048, 16, 768, 6, true, NOSSE, true, 1) | |
| 542 | |
| 543 // Tests interpolated 3/16x scale down, using optimized algorithm. | |
| 544 TEST_H(TestScaleDown316HDOptInt, 4096, 32, 768, 6, true, ALLFLAGS, true, 1) | |
| 545 | |
| 546 // Tests interpolated 3/16x scale down, using no SSSE3 optimized algorithm. | |
| 547 TEST_H(TestScaleDown316HDNoSSSE3OptInt, 4096, 32, 768, 6, true, NOSSSE3, true, | |
| 548 1) | |
| 549 | |
| 550 // Tests interpolated 3/16x scale down, using c_only optimized algorithm. | |
| 551 TEST_H(TestScaleDown316HDCOnlyOptInt, 4096, 32, 768, 6, true, NOSSE, true, 1) | |
| 552 | |
| 553 // Test special sizes dont crash | |
| 554 // Tests scaling down to 1 pixel width | |
| 555 TEST_H(TestScaleDown1x6OptInt, 3, 24, 1, 6, true, ALLFLAGS, true, 4) | |
| 556 | |
| 557 // Tests scaling down to 1 pixel height | |
| 558 TEST_H(TestScaleDown6x1OptInt, 24, 3, 6, 1, true, ALLFLAGS, true, 4) | |
| 559 | |
| 560 // Tests scaling up from 1 pixel width | |
| 561 TEST_H(TestScaleUp1x6OptInt, 1, 6, 3, 24, true, ALLFLAGS, true, 4) | |
| 562 | |
| 563 // Tests scaling up from 1 pixel height | |
| 564 TEST_H(TestScaleUp6x1OptInt, 6, 1, 24, 3, true, ALLFLAGS, true, 4) | |
| 565 | |
| 566 // Test performance of a range of box filter scale sizes | |
| 567 | |
| 568 // Tests interpolated 1/2x scale down, using optimized algorithm. | |
| 569 TEST_H(TestScaleDown2xHDOptInt, 1280, 720, 1280 / 2, 720 / 2, true, ALLFLAGS, | |
| 570 true, 1) | |
| 571 | |
| 572 // Tests interpolated 1/3x scale down, using optimized algorithm. | |
| 573 TEST_H(TestScaleDown3xHDOptInt, 1280, 720, 1280 / 3, 720 / 3, true, ALLFLAGS, | |
| 574 true, 1) | |
| 575 | |
| 576 // Tests interpolated 1/4x scale down, using optimized algorithm. | |
| 577 TEST_H(TestScaleDown4xHDOptInt, 1280, 720, 1280 / 4, 720 / 4, true, ALLFLAGS, | |
| 578 true, 1) | |
| 579 | |
| 580 // Tests interpolated 1/5x scale down, using optimized algorithm. | |
| 581 TEST_H(TestScaleDown5xHDOptInt, 1280, 720, 1280 / 5, 720 / 5, true, ALLFLAGS, | |
| 582 true, 1) | |
| 583 | |
| 584 // Tests interpolated 1/6x scale down, using optimized algorithm. | |
| 585 TEST_H(TestScaleDown6xHDOptInt, 1280, 720, 1280 / 6, 720 / 6, true, ALLFLAGS, | |
| 586 true, 1) | |
| 587 | |
| 588 // Tests interpolated 1/7x scale down, using optimized algorithm. | |
| 589 TEST_H(TestScaleDown7xHDOptInt, 1280, 720, 1280 / 7, 720 / 7, true, ALLFLAGS, | |
| 590 true, 1) | |
| 591 | |
| 592 // Tests interpolated 1/8x scale down, using optimized algorithm. | |
| 593 TEST_H(TestScaleDown8xHDOptInt, 1280, 720, 1280 / 8, 720 / 8, true, ALLFLAGS, | |
| 594 true, 1) | |
| 595 | |
| 596 // Tests interpolated 1/8x scale down, using optimized algorithm. | |
| 597 TEST_H(TestScaleDown9xHDOptInt, 1280, 720, 1280 / 9, 720 / 9, true, ALLFLAGS, | |
| 598 true, 1) | |
| 599 | |
| 600 // Tests interpolated 1/8x scale down, using optimized algorithm. | |
| 601 TEST_H(TestScaleDown10xHDOptInt, 1280, 720, 1280 / 10, 720 / 10, true, ALLFLAGS, | |
| 602 true, 1) | |
| OLD | NEW |