Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/cpu.h" | 12 #include "base/cpu.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "gpu/command_buffer/common/mailbox_holder.h" | 18 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 19 #include "media/base/bind_to_current_loop.h" | 19 #include "media/base/bind_to_current_loop.h" |
| 20 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
| 21 #include "media/base/media_log.h" | |
| 22 #include "media/base/media_switches.h" | 21 #include "media/base/media_switches.h" |
| 23 #include "media/base/pipeline.h" | 22 #include "media/base/pipeline.h" |
| 24 #include "media/base/pipeline_status.h" | 23 #include "media/base/pipeline_status.h" |
| 25 #include "media/base/video_decoder_config.h" | 24 #include "media/base/video_decoder_config.h" |
| 26 #include "media/filters/gpu_video_accelerator_factories.h" | 25 #include "media/filters/gpu_video_accelerator_factories.h" |
| 27 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
| 28 | 27 |
| 29 namespace media { | 28 namespace media { |
| 30 | 29 |
| 31 // Maximum number of concurrent VDA::Decode() operations GVD will maintain. | 30 // Maximum number of concurrent VDA::Decode() operations GVD will maintain. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 54 | 53 |
| 55 GpuVideoDecoder::BufferData::BufferData( | 54 GpuVideoDecoder::BufferData::BufferData( |
| 56 int32 bbid, base::TimeDelta ts, const gfx::Rect& vr, const gfx::Size& ns) | 55 int32 bbid, base::TimeDelta ts, const gfx::Rect& vr, const gfx::Size& ns) |
| 57 : bitstream_buffer_id(bbid), timestamp(ts), visible_rect(vr), | 56 : bitstream_buffer_id(bbid), timestamp(ts), visible_rect(vr), |
| 58 natural_size(ns) { | 57 natural_size(ns) { |
| 59 } | 58 } |
| 60 | 59 |
| 61 GpuVideoDecoder::BufferData::~BufferData() {} | 60 GpuVideoDecoder::BufferData::~BufferData() {} |
| 62 | 61 |
| 63 GpuVideoDecoder::GpuVideoDecoder( | 62 GpuVideoDecoder::GpuVideoDecoder( |
| 64 const scoped_refptr<GpuVideoAcceleratorFactories>& factories, | 63 const scoped_refptr<GpuVideoAcceleratorFactories>& factories) |
| 65 const scoped_refptr<MediaLog>& media_log) | |
| 66 : needs_bitstream_conversion_(false), | 64 : needs_bitstream_conversion_(false), |
| 67 factories_(factories), | 65 factories_(factories), |
| 68 state_(kNormal), | 66 state_(kNormal), |
| 69 media_log_(media_log), | |
| 70 decoder_texture_target_(0), | 67 decoder_texture_target_(0), |
| 71 next_picture_buffer_id_(0), | 68 next_picture_buffer_id_(0), |
| 72 next_bitstream_buffer_id_(0), | 69 next_bitstream_buffer_id_(0), |
| 73 available_pictures_(0), | 70 available_pictures_(0), |
| 74 weak_factory_(this) { | 71 weak_factory_(this) { |
| 75 DCHECK(factories_.get()); | 72 DCHECK(factories_.get()); |
| 76 } | 73 } |
| 77 | 74 |
| 78 void GpuVideoDecoder::Reset(const base::Closure& closure) { | 75 void GpuVideoDecoder::Reset(const base::Closure& closure) { |
| 79 DVLOG(3) << "Reset()"; | 76 DVLOG(3) << "Reset()"; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a | 128 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a |
| 132 // callsite to always be called with the same stat name (can't parameterize it). | 129 // callsite to always be called with the same stat name (can't parameterize it). |
| 133 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( | 130 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( |
| 134 const PipelineStatusCB& cb, | 131 const PipelineStatusCB& cb, |
| 135 PipelineStatus status) { | 132 PipelineStatus status) { |
| 136 UMA_HISTOGRAM_ENUMERATION( | 133 UMA_HISTOGRAM_ENUMERATION( |
| 137 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); | 134 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); |
| 138 cb.Run(status); | 135 cb.Run(status); |
| 139 } | 136 } |
| 140 | 137 |
| 138 std::string GpuVideoDecoder::GetDisplayName() const { | |
| 139 return "GpuVideoDecoder"; | |
| 140 } | |
| 141 | |
| 141 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, | 142 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 142 bool /* low_delay */, | 143 bool /* low_delay */, |
| 143 const PipelineStatusCB& orig_status_cb, | 144 const PipelineStatusCB& orig_status_cb, |
| 144 const OutputCB& output_cb) { | 145 const OutputCB& output_cb) { |
| 145 DVLOG(3) << "Initialize()"; | 146 DVLOG(3) << "Initialize()"; |
| 146 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 147 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 147 DCHECK(config.IsValidConfig()); | 148 DCHECK(config.IsValidConfig()); |
| 148 DCHECK(!config.is_encrypted()); | 149 DCHECK(!config.is_encrypted()); |
| 149 | 150 |
| 150 PipelineStatusCB status_cb = | 151 PipelineStatusCB status_cb = |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 180 return; | 181 return; |
| 181 } | 182 } |
| 182 | 183 |
| 183 vda_ = factories_->CreateVideoDecodeAccelerator().Pass(); | 184 vda_ = factories_->CreateVideoDecodeAccelerator().Pass(); |
| 184 if (!vda_ || !vda_->Initialize(config.profile(), this)) { | 185 if (!vda_ || !vda_->Initialize(config.profile(), this)) { |
| 185 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 186 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 186 return; | 187 return; |
| 187 } | 188 } |
| 188 | 189 |
| 189 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; | 190 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; |
| 190 media_log_->SetStringProperty("video_decoder", "gpu"); | |
|
xhwang
2014/09/08 18:34:51
Just realized we actually had something similar. B
| |
| 191 status_cb.Run(PIPELINE_OK); | 191 status_cb.Run(PIPELINE_OK); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { | 194 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { |
| 195 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 195 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 196 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); | 196 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); |
| 197 ++it) { | 197 ++it) { |
| 198 factories_->DeleteTexture(it->second.texture_id()); | 198 factories_->DeleteTexture(it->second.texture_id()); |
| 199 } | 199 } |
| 200 | 200 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 DLOG(ERROR) << "VDA Error: " << error; | 616 DLOG(ERROR) << "VDA Error: " << error; |
| 617 DestroyVDA(); | 617 DestroyVDA(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 620 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 621 const { | 621 const { |
| 622 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 622 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 623 } | 623 } |
| 624 | 624 |
| 625 } // namespace media | 625 } // namespace media |
| OLD | NEW |