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

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

Issue 109043002: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/webm/chromeos/webm_encoder.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::GetFileSize(path, &actual_size); 54 base::GetFileSize(path, &actual_size);
55 CHECK_EQ(actual_size, expected_size); 55 CHECK_EQ(actual_size, expected_size);
56 56
57 // Verify bytes read are correct. 57 // Verify bytes read are correct.
58 int bytes_read = file_util::ReadFile( 58 int bytes_read = base::ReadFile(
59 path, reinterpret_cast<char*>(data->get()), expected_size); 59 path, reinterpret_cast<char*>(data->get()), expected_size);
60 CHECK_EQ(bytes_read, expected_size); 60 CHECK_EQ(bytes_read, expected_size);
61 } 61 }
62 62
63 static void ReadYV12Data(scoped_ptr<uint8[]>* data) { 63 static void ReadYV12Data(scoped_ptr<uint8[]>* data) {
64 ReadData(FILE_PATH_LITERAL("bali_640x360_P420.yuv"), kYUV12Size, data); 64 ReadData(FILE_PATH_LITERAL("bali_640x360_P420.yuv"), kYUV12Size, data);
65 } 65 }
66 66
67 static void ReadYV16Data(scoped_ptr<uint8[]>* data) { 67 static void ReadYV16Data(scoped_ptr<uint8[]>* data) {
68 ReadData(FILE_PATH_LITERAL("bali_640x360_P422.yuv"), kYUV16Size, data); 68 ReadData(FILE_PATH_LITERAL("bali_640x360_P422.yuv"), kYUV16Size, data);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 scoped_ptr<uint8[]> rgb_converted_bytes(new uint8[kRGBSize]); 364 scoped_ptr<uint8[]> rgb_converted_bytes(new uint8[kRGBSize]);
365 365
366 // Read YUV reference data from file. 366 // Read YUV reference data from file.
367 base::FilePath yuv_url; 367 base::FilePath yuv_url;
368 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); 368 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url));
369 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) 369 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media"))
370 .Append(FILE_PATH_LITERAL("test")) 370 .Append(FILE_PATH_LITERAL("test"))
371 .Append(FILE_PATH_LITERAL("data")) 371 .Append(FILE_PATH_LITERAL("data"))
372 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); 372 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv"));
373 EXPECT_EQ(static_cast<int>(kYUV12Size), 373 EXPECT_EQ(static_cast<int>(kYUV12Size),
374 file_util::ReadFile(yuv_url, 374 base::ReadFile(yuv_url,
375 reinterpret_cast<char*>(yuv_bytes.get()), 375 reinterpret_cast<char*>(yuv_bytes.get()),
376 static_cast<int>(kYUV12Size))); 376 static_cast<int>(kYUV12Size)));
377 377
378 // Convert a frame of YUV to 32 bit ARGB. 378 // Convert a frame of YUV to 32 bit ARGB.
379 media::ConvertYUVToRGB32(yuv_bytes.get(), 379 media::ConvertYUVToRGB32(yuv_bytes.get(),
380 yuv_bytes.get() + kSourceUOffset, 380 yuv_bytes.get() + kSourceUOffset,
381 yuv_bytes.get() + kSourceVOffset, 381 yuv_bytes.get() + kSourceVOffset,
382 rgb_bytes.get(), // RGB output 382 rgb_bytes.get(), // RGB output
383 kSourceWidth, kSourceHeight, // Dimensions 383 kSourceWidth, kSourceHeight, // Dimensions
384 kSourceWidth, // YStride 384 kSourceWidth, // YStride
385 kSourceWidth / 2, // UVStride 385 kSourceWidth / 2, // UVStride
386 kSourceWidth * kBpp, // RGBStride 386 kSourceWidth * kBpp, // RGBStride
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // Read YUV reference data from file. 444 // Read YUV reference data from file.
445 base::FilePath yuv_url; 445 base::FilePath yuv_url;
446 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); 446 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url));
447 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) 447 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media"))
448 .Append(FILE_PATH_LITERAL("test")) 448 .Append(FILE_PATH_LITERAL("test"))
449 .Append(FILE_PATH_LITERAL("data")) 449 .Append(FILE_PATH_LITERAL("data"))
450 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); 450 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv"));
451 const size_t size_of_yuv = kSourceYSize * 12 / 8; // 12 bpp. 451 const size_t size_of_yuv = kSourceYSize * 12 / 8; // 12 bpp.
452 scoped_ptr<uint8[]> yuv_bytes(new uint8[size_of_yuv]); 452 scoped_ptr<uint8[]> yuv_bytes(new uint8[size_of_yuv]);
453 EXPECT_EQ(static_cast<int>(size_of_yuv), 453 EXPECT_EQ(static_cast<int>(size_of_yuv),
454 file_util::ReadFile(yuv_url, 454 base::ReadFile(yuv_url,
455 reinterpret_cast<char*>(yuv_bytes.get()), 455 reinterpret_cast<char*>(yuv_bytes.get()),
456 static_cast<int>(size_of_yuv))); 456 static_cast<int>(size_of_yuv)));
457 457
458 // Scale the full frame of YUV to 32 bit ARGB. 458 // Scale the full frame of YUV to 32 bit ARGB.
459 // The API currently only supports down-scaling, so we don't test up-scaling. 459 // The API currently only supports down-scaling, so we don't test up-scaling.
460 const size_t size_of_rgb_scaled = kDownScaledWidth * kDownScaledHeight * kBpp; 460 const size_t size_of_rgb_scaled = kDownScaledWidth * kDownScaledHeight * kBpp;
461 scoped_ptr<uint8[]> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]); 461 scoped_ptr<uint8[]> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]);
462 gfx::Rect sub_rect(0, 0, kDownScaledWidth, kDownScaledHeight); 462 gfx::Rect sub_rect(0, 0, kDownScaledWidth, kDownScaledHeight);
463 463
464 // We can't compare with the full-frame scaler because it uses slightly 464 // We can't compare with the full-frame scaler because it uses slightly
465 // different sampling coordinates. 465 // different sampling coordinates.
466 media::ScaleYUVToRGB32WithRect( 466 media::ScaleYUVToRGB32WithRect(
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(), 961 EXPECT_EQ(0, memcmp(rgb_bytes_reference.get(),
962 rgb_bytes_converted.get(), 962 rgb_bytes_converted.get(),
963 kWidth * kBpp)); 963 kWidth * kBpp));
964 } 964 }
965 965
966 #endif // defined(ARCH_CPU_X86_64) 966 #endif // defined(ARCH_CPU_X86_64)
967 967
968 #endif // defined(ARCH_CPU_X86_FAMILY) 968 #endif // defined(ARCH_CPU_X86_FAMILY)
969 969
970 } // namespace media 970 } // namespace media
OLDNEW
« no previous file with comments | « media/base/test_data_util.cc ('k') | media/webm/chromeos/webm_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698