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

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

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 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
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 28 matching lines...) Expand all
39 #include "base/strings/string_split.h" 39 #include "base/strings/string_split.h"
40 #include "base/strings/stringize_macros.h" 40 #include "base/strings/stringize_macros.h"
41 #include "base/strings/stringprintf.h" 41 #include "base/strings/stringprintf.h"
42 #include "base/strings/utf_string_conversions.h" 42 #include "base/strings/utf_string_conversions.h"
43 #include "base/synchronization/condition_variable.h" 43 #include "base/synchronization/condition_variable.h"
44 #include "base/synchronization/lock.h" 44 #include "base/synchronization/lock.h"
45 #include "base/synchronization/waitable_event.h" 45 #include "base/synchronization/waitable_event.h"
46 #include "base/thread_task_runner_handle.h" 46 #include "base/thread_task_runner_handle.h"
47 #include "base/threading/thread.h" 47 #include "base/threading/thread.h"
48 #include "build/build_config.h" 48 #include "build/build_config.h"
49 #include "content/common/gpu/media/fake_video_decode_accelerator.h"
50 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h"
51 #include "content/common/gpu/media/rendering_helper.h"
52 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
53 #include "gpu/command_buffer/service/gpu_preferences.h" 49 #include "gpu/command_buffer/service/gpu_preferences.h"
54 #include "media/filters/h264_parser.h" 50 #include "media/filters/h264_parser.h"
51 #include "media/gpu/fake_video_decode_accelerator.h"
52 #include "media/gpu/ipc/service/gpu_video_decode_accelerator_factory_impl.h"
53 #include "media/gpu/rendering_helper.h"
54 #include "media/gpu/video_accelerator_unittest_helpers.h"
55 #include "testing/gtest/include/gtest/gtest.h" 55 #include "testing/gtest/include/gtest/gtest.h"
56 #include "ui/gfx/codec/png_codec.h" 56 #include "ui/gfx/codec/png_codec.h"
57 #include "ui/gl/gl_image.h" 57 #include "ui/gl/gl_image.h"
58 58
59 #if defined(OS_WIN) 59 #if defined(OS_WIN)
60 #include "base/win/windows_version.h" 60 #include "base/win/windows_version.h"
61 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" 61 #include "media/gpu/dxva_video_decode_accelerator_win.h"
62 #elif defined(OS_CHROMEOS) 62 #elif defined(OS_CHROMEOS)
63 #if defined(USE_V4L2_CODEC) 63 #if defined(USE_V4L2_CODEC)
64 #include "content/common/gpu/media/v4l2_device.h" 64 #include "media/gpu/v4l2_device.h"
65 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" 65 #include "media/gpu/v4l2_slice_video_decode_accelerator.h"
66 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" 66 #include "media/gpu/v4l2_video_decode_accelerator.h"
67 #endif 67 #endif
68 #if defined(ARCH_CPU_X86_FAMILY) 68 #if defined(ARCH_CPU_X86_FAMILY)
69 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 69 #include "media/gpu/vaapi_video_decode_accelerator.h"
70 #include "content/common/gpu/media/vaapi_wrapper.h" 70 #include "media/gpu/vaapi_wrapper.h"
71 #endif // defined(ARCH_CPU_X86_FAMILY) 71 #endif // defined(ARCH_CPU_X86_FAMILY)
72 #else 72 #else
73 #error The VideoAccelerator tests are not supported on this platform. 73 #error The VideoAccelerator tests are not supported on this platform.
74 #endif // OS_WIN 74 #endif // OS_WIN
75 75
76 #if defined(USE_OZONE) 76 #if defined(USE_OZONE)
77 #include "ui/ozone/public/ozone_gpu_test_helper.h" 77 #include "ui/ozone/public/ozone_gpu_test_helper.h"
78 #include "ui/ozone/public/ozone_platform.h" 78 #include "ui/ozone/public/ozone_platform.h"
79 #endif // defined(USE_OZONE) 79 #endif // defined(USE_OZONE)
80 80
81 using media::VideoDecodeAccelerator; 81 using media::VideoDecodeAccelerator;
82 82
83 namespace content { 83 namespace media {
84 namespace { 84 namespace {
85 85
86 using base::MakeTuple; 86 using base::MakeTuple;
87 87
88 // Values optionally filled in from flags; see main() below. 88 // Values optionally filled in from flags; see main() below.
89 // The syntax of multiple test videos is: 89 // The syntax of multiple test videos is:
90 // test-video1;test-video2;test-video3 90 // test-video1;test-video2;test-video3
91 // where only the first video is required and other optional videos would be 91 // where only the first video is required and other optional videos would be
92 // decoded by concurrent decoders. 92 // decoded by concurrent decoders.
93 // The syntax of each test-video is: 93 // The syntax of each test-video is:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 struct TestVideoFile { 151 struct TestVideoFile {
152 explicit TestVideoFile(base::FilePath::StringType file_name) 152 explicit TestVideoFile(base::FilePath::StringType file_name)
153 : file_name(file_name), 153 : file_name(file_name),
154 width(-1), 154 width(-1),
155 height(-1), 155 height(-1),
156 num_frames(-1), 156 num_frames(-1),
157 num_fragments(-1), 157 num_fragments(-1),
158 min_fps_render(-1), 158 min_fps_render(-1),
159 min_fps_no_render(-1), 159 min_fps_no_render(-1),
160 profile(media::VIDEO_CODEC_PROFILE_UNKNOWN), 160 profile(media::VIDEO_CODEC_PROFILE_UNKNOWN),
161 reset_after_frame_num(END_OF_STREAM_RESET) { 161 reset_after_frame_num(END_OF_STREAM_RESET) {}
162 }
163 162
164 base::FilePath::StringType file_name; 163 base::FilePath::StringType file_name;
165 int width; 164 int width;
166 int height; 165 int height;
167 int num_frames; 166 int num_frames;
168 int num_fragments; 167 int num_fragments;
169 int min_fps_render; 168 int min_fps_render;
170 int min_fps_no_render; 169 int min_fps_no_render;
171 media::VideoCodecProfile profile; 170 media::VideoCodecProfile profile;
172 int reset_after_frame_num; 171 int reset_after_frame_num;
173 std::string data_str; 172 std::string data_str;
174 }; 173 };
175 174
176 const gfx::Size kThumbnailsPageSize(1600, 1200); 175 const gfx::Size kThumbnailsPageSize(1600, 1200);
177 const gfx::Size kThumbnailSize(160, 120); 176 const gfx::Size kThumbnailSize(160, 120);
178 const int kMD5StringLength = 32; 177 const int kMD5StringLength = 32;
179 178
180 // Read in golden MD5s for the thumbnailed rendering of this video 179 // Read in golden MD5s for the thumbnailed rendering of this video
181 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 180 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
182 std::vector<std::string>* md5_strings) { 181 std::vector<std::string>* md5_strings) {
183 base::FilePath filepath(video_file->file_name); 182 base::FilePath filepath(video_file->file_name);
184 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 183 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
185 std::string all_md5s; 184 std::string all_md5s;
186 base::ReadFileToString(filepath, &all_md5s); 185 base::ReadFileToString(filepath, &all_md5s);
187 *md5_strings = base::SplitString( 186 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE,
188 all_md5s, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 187 base::SPLIT_WANT_ALL);
189 // Check these are legitimate MD5s. 188 // Check these are legitimate MD5s.
190 for (const std::string& md5_string : *md5_strings) { 189 for (const std::string& md5_string : *md5_strings) {
191 // Ignore the empty string added by SplitString 190 // Ignore the empty string added by SplitString
192 if (!md5_string.length()) 191 if (!md5_string.length())
193 continue; 192 continue;
194 // Ignore comments 193 // Ignore comments
195 if (md5_string.at(0) == '#') 194 if (md5_string.at(0) == '#')
196 continue; 195 continue;
197 196
198 LOG_ASSERT(static_cast<int>(md5_string.length()) == 197 LOG_ASSERT(static_cast<int>(md5_string.length()) == kMD5StringLength)
199 kMD5StringLength) << md5_string; 198 << md5_string;
200 bool hex_only = std::count_if(md5_string.begin(), 199 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(),
201 md5_string.end(), isxdigit) == 200 isxdigit) == kMD5StringLength;
202 kMD5StringLength; 201 LOG_ASSERT(hex_only) << md5_string;
203 LOG_ASSERT(hex_only) << md5_string;
204 } 202 }
205 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" 203 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file ("
206 << filepath.MaybeAsASCII() 204 << filepath.MaybeAsASCII()
207 << ") missing or empty."; 205 << ") missing or empty.";
208 } 206 }
209 207
210 // State of the GLRenderingVDAClient below. Order matters here as the test 208 // State of the GLRenderingVDAClient below. Order matters here as the test
211 // makes assumptions about it. 209 // makes assumptions about it.
212 enum ClientState { 210 enum ClientState {
213 CS_CREATED = 0, 211 CS_CREATED = 0,
214 CS_DECODER_SET = 1, 212 CS_DECODER_SET = 1,
215 CS_INITIALIZED = 2, 213 CS_INITIALIZED = 2,
216 CS_FLUSHING = 3, 214 CS_FLUSHING = 3,
217 CS_FLUSHED = 4, 215 CS_FLUSHED = 4,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 368
371 // Compute & return the first encoded bytes (including a start frame) to send 369 // Compute & return the first encoded bytes (including a start frame) to send
372 // to the decoder, starting at |start_pos| and returning one fragment. Skips 370 // to the decoder, starting at |start_pos| and returning one fragment. Skips
373 // to the first decodable position. 371 // to the first decodable position.
374 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); 372 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos);
375 // Compute & return the encoded bytes of next fragment to send to the decoder 373 // Compute & return the encoded bytes of next fragment to send to the decoder
376 // (based on |start_pos|). 374 // (based on |start_pos|).
377 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos); 375 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos);
378 // Helpers for GetBytesForNextFragment above. 376 // Helpers for GetBytesForNextFragment above.
379 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264. 377 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264.
380 std::string GetBytesForNextFrame( 378 std::string GetBytesForNextFrame(size_t start_pos,
381 size_t start_pos, size_t* end_pos); // For VP8/9. 379 size_t* end_pos); // For VP8/9.
382 380
383 // Request decode of the next fragment in the encoded data. 381 // Request decode of the next fragment in the encoded data.
384 void DecodeNextFragment(); 382 void DecodeNextFragment();
385 383
386 size_t window_id_; 384 size_t window_id_;
387 RenderingHelper* rendering_helper_; 385 RenderingHelper* rendering_helper_;
388 gfx::Size frame_size_; 386 gfx::Size frame_size_;
389 std::string encoded_data_; 387 std::string encoded_data_;
390 const int num_in_flight_decodes_; 388 const int num_in_flight_decodes_;
391 int outstanding_decodes_; 389 int outstanding_decodes_;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return; 551 return;
554 LOG_ASSERT(textures_per_buffer == 1u); 552 LOG_ASSERT(textures_per_buffer == 1u);
555 std::vector<media::PictureBuffer> buffers; 553 std::vector<media::PictureBuffer> buffers;
556 554
557 requested_num_of_buffers += kExtraPictureBuffers; 555 requested_num_of_buffers += kExtraPictureBuffers;
558 556
559 texture_target_ = texture_target; 557 texture_target_ = texture_target;
560 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { 558 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) {
561 uint32_t texture_id; 559 uint32_t texture_id;
562 base::WaitableEvent done(false, false); 560 base::WaitableEvent done(false, false);
563 rendering_helper_->CreateTexture( 561 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions,
564 texture_target_, &texture_id, dimensions, &done); 562 &done);
565 done.Wait(); 563 done.Wait();
566 564
567 int32_t picture_buffer_id = next_picture_buffer_id_++; 565 int32_t picture_buffer_id = next_picture_buffer_id_++;
568 LOG_ASSERT(active_textures_ 566 LOG_ASSERT(
569 .insert(std::make_pair( 567 active_textures_
570 picture_buffer_id, 568 .insert(std::make_pair(
571 new TextureRef(texture_id, 569 picture_buffer_id,
572 base::Bind(&RenderingHelper::DeleteTexture, 570 new TextureRef(texture_id,
573 base::Unretained(rendering_helper_), 571 base::Bind(&RenderingHelper::DeleteTexture,
574 texture_id)))) 572 base::Unretained(rendering_helper_),
575 .second); 573 texture_id))))
574 .second);
576 575
577 media::PictureBuffer::TextureIds ids; 576 media::PictureBuffer::TextureIds ids;
578 ids.push_back(texture_id); 577 ids.push_back(texture_id);
579 buffers.push_back(media::PictureBuffer(picture_buffer_id, dimensions, ids)); 578 buffers.push_back(media::PictureBuffer(picture_buffer_id, dimensions, ids));
580 } 579 }
581 decoder_->AssignPictureBuffers(buffers); 580 decoder_->AssignPictureBuffers(buffers);
582 } 581 }
583 582
584 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) { 583 void GLRenderingVDAClient::DismissPictureBuffer(int32_t picture_buffer_id) {
585 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id)); 584 LOG_ASSERT(1U == active_textures_.erase(picture_buffer_id));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { 723 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
725 SetState(CS_ERROR); 724 SetState(CS_ERROR);
726 } 725 }
727 726
728 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { 727 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) {
729 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", 728 std::string s = base::StringPrintf("frame count: %" PRIuS "\n",
730 frame_delivery_times_.size()); 729 frame_delivery_times_.size());
731 output->WriteAtCurrentPos(s.data(), s.length()); 730 output->WriteAtCurrentPos(s.data(), s.length());
732 base::TimeTicks t0 = initialize_done_ticks_; 731 base::TimeTicks t0 = initialize_done_ticks_;
733 for (size_t i = 0; i < frame_delivery_times_.size(); ++i) { 732 for (size_t i = 0; i < frame_delivery_times_.size(); ++i) {
734 s = base::StringPrintf("frame %04" PRIuS ": %" PRId64 " us\n", 733 s = base::StringPrintf("frame %04" PRIuS ": %" PRId64 " us\n", i,
735 i,
736 (frame_delivery_times_[i] - t0).InMicroseconds()); 734 (frame_delivery_times_[i] - t0).InMicroseconds());
737 t0 = frame_delivery_times_[i]; 735 t0 = frame_delivery_times_[i];
738 output->WriteAtCurrentPos(s.data(), s.length()); 736 output->WriteAtCurrentPos(s.data(), s.length());
739 } 737 }
740 } 738 }
741 739
742 static bool LookingAtNAL(const std::string& encoded, size_t pos) { 740 static bool LookingAtNAL(const std::string& encoded, size_t pos) {
743 return encoded[pos] == 0 && encoded[pos + 1] == 0 && 741 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 &&
744 encoded[pos + 2] == 0 && encoded[pos + 3] == 1; 742 encoded[pos + 3] == 1;
745 } 743 }
746 744
747 void GLRenderingVDAClient::SetState(ClientState new_state) { 745 void GLRenderingVDAClient::SetState(ClientState new_state) {
748 note_->Notify(new_state); 746 note_->Notify(new_state);
749 state_ = new_state; 747 state_ = new_state;
750 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { 748 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) {
751 LOG_ASSERT(!decoder_deleted()); 749 LOG_ASSERT(!decoder_deleted());
752 DeleteDecoder(); 750 DeleteDecoder();
753 } 751 }
754 } 752 }
(...skipping 19 matching lines...) Expand all
774 weak_vda_ptr_factory_.reset(); 772 weak_vda_ptr_factory_.reset();
775 decoder_.reset(); 773 decoder_.reset();
776 STLClearObject(&encoded_data_); 774 STLClearObject(&encoded_data_);
777 active_textures_.clear(); 775 active_textures_.clear();
778 776
779 // Cascade through the rest of the states to simplify test code below. 777 // Cascade through the rest of the states to simplify test code below.
780 for (int i = state_ + 1; i < CS_MAX; ++i) 778 for (int i = state_ + 1; i < CS_MAX; ++i)
781 SetState(static_cast<ClientState>(i)); 779 SetState(static_cast<ClientState>(i));
782 } 780 }
783 781
784 std::string GLRenderingVDAClient::GetBytesForFirstFragment( 782 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos,
785 size_t start_pos, size_t* end_pos) { 783 size_t* end_pos) {
786 if (profile_ < media::H264PROFILE_MAX) { 784 if (profile_ < media::H264PROFILE_MAX) {
787 *end_pos = start_pos; 785 *end_pos = start_pos;
788 while (*end_pos + 4 < encoded_data_.size()) { 786 while (*end_pos + 4 < encoded_data_.size()) {
789 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame 787 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame
790 return GetBytesForNextFragment(*end_pos, end_pos); 788 return GetBytesForNextFragment(*end_pos, end_pos);
791 GetBytesForNextNALU(*end_pos, end_pos); 789 GetBytesForNextNALU(*end_pos, end_pos);
792 num_skipped_fragments_++; 790 num_skipped_fragments_++;
793 } 791 }
794 *end_pos = start_pos; 792 *end_pos = start_pos;
795 return std::string(); 793 return std::string();
796 } 794 }
797 DCHECK_LE(profile_, media::VP9PROFILE_MAX); 795 DCHECK_LE(profile_, media::VP9PROFILE_MAX);
798 return GetBytesForNextFragment(start_pos, end_pos); 796 return GetBytesForNextFragment(start_pos, end_pos);
799 } 797 }
800 798
801 std::string GLRenderingVDAClient::GetBytesForNextFragment( 799 std::string GLRenderingVDAClient::GetBytesForNextFragment(size_t start_pos,
802 size_t start_pos, size_t* end_pos) { 800 size_t* end_pos) {
803 if (profile_ < media::H264PROFILE_MAX) { 801 if (profile_ < media::H264PROFILE_MAX) {
804 *end_pos = start_pos; 802 *end_pos = start_pos;
805 GetBytesForNextNALU(*end_pos, end_pos); 803 GetBytesForNextNALU(*end_pos, end_pos);
806 if (start_pos != *end_pos) { 804 if (start_pos != *end_pos) {
807 num_queued_fragments_++; 805 num_queued_fragments_++;
808 } 806 }
809 return encoded_data_.substr(start_pos, *end_pos - start_pos); 807 return encoded_data_.substr(start_pos, *end_pos - start_pos);
810 } 808 }
811 DCHECK_LE(profile_, media::VP9PROFILE_MAX); 809 DCHECK_LE(profile_, media::VP9PROFILE_MAX);
812 return GetBytesForNextFrame(start_pos, end_pos); 810 return GetBytesForNextFrame(start_pos, end_pos);
813 } 811 }
814 812
815 void GLRenderingVDAClient::GetBytesForNextNALU( 813 void GLRenderingVDAClient::GetBytesForNextNALU(size_t start_pos,
816 size_t start_pos, size_t* end_pos) { 814 size_t* end_pos) {
817 *end_pos = start_pos; 815 *end_pos = start_pos;
818 if (*end_pos + 4 > encoded_data_.size()) 816 if (*end_pos + 4 > encoded_data_.size())
819 return; 817 return;
820 LOG_ASSERT(LookingAtNAL(encoded_data_, start_pos)); 818 LOG_ASSERT(LookingAtNAL(encoded_data_, start_pos));
821 *end_pos += 4; 819 *end_pos += 4;
822 while (*end_pos + 4 <= encoded_data_.size() && 820 while (*end_pos + 4 <= encoded_data_.size() &&
823 !LookingAtNAL(encoded_data_, *end_pos)) { 821 !LookingAtNAL(encoded_data_, *end_pos)) {
824 ++*end_pos; 822 ++*end_pos;
825 } 823 }
826 if (*end_pos + 3 >= encoded_data_.size()) 824 if (*end_pos + 3 >= encoded_data_.size())
827 *end_pos = encoded_data_.size(); 825 *end_pos = encoded_data_.size();
828 } 826 }
829 827
830 std::string GLRenderingVDAClient::GetBytesForNextFrame( 828 std::string GLRenderingVDAClient::GetBytesForNextFrame(size_t start_pos,
831 size_t start_pos, size_t* end_pos) { 829 size_t* end_pos) {
832 // Helpful description: http://wiki.multimedia.cx/index.php?title=IVF 830 // Helpful description: http://wiki.multimedia.cx/index.php?title=IVF
833 std::string bytes; 831 std::string bytes;
834 if (start_pos == 0) 832 if (start_pos == 0)
835 start_pos = 32; // Skip IVF header. 833 start_pos = 32; // Skip IVF header.
836 *end_pos = start_pos; 834 *end_pos = start_pos;
837 uint32_t frame_size = *reinterpret_cast<uint32_t*>(&encoded_data_[*end_pos]); 835 uint32_t frame_size = *reinterpret_cast<uint32_t*>(&encoded_data_[*end_pos]);
838 *end_pos += 12; // Skip frame header. 836 *end_pos += 12; // Skip frame header.
839 bytes.append(encoded_data_.substr(*end_pos, frame_size)); 837 bytes.append(encoded_data_.substr(*end_pos, frame_size));
840 *end_pos += frame_size; 838 *end_pos += frame_size;
841 num_queued_fragments_++; 839 num_queued_fragments_++;
842 return bytes; 840 return bytes;
843 } 841 }
844 842
845 static bool FragmentHasConfigInfo(const uint8_t* data, 843 static bool FragmentHasConfigInfo(const uint8_t* data,
846 size_t size, 844 size_t size,
847 media::VideoCodecProfile profile) { 845 media::VideoCodecProfile profile) {
848 if (profile >= media::H264PROFILE_MIN && 846 if (profile >= media::H264PROFILE_MIN && profile <= media::H264PROFILE_MAX) {
849 profile <= media::H264PROFILE_MAX) {
850 media::H264Parser parser; 847 media::H264Parser parser;
851 parser.SetStream(data, size); 848 parser.SetStream(data, size);
852 media::H264NALU nalu; 849 media::H264NALU nalu;
853 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu); 850 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu);
854 if (result != media::H264Parser::kOk) { 851 if (result != media::H264Parser::kOk) {
855 // Let the VDA figure out there's something wrong with the stream. 852 // Let the VDA figure out there's something wrong with the stream.
856 return false; 853 return false;
857 } 854 }
858 855
859 return nalu.nal_unit_type == media::H264NALU::kSPS; 856 return nalu.nal_unit_type == media::H264NALU::kSPS;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 if (reset_here) 889 if (reset_here)
893 reset_after_frame_num_ = END_OF_STREAM_RESET; 890 reset_after_frame_num_ = END_OF_STREAM_RESET;
894 } 891 }
895 892
896 // Populate the shared memory buffer w/ the fragment, duplicate its handle, 893 // Populate the shared memory buffer w/ the fragment, duplicate its handle,
897 // and hand it off to the decoder. 894 // and hand it off to the decoder.
898 base::SharedMemory shm; 895 base::SharedMemory shm;
899 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size)); 896 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size));
900 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); 897 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size);
901 base::SharedMemoryHandle dup_handle; 898 base::SharedMemoryHandle dup_handle;
902 bool result = shm.ShareToProcess(base::GetCurrentProcessHandle(), 899 bool result =
903 &dup_handle); 900 shm.ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle);
904 LOG_ASSERT(result); 901 LOG_ASSERT(result);
905 media::BitstreamBuffer bitstream_buffer( 902 media::BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle,
906 next_bitstream_buffer_id_, dup_handle, next_fragment_size); 903 next_fragment_size);
907 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); 904 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now();
908 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. 905 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
909 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; 906 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF;
910 decoder_->Decode(bitstream_buffer); 907 decoder_->Decode(bitstream_buffer);
911 ++outstanding_decodes_; 908 ++outstanding_decodes_;
912 if (!remaining_play_throughs_ && 909 if (!remaining_play_throughs_ &&
913 -delete_decoder_state_ == next_bitstream_buffer_id_) { 910 -delete_decoder_state_ == next_bitstream_buffer_id_) {
914 DeleteDecoder(); 911 DeleteDecoder();
915 } 912 }
916 913
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 952
956 // Parse |data| into its constituent parts, set the various output fields 953 // Parse |data| into its constituent parts, set the various output fields
957 // accordingly, and read in video stream. CHECK-fails on unexpected or 954 // accordingly, and read in video stream. CHECK-fails on unexpected or
958 // missing required data. Unspecified optional fields are set to -1. 955 // missing required data. Unspecified optional fields are set to -1.
959 void ParseAndReadTestVideoData(base::FilePath::StringType data, 956 void ParseAndReadTestVideoData(base::FilePath::StringType data,
960 std::vector<TestVideoFile*>* test_video_files); 957 std::vector<TestVideoFile*>* test_video_files);
961 958
962 // Update the parameters of |test_video_files| according to 959 // Update the parameters of |test_video_files| according to
963 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of 960 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of
964 // frames should be adjusted if decoder is reset in the middle of the stream. 961 // frames should be adjusted if decoder is reset in the middle of the stream.
965 void UpdateTestVideoFileParams( 962 void UpdateTestVideoFileParams(size_t num_concurrent_decoders,
966 size_t num_concurrent_decoders, 963 int reset_point,
967 int reset_point, 964 std::vector<TestVideoFile*>* test_video_files);
968 std::vector<TestVideoFile*>* test_video_files);
969 965
970 void InitializeRenderingHelper(const RenderingHelperParams& helper_params); 966 void InitializeRenderingHelper(const RenderingHelperParams& helper_params);
971 void CreateAndStartDecoder(GLRenderingVDAClient* client, 967 void CreateAndStartDecoder(GLRenderingVDAClient* client,
972 ClientStateNotification<ClientState>* note); 968 ClientStateNotification<ClientState>* note);
973 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); 969 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note);
974 void WaitUntilIdle(); 970 void WaitUntilIdle();
975 void OutputLogFile(const base::FilePath::CharType* log_path, 971 void OutputLogFile(const base::FilePath::CharType* log_path,
976 const std::string& content); 972 const std::string& content);
977 973
978 std::vector<TestVideoFile*> test_video_files_; 974 std::vector<TestVideoFile*> test_video_files_;
979 RenderingHelper rendering_helper_; 975 RenderingHelper rendering_helper_;
980 976
981 private: 977 private:
982 // Required for Thread to work. Not used otherwise. 978 // Required for Thread to work. Not used otherwise.
983 base::ShadowingAtExitManager at_exit_manager_; 979 base::ShadowingAtExitManager at_exit_manager_;
984 980
985 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); 981 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest);
986 }; 982 };
987 983
988 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() { 984 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {}
989 }
990 985
991 void VideoDecodeAcceleratorTest::SetUp() { 986 void VideoDecodeAcceleratorTest::SetUp() {
992 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); 987 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_);
993 } 988 }
994 989
995 void VideoDecodeAcceleratorTest::TearDown() { 990 void VideoDecodeAcceleratorTest::TearDown() {
996 g_env->GetRenderingTaskRunner()->PostTask( 991 g_env->GetRenderingTaskRunner()->PostTask(
997 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>, 992 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>,
998 &test_video_files_)); 993 &test_video_files_));
999 994
1000 base::WaitableEvent done(false, false); 995 base::WaitableEvent done(false, false);
1001 g_env->GetRenderingTaskRunner()->PostTask( 996 g_env->GetRenderingTaskRunner()->PostTask(
1002 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, 997 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize,
1003 base::Unretained(&rendering_helper_), &done)); 998 base::Unretained(&rendering_helper_), &done));
1004 done.Wait(); 999 done.Wait();
1005 1000
1006 rendering_helper_.TearDown(); 1001 rendering_helper_.TearDown();
1007 } 1002 }
1008 1003
1009 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( 1004 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData(
1010 base::FilePath::StringType data, 1005 base::FilePath::StringType data,
1011 std::vector<TestVideoFile*>* test_video_files) { 1006 std::vector<TestVideoFile*>* test_video_files) {
1012 std::vector<base::FilePath::StringType> entries = base::SplitString( 1007 std::vector<base::FilePath::StringType> entries =
1013 data, base::FilePath::StringType(1, ';'), 1008 base::SplitString(data, base::FilePath::StringType(1, ';'),
1014 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1009 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
1015 LOG_ASSERT(entries.size() >= 1U) << data; 1010 LOG_ASSERT(entries.size() >= 1U) << data;
1016 for (size_t index = 0; index < entries.size(); ++index) { 1011 for (size_t index = 0; index < entries.size(); ++index) {
1017 std::vector<base::FilePath::StringType> fields = base::SplitString( 1012 std::vector<base::FilePath::StringType> fields =
1018 entries[index], base::FilePath::StringType(1, ':'), 1013 base::SplitString(entries[index], base::FilePath::StringType(1, ':'),
1019 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1014 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
1020 LOG_ASSERT(fields.size() >= 1U) << entries[index]; 1015 LOG_ASSERT(fields.size() >= 1U) << entries[index];
1021 LOG_ASSERT(fields.size() <= 8U) << entries[index]; 1016 LOG_ASSERT(fields.size() <= 8U) << entries[index];
1022 TestVideoFile* video_file = new TestVideoFile(fields[0]); 1017 TestVideoFile* video_file = new TestVideoFile(fields[0]);
1023 if (!fields[1].empty()) 1018 if (!fields[1].empty())
1024 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width)); 1019 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width));
1025 if (!fields[2].empty()) 1020 if (!fields[2].empty())
1026 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height)); 1021 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height));
1027 if (!fields[3].empty()) 1022 if (!fields[3].empty())
1028 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames)); 1023 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames));
1029 if (!fields[4].empty()) 1024 if (!fields[4].empty())
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 // instantiated. 1117 // instantiated.
1123 // - Number of concurrent in-flight Decode() calls per decoder. 1118 // - Number of concurrent in-flight Decode() calls per decoder.
1124 // - Number of play-throughs. 1119 // - Number of play-throughs.
1125 // - reset_after_frame_num: see GLRenderingVDAClient ctor. 1120 // - reset_after_frame_num: see GLRenderingVDAClient ctor.
1126 // - delete_decoder_phase: see GLRenderingVDAClient ctor. 1121 // - delete_decoder_phase: see GLRenderingVDAClient ctor.
1127 // - whether to test slow rendering by delaying ReusePictureBuffer(). 1122 // - whether to test slow rendering by delaying ReusePictureBuffer().
1128 // - whether the video frames are rendered as thumbnails. 1123 // - whether the video frames are rendered as thumbnails.
1129 class VideoDecodeAcceleratorParamTest 1124 class VideoDecodeAcceleratorParamTest
1130 : public VideoDecodeAcceleratorTest, 1125 : public VideoDecodeAcceleratorTest,
1131 public ::testing::WithParamInterface< 1126 public ::testing::WithParamInterface<
1132 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool> > { 1127 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {};
1133 };
1134 1128
1135 // Wait for |note| to report a state and if it's not |expected_state| then 1129 // Wait for |note| to report a state and if it's not |expected_state| then
1136 // assert |client| has deleted its decoder. 1130 // assert |client| has deleted its decoder.
1137 static void AssertWaitForStateOrDeleted( 1131 static void AssertWaitForStateOrDeleted(
1138 ClientStateNotification<ClientState>* note, 1132 ClientStateNotification<ClientState>* note,
1139 GLRenderingVDAClient* client, 1133 GLRenderingVDAClient* client,
1140 ClientState expected_state) { 1134 ClientState expected_state) {
1141 ClientState state = note->Wait(); 1135 ClientState state = note->Wait();
1142 if (state == expected_state) return; 1136 if (state == expected_state)
1137 return;
1143 ASSERT_TRUE(client->decoder_deleted()) 1138 ASSERT_TRUE(client->decoder_deleted())
1144 << "Decoder not deleted but Wait() returned " << state 1139 << "Decoder not deleted but Wait() returned " << state << ", instead of "
1145 << ", instead of " << expected_state; 1140 << expected_state;
1146 } 1141 }
1147 1142
1148 // We assert a minimal number of concurrent decoders we expect to succeed. 1143 // We assert a minimal number of concurrent decoders we expect to succeed.
1149 // Different platforms can support more concurrent decoders, so we don't assert 1144 // Different platforms can support more concurrent decoders, so we don't assert
1150 // failure above this. 1145 // failure above this.
1151 enum { kMinSupportedNumConcurrentDecoders = 3 }; 1146 enum { kMinSupportedNumConcurrentDecoders = 3 };
1152 1147
1153 // Test the most straightforward case possible: data is decoded from a single 1148 // Test the most straightforward case possible: data is decoded from a single
1154 // chunk and rendered to the screen. 1149 // chunk and rendered to the screen.
1155 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { 1150 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) {
1156 size_t num_concurrent_decoders = base::get<0>(GetParam()); 1151 size_t num_concurrent_decoders = base::get<0>(GetParam());
1157 const size_t num_in_flight_decodes = base::get<1>(GetParam()); 1152 const size_t num_in_flight_decodes = base::get<1>(GetParam());
1158 int num_play_throughs = base::get<2>(GetParam()); 1153 int num_play_throughs = base::get<2>(GetParam());
1159 const int reset_point = base::get<3>(GetParam()); 1154 const int reset_point = base::get<3>(GetParam());
1160 const int delete_decoder_state = base::get<4>(GetParam()); 1155 const int delete_decoder_state = base::get<4>(GetParam());
1161 bool test_reuse_delay = base::get<5>(GetParam()); 1156 bool test_reuse_delay = base::get<5>(GetParam());
1162 const bool render_as_thumbnails = base::get<6>(GetParam()); 1157 const bool render_as_thumbnails = base::get<6>(GetParam());
1163 1158
1164 if (test_video_files_.size() > 1) 1159 if (test_video_files_.size() > 1)
1165 num_concurrent_decoders = test_video_files_.size(); 1160 num_concurrent_decoders = test_video_files_.size();
1166 1161
1167 if (g_num_play_throughs > 0) 1162 if (g_num_play_throughs > 0)
1168 num_play_throughs = g_num_play_throughs; 1163 num_play_throughs = g_num_play_throughs;
1169 1164
1170 UpdateTestVideoFileParams( 1165 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point,
1171 num_concurrent_decoders, reset_point, &test_video_files_); 1166 &test_video_files_);
1172 1167
1173 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. 1168 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1174 const bool suppress_rendering = g_rendering_fps == 0; 1169 const bool suppress_rendering = g_rendering_fps == 0;
1175 1170
1176 std::vector<ClientStateNotification<ClientState>*> 1171 std::vector<ClientStateNotification<ClientState>*> notes(
1177 notes(num_concurrent_decoders, NULL); 1172 num_concurrent_decoders, NULL);
1178 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 1173 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
1179 1174
1180 RenderingHelperParams helper_params; 1175 RenderingHelperParams helper_params;
1181 helper_params.rendering_fps = g_rendering_fps; 1176 helper_params.rendering_fps = g_rendering_fps;
1182 helper_params.warm_up_iterations = g_rendering_warm_up; 1177 helper_params.warm_up_iterations = g_rendering_warm_up;
1183 helper_params.render_as_thumbnails = render_as_thumbnails; 1178 helper_params.render_as_thumbnails = render_as_thumbnails;
1184 if (render_as_thumbnails) { 1179 if (render_as_thumbnails) {
1185 // Only one decoder is supported with thumbnail rendering 1180 // Only one decoder is supported with thumbnail rendering
1186 LOG_ASSERT(num_concurrent_decoders == 1U); 1181 LOG_ASSERT(num_concurrent_decoders == 1U);
1187 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1182 helper_params.thumbnails_page_size = kThumbnailsPageSize;
1188 helper_params.thumbnail_size = kThumbnailSize; 1183 helper_params.thumbnail_size = kThumbnailSize;
1189 } 1184 }
1190 1185
1191 // First kick off all the decoders. 1186 // First kick off all the decoders.
1192 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1187 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1193 TestVideoFile* video_file = 1188 TestVideoFile* video_file =
1194 test_video_files_[index % test_video_files_.size()]; 1189 test_video_files_[index % test_video_files_.size()];
1195 ClientStateNotification<ClientState>* note = 1190 ClientStateNotification<ClientState>* note =
1196 new ClientStateNotification<ClientState>(); 1191 new ClientStateNotification<ClientState>();
1197 notes[index] = note; 1192 notes[index] = note;
1198 1193
1199 int delay_after_frame_num = std::numeric_limits<int>::max(); 1194 int delay_after_frame_num = std::numeric_limits<int>::max();
1200 if (test_reuse_delay && 1195 if (test_reuse_delay &&
1201 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { 1196 kMaxFramesToDelayReuse * 2 < video_file->num_frames) {
1202 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; 1197 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse;
1203 } 1198 }
1204 1199
1205 GLRenderingVDAClient* client = 1200 GLRenderingVDAClient* client = new GLRenderingVDAClient(
1206 new GLRenderingVDAClient(index, 1201 index, &rendering_helper_, note, video_file->data_str,
1207 &rendering_helper_, 1202 num_in_flight_decodes, num_play_throughs,
1208 note, 1203 video_file->reset_after_frame_num, delete_decoder_state,
1209 video_file->data_str, 1204 video_file->width, video_file->height, video_file->profile,
1210 num_in_flight_decodes, 1205 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0,
1211 num_play_throughs, 1206 render_as_thumbnails);
1212 video_file->reset_after_frame_num,
1213 delete_decoder_state,
1214 video_file->width,
1215 video_file->height,
1216 video_file->profile,
1217 g_fake_decoder,
1218 suppress_rendering,
1219 delay_after_frame_num,
1220 0,
1221 render_as_thumbnails);
1222 1207
1223 clients[index] = client; 1208 clients[index] = client;
1224 helper_params.window_sizes.push_back( 1209 helper_params.window_sizes.push_back(
1225 render_as_thumbnails 1210 render_as_thumbnails
1226 ? kThumbnailsPageSize 1211 ? kThumbnailsPageSize
1227 : gfx::Size(video_file->width, video_file->height)); 1212 : gfx::Size(video_file->width, video_file->height));
1228 } 1213 }
1229 1214
1230 InitializeRenderingHelper(helper_params); 1215 InitializeRenderingHelper(helper_params);
1231 1216
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 ASSERT_NO_FATAL_FAILURE( 1251 ASSERT_NO_FATAL_FAILURE(
1267 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); 1252 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING));
1268 } 1253 }
1269 ASSERT_NO_FATAL_FAILURE( 1254 ASSERT_NO_FATAL_FAILURE(
1270 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); 1255 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET));
1271 // ResetDone requests Destroy(). 1256 // ResetDone requests Destroy().
1272 ASSERT_NO_FATAL_FAILURE( 1257 ASSERT_NO_FATAL_FAILURE(
1273 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); 1258 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED));
1274 } 1259 }
1275 // Finally assert that decoding went as expected. 1260 // Finally assert that decoding went as expected.
1276 for (size_t i = 0; i < num_concurrent_decoders && 1261 for (size_t i = 0;
1277 !skip_performance_and_correctness_checks; ++i) { 1262 i < num_concurrent_decoders && !skip_performance_and_correctness_checks;
1263 ++i) {
1278 // We can only make performance/correctness assertions if the decoder was 1264 // We can only make performance/correctness assertions if the decoder was
1279 // allowed to finish. 1265 // allowed to finish.
1280 if (delete_decoder_state < CS_FLUSHED) 1266 if (delete_decoder_state < CS_FLUSHED)
1281 continue; 1267 continue;
1282 GLRenderingVDAClient* client = clients[i]; 1268 GLRenderingVDAClient* client = clients[i];
1283 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; 1269 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()];
1284 if (video_file->num_frames > 0) { 1270 if (video_file->num_frames > 0) {
1285 // Expect the decoded frames may be more than the video frames as frames 1271 // Expect the decoded frames may be more than the video frames as frames
1286 // could still be returned until resetting done. 1272 // could still be returned until resetting done.
1287 if (video_file->reset_after_frame_num > 0) 1273 if (video_file->reset_after_frame_num > 0)
1288 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); 1274 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames);
1289 else 1275 else
1290 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); 1276 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames);
1291 } 1277 }
1292 if (reset_point == END_OF_STREAM_RESET) { 1278 if (reset_point == END_OF_STREAM_RESET) {
1293 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + 1279 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() +
1294 client->num_queued_fragments()); 1280 client->num_queued_fragments());
1295 EXPECT_EQ(client->num_done_bitstream_buffers(), 1281 EXPECT_EQ(client->num_done_bitstream_buffers(),
1296 client->num_queued_fragments()); 1282 client->num_queued_fragments());
1297 } 1283 }
1298 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); 1284 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second();
1299 if (!render_as_thumbnails) { 1285 if (!render_as_thumbnails) {
1300 int min_fps = suppress_rendering ? 1286 int min_fps = suppress_rendering ? video_file->min_fps_no_render
1301 video_file->min_fps_no_render : video_file->min_fps_render; 1287 : video_file->min_fps_render;
1302 if (min_fps > 0 && !test_reuse_delay) 1288 if (min_fps > 0 && !test_reuse_delay)
1303 EXPECT_GT(client->frames_per_second(), min_fps); 1289 EXPECT_GT(client->frames_per_second(), min_fps);
1304 } 1290 }
1305 } 1291 }
1306 1292
1307 if (render_as_thumbnails) { 1293 if (render_as_thumbnails) {
1308 std::vector<unsigned char> rgb; 1294 std::vector<unsigned char> rgb;
1309 bool alpha_solid; 1295 bool alpha_solid;
1310 base::WaitableEvent done(false, false); 1296 base::WaitableEvent done(false, false);
1311 g_env->GetRenderingTaskRunner()->PostTask( 1297 g_env->GetRenderingTaskRunner()->PostTask(
1312 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, 1298 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB,
1313 base::Unretained(&rendering_helper_), &rgb, 1299 base::Unretained(&rendering_helper_), &rgb,
1314 &alpha_solid, &done)); 1300 &alpha_solid, &done));
1315 done.Wait(); 1301 done.Wait();
1316 1302
1317 std::vector<std::string> golden_md5s; 1303 std::vector<std::string> golden_md5s;
1318 std::string md5_string = base::MD5String( 1304 std::string md5_string = base::MD5String(
1319 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); 1305 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size()));
1320 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); 1306 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s);
1321 std::vector<std::string>::iterator match = 1307 std::vector<std::string>::iterator match =
1322 find(golden_md5s.begin(), golden_md5s.end(), md5_string); 1308 find(golden_md5s.begin(), golden_md5s.end(), md5_string);
1323 if (match == golden_md5s.end()) { 1309 if (match == golden_md5s.end()) {
1324 // Convert raw RGB into PNG for export. 1310 // Convert raw RGB into PNG for export.
1325 std::vector<unsigned char> png; 1311 std::vector<unsigned char> png;
1326 gfx::PNGCodec::Encode(&rgb[0], 1312 gfx::PNGCodec::Encode(&rgb[0], gfx::PNGCodec::FORMAT_RGB,
1327 gfx::PNGCodec::FORMAT_RGB,
1328 kThumbnailsPageSize, 1313 kThumbnailsPageSize,
1329 kThumbnailsPageSize.width() * 3, 1314 kThumbnailsPageSize.width() * 3, true,
1330 true, 1315 std::vector<gfx::PNGCodec::Comment>(), &png);
1331 std::vector<gfx::PNGCodec::Comment>(),
1332 &png);
1333 1316
1334 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; 1317 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
1335 1318
1336 base::FilePath filepath(test_video_files_[0]->file_name); 1319 base::FilePath filepath(test_video_files_[0]->file_name);
1337 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); 1320 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
1338 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); 1321 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
1339 int num_bytes = base::WriteFile(filepath, 1322 int num_bytes = base::WriteFile(
1340 reinterpret_cast<char*>(&png[0]), 1323 filepath, reinterpret_cast<char*>(&png[0]), png.size());
1341 png.size());
1342 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); 1324 ASSERT_EQ(num_bytes, static_cast<int>(png.size()));
1343 } 1325 }
1344 ASSERT_NE(match, golden_md5s.end()); 1326 ASSERT_NE(match, golden_md5s.end());
1345 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; 1327 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha";
1346 } 1328 }
1347 1329
1348 // Output the frame delivery time to file 1330 // Output the frame delivery time to file
1349 // We can only make performance/correctness assertions if the decoder was 1331 // We can only make performance/correctness assertions if the decoder was
1350 // allowed to finish. 1332 // allowed to finish.
1351 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1333 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
(...skipping 12 matching lines...) Expand all
1364 g_env->GetRenderingTaskRunner()->PostTask( 1346 g_env->GetRenderingTaskRunner()->PostTask(
1365 FROM_HERE, 1347 FROM_HERE,
1366 base::Bind(&STLDeleteElements< 1348 base::Bind(&STLDeleteElements<
1367 std::vector<ClientStateNotification<ClientState>*>>, 1349 std::vector<ClientStateNotification<ClientState>*>>,
1368 &notes)); 1350 &notes));
1369 WaitUntilIdle(); 1351 WaitUntilIdle();
1370 }; 1352 };
1371 1353
1372 // Test that replay after EOS works fine. 1354 // Test that replay after EOS works fine.
1373 INSTANTIATE_TEST_CASE_P( 1355 INSTANTIATE_TEST_CASE_P(
1374 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, 1356 ReplayAfterEOS,
1357 VideoDecodeAcceleratorParamTest,
1375 ::testing::Values( 1358 ::testing::Values(
1376 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); 1359 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false)));
1377 1360
1378 // Test that Reset() before the first Decode() works fine. 1361 // Test that Reset() before the first Decode() works fine.
1379 INSTANTIATE_TEST_CASE_P( 1362 INSTANTIATE_TEST_CASE_P(
1380 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, 1363 ResetBeforeDecode,
1364 VideoDecodeAcceleratorParamTest,
1381 ::testing::Values( 1365 ::testing::Values(
1382 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); 1366 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false)));
1383 1367
1384 // Test Reset() immediately after Decode() containing config info. 1368 // Test Reset() immediately after Decode() containing config info.
1385 INSTANTIATE_TEST_CASE_P( 1369 INSTANTIATE_TEST_CASE_P(
1386 ResetAfterFirstConfigInfo, VideoDecodeAcceleratorParamTest, 1370 ResetAfterFirstConfigInfo,
1387 ::testing::Values( 1371 VideoDecodeAcceleratorParamTest,
1388 MakeTuple( 1372 ::testing::Values(MakeTuple(1,
1389 1, 1, 1, RESET_AFTER_FIRST_CONFIG_INFO, CS_RESET, false, false))); 1373 1,
1374 1,
1375 RESET_AFTER_FIRST_CONFIG_INFO,
1376 CS_RESET,
1377 false,
1378 false)));
1390 1379
1391 // Test that Reset() mid-stream works fine and doesn't affect decoding even when 1380 // Test that Reset() mid-stream works fine and doesn't affect decoding even when
1392 // Decode() calls are made during the reset. 1381 // Decode() calls are made during the reset.
1393 INSTANTIATE_TEST_CASE_P( 1382 INSTANTIATE_TEST_CASE_P(
1394 MidStreamReset, VideoDecodeAcceleratorParamTest, 1383 MidStreamReset,
1384 VideoDecodeAcceleratorParamTest,
1395 ::testing::Values( 1385 ::testing::Values(
1396 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); 1386 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false)));
1397 1387
1398 INSTANTIATE_TEST_CASE_P( 1388 INSTANTIATE_TEST_CASE_P(
1399 SlowRendering, VideoDecodeAcceleratorParamTest, 1389 SlowRendering,
1390 VideoDecodeAcceleratorParamTest,
1400 ::testing::Values( 1391 ::testing::Values(
1401 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); 1392 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false)));
1402 1393
1403 // Test that Destroy() mid-stream works fine (primarily this is testing that no 1394 // Test that Destroy() mid-stream works fine (primarily this is testing that no
1404 // crashes occur). 1395 // crashes occur).
1405 INSTANTIATE_TEST_CASE_P( 1396 INSTANTIATE_TEST_CASE_P(
1406 TearDownTiming, VideoDecodeAcceleratorParamTest, 1397 TearDownTiming,
1398 VideoDecodeAcceleratorParamTest,
1407 ::testing::Values( 1399 ::testing::Values(
1408 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), 1400 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false),
1409 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), 1401 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false),
1410 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), 1402 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false),
1411 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), 1403 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false),
1412 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), 1404 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false),
1413 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1405 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1414 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, 1406 MakeTuple(1,
1415 static_cast<ClientState>(-1), false, false), 1407 1,
1416 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, 1408 1,
1417 static_cast<ClientState>(-10), false, false), 1409 END_OF_STREAM_RESET,
1418 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, 1410 static_cast<ClientState>(-1),
1419 static_cast<ClientState>(-100), false, false))); 1411 false,
1412 false),
1413 MakeTuple(1,
1414 1,
1415 1,
1416 END_OF_STREAM_RESET,
1417 static_cast<ClientState>(-10),
1418 false,
1419 false),
1420 MakeTuple(1,
1421 1,
1422 1,
1423 END_OF_STREAM_RESET,
1424 static_cast<ClientState>(-100),
1425 false,
1426 false)));
1420 1427
1421 // Test that decoding various variation works with multiple in-flight decodes. 1428 // Test that decoding various variation works with multiple in-flight decodes.
1422 INSTANTIATE_TEST_CASE_P( 1429 INSTANTIATE_TEST_CASE_P(
1423 DecodeVariations, VideoDecodeAcceleratorParamTest, 1430 DecodeVariations,
1431 VideoDecodeAcceleratorParamTest,
1424 ::testing::Values( 1432 ::testing::Values(
1425 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1433 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1426 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1434 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1427 // Tests queuing. 1435 // Tests queuing.
1428 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); 1436 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false)));
1429 1437
1430 // Find out how many concurrent decoders can go before we exhaust system 1438 // Find out how many concurrent decoders can go before we exhaust system
1431 // resources. 1439 // resources.
1432 INSTANTIATE_TEST_CASE_P( 1440 INSTANTIATE_TEST_CASE_P(ResourceExhaustion,
1433 ResourceExhaustion, VideoDecodeAcceleratorParamTest, 1441 VideoDecodeAcceleratorParamTest,
1434 ::testing::Values( 1442 ::testing::Values(
1435 // +0 hack below to promote enum to int. 1443 // +0 hack below to promote enum to int.
1436 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, 1444 MakeTuple(kMinSupportedNumConcurrentDecoders + 0,
1437 END_OF_STREAM_RESET, CS_RESET, false, false), 1445 1,
1438 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, 1446 1,
1439 END_OF_STREAM_RESET, CS_RESET, false, false))); 1447 END_OF_STREAM_RESET,
1448 CS_RESET,
1449 false,
1450 false),
1451 MakeTuple(kMinSupportedNumConcurrentDecoders + 1,
1452 1,
1453 1,
1454 END_OF_STREAM_RESET,
1455 CS_RESET,
1456 false,
1457 false)));
1440 1458
1441 // Thumbnailing test 1459 // Thumbnailing test
1442 INSTANTIATE_TEST_CASE_P( 1460 INSTANTIATE_TEST_CASE_P(
1443 Thumbnail, VideoDecodeAcceleratorParamTest, 1461 Thumbnail,
1462 VideoDecodeAcceleratorParamTest,
1444 ::testing::Values( 1463 ::testing::Values(
1445 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1464 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1446 1465
1447 // Measure the median of the decode time when VDA::Decode is called 30 times per 1466 // Measure the median of the decode time when VDA::Decode is called 30 times per
1448 // second. 1467 // second.
1449 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1468 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1450 RenderingHelperParams helper_params; 1469 RenderingHelperParams helper_params;
1451 1470
1452 // Disable rendering by setting the rendering_fps = 0. 1471 // Disable rendering by setting the rendering_fps = 0.
1453 helper_params.rendering_fps = 0; 1472 helper_params.rendering_fps = 0;
1454 helper_params.warm_up_iterations = 0; 1473 helper_params.warm_up_iterations = 0;
1455 helper_params.render_as_thumbnails = false; 1474 helper_params.render_as_thumbnails = false;
1456 1475
1457 ClientStateNotification<ClientState>* note = 1476 ClientStateNotification<ClientState>* note =
1458 new ClientStateNotification<ClientState>(); 1477 new ClientStateNotification<ClientState>();
1459 GLRenderingVDAClient* client = 1478 GLRenderingVDAClient* client = new GLRenderingVDAClient(
1460 new GLRenderingVDAClient(0, 1479 0, &rendering_helper_, note, test_video_files_[0]->data_str, 1, 1,
1461 &rendering_helper_, 1480 test_video_files_[0]->reset_after_frame_num, CS_RESET,
1462 note, 1481 test_video_files_[0]->width, test_video_files_[0]->height,
1463 test_video_files_[0]->data_str, 1482 test_video_files_[0]->profile, g_fake_decoder, true,
1464 1, 1483 std::numeric_limits<int>::max(), kWebRtcDecodeCallsPerSecond,
1465 1, 1484 false /* render_as_thumbnail */);
1466 test_video_files_[0]->reset_after_frame_num,
1467 CS_RESET,
1468 test_video_files_[0]->width,
1469 test_video_files_[0]->height,
1470 test_video_files_[0]->profile,
1471 g_fake_decoder,
1472 true,
1473 std::numeric_limits<int>::max(),
1474 kWebRtcDecodeCallsPerSecond,
1475 false /* render_as_thumbnail */);
1476 helper_params.window_sizes.push_back( 1485 helper_params.window_sizes.push_back(
1477 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); 1486 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height));
1478 InitializeRenderingHelper(helper_params); 1487 InitializeRenderingHelper(helper_params);
1479 CreateAndStartDecoder(client, note); 1488 CreateAndStartDecoder(client, note);
1480 WaitUntilDecodeFinish(note); 1489 WaitUntilDecodeFinish(note);
1481 1490
1482 base::TimeDelta decode_time_median = client->decode_time_median(); 1491 base::TimeDelta decode_time_median = client->decode_time_median();
1483 std::string output_string = 1492 std::string output_string =
1484 base::StringPrintf("Decode time median: %" PRId64 " us", 1493 base::StringPrintf("Decode time median: %" PRId64 " us",
1485 decode_time_median.InMicroseconds()); 1494 decode_time_median.InMicroseconds());
1486 LOG(INFO) << output_string; 1495 LOG(INFO) << output_string;
1487 1496
1488 if (g_output_log != NULL) 1497 if (g_output_log != NULL)
1489 OutputLogFile(g_output_log, output_string); 1498 OutputLogFile(g_output_log, output_string);
1490 1499
1491 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client); 1500 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client);
1492 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); 1501 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note);
1493 WaitUntilIdle(); 1502 WaitUntilIdle();
1494 }; 1503 };
1495 1504
1496 // TODO(fischman, vrk): add more tests! In particular: 1505 // TODO(fischman, vrk): add more tests! In particular:
1497 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. 1506 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder.
1498 // - Test alternate configurations 1507 // - Test alternate configurations
1499 // - Test failure conditions. 1508 // - Test failure conditions.
1500 // - Test frame size changes mid-stream 1509 // - Test frame size changes mid-stream
1501 1510
1502 } // namespace 1511 } // namespace
1503 } // namespace content 1512 } // namespace media
1504 1513
1505 int main(int argc, char **argv) { 1514 int main(int argc, char** argv) {
1506 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. 1515 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args.
1507 base::CommandLine::Init(argc, argv); 1516 base::CommandLine::Init(argc, argv);
1508 1517
1509 // Needed to enable DVLOG through --vmodule. 1518 // Needed to enable DVLOG through --vmodule.
1510 logging::LoggingSettings settings; 1519 logging::LoggingSettings settings;
1511 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 1520 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
1512 LOG_ASSERT(logging::InitLogging(settings)); 1521 LOG_ASSERT(logging::InitLogging(settings));
1513 1522
1514 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 1523 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
1515 DCHECK(cmd_line); 1524 DCHECK(cmd_line);
1516 1525
1517 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); 1526 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
1518 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); 1527 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
1519 it != switches.end(); ++it) { 1528 it != switches.end(); ++it) {
1520 if (it->first == "test_video_data") { 1529 if (it->first == "test_video_data") {
1521 content::g_test_video_data = it->second.c_str(); 1530 media::g_test_video_data = it->second.c_str();
1522 continue; 1531 continue;
1523 } 1532 }
1524 // The output log for VDA performance test. 1533 // The output log for VDA performance test.
1525 if (it->first == "output_log") { 1534 if (it->first == "output_log") {
1526 content::g_output_log = it->second.c_str(); 1535 media::g_output_log = it->second.c_str();
1527 continue; 1536 continue;
1528 } 1537 }
1529 if (it->first == "rendering_fps") { 1538 if (it->first == "rendering_fps") {
1530 // On Windows, CommandLine::StringType is wstring. We need to convert 1539 // On Windows, CommandLine::StringType is wstring. We need to convert
1531 // it to std::string first 1540 // it to std::string first
1532 std::string input(it->second.begin(), it->second.end()); 1541 std::string input(it->second.begin(), it->second.end());
1533 LOG_ASSERT(base::StringToDouble(input, &content::g_rendering_fps)); 1542 LOG_ASSERT(base::StringToDouble(input, &media::g_rendering_fps));
1534 continue; 1543 continue;
1535 } 1544 }
1536 if (it->first == "rendering_warm_up") { 1545 if (it->first == "rendering_warm_up") {
1537 std::string input(it->second.begin(), it->second.end()); 1546 std::string input(it->second.begin(), it->second.end());
1538 LOG_ASSERT(base::StringToInt(input, &content::g_rendering_warm_up)); 1547 LOG_ASSERT(base::StringToInt(input, &media::g_rendering_warm_up));
1539 continue; 1548 continue;
1540 } 1549 }
1541 // TODO(owenlin): Remove this flag once it is not used in autotest. 1550 // TODO(owenlin): Remove this flag once it is not used in autotest.
1542 if (it->first == "disable_rendering") { 1551 if (it->first == "disable_rendering") {
1543 content::g_rendering_fps = 0; 1552 media::g_rendering_fps = 0;
1544 continue; 1553 continue;
1545 } 1554 }
1546 1555
1547 if (it->first == "num_play_throughs") { 1556 if (it->first == "num_play_throughs") {
1548 std::string input(it->second.begin(), it->second.end()); 1557 std::string input(it->second.begin(), it->second.end());
1549 LOG_ASSERT(base::StringToInt(input, &content::g_num_play_throughs)); 1558 LOG_ASSERT(base::StringToInt(input, &media::g_num_play_throughs));
1550 continue; 1559 continue;
1551 } 1560 }
1552 if (it->first == "fake_decoder") { 1561 if (it->first == "fake_decoder") {
1553 content::g_fake_decoder = 1; 1562 media::g_fake_decoder = 1;
1554 continue; 1563 continue;
1555 } 1564 }
1556 if (it->first == "v" || it->first == "vmodule") 1565 if (it->first == "v" || it->first == "vmodule")
1557 continue; 1566 continue;
1558 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") 1567 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1559 continue; 1568 continue;
1560 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1569 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1561 } 1570 }
1562 1571
1563 base::ShadowingAtExitManager at_exit_manager; 1572 base::ShadowingAtExitManager at_exit_manager;
1564 #if defined(OS_WIN) || defined(USE_OZONE) 1573 #if defined(OS_WIN) || defined(USE_OZONE)
1565 // For windows the decoding thread initializes the media foundation decoder 1574 // For windows the decoding thread initializes the media foundation decoder
1566 // which uses COM. We need the thread to be a UI thread. 1575 // which uses COM. We need the thread to be a UI thread.
1567 // On Ozone, the backend initializes the event system using a UI 1576 // On Ozone, the backend initializes the event system using a UI
1568 // thread. 1577 // thread.
1569 base::MessageLoopForUI main_loop; 1578 base::MessageLoopForUI main_loop;
1570 #else 1579 #else
1571 base::MessageLoop main_loop; 1580 base::MessageLoop main_loop;
1572 #endif // OS_WIN || USE_OZONE 1581 #endif // OS_WIN || USE_OZONE
1573 1582
1574 #if defined(USE_OZONE) 1583 #if defined(USE_OZONE)
1575 ui::OzonePlatform::InitializeForUI(); 1584 ui::OzonePlatform::InitializeForUI();
1576 #endif 1585 #endif
1577 1586
1578 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 1587 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
1579 content::VaapiWrapper::PreSandboxInitialization(); 1588 media::VaapiWrapper::PreSandboxInitialization();
1580 #endif 1589 #endif
1581 1590
1582 content::g_env = 1591 media::g_env =
1583 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( 1592 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1584 testing::AddGlobalTestEnvironment( 1593 testing::AddGlobalTestEnvironment(
1585 new content::VideoDecodeAcceleratorTestEnvironment())); 1594 new media::VideoDecodeAcceleratorTestEnvironment()));
1586 1595
1587 return RUN_ALL_TESTS(); 1596 return RUN_ALL_TESTS();
1588 } 1597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698