diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 00:26:16 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-10 00:26:16 +0000 |
commit | 0f1388e5dac315f5f2057df49ba0ba1338bc3143 (patch) | |
tree | 4cf3579f42db02c6fd8a61b63a8e12118b278ae2 /content/common | |
parent | d111e93688a8531eb6f3f48592dfbcb88a9a4fee (diff) | |
download | chromium_src-0f1388e5dac315f5f2057df49ba0ba1338bc3143.zip chromium_src-0f1388e5dac315f5f2057df49ba0ba1338bc3143.tar.gz chromium_src-0f1388e5dac315f5f2057df49ba0ba1338bc3143.tar.bz2 |
<video> decode in hardware!
This uses the GpuVideoDecodeAccelerator machinery (already written to enable
ppapi to take advantage of OpenMAX HW where available) to decode <video> data.
This increases idle CPU from 20% to 45% on one particularly large (internal)
test video (red0.mp4), on an ARM crosbook.
HW decode is done on a best-effort basis; if the GPU code doesn't know how to
deal with a codec/profile we still fall back to ffmpeg for decode. Because the
vast majority of chrome installs will be on HW with no video decode support
(yet) we only attempt HW video decode on platforms we know have a shot at it.
BUG=104579
TEST=manual testing w/ video test matrix, trybots.
Review URL: http://codereview.chromium.org/8686010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
3 files changed, 25 insertions, 26 deletions
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc index 7be8df8..de42351 100644 --- a/content/common/gpu/media/gpu_video_decode_accelerator.cc +++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc @@ -112,16 +112,16 @@ void GpuVideoDecodeAccelerator::Initialize( DCHECK(!video_decode_accelerator_.get()); DCHECK(!init_done_msg_); DCHECK(init_done_msg); + init_done_msg_ = init_done_msg; #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) DCHECK(stub_ && stub_->decoder()); - init_done_msg_ = init_done_msg; OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); omx_decoder->SetEglState( gfx::GLSurfaceEGL::GetHardwareDisplay(), stub_->decoder()->GetGLContext()->GetHandle()); video_decode_accelerator_ = omx_decoder; video_decode_accelerator_->Initialize(profile); -#else +#else // Update RenderViewImpl::createMediaPlayer when adding clauses. NOTIMPLEMENTED() << "HW video decode acceleration not available."; NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) diff --git a/content/common/gpu/media/omx_video_decode_accelerator.cc b/content/common/gpu/media/omx_video_decode_accelerator.cc index 53fc535..0c96b9c 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator.cc @@ -50,25 +50,25 @@ static bool AreOMXFunctionPointersInitialized() { // Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values. static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { switch (profile) { - case media::VideoDecodeAccelerator::H264PROFILE_BASELINE: + case media::H264PROFILE_BASELINE: return OMX_VIDEO_AVCProfileBaseline; - case media::VideoDecodeAccelerator::H264PROFILE_MAIN: + case media::H264PROFILE_MAIN: return OMX_VIDEO_AVCProfileMain; - case media::VideoDecodeAccelerator::H264PROFILE_EXTENDED: + case media::H264PROFILE_EXTENDED: return OMX_VIDEO_AVCProfileExtended; - case media::VideoDecodeAccelerator::H264PROFILE_HIGH: + case media::H264PROFILE_HIGH: return OMX_VIDEO_AVCProfileHigh; - case media::VideoDecodeAccelerator::H264PROFILE_HIGH10PROFILE: + case media::H264PROFILE_HIGH10PROFILE: return OMX_VIDEO_AVCProfileHigh10; - case media::VideoDecodeAccelerator::H264PROFILE_HIGH422PROFILE: + case media::H264PROFILE_HIGH422PROFILE: return OMX_VIDEO_AVCProfileHigh422; - case media::VideoDecodeAccelerator::H264PROFILE_HIGH444PREDICTIVEPROFILE: + case media::H264PROFILE_HIGH444PREDICTIVEPROFILE: return OMX_VIDEO_AVCProfileHigh444; // Below enums don't have equivalent enum in Openmax. - case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEBASELINE: - case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEHIGH: - case media::VideoDecodeAccelerator::H264PROFILE_STEREOHIGH: - case media::VideoDecodeAccelerator::H264PROFILE_MULTIVIEWHIGH: + case media::H264PROFILE_SCALABLEBASELINE: + case media::H264PROFILE_SCALABLEHIGH: + case media::H264PROFILE_STEREOHIGH: + case media::H264PROFILE_MULTIVIEWHIGH: // Nvidia OMX video decoder requires the same resources (as that of the // High profile) in every profile higher to the Main profile. return OMX_VIDEO_AVCProfileHigh444; @@ -144,7 +144,8 @@ static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { bool OmxVideoDecodeAccelerator::Initialize(Profile profile) { DCHECK_EQ(message_loop_, MessageLoop::current()); - RETURN_ON_FAILURE(profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX, + RETURN_ON_FAILURE((profile >= media::H264PROFILE_MIN && + profile <= media::H264PROFILE_MAX), "Only h264 supported", INVALID_ARGUMENT, false); profile_ = MapH264ProfileToOMXAVCProfile(profile); RETURN_ON_FAILURE(profile_ != OMX_VIDEO_AVCProfileMax, @@ -768,7 +769,8 @@ void OmxVideoDecodeAccelerator::FillBufferDoneTask( --output_buffers_at_component_; if (fake_output_buffers_.size() && fake_output_buffers_.count(buffer)) { - DCHECK_EQ(fake_output_buffers_.erase(buffer), 1U); + size_t erased = fake_output_buffers_.erase(buffer); + DCHECK_EQ(erased, 1U); OMX_ERRORTYPE result = OMX_FreeBuffer(component_handle_, output_port_, buffer); RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); diff --git a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc index a259b31..727b7fe 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc @@ -576,8 +576,7 @@ void EglRenderingVDAClient::CreateDecoder() { return; // Configure the decoder. - media::VideoDecodeAccelerator::Profile profile = - media::VideoDecodeAccelerator::H264PROFILE_BASELINE; + media::VideoDecodeAccelerator::Profile profile = media::H264PROFILE_BASELINE; if (profile_ != -1) profile = static_cast<media::VideoDecodeAccelerator::Profile>(profile_); CHECK(decoder_->Initialize(profile)); @@ -803,9 +802,10 @@ static void AssertWaitForStateOrDeleted(ClientStateNotification* note, << ", instead of " << expected_state; } -// We assert the exact number of concurrent decoders we expect to succeed and -// that one more than that fails initialization. -enum { kMaxSupportedNumConcurrentDecoders = 3 }; +// We assert a minimal number of concurrent decoders we expect to succeed. +// Different platforms can support more concurrent decoders, so we don't assert +// failure above this. +enum { kMinSupportedNumConcurrentDecoders = 3 }; // Test the most straightforward case possible: data is decoded from a single // chunk and rendered to the screen. @@ -889,7 +889,7 @@ TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { // We expect initialization to fail only when more than the supported // number of decoders is instantiated. Assert here that something else // didn't trigger failure. - ASSERT_GT(num_concurrent_decoders, kMaxSupportedNumConcurrentDecoders); + ASSERT_GT(num_concurrent_decoders, kMinSupportedNumConcurrentDecoders); continue; } ASSERT_EQ(state, CS_INITIALIZED); @@ -908,9 +908,6 @@ TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) { ASSERT_NO_FATAL_FAILURE( AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); } - ASSERT_EQ(saw_init_failure, - num_concurrent_decoders > kMaxSupportedNumConcurrentDecoders) - << num_concurrent_decoders; // Finally assert that decoding went as expected. for (size_t i = 0; i < num_concurrent_decoders && !saw_init_failure; ++i) { // We can only make performance/correctness assertions if the decoder was @@ -997,9 +994,9 @@ INSTANTIATE_TEST_CASE_P( ResourceExhaustion, OmxVideoDecodeAcceleratorTest, ::testing::Values( // +0 hack below to promote enum to int. - MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, 1, + MakeTuple(1, kMinSupportedNumConcurrentDecoders + 0, 1, END_OF_STREAM_RESET, CS_RESET), - MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, 1, + MakeTuple(1, kMinSupportedNumConcurrentDecoders + 1, 1, END_OF_STREAM_RESET, CS_RESET))); // TODO(fischman, vrk): add more tests! In particular: |