Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 // This is http://code.google.com/p/googletest/issues/detail?id=371 | 27 // This is http://code.google.com/p/googletest/issues/detail?id=371 |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 #include "base/at_exit.h" | 30 #include "base/at_exit.h" |
| 31 #include "base/bind.h" | 31 #include "base/bind.h" |
| 32 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| 33 #include "base/files/file.h" | 33 #include "base/files/file.h" |
| 34 #include "base/files/file_util.h" | 34 #include "base/files/file_util.h" |
| 35 #include "base/format_macros.h" | 35 #include "base/format_macros.h" |
| 36 #include "base/md5.h" | 36 #include "base/md5.h" |
| 37 #include "base/message_loop/message_loop.h" | |
|
Owen Lin
2014/11/03 06:59:06
Why these header files are included now ?
llandwerlin-old
2014/11/04 16:16:28
Removing.
| |
| 37 #include "base/message_loop/message_loop_proxy.h" | 38 #include "base/message_loop/message_loop_proxy.h" |
| 39 #include "base/message_loop/message_pump_libevent.h" | |
| 40 #include "base/process/process.h" | |
| 38 #include "base/process/process_handle.h" | 41 #include "base/process/process_handle.h" |
| 39 #include "base/stl_util.h" | 42 #include "base/stl_util.h" |
| 40 #include "base/strings/string_number_conversions.h" | 43 #include "base/strings/string_number_conversions.h" |
| 41 #include "base/strings/string_split.h" | 44 #include "base/strings/string_split.h" |
| 42 #include "base/strings/stringize_macros.h" | 45 #include "base/strings/stringize_macros.h" |
| 43 #include "base/strings/stringprintf.h" | 46 #include "base/strings/stringprintf.h" |
| 44 #include "base/strings/utf_string_conversions.h" | 47 #include "base/strings/utf_string_conversions.h" |
| 45 #include "base/synchronization/condition_variable.h" | 48 #include "base/synchronization/condition_variable.h" |
| 46 #include "base/synchronization/lock.h" | 49 #include "base/synchronization/lock.h" |
| 47 #include "base/synchronization/waitable_event.h" | 50 #include "base/synchronization/waitable_event.h" |
| 48 #include "base/threading/thread.h" | 51 #include "base/threading/thread.h" |
| 49 #include "content/common/gpu/media/rendering_helper.h" | 52 #include "content/common/gpu/media/rendering_helper.h" |
| 50 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" | 53 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" |
| 51 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
| 52 #include "media/filters/h264_parser.h" | 55 #include "media/filters/h264_parser.h" |
| 53 #include "ui/gfx/codec/png_codec.h" | 56 #include "ui/gfx/codec/png_codec.h" |
| 54 | 57 |
| 55 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 56 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 59 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 57 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 58 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 61 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| 59 #include "content/common/gpu/media/v4l2_video_device.h" | 62 #include "content/common/gpu/media/v4l2_video_device.h" |
| 60 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 63 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 61 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 64 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| 62 #include "content/common/gpu/media/vaapi_wrapper.h" | 65 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 63 #if defined(USE_X11) | |
| 64 #include "ui/gl/gl_implementation.h" | |
| 65 #endif // USE_X11 | |
| 66 #else | 66 #else |
| 67 #error The VideoAccelerator tests are not supported on this platform. | 67 #error The VideoAccelerator tests are not supported on this platform. |
| 68 #endif // OS_WIN | 68 #endif // OS_WIN |
| 69 | 69 |
| 70 using media::VideoDecodeAccelerator; | 70 using media::VideoDecodeAccelerator; |
| 71 | 71 |
| 72 namespace content { | 72 namespace content { |
| 73 namespace { | 73 namespace { |
| 74 | 74 |
| 75 // Values optionally filled in from flags; see main() below. | 75 // Values optionally filled in from flags; see main() below. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 94 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); | 94 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); |
| 95 | 95 |
| 96 // The file path of the test output log. This is used to communicate the test | 96 // The file path of the test output log. This is used to communicate the test |
| 97 // results to CrOS autotests. We can enable the log and specify the filename by | 97 // results to CrOS autotests. We can enable the log and specify the filename by |
| 98 // the "--output_log" switch. | 98 // the "--output_log" switch. |
| 99 const base::FilePath::CharType* g_output_log = NULL; | 99 const base::FilePath::CharType* g_output_log = NULL; |
| 100 | 100 |
| 101 // The value is set by the switch "--rendering_fps". | 101 // The value is set by the switch "--rendering_fps". |
| 102 double g_rendering_fps = 60; | 102 double g_rendering_fps = 60; |
| 103 | 103 |
| 104 // The value is set by the switch "--rendering_warm_up". | 104 // The value is set by the switch "--rendering_warm_up". We need at |
| 105 int g_rendering_warm_up = 0; | 105 // least one frame for backends like Ozone, because as opposed to the |
|
Owen Lin
2014/11/03 06:59:06
I think we should move the code into rendering hel
llandwerlin-old
2014/11/03 09:30:11
Acknowledged.
| |
| 106 // X11 backend, the compositor has been started yet and can't provide | |
| 107 // any information about the vsync interval. | |
| 108 int g_rendering_warm_up = 1; | |
| 106 | 109 |
| 107 // Magic constants for differentiating the reasons for NotifyResetDone being | 110 // Magic constants for differentiating the reasons for NotifyResetDone being |
| 108 // called. | 111 // called. |
| 109 enum ResetPoint { | 112 enum ResetPoint { |
| 110 // Reset() just after calling Decode() with a fragment containing config info. | 113 // Reset() just after calling Decode() with a fragment containing config info. |
| 111 RESET_AFTER_FIRST_CONFIG_INFO = -4, | 114 RESET_AFTER_FIRST_CONFIG_INFO = -4, |
| 112 START_OF_STREAM_RESET = -3, | 115 START_OF_STREAM_RESET = -3, |
| 113 MID_STREAM_RESET = -2, | 116 MID_STREAM_RESET = -2, |
| 114 END_OF_STREAM_RESET = -1 | 117 END_OF_STREAM_RESET = -1 |
| 115 }; | 118 }; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); | 401 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); |
| 399 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 402 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 400 | 403 |
| 401 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 404 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
| 402 if (!device.get()) { | 405 if (!device.get()) { |
| 403 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 406 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 404 return; | 407 return; |
| 405 } | 408 } |
| 406 decoder_.reset(new V4L2VideoDecodeAccelerator( | 409 decoder_.reset(new V4L2VideoDecodeAccelerator( |
| 407 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), | 410 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), |
| 408 static_cast<EGLContext>(rendering_helper_->GetGLContext()), | 411 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), |
| 409 weak_client, | 412 weak_client, |
| 410 base::Bind(&DoNothingReturnTrue), | 413 base::Bind(&DoNothingReturnTrue), |
| 411 device.Pass(), | 414 device.Pass(), |
| 412 base::MessageLoopProxy::current())); | 415 base::MessageLoopProxy::current())); |
| 413 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 416 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 414 CHECK_EQ(gfx::kGLImplementationDesktopGL, gfx::GetGLImplementation()) | 417 decoder_.reset( |
| 415 << "Hardware video decode does not work with OSMesa"; | 418 new VaapiVideoDecodeAccelerator(rendering_helper_->GetGLContext().get(), |
| 416 decoder_.reset(new VaapiVideoDecodeAccelerator( | 419 base::Bind(&DoNothingReturnTrue))); |
| 417 static_cast<Display*>(rendering_helper_->GetGLDisplay()), | |
| 418 base::Bind(&DoNothingReturnTrue))); | |
| 419 #endif // OS_WIN | 420 #endif // OS_WIN |
| 420 CHECK(decoder_.get()); | 421 CHECK(decoder_.get()); |
| 421 weak_decoder_factory_.reset( | 422 weak_decoder_factory_.reset( |
| 422 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); | 423 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); |
| 423 SetState(CS_DECODER_SET); | 424 SetState(CS_DECODER_SET); |
| 424 if (decoder_deleted()) | 425 if (decoder_deleted()) |
| 425 return; | 426 return; |
| 426 | 427 |
| 427 CHECK(decoder_->Initialize(profile_, client)); | 428 CHECK(decoder_->Initialize(profile_, client)); |
| 428 FinishInitialization(); | 429 FinishInitialization(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 | 867 |
| 867 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() | 868 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() |
| 868 : rendering_thread_("GLRenderingVDAClientThread") {} | 869 : rendering_thread_("GLRenderingVDAClientThread") {} |
| 869 | 870 |
| 870 void VideoDecodeAcceleratorTest::SetUp() { | 871 void VideoDecodeAcceleratorTest::SetUp() { |
| 871 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 872 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
| 872 | 873 |
| 873 // Initialize the rendering thread. | 874 // Initialize the rendering thread. |
| 874 base::Thread::Options options; | 875 base::Thread::Options options; |
| 875 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 876 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 876 #if defined(OS_WIN) | 877 #if defined(OS_WIN) || defined(USE_OZONE) |
| 877 // For windows the decoding thread initializes the media foundation decoder | 878 // For windows the decoding thread initializes the media foundation decoder |
| 878 // which uses COM. We need the thread to be a UI thread. | 879 // which uses COM. We need the thread to be a UI thread. |
| 880 // On Ozone, the backend initializes the event system using a UI | |
| 881 // thread. | |
| 879 options.message_loop_type = base::MessageLoop::TYPE_UI; | 882 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 880 #endif // OS_WIN | 883 #endif // OS_WIN || USE_OZONE |
| 881 | 884 |
| 882 rendering_thread_.StartWithOptions(options); | 885 rendering_thread_.StartWithOptions(options); |
| 883 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); | 886 rendering_loop_proxy_ = rendering_thread_.message_loop_proxy(); |
| 884 } | 887 } |
| 885 | 888 |
| 886 void VideoDecodeAcceleratorTest::TearDown() { | 889 void VideoDecodeAcceleratorTest::TearDown() { |
| 887 rendering_loop_proxy_->PostTask( | 890 rendering_loop_proxy_->PostTask( |
| 888 FROM_HERE, | 891 FROM_HERE, |
| 889 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, | 892 base::Bind(&STLDeleteElements<std::vector<TestVideoFile*> >, |
| 890 &test_video_files_)); | 893 &test_video_files_)); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1074 RenderingHelperParams helper_params; | 1077 RenderingHelperParams helper_params; |
| 1075 helper_params.rendering_fps = g_rendering_fps; | 1078 helper_params.rendering_fps = g_rendering_fps; |
| 1076 helper_params.warm_up_iterations = g_rendering_warm_up; | 1079 helper_params.warm_up_iterations = g_rendering_warm_up; |
| 1077 helper_params.render_as_thumbnails = render_as_thumbnails; | 1080 helper_params.render_as_thumbnails = render_as_thumbnails; |
| 1078 if (render_as_thumbnails) { | 1081 if (render_as_thumbnails) { |
| 1079 // Only one decoder is supported with thumbnail rendering | 1082 // Only one decoder is supported with thumbnail rendering |
| 1080 CHECK_EQ(num_concurrent_decoders, 1U); | 1083 CHECK_EQ(num_concurrent_decoders, 1U); |
| 1081 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1084 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
| 1082 helper_params.thumbnail_size = kThumbnailSize; | 1085 helper_params.thumbnail_size = kThumbnailSize; |
| 1083 } | 1086 } |
| 1087 helper_params.suppress_rendering = suppress_rendering; | |
| 1084 | 1088 |
| 1085 // First kick off all the decoders. | 1089 // First kick off all the decoders. |
| 1086 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1090 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
| 1087 TestVideoFile* video_file = | 1091 TestVideoFile* video_file = |
| 1088 test_video_files_[index % test_video_files_.size()]; | 1092 test_video_files_[index % test_video_files_.size()]; |
| 1089 ClientStateNotification<ClientState>* note = | 1093 ClientStateNotification<ClientState>* note = |
| 1090 new ClientStateNotification<ClientState>(); | 1094 new ClientStateNotification<ClientState>(); |
| 1091 notes[index] = note; | 1095 notes[index] = note; |
| 1092 | 1096 |
| 1093 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1097 int delay_after_frame_num = std::numeric_limits<int>::max(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1340 | 1344 |
| 1341 // Measure the median of the decode time when VDA::Decode is called 30 times per | 1345 // Measure the median of the decode time when VDA::Decode is called 30 times per |
| 1342 // second. | 1346 // second. |
| 1343 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | 1347 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| 1344 RenderingHelperParams helper_params; | 1348 RenderingHelperParams helper_params; |
| 1345 | 1349 |
| 1346 // Disable rendering by setting the rendering_fps = 0. | 1350 // Disable rendering by setting the rendering_fps = 0. |
| 1347 helper_params.rendering_fps = 0; | 1351 helper_params.rendering_fps = 0; |
| 1348 helper_params.warm_up_iterations = 0; | 1352 helper_params.warm_up_iterations = 0; |
| 1349 helper_params.render_as_thumbnails = false; | 1353 helper_params.render_as_thumbnails = false; |
| 1354 helper_params.suppress_rendering = true; | |
|
Owen Lin
2014/11/03 06:59:06
rendering_fps == 0 indicates supporess_rendering.
llandwerlin-old
2014/11/03 09:30:11
Acknowledged.
| |
| 1350 | 1355 |
| 1351 ClientStateNotification<ClientState>* note = | 1356 ClientStateNotification<ClientState>* note = |
| 1352 new ClientStateNotification<ClientState>(); | 1357 new ClientStateNotification<ClientState>(); |
| 1353 GLRenderingVDAClient* client = | 1358 GLRenderingVDAClient* client = |
| 1354 new GLRenderingVDAClient(0, | 1359 new GLRenderingVDAClient(0, |
| 1355 &rendering_helper_, | 1360 &rendering_helper_, |
| 1356 note, | 1361 note, |
| 1357 test_video_files_[0]->data_str, | 1362 test_video_files_[0]->data_str, |
| 1358 1, | 1363 1, |
| 1359 1, | 1364 1, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 CHECK(base::StringToInt(input, &content::g_rendering_warm_up)); | 1436 CHECK(base::StringToInt(input, &content::g_rendering_warm_up)); |
| 1432 continue; | 1437 continue; |
| 1433 } | 1438 } |
| 1434 // TODO(owenlin): Remove this flag once it is not used in autotest. | 1439 // TODO(owenlin): Remove this flag once it is not used in autotest. |
| 1435 if (it->first == "disable_rendering") { | 1440 if (it->first == "disable_rendering") { |
| 1436 content::g_rendering_fps = 0; | 1441 content::g_rendering_fps = 0; |
| 1437 continue; | 1442 continue; |
| 1438 } | 1443 } |
| 1439 if (it->first == "v" || it->first == "vmodule") | 1444 if (it->first == "v" || it->first == "vmodule") |
| 1440 continue; | 1445 continue; |
| 1446 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") | |
| 1447 continue; | |
| 1441 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 1448 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 1442 } | 1449 } |
| 1443 | 1450 |
| 1444 base::ShadowingAtExitManager at_exit_manager; | 1451 base::ShadowingAtExitManager at_exit_manager; |
| 1445 content::RenderingHelper::InitializeOneOff(); | 1452 content::RenderingHelper::InitializeOneOff(); |
| 1446 | 1453 |
| 1447 return RUN_ALL_TESTS(); | 1454 return RUN_ALL_TESTS(); |
| 1448 } | 1455 } |
| OLD | NEW |