| 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 26 matching lines...) Expand all Loading... |
| 37 #include "base/synchronization/condition_variable.h" | 37 #include "base/synchronization/condition_variable.h" |
| 38 #include "base/synchronization/lock.h" | 38 #include "base/synchronization/lock.h" |
| 39 #include "base/synchronization/waitable_event.h" | 39 #include "base/synchronization/waitable_event.h" |
| 40 #include "base/threading/thread.h" | 40 #include "base/threading/thread.h" |
| 41 #include "base/utf_string_conversions.h" | 41 #include "base/utf_string_conversions.h" |
| 42 #include "content/common/gpu/media/rendering_helper.h" | 42 #include "content/common/gpu/media/rendering_helper.h" |
| 43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 44 | 44 |
| 45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 46 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 46 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 47 #elif defined(OS_MACOSX) | |
| 48 #include "content/common/gpu/media/mac_video_decode_accelerator.h" | |
| 49 #elif defined(OS_CHROMEOS) | 47 #elif defined(OS_CHROMEOS) |
| 50 #if defined(ARCH_CPU_ARMEL) | 48 #if defined(ARCH_CPU_ARMEL) |
| 51 #include "content/common/gpu/media/exynos_video_decode_accelerator.h" | 49 #include "content/common/gpu/media/exynos_video_decode_accelerator.h" |
| 52 #elif defined(ARCH_CPU_X86_FAMILY) | 50 #elif defined(ARCH_CPU_X86_FAMILY) |
| 53 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 51 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
| 54 #endif // ARCH_CPU_ARMEL | 52 #endif // ARCH_CPU_ARMEL |
| 55 #else | 53 #else |
| 56 #error The VideoAccelerator tests are not supported on this platform. | 54 #error The VideoAccelerator tests are not supported on this platform. |
| 57 #endif // OS_WIN | 55 #endif // OS_WIN |
| 58 | 56 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 // where only the first field is required. Value details: | 69 // where only the first field is required. Value details: |
| 72 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8 stream. | 70 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8 stream. |
| 73 // - |width| and |height| are in pixels. | 71 // - |width| and |height| are in pixels. |
| 74 // - |numframes| is the number of picture frames in the file. | 72 // - |numframes| is the number of picture frames in the file. |
| 75 // - |numfragments| NALU (h264) or frame (VP8) count in the stream. | 73 // - |numfragments| NALU (h264) or frame (VP8) count in the stream. |
| 76 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds | 74 // - |minFPSwithRender| and |minFPSnoRender| are minimum frames/second speeds |
| 77 // expected to be achieved with and without rendering to the screen, resp. | 75 // expected to be achieved with and without rendering to the screen, resp. |
| 78 // (the latter tests just decode speed). | 76 // (the latter tests just decode speed). |
| 79 // - |profile| is the media::VideoCodecProfile set during Initialization. | 77 // - |profile| is the media::VideoCodecProfile set during Initialization. |
| 80 // An empty value for a numeric field means "ignore". | 78 // An empty value for a numeric field means "ignore". |
| 81 #if defined(OS_MACOSX) | |
| 82 const base::FilePath::CharType* test_video_data = | |
| 83 FILE_PATH_LITERAL("test-25fps_high.h264:1280:720:250:252:50:100:4"); | |
| 84 #else | |
| 85 const base::FilePath::CharType* test_video_data = | 79 const base::FilePath::CharType* test_video_data = |
| 86 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); | 80 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); |
| 87 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); | 81 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); |
| 88 #endif | |
| 89 | 82 |
| 90 struct TestVideoFile { | 83 struct TestVideoFile { |
| 91 explicit TestVideoFile(base::FilePath::StringType file_name) | 84 explicit TestVideoFile(base::FilePath::StringType file_name) |
| 92 : file_name(file_name), | 85 : file_name(file_name), |
| 93 width(-1), | 86 width(-1), |
| 94 height(-1), | 87 height(-1), |
| 95 num_frames(-1), | 88 num_frames(-1), |
| 96 num_fragments(-1), | 89 num_fragments(-1), |
| 97 min_fps_render(-1), | 90 min_fps_render(-1), |
| 98 min_fps_no_render(-1), | 91 min_fps_no_render(-1), |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 CHECK_GT(num_play_throughs, 0); | 346 CHECK_GT(num_play_throughs, 0); |
| 354 } | 347 } |
| 355 | 348 |
| 356 GLRenderingVDAClient::~GLRenderingVDAClient() { | 349 GLRenderingVDAClient::~GLRenderingVDAClient() { |
| 357 DeleteDecoder(); // Clean up in case of expected error. | 350 DeleteDecoder(); // Clean up in case of expected error. |
| 358 CHECK(decoder_deleted()); | 351 CHECK(decoder_deleted()); |
| 359 STLDeleteValues(&picture_buffers_by_id_); | 352 STLDeleteValues(&picture_buffers_by_id_); |
| 360 SetState(CS_DESTROYED); | 353 SetState(CS_DESTROYED); |
| 361 } | 354 } |
| 362 | 355 |
| 363 #if !defined(OS_MACOSX) | |
| 364 static bool DoNothingReturnTrue() { return true; } | 356 static bool DoNothingReturnTrue() { return true; } |
| 365 #endif | |
| 366 | 357 |
| 367 void GLRenderingVDAClient::CreateDecoder() { | 358 void GLRenderingVDAClient::CreateDecoder() { |
| 368 CHECK(decoder_deleted()); | 359 CHECK(decoder_deleted()); |
| 369 CHECK(!decoder_.get()); | 360 CHECK(!decoder_.get()); |
| 370 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 371 decoder_.reset(new DXVAVideoDecodeAccelerator( | 362 decoder_.reset(new DXVAVideoDecodeAccelerator( |
| 372 this, base::Bind(&DoNothingReturnTrue))); | 363 this, base::Bind(&DoNothingReturnTrue))); |
| 373 #elif defined(OS_MACOSX) | |
| 374 decoder_.reset(new MacVideoDecodeAccelerator( | |
| 375 static_cast<CGLContextObj>(rendering_helper_->GetGLContext()), this)); | |
| 376 #elif defined(OS_CHROMEOS) | 364 #elif defined(OS_CHROMEOS) |
| 377 #if defined(ARCH_CPU_ARMEL) | 365 #if defined(ARCH_CPU_ARMEL) |
| 378 decoder_.reset( | 366 decoder_.reset( |
| 379 new ExynosVideoDecodeAccelerator( | 367 new ExynosVideoDecodeAccelerator( |
| 380 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), | 368 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), |
| 381 static_cast<EGLContext>(rendering_helper_->GetGLContext()), | 369 static_cast<EGLContext>(rendering_helper_->GetGLContext()), |
| 382 this, base::Bind(&DoNothingReturnTrue))); | 370 this, base::Bind(&DoNothingReturnTrue))); |
| 383 #elif defined(ARCH_CPU_X86_FAMILY) | 371 #elif defined(ARCH_CPU_X86_FAMILY) |
| 384 decoder_.reset(new VaapiVideoDecodeAccelerator( | 372 decoder_.reset(new VaapiVideoDecodeAccelerator( |
| 385 static_cast<Display*>(rendering_helper_->GetGLDisplay()), | 373 static_cast<Display*>(rendering_helper_->GetGLDisplay()), |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 ClientState state = note->Wait(); | 682 ClientState state = note->Wait(); |
| 695 if (state == expected_state) return; | 683 if (state == expected_state) return; |
| 696 ASSERT_TRUE(client->decoder_deleted()) | 684 ASSERT_TRUE(client->decoder_deleted()) |
| 697 << "Decoder not deleted but Wait() returned " << state | 685 << "Decoder not deleted but Wait() returned " << state |
| 698 << ", instead of " << expected_state; | 686 << ", instead of " << expected_state; |
| 699 } | 687 } |
| 700 | 688 |
| 701 // We assert a minimal number of concurrent decoders we expect to succeed. | 689 // We assert a minimal number of concurrent decoders we expect to succeed. |
| 702 // Different platforms can support more concurrent decoders, so we don't assert | 690 // Different platforms can support more concurrent decoders, so we don't assert |
| 703 // failure above this. | 691 // failure above this. |
| 704 #if defined(OS_MACOSX) | |
| 705 enum { kMinSupportedNumConcurrentDecoders = 1 }; | |
| 706 #else | |
| 707 enum { kMinSupportedNumConcurrentDecoders = 3 }; | 692 enum { kMinSupportedNumConcurrentDecoders = 3 }; |
| 708 #endif | |
| 709 | 693 |
| 710 // Test the most straightforward case possible: data is decoded from a single | 694 // Test the most straightforward case possible: data is decoded from a single |
| 711 // chunk and rendered to the screen. | 695 // chunk and rendered to the screen. |
| 712 TEST_P(VideoDecodeAcceleratorTest, TestSimpleDecode) { | 696 TEST_P(VideoDecodeAcceleratorTest, TestSimpleDecode) { |
| 713 // Can be useful for debugging VLOGs from OVDA. | 697 // Can be useful for debugging VLOGs from OVDA. |
| 714 // logging::SetMinLogLevel(-1); | 698 // logging::SetMinLogLevel(-1); |
| 715 | 699 |
| 716 // Required for Thread to work. Not used otherwise. | 700 // Required for Thread to work. Not used otherwise. |
| 717 base::ShadowingAtExitManager at_exit_manager; | 701 base::ShadowingAtExitManager at_exit_manager; |
| 718 | 702 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 #elif defined(OS_CHROMEOS) | 960 #elif defined(OS_CHROMEOS) |
| 977 #if defined(ARCH_CPU_ARMEL) | 961 #if defined(ARCH_CPU_ARMEL) |
| 978 content::ExynosVideoDecodeAccelerator::PreSandboxInitialization(); | 962 content::ExynosVideoDecodeAccelerator::PreSandboxInitialization(); |
| 979 #elif defined(ARCH_CPU_X86_FAMILY) | 963 #elif defined(ARCH_CPU_X86_FAMILY) |
| 980 content::VaapiVideoDecodeAccelerator::PreSandboxInitialization(); | 964 content::VaapiVideoDecodeAccelerator::PreSandboxInitialization(); |
| 981 #endif // ARCH_CPU_ARMEL | 965 #endif // ARCH_CPU_ARMEL |
| 982 #endif // OS_CHROMEOS | 966 #endif // OS_CHROMEOS |
| 983 | 967 |
| 984 return RUN_ALL_TESTS(); | 968 return RUN_ALL_TESTS(); |
| 985 } | 969 } |
| OLD | NEW |