| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 #include "base/strings/string_split.h" | 41 #include "base/strings/string_split.h" |
| 42 #include "base/strings/stringize_macros.h" | 42 #include "base/strings/stringize_macros.h" |
| 43 #include "base/strings/stringprintf.h" | 43 #include "base/strings/stringprintf.h" |
| 44 #include "base/strings/utf_string_conversions.h" | 44 #include "base/strings/utf_string_conversions.h" |
| 45 #include "base/synchronization/condition_variable.h" | 45 #include "base/synchronization/condition_variable.h" |
| 46 #include "base/synchronization/lock.h" | 46 #include "base/synchronization/lock.h" |
| 47 #include "base/synchronization/waitable_event.h" | 47 #include "base/synchronization/waitable_event.h" |
| 48 #include "base/thread_task_runner_handle.h" | 48 #include "base/thread_task_runner_handle.h" |
| 49 #include "base/threading/thread.h" | 49 #include "base/threading/thread.h" |
| 50 #include "build/build_config.h" | 50 #include "build/build_config.h" |
| 51 #include "content/common/gpu/media/fake_video_decode_accelerator.h" | |
| 52 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" | |
| 53 #include "content/common/gpu/media/rendering_helper.h" | |
| 54 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | |
| 55 #include "gpu/command_buffer/service/gpu_preferences.h" | 51 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 56 #include "media/filters/h264_parser.h" | 52 #include "media/filters/h264_parser.h" |
| 53 #include "media/gpu/fake_video_decode_accelerator.h" |
| 54 #include "media/gpu/gpu_video_decode_accelerator_factory_impl.h" |
| 55 #include "media/gpu/rendering_helper.h" |
| 56 #include "media/gpu/video_accelerator_unittest_helpers.h" |
| 57 #include "testing/gtest/include/gtest/gtest.h" | 57 #include "testing/gtest/include/gtest/gtest.h" |
| 58 #include "ui/gfx/codec/png_codec.h" | 58 #include "ui/gfx/codec/png_codec.h" |
| 59 #include "ui/gl/gl_image.h" | 59 #include "ui/gl/gl_image.h" |
| 60 | 60 |
| 61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 62 #include "base/win/windows_version.h" | 62 #include "base/win/windows_version.h" |
| 63 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" | 63 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 64 #elif defined(OS_CHROMEOS) | 64 #elif defined(OS_CHROMEOS) |
| 65 #if defined(USE_V4L2_CODEC) | 65 #if defined(USE_V4L2_CODEC) |
| 66 #include "content/common/gpu/media/v4l2_device.h" | 66 #include "media/gpu/v4l2_device.h" |
| 67 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" | 67 #include "media/gpu/v4l2_slice_video_decode_accelerator.h" |
| 68 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 68 #include "media/gpu/v4l2_video_decode_accelerator.h" |
| 69 #endif | 69 #endif |
| 70 #if defined(ARCH_CPU_X86_FAMILY) | 70 #if defined(ARCH_CPU_X86_FAMILY) |
| 71 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 71 #include "media/gpu/vaapi_video_decode_accelerator.h" |
| 72 #include "content/common/gpu/media/vaapi_wrapper.h" | 72 #include "media/gpu/vaapi_wrapper.h" |
| 73 #endif // defined(ARCH_CPU_X86_FAMILY) | 73 #endif // defined(ARCH_CPU_X86_FAMILY) |
| 74 #else | 74 #else |
| 75 #error The VideoAccelerator tests are not supported on this platform. | 75 #error The VideoAccelerator tests are not supported on this platform. |
| 76 #endif // OS_WIN | 76 #endif // OS_WIN |
| 77 | 77 |
| 78 #if defined(USE_OZONE) | 78 #if defined(USE_OZONE) |
| 79 #include "ui/ozone/public/native_pixmap.h" | 79 #include "ui/ozone/public/native_pixmap.h" |
| 80 #include "ui/ozone/public/ozone_gpu_test_helper.h" | 80 #include "ui/ozone/public/ozone_gpu_test_helper.h" |
| 81 #include "ui/ozone/public/ozone_platform.h" | 81 #include "ui/ozone/public/ozone_platform.h" |
| 82 #include "ui/ozone/public/surface_factory_ozone.h" | 82 #include "ui/ozone/public/surface_factory_ozone.h" |
| 83 #endif // defined(USE_OZONE) | 83 #endif // defined(USE_OZONE) |
| 84 | 84 |
| 85 using media::VideoDecodeAccelerator; | 85 using media::VideoDecodeAccelerator; |
| 86 | 86 |
| 87 namespace content { | 87 namespace media { |
| 88 namespace { | 88 namespace { |
| 89 | 89 |
| 90 using base::MakeTuple; | 90 using base::MakeTuple; |
| 91 | 91 |
| 92 // Values optionally filled in from flags; see main() below. | 92 // Values optionally filled in from flags; see main() below. |
| 93 // The syntax of multiple test videos is: | 93 // The syntax of multiple test videos is: |
| 94 // test-video1;test-video2;test-video3 | 94 // test-video1;test-video2;test-video3 |
| 95 // where only the first video is required and other optional videos would be | 95 // where only the first video is required and other optional videos would be |
| 96 // decoded by concurrent decoders. | 96 // decoded by concurrent decoders. |
| 97 // The syntax of each test-video is: | 97 // The syntax of each test-video is: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 struct TestVideoFile { | 159 struct TestVideoFile { |
| 160 explicit TestVideoFile(base::FilePath::StringType file_name) | 160 explicit TestVideoFile(base::FilePath::StringType file_name) |
| 161 : file_name(file_name), | 161 : file_name(file_name), |
| 162 width(-1), | 162 width(-1), |
| 163 height(-1), | 163 height(-1), |
| 164 num_frames(-1), | 164 num_frames(-1), |
| 165 num_fragments(-1), | 165 num_fragments(-1), |
| 166 min_fps_render(-1), | 166 min_fps_render(-1), |
| 167 min_fps_no_render(-1), | 167 min_fps_no_render(-1), |
| 168 profile(media::VIDEO_CODEC_PROFILE_UNKNOWN), | 168 profile(media::VIDEO_CODEC_PROFILE_UNKNOWN), |
| 169 reset_after_frame_num(END_OF_STREAM_RESET) { | 169 reset_after_frame_num(END_OF_STREAM_RESET) {} |
| 170 } | |
| 171 | 170 |
| 172 base::FilePath::StringType file_name; | 171 base::FilePath::StringType file_name; |
| 173 int width; | 172 int width; |
| 174 int height; | 173 int height; |
| 175 int num_frames; | 174 int num_frames; |
| 176 int num_fragments; | 175 int num_fragments; |
| 177 int min_fps_render; | 176 int min_fps_render; |
| 178 int min_fps_no_render; | 177 int min_fps_no_render; |
| 179 media::VideoCodecProfile profile; | 178 media::VideoCodecProfile profile; |
| 180 int reset_after_frame_num; | 179 int reset_after_frame_num; |
| 181 std::string data_str; | 180 std::string data_str; |
| 182 }; | 181 }; |
| 183 | 182 |
| 184 const gfx::Size kThumbnailsPageSize(1600, 1200); | 183 const gfx::Size kThumbnailsPageSize(1600, 1200); |
| 185 const gfx::Size kThumbnailSize(160, 120); | 184 const gfx::Size kThumbnailSize(160, 120); |
| 186 const int kMD5StringLength = 32; | 185 const int kMD5StringLength = 32; |
| 187 | 186 |
| 188 // Read in golden MD5s for the thumbnailed rendering of this video | 187 // Read in golden MD5s for the thumbnailed rendering of this video |
| 189 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, | 188 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, |
| 190 std::vector<std::string>* md5_strings) { | 189 std::vector<std::string>* md5_strings) { |
| 191 base::FilePath filepath(video_file->file_name); | 190 base::FilePath filepath(video_file->file_name); |
| 192 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); | 191 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); |
| 193 std::string all_md5s; | 192 std::string all_md5s; |
| 194 base::ReadFileToString(filepath, &all_md5s); | 193 base::ReadFileToString(filepath, &all_md5s); |
| 195 *md5_strings = base::SplitString( | 194 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE, |
| 196 all_md5s, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 195 base::SPLIT_WANT_ALL); |
| 197 // Check these are legitimate MD5s. | 196 // Check these are legitimate MD5s. |
| 198 for (const std::string& md5_string : *md5_strings) { | 197 for (const std::string& md5_string : *md5_strings) { |
| 199 // Ignore the empty string added by SplitString | 198 // Ignore the empty string added by SplitString |
| 200 if (!md5_string.length()) | 199 if (!md5_string.length()) |
| 201 continue; | 200 continue; |
| 202 // Ignore comments | 201 // Ignore comments |
| 203 if (md5_string.at(0) == '#') | 202 if (md5_string.at(0) == '#') |
| 204 continue; | 203 continue; |
| 205 | 204 |
| 206 LOG_ASSERT(static_cast<int>(md5_string.length()) == | 205 LOG_ASSERT(static_cast<int>(md5_string.length()) == kMD5StringLength) |
| 207 kMD5StringLength) << md5_string; | 206 << md5_string; |
| 208 bool hex_only = std::count_if(md5_string.begin(), | 207 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), |
| 209 md5_string.end(), isxdigit) == | 208 isxdigit) == kMD5StringLength; |
| 210 kMD5StringLength; | 209 LOG_ASSERT(hex_only) << md5_string; |
| 211 LOG_ASSERT(hex_only) << md5_string; | |
| 212 } | 210 } |
| 213 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" | 211 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" |
| 214 << filepath.MaybeAsASCII() | 212 << filepath.MaybeAsASCII() |
| 215 << ") missing or empty."; | 213 << ") missing or empty."; |
| 216 } | 214 } |
| 217 | 215 |
| 218 // State of the GLRenderingVDAClient below. Order matters here as the test | 216 // State of the GLRenderingVDAClient below. Order matters here as the test |
| 219 // makes assumptions about it. | 217 // makes assumptions about it. |
| 220 enum ClientState { | 218 enum ClientState { |
| 221 CS_CREATED = 0, | 219 CS_CREATED = 0, |
| 222 CS_DECODER_SET = 1, | 220 CS_DECODER_SET = 1, |
| 223 CS_INITIALIZED = 2, | 221 CS_INITIALIZED = 2, |
| 224 CS_FLUSHING = 3, | 222 CS_FLUSHING = 3, |
| 225 CS_FLUSHED = 4, | 223 CS_FLUSHED = 4, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 456 |
| 459 // Compute & return the first encoded bytes (including a start frame) to send | 457 // Compute & return the first encoded bytes (including a start frame) to send |
| 460 // to the decoder, starting at |start_pos| and returning one fragment. Skips | 458 // to the decoder, starting at |start_pos| and returning one fragment. Skips |
| 461 // to the first decodable position. | 459 // to the first decodable position. |
| 462 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); | 460 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); |
| 463 // Compute & return the encoded bytes of next fragment to send to the decoder | 461 // Compute & return the encoded bytes of next fragment to send to the decoder |
| 464 // (based on |start_pos|). | 462 // (based on |start_pos|). |
| 465 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos); | 463 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos); |
| 466 // Helpers for GetBytesForNextFragment above. | 464 // Helpers for GetBytesForNextFragment above. |
| 467 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264. | 465 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264. |
| 468 std::string GetBytesForNextFrame( | 466 std::string GetBytesForNextFrame(size_t start_pos, |
| 469 size_t start_pos, size_t* end_pos); // For VP8/9. | 467 size_t* end_pos); // For VP8/9. |
| 470 | 468 |
| 471 // Request decode of the next fragment in the encoded data. | 469 // Request decode of the next fragment in the encoded data. |
| 472 void DecodeNextFragment(); | 470 void DecodeNextFragment(); |
| 473 | 471 |
| 474 size_t window_id_; | 472 size_t window_id_; |
| 475 RenderingHelper* rendering_helper_; | 473 RenderingHelper* rendering_helper_; |
| 476 gfx::Size frame_size_; | 474 gfx::Size frame_size_; |
| 477 std::string encoded_data_; | 475 std::string encoded_data_; |
| 478 const int num_in_flight_decodes_; | 476 const int num_in_flight_decodes_; |
| 479 int outstanding_decodes_; | 477 int outstanding_decodes_; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 return; | 647 return; |
| 650 LOG_ASSERT(textures_per_buffer == 1u); | 648 LOG_ASSERT(textures_per_buffer == 1u); |
| 651 std::vector<media::PictureBuffer> buffers; | 649 std::vector<media::PictureBuffer> buffers; |
| 652 | 650 |
| 653 requested_num_of_buffers += kExtraPictureBuffers; | 651 requested_num_of_buffers += kExtraPictureBuffers; |
| 654 | 652 |
| 655 texture_target_ = texture_target; | 653 texture_target_ = texture_target; |
| 656 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { | 654 for (uint32_t i = 0; i < requested_num_of_buffers; ++i) { |
| 657 uint32_t texture_id; | 655 uint32_t texture_id; |
| 658 base::WaitableEvent done(false, false); | 656 base::WaitableEvent done(false, false); |
| 659 rendering_helper_->CreateTexture( | 657 rendering_helper_->CreateTexture(texture_target_, &texture_id, dimensions, |
| 660 texture_target_, &texture_id, dimensions, &done); | 658 &done); |
| 661 done.Wait(); | 659 done.Wait(); |
| 662 | 660 |
| 663 scoped_refptr<TextureRef> texture_ref; | 661 scoped_refptr<TextureRef> texture_ref; |
| 664 base::Closure delete_texture_cb = | 662 base::Closure delete_texture_cb = |
| 665 base::Bind(&RenderingHelper::DeleteTexture, | 663 base::Bind(&RenderingHelper::DeleteTexture, |
| 666 base::Unretained(rendering_helper_), texture_id); | 664 base::Unretained(rendering_helper_), texture_id); |
| 667 | 665 |
| 668 if (g_test_import) { | 666 if (g_test_import) { |
| 669 media::VideoPixelFormat pixel_format = decoder_->GetOutputFormat(); | 667 media::VideoPixelFormat pixel_format = decoder_->GetOutputFormat(); |
| 670 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) | 668 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { | 843 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { |
| 846 SetState(CS_ERROR); | 844 SetState(CS_ERROR); |
| 847 } | 845 } |
| 848 | 846 |
| 849 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { | 847 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { |
| 850 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", | 848 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", |
| 851 frame_delivery_times_.size()); | 849 frame_delivery_times_.size()); |
| 852 output->WriteAtCurrentPos(s.data(), s.length()); | 850 output->WriteAtCurrentPos(s.data(), s.length()); |
| 853 base::TimeTicks t0 = initialize_done_ticks_; | 851 base::TimeTicks t0 = initialize_done_ticks_; |
| 854 for (size_t i = 0; i < frame_delivery_times_.size(); ++i) { | 852 for (size_t i = 0; i < frame_delivery_times_.size(); ++i) { |
| 855 s = base::StringPrintf("frame %04" PRIuS ": %" PRId64 " us\n", | 853 s = base::StringPrintf("frame %04" PRIuS ": %" PRId64 " us\n", i, |
| 856 i, | |
| 857 (frame_delivery_times_[i] - t0).InMicroseconds()); | 854 (frame_delivery_times_[i] - t0).InMicroseconds()); |
| 858 t0 = frame_delivery_times_[i]; | 855 t0 = frame_delivery_times_[i]; |
| 859 output->WriteAtCurrentPos(s.data(), s.length()); | 856 output->WriteAtCurrentPos(s.data(), s.length()); |
| 860 } | 857 } |
| 861 } | 858 } |
| 862 | 859 |
| 863 static bool LookingAtNAL(const std::string& encoded, size_t pos) { | 860 static bool LookingAtNAL(const std::string& encoded, size_t pos) { |
| 864 return encoded[pos] == 0 && encoded[pos + 1] == 0 && | 861 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 && |
| 865 encoded[pos + 2] == 0 && encoded[pos + 3] == 1; | 862 encoded[pos + 3] == 1; |
| 866 } | 863 } |
| 867 | 864 |
| 868 void GLRenderingVDAClient::SetState(ClientState new_state) { | 865 void GLRenderingVDAClient::SetState(ClientState new_state) { |
| 869 note_->Notify(new_state); | 866 note_->Notify(new_state); |
| 870 state_ = new_state; | 867 state_ = new_state; |
| 871 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { | 868 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { |
| 872 LOG_ASSERT(!decoder_deleted()); | 869 LOG_ASSERT(!decoder_deleted()); |
| 873 DeleteDecoder(); | 870 DeleteDecoder(); |
| 874 } | 871 } |
| 875 } | 872 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 895 weak_vda_ptr_factory_->InvalidateWeakPtrs(); | 892 weak_vda_ptr_factory_->InvalidateWeakPtrs(); |
| 896 decoder_.reset(); | 893 decoder_.reset(); |
| 897 STLClearObject(&encoded_data_); | 894 STLClearObject(&encoded_data_); |
| 898 active_textures_.clear(); | 895 active_textures_.clear(); |
| 899 | 896 |
| 900 // Cascade through the rest of the states to simplify test code below. | 897 // Cascade through the rest of the states to simplify test code below. |
| 901 for (int i = state_ + 1; i < CS_MAX; ++i) | 898 for (int i = state_ + 1; i < CS_MAX; ++i) |
| 902 SetState(static_cast<ClientState>(i)); | 899 SetState(static_cast<ClientState>(i)); |
| 903 } | 900 } |
| 904 | 901 |
| 905 std::string GLRenderingVDAClient::GetBytesForFirstFragment( | 902 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, |
| 906 size_t start_pos, size_t* end_pos) { | 903 size_t* end_pos) { |
| 907 if (profile_ < media::H264PROFILE_MAX) { | 904 if (profile_ < media::H264PROFILE_MAX) { |
| 908 *end_pos = start_pos; | 905 *end_pos = start_pos; |
| 909 while (*end_pos + 4 < encoded_data_.size()) { | 906 while (*end_pos + 4 < encoded_data_.size()) { |
| 910 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame | 907 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame |
| 911 return GetBytesForNextFragment(*end_pos, end_pos); | 908 return GetBytesForNextFragment(*end_pos, end_pos); |
| 912 GetBytesForNextNALU(*end_pos, end_pos); | 909 GetBytesForNextNALU(*end_pos, end_pos); |
| 913 num_skipped_fragments_++; | 910 num_skipped_fragments_++; |
| 914 } | 911 } |
| 915 *end_pos = start_pos; | 912 *end_pos = start_pos; |
| 916 return std::string(); | 913 return std::string(); |
| 917 } | 914 } |
| 918 DCHECK_LE(profile_, media::VP9PROFILE_MAX); | 915 DCHECK_LE(profile_, media::VP9PROFILE_MAX); |
| 919 return GetBytesForNextFragment(start_pos, end_pos); | 916 return GetBytesForNextFragment(start_pos, end_pos); |
| 920 } | 917 } |
| 921 | 918 |
| 922 std::string GLRenderingVDAClient::GetBytesForNextFragment( | 919 std::string GLRenderingVDAClient::GetBytesForNextFragment(size_t start_pos, |
| 923 size_t start_pos, size_t* end_pos) { | 920 size_t* end_pos) { |
| 924 if (profile_ < media::H264PROFILE_MAX) { | 921 if (profile_ < media::H264PROFILE_MAX) { |
| 925 *end_pos = start_pos; | 922 *end_pos = start_pos; |
| 926 GetBytesForNextNALU(*end_pos, end_pos); | 923 GetBytesForNextNALU(*end_pos, end_pos); |
| 927 if (start_pos != *end_pos) { | 924 if (start_pos != *end_pos) { |
| 928 num_queued_fragments_++; | 925 num_queued_fragments_++; |
| 929 } | 926 } |
| 930 return encoded_data_.substr(start_pos, *end_pos - start_pos); | 927 return encoded_data_.substr(start_pos, *end_pos - start_pos); |
| 931 } | 928 } |
| 932 DCHECK_LE(profile_, media::VP9PROFILE_MAX); | 929 DCHECK_LE(profile_, media::VP9PROFILE_MAX); |
| 933 return GetBytesForNextFrame(start_pos, end_pos); | 930 return GetBytesForNextFrame(start_pos, end_pos); |
| 934 } | 931 } |
| 935 | 932 |
| 936 void GLRenderingVDAClient::GetBytesForNextNALU( | 933 void GLRenderingVDAClient::GetBytesForNextNALU(size_t start_pos, |
| 937 size_t start_pos, size_t* end_pos) { | 934 size_t* end_pos) { |
| 938 *end_pos = start_pos; | 935 *end_pos = start_pos; |
| 939 if (*end_pos + 4 > encoded_data_.size()) | 936 if (*end_pos + 4 > encoded_data_.size()) |
| 940 return; | 937 return; |
| 941 LOG_ASSERT(LookingAtNAL(encoded_data_, start_pos)); | 938 LOG_ASSERT(LookingAtNAL(encoded_data_, start_pos)); |
| 942 *end_pos += 4; | 939 *end_pos += 4; |
| 943 while (*end_pos + 4 <= encoded_data_.size() && | 940 while (*end_pos + 4 <= encoded_data_.size() && |
| 944 !LookingAtNAL(encoded_data_, *end_pos)) { | 941 !LookingAtNAL(encoded_data_, *end_pos)) { |
| 945 ++*end_pos; | 942 ++*end_pos; |
| 946 } | 943 } |
| 947 if (*end_pos + 3 >= encoded_data_.size()) | 944 if (*end_pos + 3 >= encoded_data_.size()) |
| 948 *end_pos = encoded_data_.size(); | 945 *end_pos = encoded_data_.size(); |
| 949 } | 946 } |
| 950 | 947 |
| 951 std::string GLRenderingVDAClient::GetBytesForNextFrame( | 948 std::string GLRenderingVDAClient::GetBytesForNextFrame(size_t start_pos, |
| 952 size_t start_pos, size_t* end_pos) { | 949 size_t* end_pos) { |
| 953 // Helpful description: http://wiki.multimedia.cx/index.php?title=IVF | 950 // Helpful description: http://wiki.multimedia.cx/index.php?title=IVF |
| 954 std::string bytes; | 951 std::string bytes; |
| 955 if (start_pos == 0) | 952 if (start_pos == 0) |
| 956 start_pos = 32; // Skip IVF header. | 953 start_pos = 32; // Skip IVF header. |
| 957 *end_pos = start_pos; | 954 *end_pos = start_pos; |
| 958 uint32_t frame_size = *reinterpret_cast<uint32_t*>(&encoded_data_[*end_pos]); | 955 uint32_t frame_size = *reinterpret_cast<uint32_t*>(&encoded_data_[*end_pos]); |
| 959 *end_pos += 12; // Skip frame header. | 956 *end_pos += 12; // Skip frame header. |
| 960 bytes.append(encoded_data_.substr(*end_pos, frame_size)); | 957 bytes.append(encoded_data_.substr(*end_pos, frame_size)); |
| 961 *end_pos += frame_size; | 958 *end_pos += frame_size; |
| 962 num_queued_fragments_++; | 959 num_queued_fragments_++; |
| 963 return bytes; | 960 return bytes; |
| 964 } | 961 } |
| 965 | 962 |
| 966 static bool FragmentHasConfigInfo(const uint8_t* data, | 963 static bool FragmentHasConfigInfo(const uint8_t* data, |
| 967 size_t size, | 964 size_t size, |
| 968 media::VideoCodecProfile profile) { | 965 media::VideoCodecProfile profile) { |
| 969 if (profile >= media::H264PROFILE_MIN && | 966 if (profile >= media::H264PROFILE_MIN && profile <= media::H264PROFILE_MAX) { |
| 970 profile <= media::H264PROFILE_MAX) { | |
| 971 media::H264Parser parser; | 967 media::H264Parser parser; |
| 972 parser.SetStream(data, size); | 968 parser.SetStream(data, size); |
| 973 media::H264NALU nalu; | 969 media::H264NALU nalu; |
| 974 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu); | 970 media::H264Parser::Result result = parser.AdvanceToNextNALU(&nalu); |
| 975 if (result != media::H264Parser::kOk) { | 971 if (result != media::H264Parser::kOk) { |
| 976 // Let the VDA figure out there's something wrong with the stream. | 972 // Let the VDA figure out there's something wrong with the stream. |
| 977 return false; | 973 return false; |
| 978 } | 974 } |
| 979 | 975 |
| 980 return nalu.nal_unit_type == media::H264NALU::kSPS; | 976 return nalu.nal_unit_type == media::H264NALU::kSPS; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 if (reset_here) | 1009 if (reset_here) |
| 1014 reset_after_frame_num_ = END_OF_STREAM_RESET; | 1010 reset_after_frame_num_ = END_OF_STREAM_RESET; |
| 1015 } | 1011 } |
| 1016 | 1012 |
| 1017 // Populate the shared memory buffer w/ the fragment, duplicate its handle, | 1013 // Populate the shared memory buffer w/ the fragment, duplicate its handle, |
| 1018 // and hand it off to the decoder. | 1014 // and hand it off to the decoder. |
| 1019 base::SharedMemory shm; | 1015 base::SharedMemory shm; |
| 1020 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size)); | 1016 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size)); |
| 1021 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); | 1017 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); |
| 1022 base::SharedMemoryHandle dup_handle; | 1018 base::SharedMemoryHandle dup_handle; |
| 1023 bool result = shm.ShareToProcess(base::GetCurrentProcessHandle(), | 1019 bool result = |
| 1024 &dup_handle); | 1020 shm.ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle); |
| 1025 LOG_ASSERT(result); | 1021 LOG_ASSERT(result); |
| 1026 media::BitstreamBuffer bitstream_buffer( | 1022 media::BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle, |
| 1027 next_bitstream_buffer_id_, dup_handle, next_fragment_size); | 1023 next_fragment_size); |
| 1028 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); | 1024 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); |
| 1029 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. | 1025 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. |
| 1030 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; | 1026 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; |
| 1031 decoder_->Decode(bitstream_buffer); | 1027 decoder_->Decode(bitstream_buffer); |
| 1032 ++outstanding_decodes_; | 1028 ++outstanding_decodes_; |
| 1033 if (!remaining_play_throughs_ && | 1029 if (!remaining_play_throughs_ && |
| 1034 -delete_decoder_state_ == next_bitstream_buffer_id_) { | 1030 -delete_decoder_state_ == next_bitstream_buffer_id_) { |
| 1035 DeleteDecoder(); | 1031 DeleteDecoder(); |
| 1036 } | 1032 } |
| 1037 | 1033 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 | 1072 |
| 1077 // Parse |data| into its constituent parts, set the various output fields | 1073 // Parse |data| into its constituent parts, set the various output fields |
| 1078 // accordingly, and read in video stream. CHECK-fails on unexpected or | 1074 // accordingly, and read in video stream. CHECK-fails on unexpected or |
| 1079 // missing required data. Unspecified optional fields are set to -1. | 1075 // missing required data. Unspecified optional fields are set to -1. |
| 1080 void ParseAndReadTestVideoData(base::FilePath::StringType data, | 1076 void ParseAndReadTestVideoData(base::FilePath::StringType data, |
| 1081 std::vector<TestVideoFile*>* test_video_files); | 1077 std::vector<TestVideoFile*>* test_video_files); |
| 1082 | 1078 |
| 1083 // Update the parameters of |test_video_files| according to | 1079 // Update the parameters of |test_video_files| according to |
| 1084 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of | 1080 // |num_concurrent_decoders| and |reset_point|. Ex: the expected number of |
| 1085 // frames should be adjusted if decoder is reset in the middle of the stream. | 1081 // frames should be adjusted if decoder is reset in the middle of the stream. |
| 1086 void UpdateTestVideoFileParams( | 1082 void UpdateTestVideoFileParams(size_t num_concurrent_decoders, |
| 1087 size_t num_concurrent_decoders, | 1083 int reset_point, |
| 1088 int reset_point, | 1084 std::vector<TestVideoFile*>* test_video_files); |
| 1089 std::vector<TestVideoFile*>* test_video_files); | |
| 1090 | 1085 |
| 1091 void InitializeRenderingHelper(const RenderingHelperParams& helper_params); | 1086 void InitializeRenderingHelper(const RenderingHelperParams& helper_params); |
| 1092 void CreateAndStartDecoder(GLRenderingVDAClient* client, | 1087 void CreateAndStartDecoder(GLRenderingVDAClient* client, |
| 1093 ClientStateNotification<ClientState>* note); | 1088 ClientStateNotification<ClientState>* note); |
| 1094 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); | 1089 void WaitUntilDecodeFinish(ClientStateNotification<ClientState>* note); |
| 1095 void WaitUntilIdle(); | 1090 void WaitUntilIdle(); |
| 1096 void OutputLogFile(const base::FilePath::CharType* log_path, | 1091 void OutputLogFile(const base::FilePath::CharType* log_path, |
| 1097 const std::string& content); | 1092 const std::string& content); |
| 1098 | 1093 |
| 1099 std::vector<TestVideoFile*> test_video_files_; | 1094 std::vector<TestVideoFile*> test_video_files_; |
| 1100 RenderingHelper rendering_helper_; | 1095 RenderingHelper rendering_helper_; |
| 1101 | 1096 |
| 1102 private: | 1097 private: |
| 1103 // Required for Thread to work. Not used otherwise. | 1098 // Required for Thread to work. Not used otherwise. |
| 1104 base::ShadowingAtExitManager at_exit_manager_; | 1099 base::ShadowingAtExitManager at_exit_manager_; |
| 1105 | 1100 |
| 1106 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); | 1101 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); |
| 1107 }; | 1102 }; |
| 1108 | 1103 |
| 1109 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() { | 1104 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} |
| 1110 } | |
| 1111 | 1105 |
| 1112 void VideoDecodeAcceleratorTest::SetUp() { | 1106 void VideoDecodeAcceleratorTest::SetUp() { |
| 1113 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 1107 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
| 1114 } | 1108 } |
| 1115 | 1109 |
| 1116 void VideoDecodeAcceleratorTest::TearDown() { | 1110 void VideoDecodeAcceleratorTest::TearDown() { |
| 1117 g_env->GetRenderingTaskRunner()->PostTask( | 1111 g_env->GetRenderingTaskRunner()->PostTask( |
| 1118 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>, | 1112 FROM_HERE, base::Bind(&STLDeleteElements<std::vector<TestVideoFile*>>, |
| 1119 &test_video_files_)); | 1113 &test_video_files_)); |
| 1120 | 1114 |
| 1121 base::WaitableEvent done(false, false); | 1115 base::WaitableEvent done(false, false); |
| 1122 g_env->GetRenderingTaskRunner()->PostTask( | 1116 g_env->GetRenderingTaskRunner()->PostTask( |
| 1123 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, | 1117 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, |
| 1124 base::Unretained(&rendering_helper_), &done)); | 1118 base::Unretained(&rendering_helper_), &done)); |
| 1125 done.Wait(); | 1119 done.Wait(); |
| 1126 | 1120 |
| 1127 rendering_helper_.TearDown(); | 1121 rendering_helper_.TearDown(); |
| 1128 } | 1122 } |
| 1129 | 1123 |
| 1130 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( | 1124 void VideoDecodeAcceleratorTest::ParseAndReadTestVideoData( |
| 1131 base::FilePath::StringType data, | 1125 base::FilePath::StringType data, |
| 1132 std::vector<TestVideoFile*>* test_video_files) { | 1126 std::vector<TestVideoFile*>* test_video_files) { |
| 1133 std::vector<base::FilePath::StringType> entries = base::SplitString( | 1127 std::vector<base::FilePath::StringType> entries = |
| 1134 data, base::FilePath::StringType(1, ';'), | 1128 base::SplitString(data, base::FilePath::StringType(1, ';'), |
| 1135 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1129 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1136 LOG_ASSERT(entries.size() >= 1U) << data; | 1130 LOG_ASSERT(entries.size() >= 1U) << data; |
| 1137 for (size_t index = 0; index < entries.size(); ++index) { | 1131 for (size_t index = 0; index < entries.size(); ++index) { |
| 1138 std::vector<base::FilePath::StringType> fields = base::SplitString( | 1132 std::vector<base::FilePath::StringType> fields = |
| 1139 entries[index], base::FilePath::StringType(1, ':'), | 1133 base::SplitString(entries[index], base::FilePath::StringType(1, ':'), |
| 1140 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1134 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1141 LOG_ASSERT(fields.size() >= 1U) << entries[index]; | 1135 LOG_ASSERT(fields.size() >= 1U) << entries[index]; |
| 1142 LOG_ASSERT(fields.size() <= 8U) << entries[index]; | 1136 LOG_ASSERT(fields.size() <= 8U) << entries[index]; |
| 1143 TestVideoFile* video_file = new TestVideoFile(fields[0]); | 1137 TestVideoFile* video_file = new TestVideoFile(fields[0]); |
| 1144 if (!fields[1].empty()) | 1138 if (!fields[1].empty()) |
| 1145 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width)); | 1139 LOG_ASSERT(base::StringToInt(fields[1], &video_file->width)); |
| 1146 if (!fields[2].empty()) | 1140 if (!fields[2].empty()) |
| 1147 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height)); | 1141 LOG_ASSERT(base::StringToInt(fields[2], &video_file->height)); |
| 1148 if (!fields[3].empty()) | 1142 if (!fields[3].empty()) |
| 1149 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames)); | 1143 LOG_ASSERT(base::StringToInt(fields[3], &video_file->num_frames)); |
| 1150 if (!fields[4].empty()) | 1144 if (!fields[4].empty()) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 // instantiated. | 1237 // instantiated. |
| 1244 // - Number of concurrent in-flight Decode() calls per decoder. | 1238 // - Number of concurrent in-flight Decode() calls per decoder. |
| 1245 // - Number of play-throughs. | 1239 // - Number of play-throughs. |
| 1246 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1240 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
| 1247 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1241 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
| 1248 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1242 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
| 1249 // - whether the video frames are rendered as thumbnails. | 1243 // - whether the video frames are rendered as thumbnails. |
| 1250 class VideoDecodeAcceleratorParamTest | 1244 class VideoDecodeAcceleratorParamTest |
| 1251 : public VideoDecodeAcceleratorTest, | 1245 : public VideoDecodeAcceleratorTest, |
| 1252 public ::testing::WithParamInterface< | 1246 public ::testing::WithParamInterface< |
| 1253 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool> > { | 1247 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; |
| 1254 }; | |
| 1255 | 1248 |
| 1256 // Wait for |note| to report a state and if it's not |expected_state| then | 1249 // Wait for |note| to report a state and if it's not |expected_state| then |
| 1257 // assert |client| has deleted its decoder. | 1250 // assert |client| has deleted its decoder. |
| 1258 static void AssertWaitForStateOrDeleted( | 1251 static void AssertWaitForStateOrDeleted( |
| 1259 ClientStateNotification<ClientState>* note, | 1252 ClientStateNotification<ClientState>* note, |
| 1260 GLRenderingVDAClient* client, | 1253 GLRenderingVDAClient* client, |
| 1261 ClientState expected_state) { | 1254 ClientState expected_state) { |
| 1262 ClientState state = note->Wait(); | 1255 ClientState state = note->Wait(); |
| 1263 if (state == expected_state) return; | 1256 if (state == expected_state) |
| 1257 return; |
| 1264 ASSERT_TRUE(client->decoder_deleted()) | 1258 ASSERT_TRUE(client->decoder_deleted()) |
| 1265 << "Decoder not deleted but Wait() returned " << state | 1259 << "Decoder not deleted but Wait() returned " << state << ", instead of " |
| 1266 << ", instead of " << expected_state; | 1260 << expected_state; |
| 1267 } | 1261 } |
| 1268 | 1262 |
| 1269 // We assert a minimal number of concurrent decoders we expect to succeed. | 1263 // We assert a minimal number of concurrent decoders we expect to succeed. |
| 1270 // Different platforms can support more concurrent decoders, so we don't assert | 1264 // Different platforms can support more concurrent decoders, so we don't assert |
| 1271 // failure above this. | 1265 // failure above this. |
| 1272 enum { kMinSupportedNumConcurrentDecoders = 3 }; | 1266 enum { kMinSupportedNumConcurrentDecoders = 3 }; |
| 1273 | 1267 |
| 1274 // Test the most straightforward case possible: data is decoded from a single | 1268 // Test the most straightforward case possible: data is decoded from a single |
| 1275 // chunk and rendered to the screen. | 1269 // chunk and rendered to the screen. |
| 1276 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { | 1270 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| 1277 size_t num_concurrent_decoders = base::get<0>(GetParam()); | 1271 size_t num_concurrent_decoders = base::get<0>(GetParam()); |
| 1278 const size_t num_in_flight_decodes = base::get<1>(GetParam()); | 1272 const size_t num_in_flight_decodes = base::get<1>(GetParam()); |
| 1279 int num_play_throughs = base::get<2>(GetParam()); | 1273 int num_play_throughs = base::get<2>(GetParam()); |
| 1280 const int reset_point = base::get<3>(GetParam()); | 1274 const int reset_point = base::get<3>(GetParam()); |
| 1281 const int delete_decoder_state = base::get<4>(GetParam()); | 1275 const int delete_decoder_state = base::get<4>(GetParam()); |
| 1282 bool test_reuse_delay = base::get<5>(GetParam()); | 1276 bool test_reuse_delay = base::get<5>(GetParam()); |
| 1283 const bool render_as_thumbnails = base::get<6>(GetParam()); | 1277 const bool render_as_thumbnails = base::get<6>(GetParam()); |
| 1284 | 1278 |
| 1285 if (test_video_files_.size() > 1) | 1279 if (test_video_files_.size() > 1) |
| 1286 num_concurrent_decoders = test_video_files_.size(); | 1280 num_concurrent_decoders = test_video_files_.size(); |
| 1287 | 1281 |
| 1288 if (g_num_play_throughs > 0) | 1282 if (g_num_play_throughs > 0) |
| 1289 num_play_throughs = g_num_play_throughs; | 1283 num_play_throughs = g_num_play_throughs; |
| 1290 | 1284 |
| 1291 UpdateTestVideoFileParams( | 1285 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, |
| 1292 num_concurrent_decoders, reset_point, &test_video_files_); | 1286 &test_video_files_); |
| 1293 | 1287 |
| 1294 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. | 1288 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. |
| 1295 const bool suppress_rendering = g_rendering_fps == 0; | 1289 const bool suppress_rendering = g_rendering_fps == 0; |
| 1296 | 1290 |
| 1297 std::vector<ClientStateNotification<ClientState>*> | 1291 std::vector<ClientStateNotification<ClientState>*> notes( |
| 1298 notes(num_concurrent_decoders, NULL); | 1292 num_concurrent_decoders, NULL); |
| 1299 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); | 1293 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); |
| 1300 | 1294 |
| 1301 RenderingHelperParams helper_params; | 1295 RenderingHelperParams helper_params; |
| 1302 helper_params.rendering_fps = g_rendering_fps; | 1296 helper_params.rendering_fps = g_rendering_fps; |
| 1303 helper_params.warm_up_iterations = g_rendering_warm_up; | 1297 helper_params.warm_up_iterations = g_rendering_warm_up; |
| 1304 helper_params.render_as_thumbnails = render_as_thumbnails; | 1298 helper_params.render_as_thumbnails = render_as_thumbnails; |
| 1305 if (render_as_thumbnails) { | 1299 if (render_as_thumbnails) { |
| 1306 // Only one decoder is supported with thumbnail rendering | 1300 // Only one decoder is supported with thumbnail rendering |
| 1307 LOG_ASSERT(num_concurrent_decoders == 1U); | 1301 LOG_ASSERT(num_concurrent_decoders == 1U); |
| 1308 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1302 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
| 1309 helper_params.thumbnail_size = kThumbnailSize; | 1303 helper_params.thumbnail_size = kThumbnailSize; |
| 1310 } | 1304 } |
| 1311 | 1305 |
| 1312 // First kick off all the decoders. | 1306 // First kick off all the decoders. |
| 1313 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1307 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
| 1314 TestVideoFile* video_file = | 1308 TestVideoFile* video_file = |
| 1315 test_video_files_[index % test_video_files_.size()]; | 1309 test_video_files_[index % test_video_files_.size()]; |
| 1316 ClientStateNotification<ClientState>* note = | 1310 ClientStateNotification<ClientState>* note = |
| 1317 new ClientStateNotification<ClientState>(); | 1311 new ClientStateNotification<ClientState>(); |
| 1318 notes[index] = note; | 1312 notes[index] = note; |
| 1319 | 1313 |
| 1320 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1314 int delay_after_frame_num = std::numeric_limits<int>::max(); |
| 1321 if (test_reuse_delay && | 1315 if (test_reuse_delay && |
| 1322 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1316 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
| 1323 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1317 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
| 1324 } | 1318 } |
| 1325 | 1319 |
| 1326 GLRenderingVDAClient* client = | 1320 GLRenderingVDAClient* client = new GLRenderingVDAClient( |
| 1327 new GLRenderingVDAClient(index, | 1321 index, &rendering_helper_, note, video_file->data_str, |
| 1328 &rendering_helper_, | 1322 num_in_flight_decodes, num_play_throughs, |
| 1329 note, | 1323 video_file->reset_after_frame_num, delete_decoder_state, |
| 1330 video_file->data_str, | 1324 video_file->width, video_file->height, video_file->profile, |
| 1331 num_in_flight_decodes, | 1325 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, |
| 1332 num_play_throughs, | 1326 render_as_thumbnails); |
| 1333 video_file->reset_after_frame_num, | |
| 1334 delete_decoder_state, | |
| 1335 video_file->width, | |
| 1336 video_file->height, | |
| 1337 video_file->profile, | |
| 1338 g_fake_decoder, | |
| 1339 suppress_rendering, | |
| 1340 delay_after_frame_num, | |
| 1341 0, | |
| 1342 render_as_thumbnails); | |
| 1343 | 1327 |
| 1344 clients[index] = client; | 1328 clients[index] = client; |
| 1345 helper_params.window_sizes.push_back( | 1329 helper_params.window_sizes.push_back( |
| 1346 render_as_thumbnails | 1330 render_as_thumbnails |
| 1347 ? kThumbnailsPageSize | 1331 ? kThumbnailsPageSize |
| 1348 : gfx::Size(video_file->width, video_file->height)); | 1332 : gfx::Size(video_file->width, video_file->height)); |
| 1349 } | 1333 } |
| 1350 | 1334 |
| 1351 InitializeRenderingHelper(helper_params); | 1335 InitializeRenderingHelper(helper_params); |
| 1352 | 1336 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 ASSERT_NO_FATAL_FAILURE( | 1371 ASSERT_NO_FATAL_FAILURE( |
| 1388 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); | 1372 AssertWaitForStateOrDeleted(note, clients[i], CS_RESETTING)); |
| 1389 } | 1373 } |
| 1390 ASSERT_NO_FATAL_FAILURE( | 1374 ASSERT_NO_FATAL_FAILURE( |
| 1391 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); | 1375 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); |
| 1392 // ResetDone requests Destroy(). | 1376 // ResetDone requests Destroy(). |
| 1393 ASSERT_NO_FATAL_FAILURE( | 1377 ASSERT_NO_FATAL_FAILURE( |
| 1394 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); | 1378 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); |
| 1395 } | 1379 } |
| 1396 // Finally assert that decoding went as expected. | 1380 // Finally assert that decoding went as expected. |
| 1397 for (size_t i = 0; i < num_concurrent_decoders && | 1381 for (size_t i = 0; |
| 1398 !skip_performance_and_correctness_checks; ++i) { | 1382 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; |
| 1383 ++i) { |
| 1399 // We can only make performance/correctness assertions if the decoder was | 1384 // We can only make performance/correctness assertions if the decoder was |
| 1400 // allowed to finish. | 1385 // allowed to finish. |
| 1401 if (delete_decoder_state < CS_FLUSHED) | 1386 if (delete_decoder_state < CS_FLUSHED) |
| 1402 continue; | 1387 continue; |
| 1403 GLRenderingVDAClient* client = clients[i]; | 1388 GLRenderingVDAClient* client = clients[i]; |
| 1404 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; | 1389 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; |
| 1405 if (video_file->num_frames > 0) { | 1390 if (video_file->num_frames > 0) { |
| 1406 // Expect the decoded frames may be more than the video frames as frames | 1391 // Expect the decoded frames may be more than the video frames as frames |
| 1407 // could still be returned until resetting done. | 1392 // could still be returned until resetting done. |
| 1408 if (video_file->reset_after_frame_num > 0) | 1393 if (video_file->reset_after_frame_num > 0) |
| 1409 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); | 1394 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); |
| 1410 else | 1395 else |
| 1411 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); | 1396 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); |
| 1412 } | 1397 } |
| 1413 if (reset_point == END_OF_STREAM_RESET) { | 1398 if (reset_point == END_OF_STREAM_RESET) { |
| 1414 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + | 1399 EXPECT_EQ(video_file->num_fragments, client->num_skipped_fragments() + |
| 1415 client->num_queued_fragments()); | 1400 client->num_queued_fragments()); |
| 1416 EXPECT_EQ(client->num_done_bitstream_buffers(), | 1401 EXPECT_EQ(client->num_done_bitstream_buffers(), |
| 1417 client->num_queued_fragments()); | 1402 client->num_queued_fragments()); |
| 1418 } | 1403 } |
| 1419 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); | 1404 LOG(INFO) << "Decoder " << i << " fps: " << client->frames_per_second(); |
| 1420 if (!render_as_thumbnails) { | 1405 if (!render_as_thumbnails) { |
| 1421 int min_fps = suppress_rendering ? | 1406 int min_fps = suppress_rendering ? video_file->min_fps_no_render |
| 1422 video_file->min_fps_no_render : video_file->min_fps_render; | 1407 : video_file->min_fps_render; |
| 1423 if (min_fps > 0 && !test_reuse_delay) | 1408 if (min_fps > 0 && !test_reuse_delay) |
| 1424 EXPECT_GT(client->frames_per_second(), min_fps); | 1409 EXPECT_GT(client->frames_per_second(), min_fps); |
| 1425 } | 1410 } |
| 1426 } | 1411 } |
| 1427 | 1412 |
| 1428 if (render_as_thumbnails) { | 1413 if (render_as_thumbnails) { |
| 1429 std::vector<unsigned char> rgb; | 1414 std::vector<unsigned char> rgb; |
| 1430 bool alpha_solid; | 1415 bool alpha_solid; |
| 1431 base::WaitableEvent done(false, false); | 1416 base::WaitableEvent done(false, false); |
| 1432 g_env->GetRenderingTaskRunner()->PostTask( | 1417 g_env->GetRenderingTaskRunner()->PostTask( |
| 1433 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, | 1418 FROM_HERE, base::Bind(&RenderingHelper::GetThumbnailsAsRGB, |
| 1434 base::Unretained(&rendering_helper_), &rgb, | 1419 base::Unretained(&rendering_helper_), &rgb, |
| 1435 &alpha_solid, &done)); | 1420 &alpha_solid, &done)); |
| 1436 done.Wait(); | 1421 done.Wait(); |
| 1437 | 1422 |
| 1438 std::vector<std::string> golden_md5s; | 1423 std::vector<std::string> golden_md5s; |
| 1439 std::string md5_string = base::MD5String( | 1424 std::string md5_string = base::MD5String( |
| 1440 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); | 1425 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); |
| 1441 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); | 1426 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); |
| 1442 std::vector<std::string>::iterator match = | 1427 std::vector<std::string>::iterator match = |
| 1443 find(golden_md5s.begin(), golden_md5s.end(), md5_string); | 1428 find(golden_md5s.begin(), golden_md5s.end(), md5_string); |
| 1444 if (match == golden_md5s.end()) { | 1429 if (match == golden_md5s.end()) { |
| 1445 // Convert raw RGB into PNG for export. | 1430 // Convert raw RGB into PNG for export. |
| 1446 std::vector<unsigned char> png; | 1431 std::vector<unsigned char> png; |
| 1447 gfx::PNGCodec::Encode(&rgb[0], | 1432 gfx::PNGCodec::Encode(&rgb[0], gfx::PNGCodec::FORMAT_RGB, |
| 1448 gfx::PNGCodec::FORMAT_RGB, | |
| 1449 kThumbnailsPageSize, | 1433 kThumbnailsPageSize, |
| 1450 kThumbnailsPageSize.width() * 3, | 1434 kThumbnailsPageSize.width() * 3, true, |
| 1451 true, | 1435 std::vector<gfx::PNGCodec::Comment>(), &png); |
| 1452 std::vector<gfx::PNGCodec::Comment>(), | |
| 1453 &png); | |
| 1454 | 1436 |
| 1455 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1437 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
| 1456 | 1438 |
| 1457 base::FilePath filepath(test_video_files_[0]->file_name); | 1439 base::FilePath filepath(test_video_files_[0]->file_name); |
| 1458 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1440 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
| 1459 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1441 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
| 1460 int num_bytes = base::WriteFile(filepath, | 1442 int num_bytes = base::WriteFile( |
| 1461 reinterpret_cast<char*>(&png[0]), | 1443 filepath, reinterpret_cast<char*>(&png[0]), png.size()); |
| 1462 png.size()); | |
| 1463 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1444 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); |
| 1464 } | 1445 } |
| 1465 ASSERT_NE(match, golden_md5s.end()); | 1446 ASSERT_NE(match, golden_md5s.end()); |
| 1466 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | 1447 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; |
| 1467 } | 1448 } |
| 1468 | 1449 |
| 1469 // Output the frame delivery time to file | 1450 // Output the frame delivery time to file |
| 1470 // We can only make performance/correctness assertions if the decoder was | 1451 // We can only make performance/correctness assertions if the decoder was |
| 1471 // allowed to finish. | 1452 // allowed to finish. |
| 1472 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1453 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1485 g_env->GetRenderingTaskRunner()->PostTask( | 1466 g_env->GetRenderingTaskRunner()->PostTask( |
| 1486 FROM_HERE, | 1467 FROM_HERE, |
| 1487 base::Bind(&STLDeleteElements< | 1468 base::Bind(&STLDeleteElements< |
| 1488 std::vector<ClientStateNotification<ClientState>*>>, | 1469 std::vector<ClientStateNotification<ClientState>*>>, |
| 1489 ¬es)); | 1470 ¬es)); |
| 1490 WaitUntilIdle(); | 1471 WaitUntilIdle(); |
| 1491 }; | 1472 }; |
| 1492 | 1473 |
| 1493 // Test that replay after EOS works fine. | 1474 // Test that replay after EOS works fine. |
| 1494 INSTANTIATE_TEST_CASE_P( | 1475 INSTANTIATE_TEST_CASE_P( |
| 1495 ReplayAfterEOS, VideoDecodeAcceleratorParamTest, | 1476 ReplayAfterEOS, |
| 1477 VideoDecodeAcceleratorParamTest, |
| 1496 ::testing::Values( | 1478 ::testing::Values( |
| 1497 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1479 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1498 | 1480 |
| 1499 // Test that Reset() before the first Decode() works fine. | 1481 // Test that Reset() before the first Decode() works fine. |
| 1500 INSTANTIATE_TEST_CASE_P( | 1482 INSTANTIATE_TEST_CASE_P( |
| 1501 ResetBeforeDecode, VideoDecodeAcceleratorParamTest, | 1483 ResetBeforeDecode, |
| 1484 VideoDecodeAcceleratorParamTest, |
| 1502 ::testing::Values( | 1485 ::testing::Values( |
| 1503 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); | 1486 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1504 | 1487 |
| 1505 // Test Reset() immediately after Decode() containing config info. | 1488 // Test Reset() immediately after Decode() containing config info. |
| 1506 INSTANTIATE_TEST_CASE_P( | 1489 INSTANTIATE_TEST_CASE_P( |
| 1507 ResetAfterFirstConfigInfo, VideoDecodeAcceleratorParamTest, | 1490 ResetAfterFirstConfigInfo, |
| 1508 ::testing::Values( | 1491 VideoDecodeAcceleratorParamTest, |
| 1509 MakeTuple( | 1492 ::testing::Values(MakeTuple(1, |
| 1510 1, 1, 1, RESET_AFTER_FIRST_CONFIG_INFO, CS_RESET, false, false))); | 1493 1, |
| 1494 1, |
| 1495 RESET_AFTER_FIRST_CONFIG_INFO, |
| 1496 CS_RESET, |
| 1497 false, |
| 1498 false))); |
| 1511 | 1499 |
| 1512 // Test that Reset() mid-stream works fine and doesn't affect decoding even when | 1500 // Test that Reset() mid-stream works fine and doesn't affect decoding even when |
| 1513 // Decode() calls are made during the reset. | 1501 // Decode() calls are made during the reset. |
| 1514 INSTANTIATE_TEST_CASE_P( | 1502 INSTANTIATE_TEST_CASE_P( |
| 1515 MidStreamReset, VideoDecodeAcceleratorParamTest, | 1503 MidStreamReset, |
| 1504 VideoDecodeAcceleratorParamTest, |
| 1516 ::testing::Values( | 1505 ::testing::Values( |
| 1517 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); | 1506 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); |
| 1518 | 1507 |
| 1519 INSTANTIATE_TEST_CASE_P( | 1508 INSTANTIATE_TEST_CASE_P( |
| 1520 SlowRendering, VideoDecodeAcceleratorParamTest, | 1509 SlowRendering, |
| 1510 VideoDecodeAcceleratorParamTest, |
| 1521 ::testing::Values( | 1511 ::testing::Values( |
| 1522 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); | 1512 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); |
| 1523 | 1513 |
| 1524 // Test that Destroy() mid-stream works fine (primarily this is testing that no | 1514 // Test that Destroy() mid-stream works fine (primarily this is testing that no |
| 1525 // crashes occur). | 1515 // crashes occur). |
| 1526 INSTANTIATE_TEST_CASE_P( | 1516 INSTANTIATE_TEST_CASE_P( |
| 1527 TearDownTiming, VideoDecodeAcceleratorParamTest, | 1517 TearDownTiming, |
| 1518 VideoDecodeAcceleratorParamTest, |
| 1528 ::testing::Values( | 1519 ::testing::Values( |
| 1529 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), | 1520 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), |
| 1530 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), | 1521 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), |
| 1531 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), | 1522 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), |
| 1532 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), | 1523 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), |
| 1533 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), | 1524 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), |
| 1534 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1525 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1535 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1526 MakeTuple(1, |
| 1536 static_cast<ClientState>(-1), false, false), | 1527 1, |
| 1537 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1528 1, |
| 1538 static_cast<ClientState>(-10), false, false), | 1529 END_OF_STREAM_RESET, |
| 1539 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, | 1530 static_cast<ClientState>(-1), |
| 1540 static_cast<ClientState>(-100), false, false))); | 1531 false, |
| 1532 false), |
| 1533 MakeTuple(1, |
| 1534 1, |
| 1535 1, |
| 1536 END_OF_STREAM_RESET, |
| 1537 static_cast<ClientState>(-10), |
| 1538 false, |
| 1539 false), |
| 1540 MakeTuple(1, |
| 1541 1, |
| 1542 1, |
| 1543 END_OF_STREAM_RESET, |
| 1544 static_cast<ClientState>(-100), |
| 1545 false, |
| 1546 false))); |
| 1541 | 1547 |
| 1542 // Test that decoding various variation works with multiple in-flight decodes. | 1548 // Test that decoding various variation works with multiple in-flight decodes. |
| 1543 INSTANTIATE_TEST_CASE_P( | 1549 INSTANTIATE_TEST_CASE_P( |
| 1544 DecodeVariations, VideoDecodeAcceleratorParamTest, | 1550 DecodeVariations, |
| 1551 VideoDecodeAcceleratorParamTest, |
| 1545 ::testing::Values( | 1552 ::testing::Values( |
| 1546 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1553 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1547 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), | 1554 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), |
| 1548 // Tests queuing. | 1555 // Tests queuing. |
| 1549 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1556 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); |
| 1550 | 1557 |
| 1551 // Find out how many concurrent decoders can go before we exhaust system | 1558 // Find out how many concurrent decoders can go before we exhaust system |
| 1552 // resources. | 1559 // resources. |
| 1553 INSTANTIATE_TEST_CASE_P( | 1560 INSTANTIATE_TEST_CASE_P(ResourceExhaustion, |
| 1554 ResourceExhaustion, VideoDecodeAcceleratorParamTest, | 1561 VideoDecodeAcceleratorParamTest, |
| 1555 ::testing::Values( | 1562 ::testing::Values( |
| 1556 // +0 hack below to promote enum to int. | 1563 // +0 hack below to promote enum to int. |
| 1557 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1, 1, | 1564 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, |
| 1558 END_OF_STREAM_RESET, CS_RESET, false, false), | 1565 1, |
| 1559 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1, 1, | 1566 1, |
| 1560 END_OF_STREAM_RESET, CS_RESET, false, false))); | 1567 END_OF_STREAM_RESET, |
| 1568 CS_RESET, |
| 1569 false, |
| 1570 false), |
| 1571 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, |
| 1572 1, |
| 1573 1, |
| 1574 END_OF_STREAM_RESET, |
| 1575 CS_RESET, |
| 1576 false, |
| 1577 false))); |
| 1561 | 1578 |
| 1562 // Thumbnailing test | 1579 // Thumbnailing test |
| 1563 INSTANTIATE_TEST_CASE_P( | 1580 INSTANTIATE_TEST_CASE_P( |
| 1564 Thumbnail, VideoDecodeAcceleratorParamTest, | 1581 Thumbnail, |
| 1582 VideoDecodeAcceleratorParamTest, |
| 1565 ::testing::Values( | 1583 ::testing::Values( |
| 1566 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); | 1584 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); |
| 1567 | 1585 |
| 1568 // Measure the median of the decode time when VDA::Decode is called 30 times per | 1586 // Measure the median of the decode time when VDA::Decode is called 30 times per |
| 1569 // second. | 1587 // second. |
| 1570 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | 1588 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| 1571 RenderingHelperParams helper_params; | 1589 RenderingHelperParams helper_params; |
| 1572 | 1590 |
| 1573 // Disable rendering by setting the rendering_fps = 0. | 1591 // Disable rendering by setting the rendering_fps = 0. |
| 1574 helper_params.rendering_fps = 0; | 1592 helper_params.rendering_fps = 0; |
| 1575 helper_params.warm_up_iterations = 0; | 1593 helper_params.warm_up_iterations = 0; |
| 1576 helper_params.render_as_thumbnails = false; | 1594 helper_params.render_as_thumbnails = false; |
| 1577 | 1595 |
| 1578 ClientStateNotification<ClientState>* note = | 1596 ClientStateNotification<ClientState>* note = |
| 1579 new ClientStateNotification<ClientState>(); | 1597 new ClientStateNotification<ClientState>(); |
| 1580 GLRenderingVDAClient* client = | 1598 GLRenderingVDAClient* client = new GLRenderingVDAClient( |
| 1581 new GLRenderingVDAClient(0, | 1599 0, &rendering_helper_, note, test_video_files_[0]->data_str, 1, 1, |
| 1582 &rendering_helper_, | 1600 test_video_files_[0]->reset_after_frame_num, CS_RESET, |
| 1583 note, | 1601 test_video_files_[0]->width, test_video_files_[0]->height, |
| 1584 test_video_files_[0]->data_str, | 1602 test_video_files_[0]->profile, g_fake_decoder, true, |
| 1585 1, | 1603 std::numeric_limits<int>::max(), kWebRtcDecodeCallsPerSecond, |
| 1586 1, | 1604 false /* render_as_thumbnail */); |
| 1587 test_video_files_[0]->reset_after_frame_num, | |
| 1588 CS_RESET, | |
| 1589 test_video_files_[0]->width, | |
| 1590 test_video_files_[0]->height, | |
| 1591 test_video_files_[0]->profile, | |
| 1592 g_fake_decoder, | |
| 1593 true, | |
| 1594 std::numeric_limits<int>::max(), | |
| 1595 kWebRtcDecodeCallsPerSecond, | |
| 1596 false /* render_as_thumbnail */); | |
| 1597 helper_params.window_sizes.push_back( | 1605 helper_params.window_sizes.push_back( |
| 1598 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); | 1606 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
| 1599 InitializeRenderingHelper(helper_params); | 1607 InitializeRenderingHelper(helper_params); |
| 1600 CreateAndStartDecoder(client, note); | 1608 CreateAndStartDecoder(client, note); |
| 1601 WaitUntilDecodeFinish(note); | 1609 WaitUntilDecodeFinish(note); |
| 1602 | 1610 |
| 1603 base::TimeDelta decode_time_median = client->decode_time_median(); | 1611 base::TimeDelta decode_time_median = client->decode_time_median(); |
| 1604 std::string output_string = | 1612 std::string output_string = |
| 1605 base::StringPrintf("Decode time median: %" PRId64 " us", | 1613 base::StringPrintf("Decode time median: %" PRId64 " us", |
| 1606 decode_time_median.InMicroseconds()); | 1614 decode_time_median.InMicroseconds()); |
| 1607 LOG(INFO) << output_string; | 1615 LOG(INFO) << output_string; |
| 1608 | 1616 |
| 1609 if (g_output_log != NULL) | 1617 if (g_output_log != NULL) |
| 1610 OutputLogFile(g_output_log, output_string); | 1618 OutputLogFile(g_output_log, output_string); |
| 1611 | 1619 |
| 1612 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client); | 1620 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, client); |
| 1613 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); | 1621 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); |
| 1614 WaitUntilIdle(); | 1622 WaitUntilIdle(); |
| 1615 }; | 1623 }; |
| 1616 | 1624 |
| 1617 // TODO(fischman, vrk): add more tests! In particular: | 1625 // TODO(fischman, vrk): add more tests! In particular: |
| 1618 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. | 1626 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. |
| 1619 // - Test alternate configurations | 1627 // - Test alternate configurations |
| 1620 // - Test failure conditions. | 1628 // - Test failure conditions. |
| 1621 // - Test frame size changes mid-stream | 1629 // - Test frame size changes mid-stream |
| 1622 | 1630 |
| 1623 } // namespace | 1631 } // namespace |
| 1624 } // namespace content | 1632 } // namespace media |
| 1625 | 1633 |
| 1626 int main(int argc, char **argv) { | 1634 int main(int argc, char** argv) { |
| 1627 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. | 1635 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. |
| 1628 base::CommandLine::Init(argc, argv); | 1636 base::CommandLine::Init(argc, argv); |
| 1629 | 1637 |
| 1630 // Needed to enable DVLOG through --vmodule. | 1638 // Needed to enable DVLOG through --vmodule. |
| 1631 logging::LoggingSettings settings; | 1639 logging::LoggingSettings settings; |
| 1632 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 1640 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 1633 LOG_ASSERT(logging::InitLogging(settings)); | 1641 LOG_ASSERT(logging::InitLogging(settings)); |
| 1634 | 1642 |
| 1635 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1643 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1636 DCHECK(cmd_line); | 1644 DCHECK(cmd_line); |
| 1637 | 1645 |
| 1638 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 1646 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
| 1639 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); | 1647 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 1640 it != switches.end(); ++it) { | 1648 it != switches.end(); ++it) { |
| 1641 if (it->first == "test_video_data") { | 1649 if (it->first == "test_video_data") { |
| 1642 content::g_test_video_data = it->second.c_str(); | 1650 media::g_test_video_data = it->second.c_str(); |
| 1643 continue; | 1651 continue; |
| 1644 } | 1652 } |
| 1645 // The output log for VDA performance test. | 1653 // The output log for VDA performance test. |
| 1646 if (it->first == "output_log") { | 1654 if (it->first == "output_log") { |
| 1647 content::g_output_log = it->second.c_str(); | 1655 media::g_output_log = it->second.c_str(); |
| 1648 continue; | 1656 continue; |
| 1649 } | 1657 } |
| 1650 if (it->first == "rendering_fps") { | 1658 if (it->first == "rendering_fps") { |
| 1651 // On Windows, CommandLine::StringType is wstring. We need to convert | 1659 // On Windows, CommandLine::StringType is wstring. We need to convert |
| 1652 // it to std::string first | 1660 // it to std::string first |
| 1653 std::string input(it->second.begin(), it->second.end()); | 1661 std::string input(it->second.begin(), it->second.end()); |
| 1654 LOG_ASSERT(base::StringToDouble(input, &content::g_rendering_fps)); | 1662 LOG_ASSERT(base::StringToDouble(input, &media::g_rendering_fps)); |
| 1655 continue; | 1663 continue; |
| 1656 } | 1664 } |
| 1657 if (it->first == "rendering_warm_up") { | 1665 if (it->first == "rendering_warm_up") { |
| 1658 std::string input(it->second.begin(), it->second.end()); | 1666 std::string input(it->second.begin(), it->second.end()); |
| 1659 LOG_ASSERT(base::StringToInt(input, &content::g_rendering_warm_up)); | 1667 LOG_ASSERT(base::StringToInt(input, &media::g_rendering_warm_up)); |
| 1660 continue; | 1668 continue; |
| 1661 } | 1669 } |
| 1662 // TODO(owenlin): Remove this flag once it is not used in autotest. | 1670 // TODO(owenlin): Remove this flag once it is not used in autotest. |
| 1663 if (it->first == "disable_rendering") { | 1671 if (it->first == "disable_rendering") { |
| 1664 content::g_rendering_fps = 0; | 1672 media::g_rendering_fps = 0; |
| 1665 continue; | 1673 continue; |
| 1666 } | 1674 } |
| 1667 | 1675 |
| 1668 if (it->first == "num_play_throughs") { | 1676 if (it->first == "num_play_throughs") { |
| 1669 std::string input(it->second.begin(), it->second.end()); | 1677 std::string input(it->second.begin(), it->second.end()); |
| 1670 LOG_ASSERT(base::StringToInt(input, &content::g_num_play_throughs)); | 1678 LOG_ASSERT(base::StringToInt(input, &media::g_num_play_throughs)); |
| 1671 continue; | 1679 continue; |
| 1672 } | 1680 } |
| 1673 if (it->first == "fake_decoder") { | 1681 if (it->first == "fake_decoder") { |
| 1674 content::g_fake_decoder = 1; | 1682 media::g_fake_decoder = 1; |
| 1675 continue; | 1683 continue; |
| 1676 } | 1684 } |
| 1677 if (it->first == "v" || it->first == "vmodule") | 1685 if (it->first == "v" || it->first == "vmodule") |
| 1678 continue; | 1686 continue; |
| 1679 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") | 1687 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") |
| 1680 continue; | 1688 continue; |
| 1681 if (it->first == "test_import") { | 1689 if (it->first == "test_import") { |
| 1682 content::g_test_import = true; | 1690 media::g_test_import = true; |
| 1683 continue; | 1691 continue; |
| 1684 } | 1692 } |
| 1685 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1693 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1686 } | 1694 } |
| 1687 | 1695 |
| 1688 base::ShadowingAtExitManager at_exit_manager; | 1696 base::ShadowingAtExitManager at_exit_manager; |
| 1689 #if defined(OS_WIN) || defined(USE_OZONE) | 1697 #if defined(OS_WIN) || defined(USE_OZONE) |
| 1690 // For windows the decoding thread initializes the media foundation decoder | 1698 // For windows the decoding thread initializes the media foundation decoder |
| 1691 // which uses COM. We need the thread to be a UI thread. | 1699 // which uses COM. We need the thread to be a UI thread. |
| 1692 // On Ozone, the backend initializes the event system using a UI | 1700 // On Ozone, the backend initializes the event system using a UI |
| 1693 // thread. | 1701 // thread. |
| 1694 base::MessageLoopForUI main_loop; | 1702 base::MessageLoopForUI main_loop; |
| 1695 #else | 1703 #else |
| 1696 base::MessageLoop main_loop; | 1704 base::MessageLoop main_loop; |
| 1697 #endif // OS_WIN || USE_OZONE | 1705 #endif // OS_WIN || USE_OZONE |
| 1698 | 1706 |
| 1699 #if defined(USE_OZONE) | 1707 #if defined(USE_OZONE) |
| 1700 ui::OzonePlatform::InitializeForUI(); | 1708 ui::OzonePlatform::InitializeForUI(); |
| 1701 #endif | 1709 #endif |
| 1702 | 1710 |
| 1703 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 1711 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 1704 content::VaapiWrapper::PreSandboxInitialization(); | 1712 media::VaapiWrapper::PreSandboxInitialization(); |
| 1705 #endif | 1713 #endif |
| 1706 | 1714 |
| 1707 content::g_env = | 1715 media::g_env = |
| 1708 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( | 1716 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
| 1709 testing::AddGlobalTestEnvironment( | 1717 testing::AddGlobalTestEnvironment( |
| 1710 new content::VideoDecodeAcceleratorTestEnvironment())); | 1718 new media::VideoDecodeAcceleratorTestEnvironment())); |
| 1711 | 1719 |
| 1712 return RUN_ALL_TESTS(); | 1720 return RUN_ALL_TESTS(); |
| 1713 } | 1721 } |
| OLD | NEW |