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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 1921803002: Avoid unnecessary post task during frame delivery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 4 years, 8 months 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( 124 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB(
125 const VideoDecoder::InitCB& cb, 125 const VideoDecoder::InitCB& cb,
126 bool success) { 126 bool success) {
127 // TODO(xhwang): Report |success| directly. 127 // TODO(xhwang): Report |success| directly.
128 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED; 128 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED;
129 UMA_HISTOGRAM_ENUMERATION( 129 UMA_HISTOGRAM_ENUMERATION(
130 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); 130 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1);
131 cb.Run(success); 131 cb.Run(success);
132 } 132 }
133 133
134 // static
135 void ReleaseMailboxTrampoline(
136 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
137 const VideoFrame::ReleaseMailboxCB& release_mailbox_cb,
138 const gpu::SyncToken& release_sync_token) {
139 if (task_runner->BelongsToCurrentThread()) {
140 release_mailbox_cb.Run(release_sync_token);
141 return;
142 }
143
144 task_runner->PostTask(FROM_HERE,
145 base::Bind(release_mailbox_cb, release_sync_token));
146 }
147
134 std::string GpuVideoDecoder::GetDisplayName() const { 148 std::string GpuVideoDecoder::GetDisplayName() const {
135 return kDecoderName; 149 return kDecoderName;
136 } 150 }
137 151
138 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, 152 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config,
139 bool /* low_delay */, 153 bool /* low_delay */,
140 CdmContext* cdm_context, 154 CdmContext* cdm_context,
141 const InitCB& init_cb, 155 const InitCB& init_cb,
142 const OutputCB& output_cb) { 156 const OutputCB& output_cb) {
143 DVLOG(3) << "Initialize()"; 157 DVLOG(3) << "Initialize()";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 195 }
182 196
183 config_ = config; 197 config_ = config;
184 needs_all_picture_buffers_to_decode_ = 198 needs_all_picture_buffers_to_decode_ =
185 capabilities.flags & 199 capabilities.flags &
186 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; 200 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE;
187 needs_bitstream_conversion_ = (config.codec() == kCodecH264); 201 needs_bitstream_conversion_ = (config.codec() == kCodecH264);
188 supports_deferred_initialization_ = !!( 202 supports_deferred_initialization_ = !!(
189 capabilities.flags & 203 capabilities.flags &
190 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION); 204 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION);
191 output_cb_ = BindToCurrentLoop(output_cb); 205 output_cb_ = output_cb;
192 206
193 if (config.is_encrypted() && !supports_deferred_initialization_) { 207 if (config.is_encrypted() && !supports_deferred_initialization_) {
194 DVLOG(1) << __FUNCTION__ 208 DVLOG(1) << __FUNCTION__
195 << " Encrypted stream requires deferred initialialization."; 209 << " Encrypted stream requires deferred initialialization.";
196 bound_init_cb.Run(false); 210 bound_init_cb.Run(false);
197 return; 211 return;
198 } 212 }
199 213
200 if (previously_initialized) { 214 if (previously_initialized) {
201 DVLOG(3) << __FUNCTION__ 215 DVLOG(3) << __FUNCTION__
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 558
545 VideoPixelFormat pixel_format = vda_->GetOutputFormat(); 559 VideoPixelFormat pixel_format = vda_->GetOutputFormat();
546 if (pixel_format == PIXEL_FORMAT_UNKNOWN) { 560 if (pixel_format == PIXEL_FORMAT_UNKNOWN) {
547 pixel_format = 561 pixel_format =
548 IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB; 562 IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB;
549 } 563 }
550 564
551 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( 565 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture(
552 pixel_format, gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), 566 pixel_format, gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(),
553 decoder_texture_target_), 567 decoder_texture_target_),
554 BindToCurrentLoop(base::Bind( 568 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(),
555 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), 569 base::Bind(&GpuVideoDecoder::ReleaseMailbox,
556 factories_, picture.picture_buffer_id(), pb.texture_ids())), 570 weak_factory_.GetWeakPtr(), factories_,
571 picture.picture_buffer_id(), pb.texture_ids())),
557 pb.size(), visible_rect, natural_size, timestamp)); 572 pb.size(), visible_rect, natural_size, timestamp));
558 if (!frame) { 573 if (!frame) {
559 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 574 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
560 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 575 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
561 return; 576 return;
562 } 577 }
563 if (picture.allow_overlay()) 578 if (picture.allow_overlay())
564 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); 579 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true);
565 #if defined(OS_MACOSX) || defined(OS_WIN) 580 #if defined(OS_MACOSX) || defined(OS_WIN)
566 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); 581 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 783 }
769 return false; 784 return false;
770 } 785 }
771 786
772 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 787 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
773 const { 788 const {
774 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 789 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
775 } 790 }
776 791
777 } // namespace media 792 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698