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

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

Issue 2506363002: vda_unittest: Add a new test case to verify the visible size. (Closed)
Patch Set: Created 4 years, 1 month 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 int height; 175 int height;
176 int num_frames; 176 int num_frames;
177 int num_fragments; 177 int num_fragments;
178 int min_fps_render; 178 int min_fps_render;
179 int min_fps_no_render; 179 int min_fps_no_render;
180 VideoCodecProfile profile; 180 VideoCodecProfile profile;
181 int reset_after_frame_num; 181 int reset_after_frame_num;
182 std::string data_str; 182 std::string data_str;
183 }; 183 };
184 184
185 struct VisibleRectEntry {
Pawel Osciak 2016/11/17 07:50:01 Please add a short sentence describing what this i
186 gfx::Rect rect;
187 int count;
188 VisibleRectEntry(const gfx::Rect rect, int count)
Pawel Osciak 2016/11/17 07:50:01 const&
189 : rect(rect), count(count) {}
190 };
191
185 const gfx::Size kThumbnailsPageSize(1600, 1200); 192 const gfx::Size kThumbnailsPageSize(1600, 1200);
186 const gfx::Size kThumbnailSize(160, 120); 193 const gfx::Size kThumbnailSize(160, 120);
187 const int kMD5StringLength = 32; 194 const int kMD5StringLength = 32;
188 195
189 // Read in golden MD5s for the thumbnailed rendering of this video 196 // Read in golden MD5s for the thumbnailed rendering of this video
190 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 197 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
191 std::vector<std::string>* md5_strings) { 198 std::vector<std::string>* md5_strings) {
192 base::FilePath filepath(video_file->file_name); 199 base::FilePath filepath(video_file->file_name);
193 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 200 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
194 std::string all_md5s; 201 std::string all_md5s;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 void OutputFrameDeliveryTimes(base::File* output); 451 void OutputFrameDeliveryTimes(base::File* output);
445 452
446 // Simple getters for inspecting the state of the Client. 453 // Simple getters for inspecting the state of the Client.
447 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } 454 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; }
448 int num_skipped_fragments() { return num_skipped_fragments_; } 455 int num_skipped_fragments() { return num_skipped_fragments_; }
449 int num_queued_fragments() { return num_queued_fragments_; } 456 int num_queued_fragments() { return num_queued_fragments_; }
450 int num_decoded_frames() { return num_decoded_frames_; } 457 int num_decoded_frames() { return num_decoded_frames_; }
451 double frames_per_second(); 458 double frames_per_second();
452 // Return the median of the decode time of all decoded frames. 459 // Return the median of the decode time of all decoded frames.
453 base::TimeDelta decode_time_median(); 460 base::TimeDelta decode_time_median();
461 const std::vector<VisibleRectEntry>& visible_rects() {
462 return visible_rects_;
463 }
454 bool decoder_deleted() { return !decoder_.get(); } 464 bool decoder_deleted() { return !decoder_.get(); }
455 465
456 private: 466 private:
457 typedef std::map<int32_t, scoped_refptr<TextureRef>> TextureRefMap; 467 typedef std::map<int32_t, scoped_refptr<TextureRef>> TextureRefMap;
458 468
459 void SetState(ClientState new_state); 469 void SetState(ClientState new_state);
460 void FinishInitialization(); 470 void FinishInitialization();
461 void ReturnPicture(int32_t picture_buffer_id); 471 void ReturnPicture(int32_t picture_buffer_id);
462 472
463 // Delete the associated decoder helper. 473 // Delete the associated decoder helper.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 int fake_decoder_; 515 int fake_decoder_;
506 GLenum texture_target_; 516 GLenum texture_target_;
507 VideoPixelFormat pixel_format_; 517 VideoPixelFormat pixel_format_;
508 bool suppress_rendering_; 518 bool suppress_rendering_;
509 std::vector<base::TimeTicks> frame_delivery_times_; 519 std::vector<base::TimeTicks> frame_delivery_times_;
510 int delay_reuse_after_frame_num_; 520 int delay_reuse_after_frame_num_;
511 // A map from bitstream buffer id to the decode start time of the buffer. 521 // A map from bitstream buffer id to the decode start time of the buffer.
512 std::map<int, base::TimeTicks> decode_start_time_; 522 std::map<int, base::TimeTicks> decode_start_time_;
513 // The decode time of all decoded frames. 523 // The decode time of all decoded frames.
514 std::vector<base::TimeDelta> decode_time_; 524 std::vector<base::TimeDelta> decode_time_;
525 // The visible rectangles of the picture returned from PictureReady().
526 std::vector<VisibleRectEntry> visible_rects_;
515 // The number of VDA::Decode calls per second. This is to simulate webrtc. 527 // The number of VDA::Decode calls per second. This is to simulate webrtc.
516 int decode_calls_per_second_; 528 int decode_calls_per_second_;
517 bool render_as_thumbnails_; 529 bool render_as_thumbnails_;
518 530
519 // A map of the textures that are currently active for the decoder, i.e., 531 // A map of the textures that are currently active for the decoder, i.e.,
520 // have been created via AssignPictureBuffers() and not dismissed via 532 // have been created via AssignPictureBuffers() and not dismissed via
521 // DismissPictureBuffer(). The keys in the map are the IDs of the 533 // DismissPictureBuffer(). The keys in the map are the IDs of the
522 // corresponding picture buffers, and the values are TextureRefs to the 534 // corresponding picture buffers, and the values are TextureRefs to the
523 // textures. 535 // textures.
524 TextureRefMap active_textures_; 536 TextureRefMap active_textures_;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 // We shouldn't be getting pictures delivered after Reset has completed. 735 // We shouldn't be getting pictures delivered after Reset has completed.
724 LOG_ASSERT(state_ < CS_RESET); 736 LOG_ASSERT(state_ < CS_RESET);
725 737
726 if (decoder_deleted()) 738 if (decoder_deleted())
727 return; 739 return;
728 740
729 base::TimeTicks now = base::TimeTicks::Now(); 741 base::TimeTicks now = base::TimeTicks::Now();
730 742
731 frame_delivery_times_.push_back(now); 743 frame_delivery_times_.push_back(now);
732 744
745 if (visible_rects_.empty() ||
746 visible_rects_.back().rect != picture.visible_rect()) {
747 visible_rects_.push_back(VisibleRectEntry(picture.visible_rect(), 1));
Pawel Osciak 2016/11/17 07:50:01 Perhaps just have count=1 as default when construc
748 } else {
749 ++visible_rects_.back().count;
750 }
751
733 // Save the decode time of this picture. 752 // Save the decode time of this picture.
734 std::map<int, base::TimeTicks>::iterator it = 753 std::map<int, base::TimeTicks>::iterator it =
735 decode_start_time_.find(picture.bitstream_buffer_id()); 754 decode_start_time_.find(picture.bitstream_buffer_id());
736 ASSERT_NE(decode_start_time_.end(), it); 755 ASSERT_NE(decode_start_time_.end(), it);
737 decode_time_.push_back(now - it->second); 756 decode_time_.push_back(now - it->second);
738 decode_start_time_.erase(it); 757 decode_start_time_.erase(it);
739 758
740 LOG_ASSERT(picture.bitstream_buffer_id() <= next_bitstream_buffer_id_); 759 LOG_ASSERT(picture.bitstream_buffer_id() <= next_bitstream_buffer_id_);
741 ++num_decoded_frames_; 760 ++num_decoded_frames_;
742 761
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 LOG(INFO) << output_string; 1720 LOG(INFO) << output_string;
1702 1721
1703 if (g_output_log != NULL) 1722 if (g_output_log != NULL)
1704 OutputLogFile(g_output_log, output_string); 1723 OutputLogFile(g_output_log, output_string);
1705 1724
1706 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client); 1725 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client);
1707 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); 1726 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note);
1708 WaitUntilIdle(); 1727 WaitUntilIdle();
1709 }; 1728 };
1710 1729
1730 // This test Logs the visible rectangles of the picture returned from
Pawel Osciak 2016/11/17 07:50:01 s/Logs/verifies/
1731 // PictureReady().
1732 TEST_F(VideoDecodeAcceleratorTest, TestVisibleRect) {
1733 RenderingHelperParams helper_params;
1734
1735 // Disable rendering by setting the rendering_fps = 0.
1736 helper_params.rendering_fps = 0;
1737 helper_params.warm_up_iterations = 0;
1738 helper_params.render_as_thumbnails = false;
1739
1740 ClientStateNotification<ClientState>* note =
1741 new ClientStateNotification<ClientState>();
1742 GLRenderingVDAClient* client = new GLRenderingVDAClient(
1743 0, &rendering_helper_, note, test_video_files_[0]->data_str, 1, 1,
1744 test_video_files_[0]->reset_after_frame_num, CS_RESET,
1745 test_video_files_[0]->width, test_video_files_[0]->height,
1746 test_video_files_[0]->profile, g_fake_decoder, true,
1747 std::numeric_limits<int>::max(), 0, false /* render_as_thumbnail */);
1748 helper_params.window_sizes.push_back(
1749 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height));
1750 InitializeRenderingHelper(helper_params);
1751 CreateAndStartDecoder(client, note);
Pawel Osciak 2016/11/17 07:50:01 I wonder if we need an additional test case just f
wuchengli 2016/11/17 08:23:41 Adding a test case has a benefits that it's clear
Pawel Osciak 2016/11/17 08:40:31 Yes, but I believe making the test run longer outw
1752 WaitUntilDecodeFinish(note);
1753
1754 for (const auto& entry : client->visible_rects()) {
1755 const auto& r = entry.rect;
1756 std::string output_string =
1757 base::StringPrintf("(%d, %d, %d, %d) %d", r.x(), r.y(), r.width(),
kcwu 2016/11/17 07:54:51 How about LOG(INFO) << entry.rect << " " << entry
1758 r.height(), entry.count);
1759 LOG(INFO) << output_string;
Pawel Osciak 2016/11/17 07:50:01 Perhaps just DVLOG?
1760 }
1761
1762 // Resolution change video is not supported yet. Simply verify there is
1763 // only one resolution and it matches to the expected visible rect.
1764 ASSERT_EQ(1U, client->visible_rects().size());
1765 gfx::Rect expected_rect(test_video_files_[0]->width,
1766 test_video_files_[0]->height);
1767 const auto& entry = client->visible_rects().front();
1768 ASSERT_TRUE(entry.rect.IsEmpty() || (entry.rect == expected_rect));
Pawel Osciak 2016/11/17 07:50:01 I think we could just EXPECT?
kcwu 2016/11/17 07:54:51 EXPECT_TRUE
1769 ASSERT_EQ(test_video_files_[0]->num_frames, entry.count);
kcwu 2016/11/17 07:54:51 EXPECT_EQ
1770
1771 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client);
1772 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note);
1773 WaitUntilIdle();
1774 };
1775
1711 // TODO(fischman, vrk): add more tests! In particular: 1776 // TODO(fischman, vrk): add more tests! In particular:
1712 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. 1777 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder.
1713 // - Test alternate configurations 1778 // - Test alternate configurations
1714 // - Test failure conditions. 1779 // - Test failure conditions.
1715 // - Test frame size changes mid-stream 1780 // - Test frame size changes mid-stream
1716 1781
1717 } // namespace 1782 } // namespace
1718 } // namespace media 1783 } // namespace media
1719 1784
1720 int main(int argc, char** argv) { 1785 int main(int argc, char** argv) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); 1869 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
1805 #endif 1870 #endif
1806 1871
1807 media::g_env = 1872 media::g_env =
1808 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1873 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1809 testing::AddGlobalTestEnvironment( 1874 testing::AddGlobalTestEnvironment(
1810 new media::VideoDecodeAcceleratorTestEnvironment())); 1875 new media::VideoDecodeAcceleratorTestEnvironment()));
1811 1876
1812 return RUN_ALL_TESTS(); 1877 return RUN_ALL_TESTS();
1813 } 1878 }
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