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

Side by Side Diff: media/gpu/video_decode_accelerator_unittest.cc

Issue 2594243002: Add flag to make vda_unittest input paths relative to media/test/data (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « media/gpu/BUILD.gn ('k') | no next file » | 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 // 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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" 52 #include "base/test/launcher/unit_test_launcher.h"
53 #include "base/test/test_suite.h" 53 #include "base/test/test_suite.h"
54 #include "base/threading/thread.h" 54 #include "base/threading/thread.h"
55 #include "base/threading/thread_task_runner_handle.h" 55 #include "base/threading/thread_task_runner_handle.h"
56 #include "build/build_config.h" 56 #include "build/build_config.h"
57 #include "gpu/command_buffer/service/gpu_preferences.h" 57 #include "gpu/command_buffer/service/gpu_preferences.h"
58 #include "gpu/config/gpu_driver_bug_workarounds.h" 58 #include "gpu/config/gpu_driver_bug_workarounds.h"
59 #include "media/base/test_data_util.h"
59 #include "media/filters/h264_parser.h" 60 #include "media/filters/h264_parser.h"
60 #include "media/gpu/fake_video_decode_accelerator.h" 61 #include "media/gpu/fake_video_decode_accelerator.h"
61 #include "media/gpu/gpu_video_decode_accelerator_factory.h" 62 #include "media/gpu/gpu_video_decode_accelerator_factory.h"
62 #include "media/gpu/rendering_helper.h" 63 #include "media/gpu/rendering_helper.h"
63 #include "media/gpu/video_accelerator_unittest_helpers.h" 64 #include "media/gpu/video_accelerator_unittest_helpers.h"
64 #include "testing/gtest/include/gtest/gtest.h" 65 #include "testing/gtest/include/gtest/gtest.h"
65 #include "ui/gfx/codec/png_codec.h" 66 #include "ui/gfx/codec/png_codec.h"
66 #include "ui/gl/gl_image.h" 67 #include "ui/gl/gl_image.h"
67 68
68 #if defined(OS_WIN) 69 #if defined(OS_WIN)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // values for |num_play_throughs|. This setting will override the value. A 131 // values for |num_play_throughs|. This setting will override the value. A
131 // special value "0" means no override. 132 // special value "0" means no override.
132 int g_num_play_throughs = 0; 133 int g_num_play_throughs = 0;
133 // Fake decode 134 // Fake decode
134 int g_fake_decoder = 0; 135 int g_fake_decoder = 0;
135 136
136 // Test buffer import into VDA, providing buffers allocated by us, instead of 137 // Test buffer import into VDA, providing buffers allocated by us, instead of
137 // requesting the VDA itself to allocate buffers. 138 // requesting the VDA itself to allocate buffers.
138 bool g_test_import = false; 139 bool g_test_import = false;
139 140
141 // This is the location of the test files. If empty, they're in the current
142 // working directory.
143 base::FilePath g_test_file_path;
144
140 // Environment to store rendering thread. 145 // Environment to store rendering thread.
141 class VideoDecodeAcceleratorTestEnvironment; 146 class VideoDecodeAcceleratorTestEnvironment;
142 VideoDecodeAcceleratorTestEnvironment* g_env; 147 VideoDecodeAcceleratorTestEnvironment* g_env;
143 148
144 // Magic constants for differentiating the reasons for NotifyResetDone being 149 // Magic constants for differentiating the reasons for NotifyResetDone being
145 // called. 150 // called.
146 enum ResetPoint { 151 enum ResetPoint {
147 // Reset() just after calling Decode() with a fragment containing config info. 152 // Reset() just after calling Decode() with a fragment containing config info.
148 RESET_AFTER_FIRST_CONFIG_INFO = -4, 153 RESET_AFTER_FIRST_CONFIG_INFO = -4,
149 START_OF_STREAM_RESET = -3, 154 START_OF_STREAM_RESET = -3,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int min_fps_no_render; 186 int min_fps_no_render;
182 VideoCodecProfile profile; 187 VideoCodecProfile profile;
183 int reset_after_frame_num; 188 int reset_after_frame_num;
184 std::string data_str; 189 std::string data_str;
185 }; 190 };
186 191
187 const gfx::Size kThumbnailsPageSize(1600, 1200); 192 const gfx::Size kThumbnailsPageSize(1600, 1200);
188 const gfx::Size kThumbnailSize(160, 120); 193 const gfx::Size kThumbnailSize(160, 120);
189 const int kMD5StringLength = 32; 194 const int kMD5StringLength = 32;
190 195
196 base::FilePath GetTestDataFile(const base::FilePath& input_file) {
197 if (input_file.IsAbsolute())
198 return input_file;
199 return base::MakeAbsoluteFilePath(g_test_file_path.Append(input_file));
200 }
201
191 // Read in golden MD5s for the thumbnailed rendering of this video 202 // Read in golden MD5s for the thumbnailed rendering of this video
192 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 203 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
193 std::vector<std::string>* md5_strings) { 204 std::vector<std::string>* md5_strings) {
194 base::FilePath filepath(video_file->file_name); 205 base::FilePath filepath(video_file->file_name);
195 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 206 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
196 std::string all_md5s; 207 std::string all_md5s;
197 base::ReadFileToString(base::MakeAbsoluteFilePath(filepath), &all_md5s); 208 base::ReadFileToString(GetTestDataFile(filepath), &all_md5s);
198 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE, 209 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE,
199 base::SPLIT_WANT_ALL); 210 base::SPLIT_WANT_ALL);
200 // Check these are legitimate MD5s. 211 // Check these are legitimate MD5s.
201 for (const std::string& md5_string : *md5_strings) { 212 for (const std::string& md5_string : *md5_strings) {
202 // Ignore the empty string added by SplitString 213 // Ignore the empty string added by SplitString
203 if (!md5_string.length()) 214 if (!md5_string.length())
204 continue; 215 continue;
205 // Ignore comments 216 // Ignore comments
206 if (md5_string.at(0) == '#') 217 if (md5_string.at(0) == '#')
207 continue; 218 continue;
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render)); 1191 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render));
1181 if (!fields[6].empty()) 1192 if (!fields[6].empty())
1182 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render)); 1193 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render));
1183 int profile = -1; 1194 int profile = -1;
1184 if (!fields[7].empty()) 1195 if (!fields[7].empty())
1185 LOG_ASSERT(base::StringToInt(fields[7], &profile)); 1196 LOG_ASSERT(base::StringToInt(fields[7], &profile));
1186 video_file->profile = static_cast<VideoCodecProfile>(profile); 1197 video_file->profile = static_cast<VideoCodecProfile>(profile);
1187 1198
1188 // Read in the video data. 1199 // Read in the video data.
1189 base::FilePath filepath(video_file->file_name); 1200 base::FilePath filepath(video_file->file_name);
1190 LOG_ASSERT(base::ReadFileToString(base::MakeAbsoluteFilePath(filepath), 1201 LOG_ASSERT(base::ReadFileToString(GetTestDataFile(filepath),
1191 &video_file->data_str)) 1202 &video_file->data_str))
1192 << "test_video_file: " << filepath.MaybeAsASCII(); 1203 << "test_video_file: " << filepath.MaybeAsASCII();
1193 1204
1194 test_video_files->push_back(std::move(video_file)); 1205 test_video_files->push_back(std::move(video_file));
1195 } 1206 }
1196 } 1207 }
1197 1208
1198 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( 1209 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams(
1199 size_t num_concurrent_decoders, 1210 size_t num_concurrent_decoders,
1200 int reset_point, 1211 int reset_point,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 kThumbnailsPageSize.width() * 3, 1487 kThumbnailsPageSize.width() * 3,
1477 true, 1488 true,
1478 std::vector<gfx::PNGCodec::Comment>(), 1489 std::vector<gfx::PNGCodec::Comment>(),
1479 &png); 1490 &png);
1480 1491
1481 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; 1492 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
1482 1493
1483 base::FilePath filepath(test_video_files_[0]->file_name); 1494 base::FilePath filepath(test_video_files_[0]->file_name);
1484 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); 1495 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
1485 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); 1496 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
1486 int num_bytes = base::WriteFile( 1497 int num_bytes =
1487 filepath, reinterpret_cast<char*>(&png[0]), png.size()); 1498 base::WriteFile(GetTestDataFile(filepath),
1499 reinterpret_cast<char*>(&png[0]), png.size());
1488 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); 1500 ASSERT_EQ(num_bytes, static_cast<int>(png.size()));
1489 } 1501 }
1490 ASSERT_NE(match, golden_md5s.end()); 1502 ASSERT_NE(match, golden_md5s.end());
1491 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; 1503 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha";
1492 } 1504 }
1493 1505
1494 // Output the frame delivery time to file 1506 // Output the frame delivery time to file
1495 // We can only make performance/correctness assertions if the decoder was 1507 // We can only make performance/correctness assertions if the decoder was
1496 // allowed to finish. 1508 // allowed to finish.
1497 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1509 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 continue; 1824 continue;
1813 } 1825 }
1814 if (it->first == "v" || it->first == "vmodule") 1826 if (it->first == "v" || it->first == "vmodule")
1815 continue; 1827 continue;
1816 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") 1828 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1817 continue; 1829 continue;
1818 if (it->first == "test_import") { 1830 if (it->first == "test_import") {
1819 media::g_test_import = true; 1831 media::g_test_import = true;
1820 continue; 1832 continue;
1821 } 1833 }
1834 if (it->first == "use-test-data-path") {
1835 media::g_test_file_path = media::GetTestDataFilePath("");
1836 continue;
1837 }
1822 } 1838 }
1823 1839
1824 base::ShadowingAtExitManager at_exit_manager; 1840 base::ShadowingAtExitManager at_exit_manager;
1825 1841
1826 media::g_env = 1842 media::g_env =
1827 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1843 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1828 testing::AddGlobalTestEnvironment( 1844 testing::AddGlobalTestEnvironment(
1829 new media::VideoDecodeAcceleratorTestEnvironment())); 1845 new media::VideoDecodeAcceleratorTestEnvironment()));
1830 1846
1831 return base::LaunchUnitTestsSerially( 1847 return base::LaunchUnitTestsSerially(
1832 argc, argv, 1848 argc, argv,
1833 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); 1849 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1834 } 1850 }
OLDNEW
« no previous file with comments | « media/gpu/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698