Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "base/single_thread_task_runner.h" | 42 #include "base/single_thread_task_runner.h" |
| 43 #include "base/stl_util.h" | 43 #include "base/stl_util.h" |
| 44 #include "base/strings/string_number_conversions.h" | 44 #include "base/strings/string_number_conversions.h" |
| 45 #include "base/strings/string_split.h" | 45 #include "base/strings/string_split.h" |
| 46 #include "base/strings/stringize_macros.h" | 46 #include "base/strings/stringize_macros.h" |
| 47 #include "base/strings/stringprintf.h" | 47 #include "base/strings/stringprintf.h" |
| 48 #include "base/strings/utf_string_conversions.h" | 48 #include "base/strings/utf_string_conversions.h" |
| 49 #include "base/synchronization/condition_variable.h" | 49 #include "base/synchronization/condition_variable.h" |
| 50 #include "base/synchronization/lock.h" | 50 #include "base/synchronization/lock.h" |
| 51 #include "base/synchronization/waitable_event.h" | 51 #include "base/synchronization/waitable_event.h" |
| 52 #include "base/test/launcher/unit_test_launcher.h" | |
| 53 #include "base/test/test_suite.h" | |
| 52 #include "base/threading/thread.h" | 54 #include "base/threading/thread.h" |
| 53 #include "base/threading/thread_task_runner_handle.h" | 55 #include "base/threading/thread_task_runner_handle.h" |
| 54 #include "build/build_config.h" | 56 #include "build/build_config.h" |
| 55 #include "gpu/command_buffer/service/gpu_preferences.h" | 57 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 56 #include "gpu/config/gpu_driver_bug_workarounds.h" | 58 #include "gpu/config/gpu_driver_bug_workarounds.h" |
| 57 #include "media/filters/h264_parser.h" | 59 #include "media/filters/h264_parser.h" |
| 58 #include "media/gpu/fake_video_decode_accelerator.h" | 60 #include "media/gpu/fake_video_decode_accelerator.h" |
| 59 #include "media/gpu/gpu_video_decode_accelerator_factory.h" | 61 #include "media/gpu/gpu_video_decode_accelerator_factory.h" |
| 60 #include "media/gpu/rendering_helper.h" | 62 #include "media/gpu/rendering_helper.h" |
| 61 #include "media/gpu/video_accelerator_unittest_helpers.h" | 63 #include "media/gpu/video_accelerator_unittest_helpers.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 const gfx::Size kThumbnailsPageSize(1600, 1200); | 187 const gfx::Size kThumbnailsPageSize(1600, 1200); |
| 186 const gfx::Size kThumbnailSize(160, 120); | 188 const gfx::Size kThumbnailSize(160, 120); |
| 187 const int kMD5StringLength = 32; | 189 const int kMD5StringLength = 32; |
| 188 | 190 |
| 189 // Read in golden MD5s for the thumbnailed rendering of this video | 191 // Read in golden MD5s for the thumbnailed rendering of this video |
| 190 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, | 192 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, |
| 191 std::vector<std::string>* md5_strings) { | 193 std::vector<std::string>* md5_strings) { |
| 192 base::FilePath filepath(video_file->file_name); | 194 base::FilePath filepath(video_file->file_name); |
| 193 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); | 195 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); |
| 194 std::string all_md5s; | 196 std::string all_md5s; |
| 195 base::ReadFileToString(filepath, &all_md5s); | 197 base::ReadFileToString(base::MakeAbsoluteFilePath(filepath), &all_md5s); |
| 196 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE, | 198 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE, |
| 197 base::SPLIT_WANT_ALL); | 199 base::SPLIT_WANT_ALL); |
| 198 // Check these are legitimate MD5s. | 200 // Check these are legitimate MD5s. |
| 199 for (const std::string& md5_string : *md5_strings) { | 201 for (const std::string& md5_string : *md5_strings) { |
| 200 // Ignore the empty string added by SplitString | 202 // Ignore the empty string added by SplitString |
| 201 if (!md5_string.length()) | 203 if (!md5_string.length()) |
| 202 continue; | 204 continue; |
| 203 // Ignore comments | 205 // Ignore comments |
| 204 if (md5_string.at(0) == '#') | 206 if (md5_string.at(0) == '#') |
| 205 continue; | 207 continue; |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1175 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render)); | 1177 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render)); |
| 1176 if (!fields[6].empty()) | 1178 if (!fields[6].empty()) |
| 1177 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render)); | 1179 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render)); |
| 1178 int profile = -1; | 1180 int profile = -1; |
| 1179 if (!fields[7].empty()) | 1181 if (!fields[7].empty()) |
| 1180 LOG_ASSERT(base::StringToInt(fields[7], &profile)); | 1182 LOG_ASSERT(base::StringToInt(fields[7], &profile)); |
| 1181 video_file->profile = static_cast<VideoCodecProfile>(profile); | 1183 video_file->profile = static_cast<VideoCodecProfile>(profile); |
| 1182 | 1184 |
| 1183 // Read in the video data. | 1185 // Read in the video data. |
| 1184 base::FilePath filepath(video_file->file_name); | 1186 base::FilePath filepath(video_file->file_name); |
| 1185 LOG_ASSERT(base::ReadFileToString(filepath, &video_file->data_str)) | 1187 LOG_ASSERT(base::ReadFileToString(base::MakeAbsoluteFilePath(filepath), |
| 1188 &video_file->data_str)) | |
| 1186 << "test_video_file: " << filepath.MaybeAsASCII(); | 1189 << "test_video_file: " << filepath.MaybeAsASCII(); |
| 1187 | 1190 |
| 1188 test_video_files->push_back(std::move(video_file)); | 1191 test_video_files->push_back(std::move(video_file)); |
| 1189 } | 1192 } |
| 1190 } | 1193 } |
| 1191 | 1194 |
| 1192 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( | 1195 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( |
| 1193 size_t num_concurrent_decoders, | 1196 size_t num_concurrent_decoders, |
| 1194 int reset_point, | 1197 int reset_point, |
| 1195 TestFilesVector* test_video_files) { | 1198 TestFilesVector* test_video_files) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 | 1363 |
| 1361 clients[index] = std::move(client); | 1364 clients[index] = std::move(client); |
| 1362 helper_params.window_sizes.push_back( | 1365 helper_params.window_sizes.push_back( |
| 1363 render_as_thumbnails | 1366 render_as_thumbnails |
| 1364 ? kThumbnailsPageSize | 1367 ? kThumbnailsPageSize |
| 1365 : gfx::Size(video_file->width, video_file->height)); | 1368 : gfx::Size(video_file->width, video_file->height)); |
| 1366 } | 1369 } |
| 1367 | 1370 |
| 1368 InitializeRenderingHelper(helper_params); | 1371 InitializeRenderingHelper(helper_params); |
| 1369 | 1372 |
| 1373 #if defined(OS_WIN) | |
| 1374 // Windows doesn't have thumbnail expectations yet. | |
| 1375 if (render_as_thumbnails) | |
|
Pawel Osciak
2016/12/06 09:45:00
Should we perhaps disable VideoDecodeAcceleratorPa
| |
| 1376 return; | |
| 1377 #endif | |
| 1378 | |
| 1370 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1379 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
| 1371 CreateAndStartDecoder(clients[index].get(), notes[index].get()); | 1380 CreateAndStartDecoder(clients[index].get(), notes[index].get()); |
| 1372 } | 1381 } |
| 1373 | 1382 |
| 1374 // Then wait for all the decodes to finish. | 1383 // Then wait for all the decodes to finish. |
| 1375 // Only check performance & correctness later if we play through only once. | 1384 // Only check performance & correctness later if we play through only once. |
| 1376 bool skip_performance_and_correctness_checks = num_play_throughs > 1; | 1385 bool skip_performance_and_correctness_checks = num_play_throughs > 1; |
| 1377 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1386 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
| 1378 ClientStateNotification<ClientState>* note = notes[i].get(); | 1387 ClientStateNotification<ClientState>* note = notes[i].get(); |
| 1379 ClientState state = note->Wait(); | 1388 ClientState state = note->Wait(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); | 1716 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); |
| 1708 WaitUntilIdle(); | 1717 WaitUntilIdle(); |
| 1709 }; | 1718 }; |
| 1710 | 1719 |
| 1711 // TODO(fischman, vrk): add more tests! In particular: | 1720 // TODO(fischman, vrk): add more tests! In particular: |
| 1712 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. | 1721 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. |
| 1713 // - Test alternate configurations | 1722 // - Test alternate configurations |
| 1714 // - Test failure conditions. | 1723 // - Test failure conditions. |
| 1715 // - Test frame size changes mid-stream | 1724 // - Test frame size changes mid-stream |
| 1716 | 1725 |
| 1726 class VDATestSuite : public base::TestSuite { | |
| 1727 public: | |
| 1728 VDATestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | |
| 1729 | |
| 1730 int Run() { | |
| 1731 #if defined(OS_WIN) || defined(USE_OZONE) | |
| 1732 // For windows the decoding thread initializes the media foundation decoder | |
| 1733 // which uses COM. We need the thread to be a UI thread. | |
| 1734 // On Ozone, the backend initializes the event system using a UI | |
| 1735 // thread. | |
| 1736 base::MessageLoopForUI main_loop; | |
| 1737 #else | |
| 1738 base::MessageLoop main_loop; | |
| 1739 #endif // OS_WIN || USE_OZONE | |
| 1740 | |
| 1741 #if defined(USE_OZONE) | |
| 1742 ui::OzonePlatform::InitializeForUI(); | |
| 1743 #endif | |
| 1744 | |
| 1745 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 1746 media::VaapiWrapper::PreSandboxInitialization(); | |
| 1747 #elif defined(OS_WIN) | |
| 1748 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | |
| 1749 #endif | |
| 1750 return base::TestSuite::Run(); | |
| 1751 } | |
| 1752 }; | |
| 1753 | |
| 1717 } // namespace | 1754 } // namespace |
| 1718 } // namespace media | 1755 } // namespace media |
| 1719 | 1756 |
| 1720 int main(int argc, char** argv) { | 1757 int main(int argc, char** argv) { |
| 1721 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1758 media::VDATestSuite test_suite(argc, argv); |
| 1722 #if defined(OS_WIN) | |
| 1723 base::CommandLine::InitUsingArgvForTesting(argc, argv); | |
| 1724 #else | |
| 1725 base::CommandLine::Init(argc, argv); | |
| 1726 #endif | |
| 1727 | 1759 |
| 1728 // Needed to enable DVLOG through --vmodule. | 1760 // Needed to enable DVLOG through --vmodule. |
| 1729 logging::LoggingSettings settings; | 1761 logging::LoggingSettings settings; |
| 1730 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 1762 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 1731 LOG_ASSERT(logging::InitLogging(settings)); | 1763 LOG_ASSERT(logging::InitLogging(settings)); |
| 1732 | 1764 |
| 1733 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1765 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1734 DCHECK(cmd_line); | 1766 DCHECK(cmd_line); |
| 1735 | 1767 |
| 1736 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1768 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1773 continue; | 1805 continue; |
| 1774 } | 1806 } |
| 1775 if (it->first == "v" || it->first == "vmodule") | 1807 if (it->first == "v" || it->first == "vmodule") |
| 1776 continue; | 1808 continue; |
| 1777 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") | 1809 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") |
| 1778 continue; | 1810 continue; |
| 1779 if (it->first == "test_import") { | 1811 if (it->first == "test_import") { |
| 1780 media::g_test_import = true; | 1812 media::g_test_import = true; |
| 1781 continue; | 1813 continue; |
| 1782 } | 1814 } |
| 1783 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | |
|
Pawel Osciak
2016/12/06 09:45:00
Could we keep this?
| |
| 1784 } | 1815 } |
| 1785 | 1816 |
| 1786 base::ShadowingAtExitManager at_exit_manager; | 1817 base::ShadowingAtExitManager at_exit_manager; |
| 1787 #if defined(OS_WIN) || defined(USE_OZONE) | |
| 1788 // For windows the decoding thread initializes the media foundation decoder | |
| 1789 // which uses COM. We need the thread to be a UI thread. | |
| 1790 // On Ozone, the backend initializes the event system using a UI | |
| 1791 // thread. | |
| 1792 base::MessageLoopForUI main_loop; | |
| 1793 #else | |
| 1794 base::MessageLoop main_loop; | |
| 1795 #endif // OS_WIN || USE_OZONE | |
| 1796 | |
| 1797 #if defined(USE_OZONE) | |
| 1798 ui::OzonePlatform::InitializeForUI(); | |
| 1799 #endif | |
| 1800 | |
| 1801 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 1802 media::VaapiWrapper::PreSandboxInitialization(); | |
| 1803 #elif defined(OS_WIN) | |
| 1804 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | |
| 1805 #endif | |
| 1806 | 1818 |
| 1807 media::g_env = | 1819 media::g_env = |
| 1808 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1820 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
| 1809 testing::AddGlobalTestEnvironment( | 1821 testing::AddGlobalTestEnvironment( |
| 1810 new media::VideoDecodeAcceleratorTestEnvironment())); | 1822 new media::VideoDecodeAcceleratorTestEnvironment())); |
| 1811 | 1823 |
| 1812 return RUN_ALL_TESTS(); | 1824 return base::LaunchUnitTestsSerially( |
| 1825 argc, argv, | |
| 1826 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | |
| 1813 } | 1827 } |
| OLD | NEW |