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

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

Issue 2713863002: VDA unittest: test for calling Reset before NotifyFlushDone (Closed)
Patch Set: VDA unittest: test for calling Reset before NotifyFlushDone Created 3 years, 9 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // working directory. 143 // working directory.
144 base::FilePath g_test_file_path; 144 base::FilePath g_test_file_path;
145 145
146 // Environment to store rendering thread. 146 // Environment to store rendering thread.
147 class VideoDecodeAcceleratorTestEnvironment; 147 class VideoDecodeAcceleratorTestEnvironment;
148 VideoDecodeAcceleratorTestEnvironment* g_env; 148 VideoDecodeAcceleratorTestEnvironment* g_env;
149 149
150 // Magic constants for differentiating the reasons for NotifyResetDone being 150 // Magic constants for differentiating the reasons for NotifyResetDone being
151 // called. 151 // called.
152 enum ResetPoint { 152 enum ResetPoint {
153 // Reset() right after calling Flush() (before getting NotifyFlushDone()).
154 RESET_BEFORE_NOTIFY_FLUSH_DONE = -5,
153 // Reset() just after calling Decode() with a fragment containing config info. 155 // Reset() just after calling Decode() with a fragment containing config info.
154 RESET_AFTER_FIRST_CONFIG_INFO = -4, 156 RESET_AFTER_FIRST_CONFIG_INFO = -4,
155 START_OF_STREAM_RESET = -3, 157 START_OF_STREAM_RESET = -3,
156 MID_STREAM_RESET = -2, 158 MID_STREAM_RESET = -2,
157 END_OF_STREAM_RESET = -1 159 END_OF_STREAM_RESET = -1
158 }; 160 };
159 161
160 const int kMaxResetAfterFrameNum = 100; 162 const int kMaxResetAfterFrameNum = 100;
161 const int kMaxFramesToDelayReuse = 64; 163 const int kMaxFramesToDelayReuse = 64;
162 const base::TimeDelta kReuseDelay = base::TimeDelta::FromSeconds(1); 164 const base::TimeDelta kReuseDelay = base::TimeDelta::FromSeconds(1);
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // guarantee this, so stop relying on it (and remove the notifications from 819 // guarantee this, so stop relying on it (and remove the notifications from
818 // VaapiVideoDecodeAccelerator::FinishReset()). 820 // VaapiVideoDecodeAccelerator::FinishReset()).
819 ++num_done_bitstream_buffers_; 821 ++num_done_bitstream_buffers_;
820 --outstanding_decodes_; 822 --outstanding_decodes_;
821 823
822 // Flush decoder after all BitstreamBuffers are processed. 824 // Flush decoder after all BitstreamBuffers are processed.
823 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { 825 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) {
824 if (state_ != CS_FLUSHING) { 826 if (state_ != CS_FLUSHING) {
825 decoder_->Flush(); 827 decoder_->Flush();
826 SetState(CS_FLUSHING); 828 SetState(CS_FLUSHING);
829 if (reset_after_frame_num_ == RESET_BEFORE_NOTIFY_FLUSH_DONE) {
830 SetState(CS_FLUSHED);
Pawel Osciak 2017/02/24 07:49:42 Would it make sense to unify this code with other
johnylin1 2017/03/01 07:17:08 Done.
831 --remaining_play_throughs_;
832 DCHECK_GE(remaining_play_throughs_, 0);
833 decoder_->Reset();
834 SetState(CS_RESETTING);
835 }
827 } 836 }
828 } else if (decode_calls_per_second_ == 0) { 837 } else if (decode_calls_per_second_ == 0) {
829 DecodeNextFragment(); 838 DecodeNextFragment();
830 } 839 }
831 } 840 }
832 841
833 void GLRenderingVDAClient::NotifyFlushDone() { 842 void GLRenderingVDAClient::NotifyFlushDone() {
834 if (decoder_deleted()) 843 if (decoder_deleted())
835 return; 844 return;
836 845
846 if (reset_after_frame_num_ == RESET_BEFORE_NOTIFY_FLUSH_DONE) {
847 // In ResetBeforeNotifyFlushDone case client is not necessary to wait for
848 // NotifyFlushDone(). But if client gets, it should be always before
849 // NotifyResetDone().
850 LOG_ASSERT(state_ == CS_RESETTING);
851 return;
852 }
853
837 SetState(CS_FLUSHED); 854 SetState(CS_FLUSHED);
838 --remaining_play_throughs_; 855 --remaining_play_throughs_;
839 DCHECK_GE(remaining_play_throughs_, 0); 856 DCHECK_GE(remaining_play_throughs_, 0);
840 if (decoder_deleted())
841 return;
842 decoder_->Reset(); 857 decoder_->Reset();
843 SetState(CS_RESETTING); 858 SetState(CS_RESETTING);
844 } 859 }
845 860
846 void GLRenderingVDAClient::NotifyResetDone() { 861 void GLRenderingVDAClient::NotifyResetDone() {
847 if (decoder_deleted()) 862 if (decoder_deleted())
848 return; 863 return;
849 864
850 if (reset_after_frame_num_ == MID_STREAM_RESET) { 865 if (reset_after_frame_num_ == MID_STREAM_RESET) {
851 reset_after_frame_num_ = END_OF_STREAM_RESET; 866 reset_after_frame_num_ = END_OF_STREAM_RESET;
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 if (delete_decoder_state < CS_FLUSHED) 1471 if (delete_decoder_state < CS_FLUSHED)
1457 continue; 1472 continue;
1458 GLRenderingVDAClient* client = clients_[i].get(); 1473 GLRenderingVDAClient* client = clients_[i].get();
1459 TestVideoFile* video_file = 1474 TestVideoFile* video_file =
1460 test_video_files_[i % test_video_files_.size()].get(); 1475 test_video_files_[i % test_video_files_.size()].get();
1461 if (video_file->num_frames > 0) { 1476 if (video_file->num_frames > 0) {
1462 // Expect the decoded frames may be more than the video frames as frames 1477 // Expect the decoded frames may be more than the video frames as frames
1463 // could still be returned until resetting done. 1478 // could still be returned until resetting done.
1464 if (video_file->reset_after_frame_num > 0) 1479 if (video_file->reset_after_frame_num > 0)
1465 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); 1480 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames);
1466 else 1481 // In ResetBeforeNotifyFlushDone case the decoded frames may be less than
1482 // the video frames because decoder is reset before flush done.
1483 else if (video_file->reset_after_frame_num !=
Pawel Osciak 2017/02/24 07:49:41 Would it perhaps be possible to improve both check
johnylin1 2017/03/01 07:17:09 Done.
1484 RESET_BEFORE_NOTIFY_FLUSH_DONE)
1467 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); 1485 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames);
1468 } 1486 }
1469 if (reset_point == END_OF_STREAM_RESET) { 1487 if (reset_point == END_OF_STREAM_RESET) {
1470 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + 1488 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() +
1471 client->num_queued_fragments()); 1489 client->num_queued_fragments());
1472 EXPECT_EQ(client->num_done_bitstream_buffers(), 1490 EXPECT_EQ(client->num_done_bitstream_buffers(),
1473 client->num_queued_fragments()); 1491 client->num_queued_fragments());
1474 } 1492 }
1475 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); 1493 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second();
1476 if (!render_as_thumbnails) { 1494 if (!render_as_thumbnails) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 ResetAfterFirstConfigInfo, 1577 ResetAfterFirstConfigInfo,
1560 VideoDecodeAcceleratorParamTest, 1578 VideoDecodeAcceleratorParamTest,
1561 ::testing::Values(std::make_tuple(1, 1579 ::testing::Values(std::make_tuple(1,
1562 1, 1580 1,
1563 1, 1581 1,
1564 RESET_AFTER_FIRST_CONFIG_INFO, 1582 RESET_AFTER_FIRST_CONFIG_INFO,
1565 CS_RESET, 1583 CS_RESET,
1566 false, 1584 false,
1567 false))); 1585 false)));
1568 1586
1587 // Test Reset() immediately after Flush() and before NotifyFlushDone().
1588 INSTANTIATE_TEST_CASE_P(
1589 ResetBeforeNotifyFlushDone,
1590 VideoDecodeAcceleratorParamTest,
1591 ::testing::Values(std::make_tuple(1,
1592 1,
1593 1,
1594 RESET_BEFORE_NOTIFY_FLUSH_DONE,
1595 CS_RESET,
1596 false,
1597 false)));
1598
1569 // Test that Reset() mid-stream works fine and doesn't affect decoding even when 1599 // Test that Reset() mid-stream works fine and doesn't affect decoding even when
1570 // Decode() calls are made during the reset. 1600 // Decode() calls are made during the reset.
1571 INSTANTIATE_TEST_CASE_P( 1601 INSTANTIATE_TEST_CASE_P(
1572 MidStreamReset, 1602 MidStreamReset,
1573 VideoDecodeAcceleratorParamTest, 1603 VideoDecodeAcceleratorParamTest,
1574 ::testing::Values( 1604 ::testing::Values(
1575 std::make_tuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); 1605 std::make_tuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false)));
1576 1606
1577 INSTANTIATE_TEST_CASE_P( 1607 INSTANTIATE_TEST_CASE_P(
1578 SlowRendering, 1608 SlowRendering,
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 continue; 1879 continue;
1850 } 1880 }
1851 } 1881 }
1852 1882
1853 base::ShadowingAtExitManager at_exit_manager; 1883 base::ShadowingAtExitManager at_exit_manager;
1854 1884
1855 return base::LaunchUnitTestsSerially( 1885 return base::LaunchUnitTestsSerially(
1856 argc, argv, 1886 argc, argv,
1857 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); 1887 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1858 } 1888 }
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