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

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 1515993003: Use AVDA copying strategy unless the unified pipeline flag is set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
12 #include "content/common/gpu/gpu_channel.h" 13 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/media/android_copying_backing_strategy.h" 14 #include "content/common/gpu/media/android_copying_backing_strategy.h"
14 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " 15 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h "
15 #include "content/common/gpu/media/avda_return_on_failure.h" 16 #include "content/common/gpu/media/avda_return_on_failure.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
17 #include "media/base/bitstream_buffer.h" 18 #include "media/base/bitstream_buffer.h"
18 #include "media/base/limits.h" 19 #include "media/base/limits.h"
20 #include "media/base/media_switches.h"
19 #include "media/base/timestamp_constants.h" 21 #include "media/base/timestamp_constants.h"
20 #include "media/base/video_decoder_config.h" 22 #include "media/base/video_decoder_config.h"
21 #include "media/video/picture.h" 23 #include "media/video/picture.h"
22 #include "ui/gl/android/scoped_java_surface.h" 24 #include "ui/gl/android/scoped_java_surface.h"
23 #include "ui/gl/android/surface_texture.h" 25 #include "ui/gl/android/surface_texture.h"
24 #include "ui/gl/gl_bindings.h" 26 #include "ui/gl/gl_bindings.h"
25 27
26 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 28 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
27 #include "media/base/media_keys.h" 29 #include "media/base/media_keys.h"
28 #include "media/mojo/services/mojo_cdm_service.h" 30 #include "media/mojo/services/mojo_cdm_service.h"
(...skipping 23 matching lines...) Expand all
52 media::H264PROFILE_EXTENDED, 54 media::H264PROFILE_EXTENDED,
53 media::H264PROFILE_HIGH, 55 media::H264PROFILE_HIGH,
54 media::H264PROFILE_HIGH10PROFILE, 56 media::H264PROFILE_HIGH10PROFILE,
55 media::H264PROFILE_HIGH422PROFILE, 57 media::H264PROFILE_HIGH422PROFILE,
56 media::H264PROFILE_HIGH444PREDICTIVEPROFILE, 58 media::H264PROFILE_HIGH444PREDICTIVEPROFILE,
57 media::H264PROFILE_SCALABLEBASELINE, 59 media::H264PROFILE_SCALABLEBASELINE,
58 media::H264PROFILE_SCALABLEHIGH, 60 media::H264PROFILE_SCALABLEHIGH,
59 media::H264PROFILE_STEREOHIGH, 61 media::H264PROFILE_STEREOHIGH,
60 media::H264PROFILE_MULTIVIEWHIGH 62 media::H264PROFILE_MULTIVIEWHIGH
61 }; 63 };
62
63 #define BACKING_STRATEGY AndroidDeferredRenderingBackingStrategy
64 #else
65 #define BACKING_STRATEGY AndroidCopyingBackingStrategy
66 #endif 64 #endif
67 65
68 // Because MediaCodec is thread-hostile (must be poked on a single thread) and 66 // Because MediaCodec is thread-hostile (must be poked on a single thread) and
69 // has no callback mechanism (b/11990118), we must drive it by polling for 67 // has no callback mechanism (b/11990118), we must drive it by polling for
70 // complete frames (and available input buffers, when the codec is fully 68 // complete frames (and available input buffers, when the codec is fully
71 // saturated). This function defines the polling delay. The value used is an 69 // saturated). This function defines the polling delay. The value used is an
72 // arbitrary choice that trades off CPU utilization (spinning) against latency. 70 // arbitrary choice that trades off CPU utilization (spinning) against latency.
73 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay(). 71 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay().
74 static inline const base::TimeDelta DecodePollDelay() { 72 static inline const base::TimeDelta DecodePollDelay() {
75 // An alternative to this polling scheme could be to dedicate a new thread 73 // An alternative to this polling scheme could be to dedicate a new thread
(...skipping 14 matching lines...) Expand all
90 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( 88 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
91 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, 89 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
92 const base::Callback<bool(void)>& make_context_current) 90 const base::Callback<bool(void)>& make_context_current)
93 : client_(NULL), 91 : client_(NULL),
94 make_context_current_(make_context_current), 92 make_context_current_(make_context_current),
95 codec_(media::kCodecH264), 93 codec_(media::kCodecH264),
96 is_encrypted_(false), 94 is_encrypted_(false),
97 state_(NO_ERROR), 95 state_(NO_ERROR),
98 picturebuffers_requested_(false), 96 picturebuffers_requested_(false),
99 gl_decoder_(decoder), 97 gl_decoder_(decoder),
100 strategy_(new BACKING_STRATEGY()), 98 weak_this_factory_(this) {
101 weak_this_factory_(this) {} 99 if (UseDeferredRenderingStrategy())
100 strategy_.reset(new AndroidDeferredRenderingBackingStrategy());
101 else
102 strategy_.reset(new AndroidCopyingBackingStrategy());
103 }
102 104
103 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() { 105 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
104 DCHECK(thread_checker_.CalledOnValidThread()); 106 DCHECK(thread_checker_.CalledOnValidThread());
105 } 107 }
106 108
107 bool AndroidVideoDecodeAccelerator::Initialize(const Config& config, 109 bool AndroidVideoDecodeAccelerator::Initialize(const Config& config,
108 Client* client) { 110 Client* client) {
109 DCHECK(!media_codec_); 111 DCHECK(!media_codec_);
110 DCHECK(thread_checker_.CalledOnValidThread()); 112 DCHECK(thread_checker_.CalledOnValidThread());
111 TRACE_EVENT0("media", "AVDA::Initialize"); 113 TRACE_EVENT0("media", "AVDA::Initialize");
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 void AndroidVideoDecodeAccelerator::NotifyResetDone() { 640 void AndroidVideoDecodeAccelerator::NotifyResetDone() {
639 client_->NotifyResetDone(); 641 client_->NotifyResetDone();
640 } 642 }
641 643
642 void AndroidVideoDecodeAccelerator::NotifyError( 644 void AndroidVideoDecodeAccelerator::NotifyError(
643 media::VideoDecodeAccelerator::Error error) { 645 media::VideoDecodeAccelerator::Error error) {
644 client_->NotifyError(error); 646 client_->NotifyError(error);
645 } 647 }
646 648
647 // static 649 // static
650 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy() {
651 #if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
652 return base::CommandLine::ForCurrentProcess()->HasSwitch(
653 switches::kEnableUnifiedMediaPipeline);
654 #endif
655
656 return false;
657 }
658
659 // static
648 media::VideoDecodeAccelerator::Capabilities 660 media::VideoDecodeAccelerator::Capabilities
649 AndroidVideoDecodeAccelerator::GetCapabilities() { 661 AndroidVideoDecodeAccelerator::GetCapabilities() {
650 Capabilities capabilities; 662 Capabilities capabilities;
651 SupportedProfiles& profiles = capabilities.supported_profiles; 663 SupportedProfiles& profiles = capabilities.supported_profiles;
652 664
653 if (!media::VideoCodecBridge::IsKnownUnaccelerated( 665 if (!media::VideoCodecBridge::IsKnownUnaccelerated(
654 media::kCodecVP8, media::MEDIA_CODEC_DECODER)) { 666 media::kCodecVP8, media::MEDIA_CODEC_DECODER)) {
655 SupportedProfile profile; 667 SupportedProfile profile;
656 profile.profile = media::VP8PROFILE_ANY; 668 profile.profile = media::VP8PROFILE_ANY;
657 profile.min_resolution.SetSize(0, 0); 669 profile.min_resolution.SetSize(0, 0);
(...skipping 16 matching lines...) Expand all
674 profile.profile = supported_profile; 686 profile.profile = supported_profile;
675 profile.min_resolution.SetSize(0, 0); 687 profile.min_resolution.SetSize(0, 0);
676 // Advertise support for 4k and let the MediaCodec fail when decoding if it 688 // Advertise support for 4k and let the MediaCodec fail when decoding if it
677 // doesn't support the resolution. It's assumed that consumers won't have 689 // doesn't support the resolution. It's assumed that consumers won't have
678 // software fallback for H264 on Android anyway. 690 // software fallback for H264 on Android anyway.
679 profile.max_resolution.SetSize(3840, 2160); 691 profile.max_resolution.SetSize(3840, 2160);
680 profiles.push_back(profile); 692 profiles.push_back(profile);
681 } 693 }
682 #endif 694 #endif
683 695
684 capabilities.flags = BACKING_STRATEGY::GetCapabilitiesFlags(); 696 if (UseDeferredRenderingStrategy()) {
697 capabilities.flags = media::VideoDecodeAccelerator::Capabilities::
698 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE;
699 }
685 700
686 return capabilities; 701 return capabilities;
687 } 702 }
688 703
689 } // namespace content 704 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698