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

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

Issue 1490333005: Don't require VDAs to return all PictureBuffers at once. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "content/common/gpu/gpu_channel.h" 12 #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_deferred_rendering_backing_strategy.h "
13 #include "content/common/gpu/media/avda_return_on_failure.h" 15 #include "content/common/gpu/media/avda_return_on_failure.h"
14 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
15 #include "media/base/bitstream_buffer.h" 17 #include "media/base/bitstream_buffer.h"
16 #include "media/base/limits.h" 18 #include "media/base/limits.h"
17 #include "media/base/timestamp_constants.h" 19 #include "media/base/timestamp_constants.h"
18 #include "media/base/video_decoder_config.h" 20 #include "media/base/video_decoder_config.h"
19 #include "media/video/picture.h" 21 #include "media/video/picture.h"
20 #include "ui/gl/android/scoped_java_surface.h" 22 #include "ui/gl/android/scoped_java_surface.h"
21 #include "ui/gl/android/surface_texture.h" 23 #include "ui/gl/android/surface_texture.h"
22 #include "ui/gl/gl_bindings.h" 24 #include "ui/gl/gl_bindings.h"
(...skipping 20 matching lines...) Expand all
43 media::H264PROFILE_EXTENDED, 45 media::H264PROFILE_EXTENDED,
44 media::H264PROFILE_HIGH, 46 media::H264PROFILE_HIGH,
45 media::H264PROFILE_HIGH10PROFILE, 47 media::H264PROFILE_HIGH10PROFILE,
46 media::H264PROFILE_HIGH422PROFILE, 48 media::H264PROFILE_HIGH422PROFILE,
47 media::H264PROFILE_HIGH444PREDICTIVEPROFILE, 49 media::H264PROFILE_HIGH444PREDICTIVEPROFILE,
48 media::H264PROFILE_SCALABLEBASELINE, 50 media::H264PROFILE_SCALABLEBASELINE,
49 media::H264PROFILE_SCALABLEHIGH, 51 media::H264PROFILE_SCALABLEHIGH,
50 media::H264PROFILE_STEREOHIGH, 52 media::H264PROFILE_STEREOHIGH,
51 media::H264PROFILE_MULTIVIEWHIGH 53 media::H264PROFILE_MULTIVIEWHIGH
52 }; 54 };
55
56 #define kBackingStrategy AndroidDeferredRenderingBackingStrategy
DaleCurtis 2015/12/03 21:59:46 ALL_CAPS
liberato (no reviews please) 2015/12/04 18:28:58 DONE
57 #else
58 #define kBackingStrategy AndroidCopyingBackingStrategy
53 #endif 59 #endif
54 60
55 // Because MediaCodec is thread-hostile (must be poked on a single thread) and 61 // Because MediaCodec is thread-hostile (must be poked on a single thread) and
56 // has no callback mechanism (b/11990118), we must drive it by polling for 62 // has no callback mechanism (b/11990118), we must drive it by polling for
57 // complete frames (and available input buffers, when the codec is fully 63 // complete frames (and available input buffers, when the codec is fully
58 // saturated). This function defines the polling delay. The value used is an 64 // saturated). This function defines the polling delay. The value used is an
59 // arbitrary choice that trades off CPU utilization (spinning) against latency. 65 // arbitrary choice that trades off CPU utilization (spinning) against latency.
60 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay(). 66 // Mirrors android_video_encode_accelerator.cc:EncodePollDelay().
61 static inline const base::TimeDelta DecodePollDelay() { 67 static inline const base::TimeDelta DecodePollDelay() {
62 // An alternative to this polling scheme could be to dedicate a new thread 68 // An alternative to this polling scheme could be to dedicate a new thread
63 // (instead of using the ChildThread) to run the MediaCodec, and make that 69 // (instead of using the ChildThread) to run the MediaCodec, and make that
64 // thread use the timeout-based flavor of MediaCodec's dequeue methods when it 70 // thread use the timeout-based flavor of MediaCodec's dequeue methods when it
65 // believes the codec should complete "soon" (e.g. waiting for an input 71 // believes the codec should complete "soon" (e.g. waiting for an input
66 // buffer, or waiting for a picture when it knows enough complete input 72 // buffer, or waiting for a picture when it knows enough complete input
67 // pictures have been fed to saturate any internal buffering). This is 73 // pictures have been fed to saturate any internal buffering). This is
68 // speculative and it's unclear that this would be a win (nor that there's a 74 // speculative and it's unclear that this would be a win (nor that there's a
69 // reasonably device-agnostic way to fill in the "believes" above). 75 // reasonably device-agnostic way to fill in the "believes" above).
70 return base::TimeDelta::FromMilliseconds(10); 76 return base::TimeDelta::FromMilliseconds(10);
71 } 77 }
72 78
73 static inline const base::TimeDelta NoWaitTimeOut() { 79 static inline const base::TimeDelta NoWaitTimeOut() {
74 return base::TimeDelta::FromMicroseconds(0); 80 return base::TimeDelta::FromMicroseconds(0);
75 } 81 }
76 82
77 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( 83 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
78 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, 84 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
79 const base::Callback<bool(void)>& make_context_current, 85 const base::Callback<bool(void)>& make_context_current)
80 scoped_ptr<BackingStrategy> strategy)
81 : client_(NULL), 86 : client_(NULL),
82 make_context_current_(make_context_current), 87 make_context_current_(make_context_current),
83 codec_(media::kCodecH264), 88 codec_(media::kCodecH264),
84 state_(NO_ERROR), 89 state_(NO_ERROR),
85 picturebuffers_requested_(false), 90 picturebuffers_requested_(false),
86 gl_decoder_(decoder), 91 gl_decoder_(decoder),
87 strategy_(strategy.Pass()), 92 strategy_(new kBackingStrategy()),
liberato (no reviews please) 2015/12/03 21:21:01 interesting aside: this isn't, and wasn't before,
88 weak_this_factory_(this) {} 93 weak_this_factory_(this) {}
89 94
90 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() { 95 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
91 DCHECK(thread_checker_.CalledOnValidThread()); 96 DCHECK(thread_checker_.CalledOnValidThread());
92 } 97 }
93 98
94 bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, 99 bool AndroidVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
95 Client* client) { 100 Client* client) {
96 DCHECK(!media_codec_); 101 DCHECK(!media_codec_);
97 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 profile.profile = supported_profile; 662 profile.profile = supported_profile;
658 profile.min_resolution.SetSize(0, 0); 663 profile.min_resolution.SetSize(0, 0);
659 // Advertise support for 4k and let the MediaCodec fail when decoding if it 664 // Advertise support for 4k and let the MediaCodec fail when decoding if it
660 // doesn't support the resolution. It's assumed that consumers won't have 665 // doesn't support the resolution. It's assumed that consumers won't have
661 // software fallback for H264 on Android anyway. 666 // software fallback for H264 on Android anyway.
662 profile.max_resolution.SetSize(3840, 2160); 667 profile.max_resolution.SetSize(3840, 2160);
663 profiles.push_back(profile); 668 profiles.push_back(profile);
664 } 669 }
665 #endif 670 #endif
666 671
672 // Allow the backing strategy to set the flags for each profile.
673 for (auto& profile : profiles) {
674 profile.flags = kBackingStrategy::GetProfileFlags();
675 }
676
667 return profiles; 677 return profiles;
668 } 678 }
669 679
670 } // namespace content 680 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698