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

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
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/renderers/gpu_video_accelerator_factories.h » ('j') | 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) 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 needs_all_picture_buffers_to_decode_(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 needs_all_picture_buffers_to_decode_ =
170 capabilities.flags &
171 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE;
165 needs_bitstream_conversion_ = (config.codec() == kCodecH264); 172 needs_bitstream_conversion_ = (config.codec() == kCodecH264);
166 output_cb_ = BindToCurrentLoop(output_cb); 173 output_cb_ = BindToCurrentLoop(output_cb);
167 174
168 if (previously_initialized) { 175 if (previously_initialized) {
169 // Reinitialization with a different config (but same codec and profile). 176 // Reinitialization with a different config (but same codec and profile).
170 // VDA should handle it by detecting this in-stream by itself, 177 // VDA should handle it by detecting this in-stream by itself,
171 // no need to notify it. 178 // no need to notify it.
172 bound_init_cb.Run(true); 179 bound_init_cb.Run(true);
173 return; 180 return;
174 } 181 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 NOTREACHED() << "Missing bitstreambuffer id: " << id; 354 NOTREACHED() << "Missing bitstreambuffer id: " << id;
348 } 355 }
349 356
350 bool GpuVideoDecoder::NeedsBitstreamConversion() const { 357 bool GpuVideoDecoder::NeedsBitstreamConversion() const {
351 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 358 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
352 return needs_bitstream_conversion_; 359 return needs_bitstream_conversion_;
353 } 360 }
354 361
355 bool GpuVideoDecoder::CanReadWithoutStalling() const { 362 bool GpuVideoDecoder::CanReadWithoutStalling() const {
356 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 363 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
357 return 364 return next_picture_buffer_id_ ==
358 next_picture_buffer_id_ == 0 || // Decode() will ProvidePictureBuffers(). 365 0 || // Decode() will ProvidePictureBuffers().
359 available_pictures_ > 0; 366 (!needs_all_picture_buffers_to_decode_ && available_pictures_ > 0) ||
367 available_pictures_ ==
368 static_cast<int>(assigned_picture_buffers_.size());
360 } 369 }
361 370
362 int GpuVideoDecoder::GetMaxDecodeRequests() const { 371 int GpuVideoDecoder::GetMaxDecodeRequests() const {
363 return kMaxInFlightDecodes; 372 return kMaxInFlightDecodes;
364 } 373 }
365 374
366 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, 375 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
367 const gfx::Size& size, 376 const gfx::Size& size,
368 uint32 texture_target) { 377 uint32 texture_target) {
369 DVLOG(3) << "ProvidePictureBuffers(" << count << ", " 378 DVLOG(3) << "ProvidePictureBuffers(" << count << ", "
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 647 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
639 if (!vda_) 648 if (!vda_)
640 return; 649 return;
641 650
642 state_ = kError; 651 state_ = kError;
643 652
644 DLOG(ERROR) << "VDA Error: " << error; 653 DLOG(ERROR) << "VDA Error: " << error;
645 DestroyVDA(); 654 DestroyVDA();
646 } 655 }
647 656
648 bool GpuVideoDecoder::IsProfileSupported(VideoCodecProfile profile, 657 bool GpuVideoDecoder::IsProfileSupported(
649 const gfx::Size& coded_size) { 658 const VideoDecodeAccelerator::Capabilities& capabilities,
659 VideoCodecProfile profile,
660 const gfx::Size& coded_size) {
650 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 661 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
651 VideoDecodeAccelerator::SupportedProfiles supported_profiles = 662 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) { 663 if (profile == supported_profile.profile) {
655 return IsCodedSizeSupported(coded_size, 664 return IsCodedSizeSupported(coded_size,
656 supported_profile.min_resolution, 665 supported_profile.min_resolution,
657 supported_profile.max_resolution); 666 supported_profile.max_resolution);
658 } 667 }
659 } 668 }
660 return false; 669 return false;
661 } 670 }
662 671
663 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 672 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
664 const { 673 const {
665 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 674 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
666 } 675 }
667 676
668 } // namespace media 677 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/renderers/gpu_video_accelerator_factories.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698