OLD | NEW |
---|---|
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 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
8 // Win/EGL. | 8 // Win/EGL. |
9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); | 1520 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); |
1521 if (!render_as_thumbnails) { | 1521 if (!render_as_thumbnails) { |
1522 int min_fps = suppress_rendering ? video_file->min_fps_no_render | 1522 int min_fps = suppress_rendering ? video_file->min_fps_no_render |
1523 : video_file->min_fps_render; | 1523 : video_file->min_fps_render; |
1524 if (min_fps > 0 && !test_reuse_delay) | 1524 if (min_fps > 0 && !test_reuse_delay) |
1525 EXPECT_GT(client->frames_per_second(), min_fps); | 1525 EXPECT_GT(client->frames_per_second(), min_fps); |
1526 } | 1526 } |
1527 } | 1527 } |
1528 | 1528 |
1529 if (render_as_thumbnails) { | 1529 if (render_as_thumbnails) { |
1530 std::vector<unsigned char> rgb; | 1530 std::vector<unsigned char> rgba; |
1531 bool alpha_solid; | |
1532 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 1531 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
1533 base::WaitableEvent::InitialState::NOT_SIGNALED); | 1532 base::WaitableEvent::InitialState::NOT_SIGNALED); |
1534 g_env->GetRenderingTaskRunner()->PostTask( | 1533 g_env->GetRenderingTaskRunner()->PostTask( |
1535 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, | 1534 FROM_HERE, |
1536 base::Unretained(&rendering_helper_), &rgb, | 1535 base::Bind(&RenderingHelper::GetThumbnailsAsRGBA, |
1537 &alpha_solid, &done)); | 1536 base::Unretained(&rendering_helper_), &rgba, &done)); |
1538 done.Wait(); | 1537 done.Wait(); |
1539 | 1538 |
1539 size_t num_pixels = rgba.size() / 4; | |
1540 for (size_t i = 0; i < num_pixels; i++) { | |
1541 EXPECT_EQ(rgba[4 * i + 3], 0xff) << "RGBA frame had incorrect alpha"; | |
Owen Lin
2017/06/16 01:24:05
If the values of alpha are wrong, this may leave t
msarett1
2017/06/16 02:11:03
FIxed.
| |
1542 } | |
1543 | |
1540 std::vector<std::string> golden_md5s; | 1544 std::vector<std::string> golden_md5s; |
1541 std::string md5_string = base::MD5String( | 1545 std::string md5_string = base::MD5String( |
1542 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); | 1546 base::StringPiece(reinterpret_cast<char*>(&rgba[0]), rgba.size())); |
Owen Lin
2017/06/15 07:28:05
This will changes the md5 checksum. You need updat
msarett
2017/06/15 18:06:44
Can you help with how to do this? I am able to bu
Owen Lin
2017/06/16 01:24:05
The test data stream and golden md5 golden value a
msarett1
2017/06/16 02:11:03
Ahh yes, that's a much better idea. Done. I thin
| |
1543 ReadGoldenThumbnailMD5s(test_video_files_[0].get(), &golden_md5s); | 1547 ReadGoldenThumbnailMD5s(test_video_files_[0].get(), &golden_md5s); |
1544 std::vector<std::string>::iterator match = | 1548 std::vector<std::string>::iterator match = |
1545 find(golden_md5s.begin(), golden_md5s.end(), md5_string); | 1549 find(golden_md5s.begin(), golden_md5s.end(), md5_string); |
1546 if (match == golden_md5s.end()) { | 1550 if (match == golden_md5s.end()) { |
1547 // Convert raw RGB into PNG for export. | 1551 // Convert raw RGBA into PNG for export. |
1548 std::vector<unsigned char> png; | 1552 std::vector<unsigned char> png; |
1549 gfx::PNGCodec::Encode(&rgb[0], | 1553 gfx::PNGCodec::Encode(&rgba[0], gfx::PNGCodec::FORMAT_RGBA, |
1550 gfx::PNGCodec::FORMAT_RGB, | |
1551 kThumbnailsPageSize, | 1554 kThumbnailsPageSize, |
1552 kThumbnailsPageSize.width() * 3, | 1555 kThumbnailsPageSize.width() * 4, true, |
1553 true, | 1556 std::vector<gfx::PNGCodec::Comment>(), &png); |
1554 std::vector<gfx::PNGCodec::Comment>(), | |
1555 &png); | |
1556 | 1557 |
1557 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1558 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
1558 | 1559 |
1559 base::FilePath filepath(test_video_files_[0]->file_name); | 1560 base::FilePath filepath(test_video_files_[0]->file_name); |
1560 if (!g_thumbnail_output_dir.empty() && | 1561 if (!g_thumbnail_output_dir.empty() && |
1561 base::DirectoryExists(g_thumbnail_output_dir)) { | 1562 base::DirectoryExists(g_thumbnail_output_dir)) { |
1562 // Write bad thumbnails image to where --thumbnail_output_dir assigned. | 1563 // Write bad thumbnails image to where --thumbnail_output_dir assigned. |
1563 filepath = g_thumbnail_output_dir.Append(filepath.BaseName()); | 1564 filepath = g_thumbnail_output_dir.Append(filepath.BaseName()); |
1564 } else { | 1565 } else { |
1565 // Fallback to write to test data directory. | 1566 // Fallback to write to test data directory. |
1566 // Note: test data directory is not writable by vda_unittest while | 1567 // Note: test data directory is not writable by vda_unittest while |
1567 // running by autotest. It should assign its resultsdir as output | 1568 // running by autotest. It should assign its resultsdir as output |
1568 // directory. | 1569 // directory. |
1569 filepath = GetTestDataFile(filepath); | 1570 filepath = GetTestDataFile(filepath); |
1570 } | 1571 } |
1571 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1572 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
1572 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1573 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
1573 LOG(INFO) << "Write bad thumbnails image to: " | 1574 LOG(INFO) << "Write bad thumbnails image to: " |
1574 << filepath.value().c_str(); | 1575 << filepath.value().c_str(); |
1575 int num_bytes = base::WriteFile( | 1576 int num_bytes = base::WriteFile( |
1576 filepath, reinterpret_cast<char*>(&png[0]), png.size()); | 1577 filepath, reinterpret_cast<char*>(&png[0]), png.size()); |
1577 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); | 1578 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); |
1578 } | 1579 } |
1579 EXPECT_NE(match, golden_md5s.end()); | 1580 EXPECT_NE(match, golden_md5s.end()); |
1580 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | |
1581 } | 1581 } |
1582 | 1582 |
1583 // Output the frame delivery time to file | 1583 // Output the frame delivery time to file |
1584 // We can only make performance/correctness assertions if the decoder was | 1584 // We can only make performance/correctness assertions if the decoder was |
1585 // allowed to finish. | 1585 // allowed to finish. |
1586 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1586 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
1587 base::File output_file( | 1587 base::File output_file( |
1588 base::FilePath(g_output_log), | 1588 base::FilePath(g_output_log), |
1589 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 1589 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
1590 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1590 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1918 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str()); | 1918 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str()); |
1919 } | 1919 } |
1920 } | 1920 } |
1921 | 1921 |
1922 base::ShadowingAtExitManager at_exit_manager; | 1922 base::ShadowingAtExitManager at_exit_manager; |
1923 | 1923 |
1924 return base::LaunchUnitTestsSerially( | 1924 return base::LaunchUnitTestsSerially( |
1925 argc, argv, | 1925 argc, argv, |
1926 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | 1926 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); |
1927 } | 1927 } |
OLD | NEW |