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

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

Issue 2371783002: Remove stl_util's deletion functions from media/. (Closed)
Patch Set: wolenetz Created 4 years, 2 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/ipc/service/gpu_jpeg_decode_accelerator.cc ('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 19 matching lines...) Expand all
30 #include "base/at_exit.h" 30 #include "base/at_exit.h"
31 #include "base/bind.h" 31 #include "base/bind.h"
32 #include "base/callback_helpers.h" 32 #include "base/callback_helpers.h"
33 #include "base/command_line.h" 33 #include "base/command_line.h"
34 #include "base/files/file.h" 34 #include "base/files/file.h"
35 #include "base/files/file_util.h" 35 #include "base/files/file_util.h"
36 #include "base/format_macros.h" 36 #include "base/format_macros.h"
37 #include "base/location.h" 37 #include "base/location.h"
38 #include "base/macros.h" 38 #include "base/macros.h"
39 #include "base/md5.h" 39 #include "base/md5.h"
40 #include "base/memory/ptr_util.h"
40 #include "base/process/process_handle.h" 41 #include "base/process/process_handle.h"
41 #include "base/single_thread_task_runner.h" 42 #include "base/single_thread_task_runner.h"
42 #include "base/stl_util.h" 43 #include "base/stl_util.h"
43 #include "base/strings/string_number_conversions.h" 44 #include "base/strings/string_number_conversions.h"
44 #include "base/strings/string_split.h" 45 #include "base/strings/string_split.h"
45 #include "base/strings/stringize_macros.h" 46 #include "base/strings/stringize_macros.h"
46 #include "base/strings/stringprintf.h" 47 #include "base/strings/stringprintf.h"
47 #include "base/strings/utf_string_conversions.h" 48 #include "base/strings/utf_string_conversions.h"
48 #include "base/synchronization/condition_variable.h" 49 #include "base/synchronization/condition_variable.h"
49 #include "base/synchronization/lock.h" 50 #include "base/synchronization/lock.h"
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 std::sort(decode_time_.begin(), decode_time_.end()); 1069 std::sort(decode_time_.begin(), decode_time_.end());
1069 int index = decode_time_.size() / 2; 1070 int index = decode_time_.size() / 2;
1070 if (decode_time_.size() % 2 != 0) 1071 if (decode_time_.size() % 2 != 0)
1071 return decode_time_[index]; 1072 return decode_time_[index];
1072 1073
1073 return (decode_time_[index] + decode_time_[index - 1]) / 2; 1074 return (decode_time_[index] + decode_time_[index - 1]) / 2;
1074 } 1075 }
1075 1076
1076 class VideoDecodeAcceleratorTest : public ::testing::Test { 1077 class VideoDecodeAcceleratorTest : public ::testing::Test {
1077 protected: 1078 protected:
1079 using TestFilesVector = std::vector<std::unique_ptr<TestVideoFile>>;
1080
1078 VideoDecodeAcceleratorTest(); 1081 VideoDecodeAcceleratorTest();
1079 void SetUp() override; 1082 void SetUp() override;
1080 void TearDown() override; 1083 void TearDown() override;
1081 1084
1082 // Parse |data| into its constituent parts, set the various output fields 1085 // Parse |data| into its constituent parts, set the various output fields
1083 // accordingly, and read in video stream. CHECK-fails on unexpected or 1086 // accordingly, and read in video stream. CHECK-fails on unexpected or
1084 // missing required data. Unspecified optional fields are set to -1. 1087 // missing required data. Unspecified optional fields are set to -1.
1085 void ParseAndReadTestVideoData(base::FilePath::StringType data, 1088 void ParseAndReadTestVideoData(base::FilePath::StringType data,
1086 std::vector<TestVideoFile*>* test_video_files); 1089 TestFilesVector* test_video_files);
1087 1090
1088 // Update the parameters of |test_video_files| according to 1091 // Update the parameters of |test_video_files| according to
1089 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of 1092 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of
1090 // frames should be adjusted if decoder is reset in the middle of the stream. 1093 // frames should be adjusted if decoder is reset in the middle of the stream.
1091 void UpdateTestVideoFileParams(size_t num_concurrent_decoders, 1094 void UpdateTestVideoFileParams(size_t num_concurrent_decoders,
1092 int reset_point, 1095 int reset_point,
1093 std::vector<TestVideoFile*>* test_video_files); 1096 TestFilesVector* test_video_files);
1094 1097
1095 void InitializeRenderingHelper(const RenderingHelperParams& helper_params); 1098 void InitializeRenderingHelper(const RenderingHelperParams& helper_params);
1096 void CreateAndStartDecoder(GLRenderingVDAClient* client, 1099 void CreateAndStartDecoder(GLRenderingVDAClient* client,
1097 ClientStateNotification<ClientState>* note); 1100 ClientStateNotification<ClientState>* note);
1098 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); 1101 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note);
1099 void WaitUntilIdle(); 1102 void WaitUntilIdle();
1100 void OutputLogFile(const base::FilePath::CharType* log_path, 1103 void OutputLogFile(const base::FilePath::CharType* log_path,
1101 const std::string& content); 1104 const std::string& content);
1102 1105
1103 std::vector<TestVideoFile*> test_video_files_; 1106 TestFilesVector test_video_files_;
1104 RenderingHelper rendering_helper_; 1107 RenderingHelper rendering_helper_;
1105 1108
1109 protected:
1110 // Must be static because this method may run after the destructor.
1111 template <typename T>
1112 static void Delete(std::unique_ptr<T> item) {
1113 // |item| is cleared when the scope of this function is left.
1114 }
1115
1106 private: 1116 private:
1107 // Required for Thread to work. Not used otherwise. 1117 // Required for Thread to work. Not used otherwise.
1108 base::ShadowingAtExitManager at_exit_manager_; 1118 base::ShadowingAtExitManager at_exit_manager_;
1109 1119
1110 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); 1120 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest);
1111 }; 1121 };
1112 1122
1113 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} 1123 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {}
1114 1124
1115 void VideoDecodeAcceleratorTest::SetUp() { 1125 void VideoDecodeAcceleratorTest::SetUp() {
1116 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); 1126 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_);
1117 } 1127 }
1118 1128
1119 void VideoDecodeAcceleratorTest::TearDown() { 1129 void VideoDecodeAcceleratorTest::TearDown() {
1130 std::unique_ptr<TestFilesVector> test_video_files(new TestFilesVector);
1131 test_video_files->swap(test_video_files_);
1132
1120 g_env->GetRenderingTaskRunner()->PostTask( 1133 g_env->GetRenderingTaskRunner()->PostTask(
1121 FROM_HERE, 1134 FROM_HERE,
1122 base::Bind(&base::STLDeleteElements<std::vector<TestVideoFile*>>, 1135 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files)));
1123 &test_video_files_));
1124 1136
1125 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, 1137 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
1126 base::WaitableEvent::InitialState::NOT_SIGNALED); 1138 base::WaitableEvent::InitialState::NOT_SIGNALED);
1127 g_env->GetRenderingTaskRunner()->PostTask( 1139 g_env->GetRenderingTaskRunner()->PostTask(
1128 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, 1140 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize,
1129 base::Unretained(&rendering_helper_), &done)); 1141 base::Unretained(&rendering_helper_), &done));
1130 done.Wait(); 1142 done.Wait();
1131 1143
1132 rendering_helper_.TearDown(); 1144 rendering_helper_.TearDown();
1133 } 1145 }
1134 1146
1135 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( 1147 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData(
1136 base::FilePath::StringType data, 1148 base::FilePath::StringType data,
1137 std::vector<TestVideoFile*>* test_video_files) { 1149 TestFilesVector* test_video_files) {
1138 std::vector<base::FilePath::StringType> entries = 1150 std::vector<base::FilePath::StringType> entries =
1139 base::SplitString(data, base::FilePath::StringType(1, ';'), 1151 base::SplitString(data, base::FilePath::StringType(1, ';'),
1140 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1152 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
1141 LOG_ASSERT(entries.size() >= 1U) << data; 1153 LOG_ASSERT(entries.size() >= 1U) << data;
1142 for (size_t index = 0; index < entries.size(); ++index) { 1154 for (size_t index = 0; index < entries.size(); ++index) {
1143 std::vector<base::FilePath::StringType> fields = 1155 std::vector<base::FilePath::StringType> fields =
1144 base::SplitString(entries[index], base::FilePath::StringType(1, ':'), 1156 base::SplitString(entries[index], base::FilePath::StringType(1, ':'),
1145 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1157 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
1146 LOG_ASSERT(fields.size() >= 1U) << entries[index]; 1158 LOG_ASSERT(fields.size() >= 1U) << entries[index];
1147 LOG_ASSERT(fields.size() <= 8U) << entries[index]; 1159 LOG_ASSERT(fields.size() <= 8U) << entries[index];
1148 TestVideoFile* video_file = new TestVideoFile(fields[0]); 1160 std::unique_ptr<TestVideoFile> video_file =
1161 base::MakeUnique<TestVideoFile>(fields[0]);
1149 if (!fields[1].empty()) 1162 if (!fields[1].empty())
1150 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width)); 1163 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width));
1151 if (!fields[2].empty()) 1164 if (!fields[2].empty())
1152 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height)); 1165 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height));
1153 if (!fields[3].empty()) 1166 if (!fields[3].empty())
1154 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames)); 1167 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames));
1155 if (!fields[4].empty()) 1168 if (!fields[4].empty())
1156 LOG_ASSERT(base::StringToInt(fields[4], &video_file->num_fragments)); 1169 LOG_ASSERT(base::StringToInt(fields[4], &video_file->num_fragments));
1157 if (!fields[5].empty()) 1170 if (!fields[5].empty())
1158 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render)); 1171 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render));
1159 if (!fields[6].empty()) 1172 if (!fields[6].empty())
1160 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render)); 1173 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render));
1161 int profile = -1; 1174 int profile = -1;
1162 if (!fields[7].empty()) 1175 if (!fields[7].empty())
1163 LOG_ASSERT(base::StringToInt(fields[7], &profile)); 1176 LOG_ASSERT(base::StringToInt(fields[7], &profile));
1164 video_file->profile = static_cast<VideoCodecProfile>(profile); 1177 video_file->profile = static_cast<VideoCodecProfile>(profile);
1165 1178
1166 // Read in the video data. 1179 // Read in the video data.
1167 base::FilePath filepath(video_file->file_name); 1180 base::FilePath filepath(video_file->file_name);
1168 LOG_ASSERT(base::ReadFileToString(filepath, &video_file->data_str)) 1181 LOG_ASSERT(base::ReadFileToString(filepath, &video_file->data_str))
1169 << "test_video_file: " << filepath.MaybeAsASCII(); 1182 << "test_video_file: " << filepath.MaybeAsASCII();
1170 1183
1171 test_video_files->push_back(video_file); 1184 test_video_files->push_back(std::move(video_file));
1172 } 1185 }
1173 } 1186 }
1174 1187
1175 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( 1188 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams(
1176 size_t num_concurrent_decoders, 1189 size_t num_concurrent_decoders,
1177 int reset_point, 1190 int reset_point,
1178 std::vector<TestVideoFile*>* test_video_files) { 1191 TestFilesVector* test_video_files) {
1179 for (size_t i = 0; i < test_video_files->size(); i++) { 1192 for (size_t i = 0; i < test_video_files->size(); i++) {
1180 TestVideoFile* video_file = (*test_video_files)[i]; 1193 TestVideoFile* video_file = (*test_video_files)[i].get();
1181 if (reset_point == MID_STREAM_RESET) { 1194 if (reset_point == MID_STREAM_RESET) {
1182 // Reset should not go beyond the last frame; 1195 // Reset should not go beyond the last frame;
1183 // reset in the middle of the stream for short videos. 1196 // reset in the middle of the stream for short videos.
1184 video_file->reset_after_frame_num = kMaxResetAfterFrameNum; 1197 video_file->reset_after_frame_num = kMaxResetAfterFrameNum;
1185 if (video_file->num_frames <= video_file->reset_after_frame_num) 1198 if (video_file->num_frames <= video_file->reset_after_frame_num)
1186 video_file->reset_after_frame_num = video_file->num_frames / 2; 1199 video_file->reset_after_frame_num = video_file->num_frames / 2;
1187 1200
1188 video_file->num_frames += video_file->reset_after_frame_num; 1201 video_file->num_frames += video_file->reset_after_frame_num;
1189 } else { 1202 } else {
1190 video_file->reset_after_frame_num = reset_point; 1203 video_file->reset_after_frame_num = reset_point;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 1307
1295 if (g_num_play_throughs > 0) 1308 if (g_num_play_throughs > 0)
1296 num_play_throughs = g_num_play_throughs; 1309 num_play_throughs = g_num_play_throughs;
1297 1310
1298 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, 1311 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point,
1299 &test_video_files_); 1312 &test_video_files_);
1300 1313
1301 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. 1314 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1302 const bool suppress_rendering = g_rendering_fps == 0; 1315 const bool suppress_rendering = g_rendering_fps == 0;
1303 1316
1304 std::vector<ClientStateNotification<ClientState>*> notes( 1317 using NotesVector =
1305 num_concurrent_decoders, NULL); 1318 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>;
1306 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 1319 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>;
1320 NotesVector notes(num_concurrent_decoders);
1321 ClientsVector clients(num_concurrent_decoders);
1307 1322
1308 RenderingHelperParams helper_params; 1323 RenderingHelperParams helper_params;
1309 helper_params.rendering_fps = g_rendering_fps; 1324 helper_params.rendering_fps = g_rendering_fps;
1310 helper_params.warm_up_iterations = g_rendering_warm_up; 1325 helper_params.warm_up_iterations = g_rendering_warm_up;
1311 helper_params.render_as_thumbnails = render_as_thumbnails; 1326 helper_params.render_as_thumbnails = render_as_thumbnails;
1312 if (render_as_thumbnails) { 1327 if (render_as_thumbnails) {
1313 // Only one decoder is supported with thumbnail rendering 1328 // Only one decoder is supported with thumbnail rendering
1314 LOG_ASSERT(num_concurrent_decoders == 1U); 1329 LOG_ASSERT(num_concurrent_decoders == 1U);
1315 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1330 helper_params.thumbnails_page_size = kThumbnailsPageSize;
1316 helper_params.thumbnail_size = kThumbnailSize; 1331 helper_params.thumbnail_size = kThumbnailSize;
1317 } 1332 }
1318 1333
1319 // First kick off all the decoders. 1334 // First kick off all the decoders.
1320 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1335 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1321 TestVideoFile* video_file = 1336 TestVideoFile* video_file =
1322 test_video_files_[index % test_video_files_.size()]; 1337 test_video_files_[index % test_video_files_.size()].get();
1323 ClientStateNotification<ClientState>* note = 1338 std::unique_ptr<ClientStateNotification<ClientState>> note =
1324 new ClientStateNotification<ClientState>(); 1339 base::MakeUnique<ClientStateNotification<ClientState>>();
1325 notes[index] = note; 1340 notes[index] = std::move(note);
1326 1341
1327 int delay_after_frame_num = std::numeric_limits<int>::max(); 1342 int delay_after_frame_num = std::numeric_limits<int>::max();
1328 if (test_reuse_delay && 1343 if (test_reuse_delay &&
1329 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { 1344 kMaxFramesToDelayReuse * 2 < video_file->num_frames) {
1330 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; 1345 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse;
1331 } 1346 }
1332 1347
1333 GLRenderingVDAClient* client = 1348 std::unique_ptr<GLRenderingVDAClient> client =
1334 new GLRenderingVDAClient(index, 1349 base::MakeUnique<GLRenderingVDAClient>(
1335 &rendering_helper_, 1350 index, &rendering_helper_, notes[index].get(), video_file->data_str,
1336 note, 1351 num_in_flight_decodes, num_play_throughs,
1337 video_file->data_str, 1352 video_file->reset_after_frame_num, delete_decoder_state,
1338 num_in_flight_decodes, 1353 video_file->width, video_file->height, video_file->profile,
1339 num_play_throughs, 1354 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0,
1340 video_file->reset_after_frame_num, 1355 render_as_thumbnails);
1341 delete_decoder_state,
1342 video_file->width,
1343 video_file->height,
1344 video_file->profile,
1345 g_fake_decoder,
1346 suppress_rendering,
1347 delay_after_frame_num,
1348 0,
1349 render_as_thumbnails);
1350 1356
1351 clients[index] = client; 1357 clients[index] = std::move(client);
1352 helper_params.window_sizes.push_back( 1358 helper_params.window_sizes.push_back(
1353 render_as_thumbnails 1359 render_as_thumbnails
1354 ? kThumbnailsPageSize 1360 ? kThumbnailsPageSize
1355 : gfx::Size(video_file->width, video_file->height)); 1361 : gfx::Size(video_file->width, video_file->height));
1356 } 1362 }
1357 1363
1358 InitializeRenderingHelper(helper_params); 1364 InitializeRenderingHelper(helper_params);
1359 1365
1360 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1366 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1361 CreateAndStartDecoder(clients[index], notes[index]); 1367 CreateAndStartDecoder(clients[index].get(), notes[index].get());
1362 } 1368 }
1363 1369
1364 // Then wait for all the decodes to finish. 1370 // Then wait for all the decodes to finish.
1365 // Only check performance & correctness later if we play through only once. 1371 // Only check performance & correctness later if we play through only once.
1366 bool skip_performance_and_correctness_checks = num_play_throughs > 1; 1372 bool skip_performance_and_correctness_checks = num_play_throughs > 1;
1367 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1373 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
1368 ClientStateNotification<ClientState>* note = notes[i]; 1374 ClientStateNotification<ClientState>* note = notes[i].get();
1369 ClientState state = note->Wait(); 1375 ClientState state = note->Wait();
1370 if (state != CS_INITIALIZED) { 1376 if (state != CS_INITIALIZED) {
1371 skip_performance_and_correctness_checks = true; 1377 skip_performance_and_correctness_checks = true;
1372 // We expect initialization to fail only when more than the supported 1378 // We expect initialization to fail only when more than the supported
1373 // number of decoders is instantiated. Assert here that something else 1379 // number of decoders is instantiated. Assert here that something else
1374 // didn't trigger failure. 1380 // didn't trigger failure.
1375 ASSERT_GT(num_concurrent_decoders, 1381 ASSERT_GT(num_concurrent_decoders,
1376 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); 1382 static_cast<size_t>(kMinSupportedNumConcurrentDecoders));
1377 continue; 1383 continue;
1378 } 1384 }
1379 ASSERT_EQ(state, CS_INITIALIZED); 1385 ASSERT_EQ(state, CS_INITIALIZED);
1380 for (int n = 0; n < num_play_throughs; ++n) { 1386 for (int n = 0; n < num_play_throughs; ++n) {
1381 // For play-throughs other than the first, we expect initialization to 1387 // For play-throughs other than the first, we expect initialization to
1382 // succeed unconditionally. 1388 // succeed unconditionally.
1383 if (n > 0) { 1389 if (n > 0) {
1384 ASSERT_NO_FATAL_FAILURE( 1390 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted(
1385 AssertWaitForStateOrDeleted(note, clients[i], CS_INITIALIZED)); 1391 note, clients[i].get(), CS_INITIALIZED));
1386 } 1392 }
1387 // InitializeDone kicks off decoding inside the client, so we just need to 1393 // InitializeDone kicks off decoding inside the client, so we just need to
1388 // wait for Flush. 1394 // wait for Flush.
1389 ASSERT_NO_FATAL_FAILURE( 1395 ASSERT_NO_FATAL_FAILURE(
1390 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHING)); 1396 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHING));
1391 ASSERT_NO_FATAL_FAILURE( 1397 ASSERT_NO_FATAL_FAILURE(
1392 AssertWaitForStateOrDeleted(note, clients[i], CS_FLUSHED)); 1398 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHED));
1393 // FlushDone requests Reset(). 1399 // FlushDone requests Reset().
1394 ASSERT_NO_FATAL_FAILURE( 1400 ASSERT_NO_FATAL_FAILURE(
1395 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); 1401 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESETTING));
1396 } 1402 }
1397 ASSERT_NO_FATAL_FAILURE( 1403 ASSERT_NO_FATAL_FAILURE(
1398 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); 1404 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESET));
1399 // ResetDone requests Destroy(). 1405 // ResetDone requests Destroy().
1400 ASSERT_NO_FATAL_FAILURE( 1406 ASSERT_NO_FATAL_FAILURE(
1401 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); 1407 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_DESTROYED));
1402 } 1408 }
1403 // Finally assert that decoding went as expected. 1409 // Finally assert that decoding went as expected.
1404 for (size_t i = 0; 1410 for (size_t i = 0;
1405 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; 1411 i < num_concurrent_decoders && !skip_performance_and_correctness_checks;
1406 ++i) { 1412 ++i) {
1407 // We can only make performance/correctness assertions if the decoder was 1413 // We can only make performance/correctness assertions if the decoder was
1408 // allowed to finish. 1414 // allowed to finish.
1409 if (delete_decoder_state < CS_FLUSHED) 1415 if (delete_decoder_state < CS_FLUSHED)
1410 continue; 1416 continue;
1411 GLRenderingVDAClient* client = clients[i]; 1417 GLRenderingVDAClient* client = clients[i].get();
1412 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; 1418 TestVideoFile* video_file =
1419 test_video_files_[i % test_video_files_.size()].get();
1413 if (video_file->num_frames > 0) { 1420 if (video_file->num_frames > 0) {
1414 // Expect the decoded frames may be more than the video frames as frames 1421 // Expect the decoded frames may be more than the video frames as frames
1415 // could still be returned until resetting done. 1422 // could still be returned until resetting done.
1416 if (video_file->reset_after_frame_num > 0) 1423 if (video_file->reset_after_frame_num > 0)
1417 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); 1424 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames);
1418 else 1425 else
1419 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); 1426 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames);
1420 } 1427 }
1421 if (reset_point == END_OF_STREAM_RESET) { 1428 if (reset_point == END_OF_STREAM_RESET) {
1422 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + 1429 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() +
(...skipping 17 matching lines...) Expand all
1440 base::WaitableEvent::InitialState::NOT_SIGNALED); 1447 base::WaitableEvent::InitialState::NOT_SIGNALED);
1441 g_env->GetRenderingTaskRunner()->PostTask( 1448 g_env->GetRenderingTaskRunner()->PostTask(
1442 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, 1449 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB,
1443 base::Unretained(&rendering_helper_), &rgb, 1450 base::Unretained(&rendering_helper_), &rgb,
1444 &alpha_solid, &done)); 1451 &alpha_solid, &done));
1445 done.Wait(); 1452 done.Wait();
1446 1453
1447 std::vector<std::string> golden_md5s; 1454 std::vector<std::string> golden_md5s;
1448 std::string md5_string = base::MD5String( 1455 std::string md5_string = base::MD5String(
1449 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); 1456 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size()));
1450 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); 1457 ReadGoldenThumbnailMD5s(test_video_files_[0].get(), &golden_md5s);
1451 std::vector<std::string>::iterator match = 1458 std::vector<std::string>::iterator match =
1452 find(golden_md5s.begin(), golden_md5s.end(), md5_string); 1459 find(golden_md5s.begin(), golden_md5s.end(), md5_string);
1453 if (match == golden_md5s.end()) { 1460 if (match == golden_md5s.end()) {
1454 // Convert raw RGB into PNG for export. 1461 // Convert raw RGB into PNG for export.
1455 std::vector<unsigned char> png; 1462 std::vector<unsigned char> png;
1456 gfx::PNGCodec::Encode(&rgb[0], 1463 gfx::PNGCodec::Encode(&rgb[0],
1457 gfx::PNGCodec::FORMAT_RGB, 1464 gfx::PNGCodec::FORMAT_RGB,
1458 kThumbnailsPageSize, 1465 kThumbnailsPageSize,
1459 kThumbnailsPageSize.width() * 3, 1466 kThumbnailsPageSize.width() * 3,
1460 true, 1467 true,
(...skipping 18 matching lines...) Expand all
1479 // allowed to finish. 1486 // allowed to finish.
1480 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1487 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
1481 base::File output_file( 1488 base::File output_file(
1482 base::FilePath(g_output_log), 1489 base::FilePath(g_output_log),
1483 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); 1490 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
1484 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1491 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
1485 clients[i]->OutputFrameDeliveryTimes(&output_file); 1492 clients[i]->OutputFrameDeliveryTimes(&output_file);
1486 } 1493 }
1487 } 1494 }
1488 1495
1496 std::unique_ptr<NotesVector> notes2(new NotesVector);
1497 notes2->swap(notes);
1498 std::unique_ptr<ClientsVector> clients2(new ClientsVector);
1499 clients2->swap(clients);
1500
1489 g_env->GetRenderingTaskRunner()->PostTask( 1501 g_env->GetRenderingTaskRunner()->PostTask(
1490 FROM_HERE, 1502 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(&notes2)));
1491 base::Bind(&base::STLDeleteElements<std::vector<GLRenderingVDAClient*>>, 1503
1492 &clients));
1493 g_env->GetRenderingTaskRunner()->PostTask( 1504 g_env->GetRenderingTaskRunner()->PostTask(
1494 FROM_HERE, 1505 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients2)));
1495 base::Bind(&base::STLDeleteElements< 1506
1496 std::vector<ClientStateNotification<ClientState>*>>,
1497 &notes));
1498 WaitUntilIdle(); 1507 WaitUntilIdle();
1499 }; 1508 };
1500 1509
1501 // Test that replay after EOS works fine. 1510 // Test that replay after EOS works fine.
1502 INSTANTIATE_TEST_CASE_P( 1511 INSTANTIATE_TEST_CASE_P(
1503 ReplayAfterEOS, 1512 ReplayAfterEOS,
1504 VideoDecodeAcceleratorParamTest, 1513 VideoDecodeAcceleratorParamTest,
1505 ::testing::Values( 1514 ::testing::Values(
1506 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); 1515 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false)));
1507 1516
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 media::VaapiWrapper::PreSandboxInitialization(); 1793 media::VaapiWrapper::PreSandboxInitialization();
1785 #endif 1794 #endif
1786 1795
1787 media::g_env = 1796 media::g_env =
1788 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1797 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1789 testing::AddGlobalTestEnvironment( 1798 testing::AddGlobalTestEnvironment(
1790 new media::VideoDecodeAcceleratorTestEnvironment())); 1799 new media::VideoDecodeAcceleratorTestEnvironment()));
1791 1800
1792 return RUN_ALL_TESTS(); 1801 return RUN_ALL_TESTS();
1793 } 1802 }
OLDNEW
« no previous file with comments | « media/gpu/ipc/service/gpu_jpeg_decode_accelerator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698