Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: media/base/yuv_convert_unittest.cc

Issue 12217101: Replace FilePath with base::FilePath in some more top level directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/test_data_util.cc ('k') | media/ffmpeg/ffmpeg_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/cpu.h" 6 #include "base/cpu.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "media/base/djb2.h" 10 #include "media/base/djb2.h"
(...skipping 19 matching lines...) Expand all
30 // Surface sizes for various test files. 30 // Surface sizes for various test files.
31 static const int kYUV12Size = kSourceYSize * 12 / 8; 31 static const int kYUV12Size = kSourceYSize * 12 / 8;
32 static const int kYUV16Size = kSourceYSize * 16 / 8; 32 static const int kYUV16Size = kSourceYSize * 16 / 8;
33 static const int kYUY2Size = kSourceYSize * 16 / 8; 33 static const int kYUY2Size = kSourceYSize * 16 / 8;
34 static const int kRGBSize = kSourceYSize * kBpp; 34 static const int kRGBSize = kSourceYSize * kBpp;
35 static const int kRGBSizeScaled = kScaledWidth * kScaledHeight * kBpp; 35 static const int kRGBSizeScaled = kScaledWidth * kScaledHeight * kBpp;
36 static const int kRGB24Size = kSourceYSize * 3; 36 static const int kRGB24Size = kSourceYSize * 3;
37 static const int kRGBSizeConverted = kSourceYSize * kBpp; 37 static const int kRGBSizeConverted = kSourceYSize * kBpp;
38 38
39 // Helper for reading test data into a scoped_array<uint8>. 39 // Helper for reading test data into a scoped_array<uint8>.
40 static void ReadData(const FilePath::CharType* filename, 40 static void ReadData(const base::FilePath::CharType* filename,
41 int expected_size, 41 int expected_size,
42 scoped_array<uint8>* data) { 42 scoped_array<uint8>* data) {
43 data->reset(new uint8[expected_size]); 43 data->reset(new uint8[expected_size]);
44 44
45 FilePath path; 45 base::FilePath path;
46 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &path)); 46 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &path));
47 path = path.Append(FILE_PATH_LITERAL("media")) 47 path = path.Append(FILE_PATH_LITERAL("media"))
48 .Append(FILE_PATH_LITERAL("test")) 48 .Append(FILE_PATH_LITERAL("test"))
49 .Append(FILE_PATH_LITERAL("data")) 49 .Append(FILE_PATH_LITERAL("data"))
50 .Append(filename); 50 .Append(filename);
51 51
52 // Verify file size is correct. 52 // Verify file size is correct.
53 int64 actual_size = 0; 53 int64 actual_size = 0;
54 file_util::GetFileSize(path, &actual_size); 54 file_util::GetFileSize(path, &actual_size);
55 CHECK_EQ(actual_size, expected_size); 55 CHECK_EQ(actual_size, expected_size);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 330 }
331 331
332 TEST(YUVConvertTest, RGB32ToYUV) { 332 TEST(YUVConvertTest, RGB32ToYUV) {
333 // Allocate all surfaces. 333 // Allocate all surfaces.
334 scoped_array<uint8> yuv_bytes(new uint8[kYUV12Size]); 334 scoped_array<uint8> yuv_bytes(new uint8[kYUV12Size]);
335 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]); 335 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]);
336 scoped_array<uint8> yuv_converted_bytes(new uint8[kYUV12Size]); 336 scoped_array<uint8> yuv_converted_bytes(new uint8[kYUV12Size]);
337 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSize]); 337 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSize]);
338 338
339 // Read YUV reference data from file. 339 // Read YUV reference data from file.
340 FilePath yuv_url; 340 base::FilePath yuv_url;
341 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); 341 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url));
342 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) 342 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media"))
343 .Append(FILE_PATH_LITERAL("test")) 343 .Append(FILE_PATH_LITERAL("test"))
344 .Append(FILE_PATH_LITERAL("data")) 344 .Append(FILE_PATH_LITERAL("data"))
345 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); 345 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv"));
346 EXPECT_EQ(static_cast<int>(kYUV12Size), 346 EXPECT_EQ(static_cast<int>(kYUV12Size),
347 file_util::ReadFile(yuv_url, 347 file_util::ReadFile(yuv_url,
348 reinterpret_cast<char*>(yuv_bytes.get()), 348 reinterpret_cast<char*>(yuv_bytes.get()),
349 static_cast<int>(kYUV12Size))); 349 static_cast<int>(kYUV12Size)));
350 350
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 yuv_converted_bytes.get() + kSourceVOffset, 408 yuv_converted_bytes.get() + kSourceVOffset,
409 kSourceWidth, kSourceHeight); 409 kSourceWidth, kSourceHeight);
410 410
411 uint32 yuy_hash = DJB2Hash(yuv_converted_bytes.get(), kYUV12Size, 411 uint32 yuy_hash = DJB2Hash(yuv_converted_bytes.get(), kYUV12Size,
412 kDJB2HashSeed); 412 kDJB2HashSeed);
413 EXPECT_EQ(666823187u, yuy_hash); 413 EXPECT_EQ(666823187u, yuy_hash);
414 } 414 }
415 415
416 TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) { 416 TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) {
417 // Read YUV reference data from file. 417 // Read YUV reference data from file.
418 FilePath yuv_url; 418 base::FilePath yuv_url;
419 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); 419 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url));
420 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) 420 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media"))
421 .Append(FILE_PATH_LITERAL("test")) 421 .Append(FILE_PATH_LITERAL("test"))
422 .Append(FILE_PATH_LITERAL("data")) 422 .Append(FILE_PATH_LITERAL("data"))
423 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); 423 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv"));
424 const size_t size_of_yuv = kSourceYSize * 12 / 8; // 12 bpp. 424 const size_t size_of_yuv = kSourceYSize * 12 / 8; // 12 bpp.
425 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); 425 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]);
426 EXPECT_EQ(static_cast<int>(size_of_yuv), 426 EXPECT_EQ(static_cast<int>(size_of_yuv),
427 file_util::ReadFile(yuv_url, 427 file_util::ReadFile(yuv_url,
428 reinterpret_cast<char*>(yuv_bytes.get()), 428 reinterpret_cast<char*>(yuv_bytes.get()),
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 kSourceDx); 932 kSourceDx);
933 media::EmptyRegisterState(); 933 media::EmptyRegisterState();
934 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 934 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
935 rgb_bytes_converted.get(), 935 rgb_bytes_converted.get(),
936 kWidth * kBpp)); 936 kWidth * kBpp));
937 } 937 }
938 938
939 #endif // defined(ARCH_CPU_X86_64) 939 #endif // defined(ARCH_CPU_X86_64)
940 940
941 #endif // defined(ARCH_CPU_X86_FAMILY) 941 #endif // defined(ARCH_CPU_X86_FAMILY)
OLDNEW
« no previous file with comments | « media/base/test_data_util.cc ('k') | media/ffmpeg/ffmpeg_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698