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

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

Issue 2596193005: vda unittest: delete GLRenderingVDAClient in correct thread (Closed)
Patch Set: vda unittest: delete GLRenderingVDAClient in correct thread Created 3 years, 11 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 | « no previous file | 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 base::SPLIT_WANT_ALL); 199 base::SPLIT_WANT_ALL);
200 // Check these are legitimate MD5s. 200 // Check these are legitimate MD5s.
201 for (const std::string& md5_string : *md5_strings) { 201 for (const std::string& md5_string : *md5_strings) {
202 // Ignore the empty string added by SplitString 202 // Ignore the empty string added by SplitString
203 if (!md5_string.length()) 203 if (!md5_string.length())
204 continue; 204 continue;
205 // Ignore comments 205 // Ignore comments
206 if (md5_string.at(0) == '#') 206 if (md5_string.at(0) == '#')
207 continue; 207 continue;
208 208
209 LOG_ASSERT(static_cast<int>(md5_string.length()) == kMD5StringLength) 209 LOG_IF(ERROR, static_cast<int>(md5_string.length()) != kMD5StringLength)
210 << md5_string; 210 << "MD5 length error: " << md5_string;
211 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), 211 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(),
212 isxdigit) == kMD5StringLength; 212 isxdigit) == kMD5StringLength;
213 LOG_ASSERT(hex_only) << md5_string; 213 LOG_IF(ERROR, !hex_only) << "MD5 includes non-hex char: " << md5_string;
214 } 214 }
215 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" 215 LOG_IF(ERROR, md5_strings->empty()) << " MD5 checksum file ("
216 << filepath.MaybeAsASCII() 216 << filepath.MaybeAsASCII()
217 << ") missing or empty."; 217 << ") missing or empty.";
218 } 218 }
219 219
220 // State of the GLRenderingVDAClient below. Order matters here as the test 220 // State of the GLRenderingVDAClient below. Order matters here as the test
221 // makes assumptions about it. 221 // makes assumptions about it.
222 enum ClientState { 222 enum ClientState {
223 CS_CREATED = 0, 223 CS_CREATED = 0,
224 CS_DECODER_SET = 1, 224 CS_DECODER_SET = 1,
225 CS_INITIALIZED = 2, 225 CS_INITIALIZED = 2,
226 CS_FLUSHING = 3, 226 CS_FLUSHING = 3,
227 CS_FLUSHED = 4, 227 CS_FLUSHED = 4,
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, 790 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer,
791 weak_vda_, picture_buffer_id), 791 weak_vda_, picture_buffer_id),
792 kReuseDelay); 792 kReuseDelay);
793 } else { 793 } else {
794 decoder_->ReusePictureBuffer(picture_buffer_id); 794 decoder_->ReusePictureBuffer(picture_buffer_id);
795 } 795 }
796 } 796 }
797 797
798 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( 798 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer(
799 int32_t bitstream_buffer_id) { 799 int32_t bitstream_buffer_id) {
800 if (decoder_deleted())
801 return;
802
800 // TODO(fischman): this test currently relies on this notification to make 803 // TODO(fischman): this test currently relies on this notification to make
801 // forward progress during a Reset(). But the VDA::Reset() API doesn't 804 // forward progress during a Reset(). But the VDA::Reset() API doesn't
802 // guarantee this, so stop relying on it (and remove the notifications from 805 // guarantee this, so stop relying on it (and remove the notifications from
803 // VaapiVideoDecodeAccelerator::FinishReset()). 806 // VaapiVideoDecodeAccelerator::FinishReset()).
804 ++num_done_bitstream_buffers_; 807 ++num_done_bitstream_buffers_;
805 --outstanding_decodes_; 808 --outstanding_decodes_;
806 809
807 // Flush decoder after all BitstreamBuffers are processed. 810 // Flush decoder after all BitstreamBuffers are processed.
808 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { 811 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) {
809 // TODO(owenlin): We should not have to check the number of 812 // TODO(owenlin): We should not have to check the number of
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } 881 }
879 882
880 static bool LookingAtNAL(const std::string& encoded, size_t pos) { 883 static bool LookingAtNAL(const std::string& encoded, size_t pos) {
881 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 && 884 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 &&
882 encoded[pos + 3] == 1; 885 encoded[pos + 3] == 1;
883 } 886 }
884 887
885 void GLRenderingVDAClient::SetState(ClientState new_state) { 888 void GLRenderingVDAClient::SetState(ClientState new_state) {
886 note_->Notify(new_state); 889 note_->Notify(new_state);
887 state_ = new_state; 890 state_ = new_state;
888 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { 891 if (!remaining_play_throughs_ && new_state == delete_decoder_state_ &&
889 LOG_ASSERT(!decoder_deleted()); 892 !decoder_deleted()) {
johnylin1 2017/01/09 07:11:05 Hi Pawel, we found that the deletion of current GL
890 DeleteDecoder(); 893 DeleteDecoder();
891 } 894 }
892 } 895 }
893 896
894 void GLRenderingVDAClient::FinishInitialization() { 897 void GLRenderingVDAClient::FinishInitialization() {
895 SetState(CS_INITIALIZED); 898 SetState(CS_INITIALIZED);
896 initialize_done_ticks_ = base::TimeTicks::Now(); 899 initialize_done_ticks_ = base::TimeTicks::Now();
897 900
898 if (reset_after_frame_num_ == START_OF_STREAM_RESET) { 901 if (reset_after_frame_num_ == START_OF_STREAM_RESET) {
899 reset_after_frame_num_ = MID_STREAM_RESET; 902 reset_after_frame_num_ = MID_STREAM_RESET;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 void WaitUntilIdle(); 1114 void WaitUntilIdle();
1112 void OutputLogFile(const base::FilePath::CharType* log_path, 1115 void OutputLogFile(const base::FilePath::CharType* log_path,
1113 const std::string& content); 1116 const std::string& content);
1114 1117
1115 TestFilesVector test_video_files_; 1118 TestFilesVector test_video_files_;
1116 RenderingHelper rendering_helper_; 1119 RenderingHelper rendering_helper_;
1117 1120
1118 protected: 1121 protected:
1119 // Must be static because this method may run after the destructor. 1122 // Must be static because this method may run after the destructor.
1120 template <typename T> 1123 template <typename T>
1121 static void Delete(std::unique_ptr<T> item) { 1124 static void Delete(T item) {
1122 // |item| is cleared when the scope of this function is left. 1125 // |item| is cleared when the scope of this function is left.
1123 } 1126 }
1124 1127
1125 private: 1128 private:
1126 // Required for Thread to work. Not used otherwise. 1129 // Required for Thread to work. Not used otherwise.
1127 base::ShadowingAtExitManager at_exit_manager_; 1130 base::ShadowingAtExitManager at_exit_manager_;
1128 1131
1129 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); 1132 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest);
1130 }; 1133 };
1131 1134
1132 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} 1135 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {}
1133 1136
1134 void VideoDecodeAcceleratorTest::SetUp() { 1137 void VideoDecodeAcceleratorTest::SetUp() {
1135 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); 1138 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_);
1136 } 1139 }
1137 1140
1138 void VideoDecodeAcceleratorTest::TearDown() { 1141 void VideoDecodeAcceleratorTest::TearDown() {
1139 std::unique_ptr<TestFilesVector> test_video_files(new TestFilesVector);
1140 test_video_files->swap(test_video_files_);
1141
1142 g_env->GetRenderingTaskRunner()->PostTask( 1142 g_env->GetRenderingTaskRunner()->PostTask(
1143 FROM_HERE, 1143 FROM_HERE,
1144 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files))); 1144 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files_)));
1145 1145
1146 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, 1146 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
1147 base::WaitableEvent::InitialState::NOT_SIGNALED); 1147 base::WaitableEvent::InitialState::NOT_SIGNALED);
1148 g_env->GetRenderingTaskRunner()->PostTask( 1148 g_env->GetRenderingTaskRunner()->PostTask(
1149 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, 1149 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize,
1150 base::Unretained(&rendering_helper_), &done)); 1150 base::Unretained(&rendering_helper_), &done));
1151 done.Wait(); 1151 done.Wait();
1152 1152
1153 rendering_helper_.TearDown(); 1153 rendering_helper_.TearDown();
1154 } 1154 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 // instantiated. 1273 // instantiated.
1274 // - Number of concurrent in-flight Decode() calls per decoder. 1274 // - Number of concurrent in-flight Decode() calls per decoder.
1275 // - Number of play-throughs. 1275 // - Number of play-throughs.
1276 // - reset_after_frame_num: see GLRenderingVDAClient ctor. 1276 // - reset_after_frame_num: see GLRenderingVDAClient ctor.
1277 // - delete_decoder_phase: see GLRenderingVDAClient ctor. 1277 // - delete_decoder_phase: see GLRenderingVDAClient ctor.
1278 // - whether to test slow rendering by delaying ReusePictureBuffer(). 1278 // - whether to test slow rendering by delaying ReusePictureBuffer().
1279 // - whether the video frames are rendered as thumbnails. 1279 // - whether the video frames are rendered as thumbnails.
1280 class VideoDecodeAcceleratorParamTest 1280 class VideoDecodeAcceleratorParamTest
1281 : public VideoDecodeAcceleratorTest, 1281 : public VideoDecodeAcceleratorTest,
1282 public ::testing::WithParamInterface< 1282 public ::testing::WithParamInterface<
1283 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; 1283 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {
1284 protected:
1285 using NotesVector =
1286 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>;
1287 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>;
1288
1289 void TearDown() override;
1290
1291 NotesVector notes_;
1292 ClientsVector clients_;
1293 };
1294
1295 void VideoDecodeAcceleratorParamTest::TearDown() {
1296 // |clients_| must be deleted first because |clients_| use |notes_|.
1297 g_env->GetRenderingTaskRunner()->PostTask(
1298 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients_)));
1299
1300 g_env->GetRenderingTaskRunner()->PostTask(
1301 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(&notes_)));
1302
1303 WaitUntilIdle();
1304
1305 // Do VideoDecodeAcceleratorTest clean-up after deleting clients and notes.
1306 VideoDecodeAcceleratorTest::TearDown();
1307 }
1284 1308
1285 // Wait for |note| to report a state and if it's not |expected_state| then 1309 // Wait for |note| to report a state and if it's not |expected_state| then
1286 // assert |client| has deleted its decoder. 1310 // assert |client| has deleted its decoder.
1287 static void AssertWaitForStateOrDeleted( 1311 static void AssertWaitForStateOrDeleted(
1288 ClientStateNotification<ClientState>* note, 1312 ClientStateNotification<ClientState>* note,
1289 GLRenderingVDAClient* client, 1313 GLRenderingVDAClient* client,
1290 ClientState expected_state) { 1314 ClientState expected_state) {
1291 ClientState state = note->Wait(); 1315 ClientState state = note->Wait();
1292 if (state == expected_state) 1316 if (state == expected_state)
1293 return; 1317 return;
(...skipping 23 matching lines...) Expand all
1317 1341
1318 if (g_num_play_throughs > 0) 1342 if (g_num_play_throughs > 0)
1319 num_play_throughs = g_num_play_throughs; 1343 num_play_throughs = g_num_play_throughs;
1320 1344
1321 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, 1345 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point,
1322 &test_video_files_); 1346 &test_video_files_);
1323 1347
1324 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. 1348 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1325 const bool suppress_rendering = g_rendering_fps == 0; 1349 const bool suppress_rendering = g_rendering_fps == 0;
1326 1350
1327 using NotesVector = 1351 notes_.resize(num_concurrent_decoders);
1328 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; 1352 clients_.resize(num_concurrent_decoders);
1329 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>;
1330 NotesVector notes(num_concurrent_decoders);
1331 ClientsVector clients(num_concurrent_decoders);
1332 1353
1333 RenderingHelperParams helper_params; 1354 RenderingHelperParams helper_params;
1334 helper_params.rendering_fps = g_rendering_fps; 1355 helper_params.rendering_fps = g_rendering_fps;
1335 helper_params.warm_up_iterations = g_rendering_warm_up; 1356 helper_params.warm_up_iterations = g_rendering_warm_up;
1336 helper_params.render_as_thumbnails = render_as_thumbnails; 1357 helper_params.render_as_thumbnails = render_as_thumbnails;
1337 if (render_as_thumbnails) { 1358 if (render_as_thumbnails) {
1338 // Only one decoder is supported with thumbnail rendering 1359 // Only one decoder is supported with thumbnail rendering
1339 LOG_ASSERT(num_concurrent_decoders == 1U); 1360 LOG_ASSERT(num_concurrent_decoders == 1U);
1340 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1361 helper_params.thumbnails_page_size = kThumbnailsPageSize;
1341 helper_params.thumbnail_size = kThumbnailSize; 1362 helper_params.thumbnail_size = kThumbnailSize;
1342 } 1363 }
1343 1364
1344 // First kick off all the decoders. 1365 // First kick off all the decoders.
1345 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1366 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1346 TestVideoFile* video_file = 1367 TestVideoFile* video_file =
1347 test_video_files_[index % test_video_files_.size()].get(); 1368 test_video_files_[index % test_video_files_.size()].get();
1348 std::unique_ptr<ClientStateNotification<ClientState>> note = 1369 std::unique_ptr<ClientStateNotification<ClientState>> note =
1349 base::MakeUnique<ClientStateNotification<ClientState>>(); 1370 base::MakeUnique<ClientStateNotification<ClientState>>();
1350 notes[index] = std::move(note); 1371 notes_[index] = std::move(note);
1351 1372
1352 int delay_after_frame_num = std::numeric_limits<int>::max(); 1373 int delay_after_frame_num = std::numeric_limits<int>::max();
1353 if (test_reuse_delay && 1374 if (test_reuse_delay &&
1354 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { 1375 kMaxFramesToDelayReuse * 2 < video_file->num_frames) {
1355 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; 1376 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse;
1356 } 1377 }
1357 1378
1358 std::unique_ptr<GLRenderingVDAClient> client = 1379 std::unique_ptr<GLRenderingVDAClient> client =
1359 base::MakeUnique<GLRenderingVDAClient>( 1380 base::MakeUnique<GLRenderingVDAClient>(
1360 index, &rendering_helper_, notes[index].get(), video_file->data_str, 1381 index, &rendering_helper_, notes_[index].get(),
1361 num_in_flight_decodes, num_play_throughs, 1382 video_file->data_str, num_in_flight_decodes, num_play_throughs,
1362 video_file->reset_after_frame_num, delete_decoder_state, 1383 video_file->reset_after_frame_num, delete_decoder_state,
1363 video_file->width, video_file->height, video_file->profile, 1384 video_file->width, video_file->height, video_file->profile,
1364 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, 1385 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0,
1365 render_as_thumbnails); 1386 render_as_thumbnails);
1366 1387
1367 clients[index] = std::move(client); 1388 clients_[index] = std::move(client);
1368 helper_params.window_sizes.push_back( 1389 helper_params.window_sizes.push_back(
1369 render_as_thumbnails 1390 render_as_thumbnails
1370 ? kThumbnailsPageSize 1391 ? kThumbnailsPageSize
1371 : gfx::Size(video_file->width, video_file->height)); 1392 : gfx::Size(video_file->width, video_file->height));
1372 } 1393 }
1373 1394
1374 InitializeRenderingHelper(helper_params); 1395 InitializeRenderingHelper(helper_params);
1375 1396
1376 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1397 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1377 CreateAndStartDecoder(clients[index].get(), notes[index].get()); 1398 CreateAndStartDecoder(clients_[index].get(), notes_[index].get());
1378 } 1399 }
1379 1400
1380 // Then wait for all the decodes to finish. 1401 // Then wait for all the decodes to finish.
1381 // Only check performance & correctness later if we play through only once. 1402 // Only check performance & correctness later if we play through only once.
1382 bool skip_performance_and_correctness_checks = num_play_throughs > 1; 1403 bool skip_performance_and_correctness_checks = num_play_throughs > 1;
1383 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1404 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
1384 ClientStateNotification<ClientState>* note = notes[i].get(); 1405 ClientStateNotification<ClientState>* note = notes_[i].get();
1385 ClientState state = note->Wait(); 1406 ClientState state = note->Wait();
1386 if (state != CS_INITIALIZED) { 1407 if (state != CS_INITIALIZED) {
1387 skip_performance_and_correctness_checks = true; 1408 skip_performance_and_correctness_checks = true;
1388 // We expect initialization to fail only when more than the supported 1409 // We expect initialization to fail only when more than the supported
1389 // number of decoders is instantiated. Assert here that something else 1410 // number of decoders is instantiated. Assert here that something else
1390 // didn't trigger failure. 1411 // didn't trigger failure.
1391 ASSERT_GT(num_concurrent_decoders, 1412 ASSERT_GT(num_concurrent_decoders,
1392 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); 1413 static_cast<size_t>(kMinSupportedNumConcurrentDecoders));
1393 continue; 1414 continue;
1394 } 1415 }
1395 ASSERT_EQ(state, CS_INITIALIZED);
1396 for (int n = 0; n < num_play_throughs; ++n) { 1416 for (int n = 0; n < num_play_throughs; ++n) {
1397 // For play-throughs other than the first, we expect initialization to 1417 // For play-throughs other than the first, we expect initialization to
1398 // succeed unconditionally. 1418 // succeed unconditionally.
1399 if (n > 0) { 1419 if (n > 0) {
1400 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( 1420 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted(
1401 note, clients[i].get(), CS_INITIALIZED)); 1421 note, clients_[i].get(), CS_INITIALIZED));
1402 } 1422 }
1403 // InitializeDone kicks off decoding inside the client, so we just need to 1423 // InitializeDone kicks off decoding inside the client, so we just need to
1404 // wait for Flush. 1424 // wait for Flush.
1405 ASSERT_NO_FATAL_FAILURE( 1425 ASSERT_NO_FATAL_FAILURE(
1406 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHING)); 1426 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHING));
1407 ASSERT_NO_FATAL_FAILURE( 1427 ASSERT_NO_FATAL_FAILURE(
1408 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHED)); 1428 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHED));
1409 // FlushDone requests Reset(). 1429 // FlushDone requests Reset().
1410 ASSERT_NO_FATAL_FAILURE( 1430 ASSERT_NO_FATAL_FAILURE(
1411 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESETTING)); 1431 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESETTING));
1412 } 1432 }
1413 ASSERT_NO_FATAL_FAILURE( 1433 ASSERT_NO_FATAL_FAILURE(
1414 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESET)); 1434 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESET));
1415 // ResetDone requests Destroy(). 1435 // ResetDone requests Destroy().
1416 ASSERT_NO_FATAL_FAILURE( 1436 ASSERT_NO_FATAL_FAILURE(
1417 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_DESTROYED)); 1437 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_DESTROYED));
1418 } 1438 }
1419 // Finally assert that decoding went as expected. 1439 // Finally assert that decoding went as expected.
1420 for (size_t i = 0; 1440 for (size_t i = 0;
1421 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; 1441 i < num_concurrent_decoders && !skip_performance_and_correctness_checks;
1422 ++i) { 1442 ++i) {
1423 // We can only make performance/correctness assertions if the decoder was 1443 // We can only make performance/correctness assertions if the decoder was
1424 // allowed to finish. 1444 // allowed to finish.
1425 if (delete_decoder_state < CS_FLUSHED) 1445 if (delete_decoder_state < CS_FLUSHED)
1426 continue; 1446 continue;
1427 GLRenderingVDAClient* client = clients[i].get(); 1447 GLRenderingVDAClient* client = clients_[i].get();
1428 TestVideoFile* video_file = 1448 TestVideoFile* video_file =
1429 test_video_files_[i % test_video_files_.size()].get(); 1449 test_video_files_[i % test_video_files_.size()].get();
1430 if (video_file->num_frames > 0) { 1450 if (video_file->num_frames > 0) {
1431 // Expect the decoded frames may be more than the video frames as frames 1451 // Expect the decoded frames may be more than the video frames as frames
1432 // could still be returned until resetting done. 1452 // could still be returned until resetting done.
1433 if (video_file->reset_after_frame_num > 0) 1453 if (video_file->reset_after_frame_num > 0)
1434 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); 1454 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames);
1435 else 1455 else
1436 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); 1456 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames);
1437 } 1457 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 std::vector<gfx::PNGCodec::Comment>(), 1498 std::vector<gfx::PNGCodec::Comment>(),
1479 &png); 1499 &png);
1480 1500
1481 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; 1501 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
1482 1502
1483 base::FilePath filepath(test_video_files_[0]->file_name); 1503 base::FilePath filepath(test_video_files_[0]->file_name);
1484 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); 1504 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
1485 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); 1505 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
1486 int num_bytes = base::WriteFile( 1506 int num_bytes = base::WriteFile(
1487 filepath, reinterpret_cast<char*>(&png[0]), png.size()); 1507 filepath, reinterpret_cast<char*>(&png[0]), png.size());
1488 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); 1508 EXPECT_EQ(num_bytes, static_cast<int>(png.size()));
1489 } 1509 }
1490 ASSERT_NE(match, golden_md5s.end()); 1510 EXPECT_NE(match, golden_md5s.end());
1491 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; 1511 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha";
1492 } 1512 }
1493 1513
1494 // Output the frame delivery time to file 1514 // Output the frame delivery time to file
1495 // We can only make performance/correctness assertions if the decoder was 1515 // We can only make performance/correctness assertions if the decoder was
1496 // allowed to finish. 1516 // allowed to finish.
1497 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1517 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
1498 base::File output_file( 1518 base::File output_file(
1499 base::FilePath(g_output_log), 1519 base::FilePath(g_output_log),
1500 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); 1520 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
1501 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1521 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
1502 clients[i]->OutputFrameDeliveryTimes(&output_file); 1522 clients_[i]->OutputFrameDeliveryTimes(&output_file);
1503 } 1523 }
1504 } 1524 }
1505
1506 std::unique_ptr<ClientsVector> clients2(new ClientsVector);
1507 clients2->swap(clients);
1508 std::unique_ptr<NotesVector> notes2(new NotesVector);
1509 notes2->swap(notes);
1510
1511 // |clients| must be deleted first because |clients| use |notes2|.
1512 g_env->GetRenderingTaskRunner()->PostTask(
1513 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients2)));
1514
1515 g_env->GetRenderingTaskRunner()->PostTask(
1516 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(&notes2)));
1517
1518 WaitUntilIdle();
1519 }; 1525 };
1520 1526
1521 // Test that replay after EOS works fine. 1527 // Test that replay after EOS works fine.
1522 INSTANTIATE_TEST_CASE_P( 1528 INSTANTIATE_TEST_CASE_P(
1523 ReplayAfterEOS, 1529 ReplayAfterEOS,
1524 VideoDecodeAcceleratorParamTest, 1530 VideoDecodeAcceleratorParamTest,
1525 ::testing::Values( 1531 ::testing::Values(
1526 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); 1532 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false)));
1527 1533
1528 // Test that Reset() before the first Decode() works fine. 1534 // Test that Reset() before the first Decode() works fine.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 1831
1826 media::g_env = 1832 media::g_env =
1827 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1833 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1828 testing::AddGlobalTestEnvironment( 1834 testing::AddGlobalTestEnvironment(
1829 new media::VideoDecodeAcceleratorTestEnvironment())); 1835 new media::VideoDecodeAcceleratorTestEnvironment()));
1830 1836
1831 return base::LaunchUnitTestsSerially( 1837 return base::LaunchUnitTestsSerially(
1832 argc, argv, 1838 argc, argv,
1833 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); 1839 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1834 } 1840 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698