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

Side by Side Diff: media/filters/gpu_video_decoder.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: 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
OLDNEW
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 #include "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 GpuVideoDecoder::BufferData::~BufferData() {} 61 GpuVideoDecoder::BufferData::~BufferData() {}
62 62
63 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories) 63 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories)
64 : needs_bitstream_conversion_(false), 64 : needs_bitstream_conversion_(false),
65 factories_(factories), 65 factories_(factories),
66 state_(kNormal), 66 state_(kNormal),
67 decoder_texture_target_(0), 67 decoder_texture_target_(0),
68 next_picture_buffer_id_(0), 68 next_picture_buffer_id_(0),
69 next_bitstream_buffer_id_(0), 69 next_bitstream_buffer_id_(0),
70 available_pictures_(0), 70 available_pictures_(0),
71 can_stall_anytime_(false),
71 weak_factory_(this) { 72 weak_factory_(this) {
72 DCHECK(factories_); 73 DCHECK(factories_);
73 } 74 }
74 75
75 void GpuVideoDecoder::Reset(const base::Closure& closure) { 76 void GpuVideoDecoder::Reset(const base::Closure& closure) {
76 DVLOG(3) << "Reset()"; 77 DVLOG(3) << "Reset()";
77 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 78 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
78 79
79 if (state_ == kDrainingDecoder) { 80 if (state_ == kDrainingDecoder) {
80 base::MessageLoop::current()->PostTask( 81 base::MessageLoop::current()->PostTask(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 << config.AsHumanReadableString(); 148 << config.AsHumanReadableString();
148 149
149 // TODO(posciak): destroy and create a new VDA on codec/profile change 150 // TODO(posciak): destroy and create a new VDA on codec/profile change
150 // (http://crbug.com/260224). 151 // (http://crbug.com/260224).
151 if (previously_initialized && (config_.profile() != config.profile())) { 152 if (previously_initialized && (config_.profile() != config.profile())) {
152 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; 153 DVLOG(1) << "Codec or profile changed, cannot reinitialize.";
153 bound_init_cb.Run(false); 154 bound_init_cb.Run(false);
154 return; 155 return;
155 } 156 }
156 157
157 if (!IsProfileSupported(config.profile(), config.coded_size())) { 158 VideoDecodeAccelerator::Capabilities capabilities =
159 factories_->GetVideoDecodeAcceleratorCapabilities();
160 if (!IsProfileSupported(capabilities, config.profile(),
161 config.coded_size())) {
158 DVLOG(1) << "Profile " << config.profile() << " or coded size " 162 DVLOG(1) << "Profile " << config.profile() << " or coded size "
159 << config.coded_size().ToString() << " not supported."; 163 << config.coded_size().ToString() << " not supported.";
160 bound_init_cb.Run(false); 164 bound_init_cb.Run(false);
161 return; 165 return;
162 } 166 }
163 167
164 config_ = config; 168 config_ = config;
169 can_stall_anytime_ = capabilities.flags &
170 VideoDecodeAccelerator::Capabilities::CAN_STALL_ANY_TIME;
165 needs_bitstream_conversion_ = (config.codec() == kCodecH264); 171 needs_bitstream_conversion_ = (config.codec() == kCodecH264);
166 output_cb_ = BindToCurrentLoop(output_cb); 172 output_cb_ = BindToCurrentLoop(output_cb);
167 173
168 if (previously_initialized) { 174 if (previously_initialized) {
169 // Reinitialization with a different config (but same codec and profile). 175 // Reinitialization with a different config (but same codec and profile).
170 // VDA should handle it by detecting this in-stream by itself, 176 // VDA should handle it by detecting this in-stream by itself,
171 // no need to notify it. 177 // no need to notify it.
172 bound_init_cb.Run(true); 178 bound_init_cb.Run(true);
173 return; 179 return;
174 } 180 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 NOTREACHED() << "Missing bitstreambuffer id: " << id; 353 NOTREACHED() << "Missing bitstreambuffer id: " << id;
348 } 354 }
349 355
350 bool GpuVideoDecoder::NeedsBitstreamConversion() const { 356 bool GpuVideoDecoder::NeedsBitstreamConversion() const {
351 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 357 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
352 return needs_bitstream_conversion_; 358 return needs_bitstream_conversion_;
353 } 359 }
354 360
355 bool GpuVideoDecoder::CanReadWithoutStalling() const { 361 bool GpuVideoDecoder::CanReadWithoutStalling() const {
356 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 362 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
357 return 363 return next_picture_buffer_id_ ==
358 next_picture_buffer_id_ == 0 || // Decode() will ProvidePictureBuffers(). 364 0 || // Decode() will ProvidePictureBuffers().
359 available_pictures_ > 0; 365 (!can_stall_anytime_ && available_pictures_ > 0);
360 } 366 }
361 367
362 int GpuVideoDecoder::GetMaxDecodeRequests() const { 368 int GpuVideoDecoder::GetMaxDecodeRequests() const {
363 return kMaxInFlightDecodes; 369 return kMaxInFlightDecodes;
364 } 370 }
365 371
366 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, 372 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
367 const gfx::Size& size, 373 const gfx::Size& size,
368 uint32 texture_target) { 374 uint32 texture_target) {
369 DVLOG(3) << "ProvidePictureBuffers(" << count << ", " 375 DVLOG(3) << "ProvidePictureBuffers(" << count << ", "
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 644 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
639 if (!vda_) 645 if (!vda_)
640 return; 646 return;
641 647
642 state_ = kError; 648 state_ = kError;
643 649
644 DLOG(ERROR) << "VDA Error: " << error; 650 DLOG(ERROR) << "VDA Error: " << error;
645 DestroyVDA(); 651 DestroyVDA();
646 } 652 }
647 653
648 bool GpuVideoDecoder::IsProfileSupported(VideoCodecProfile profile, 654 bool GpuVideoDecoder::IsProfileSupported(
649 const gfx::Size& coded_size) { 655 const VideoDecodeAccelerator::Capabilities& capabilities,
656 VideoCodecProfile profile,
657 const gfx::Size& coded_size) {
650 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 658 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
651 VideoDecodeAccelerator::SupportedProfiles supported_profiles = 659 for (const auto& supported_profile : capabilities.supported_profiles) {
652 factories_->GetVideoDecodeAcceleratorSupportedProfiles();
653 for (const auto& supported_profile : supported_profiles) {
654 if (profile == supported_profile.profile) { 660 if (profile == supported_profile.profile) {
655 return IsCodedSizeSupported(coded_size, 661 return IsCodedSizeSupported(coded_size,
656 supported_profile.min_resolution, 662 supported_profile.min_resolution,
657 supported_profile.max_resolution); 663 supported_profile.max_resolution);
658 } 664 }
659 } 665 }
660 return false; 666 return false;
661 } 667 }
662 668
663 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 669 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
664 const { 670 const {
665 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 671 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
666 } 672 }
667 673
668 } // namespace media 674 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698