| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 const RequestSurfaceCB& request_surface_cb) | 73 const RequestSurfaceCB& request_surface_cb) |
| 74 : needs_bitstream_conversion_(false), | 74 : needs_bitstream_conversion_(false), |
| 75 factories_(factories), | 75 factories_(factories), |
| 76 state_(kNormal), | 76 state_(kNormal), |
| 77 request_surface_cb_(request_surface_cb), | 77 request_surface_cb_(request_surface_cb), |
| 78 decoder_texture_target_(0), | 78 decoder_texture_target_(0), |
| 79 next_picture_buffer_id_(0), | 79 next_picture_buffer_id_(0), |
| 80 next_bitstream_buffer_id_(0), | 80 next_bitstream_buffer_id_(0), |
| 81 available_pictures_(0), | 81 available_pictures_(0), |
| 82 needs_all_picture_buffers_to_decode_(false), | 82 needs_all_picture_buffers_to_decode_(false), |
| 83 copy_required_(false), |
| 83 weak_factory_(this) { | 84 weak_factory_(this) { |
| 84 DCHECK(factories_); | 85 DCHECK(factories_); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void GpuVideoDecoder::Reset(const base::Closure& closure) { | 88 void GpuVideoDecoder::Reset(const base::Closure& closure) { |
| 88 DVLOG(3) << "Reset()"; | 89 DVLOG(3) << "Reset()"; |
| 89 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 90 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 90 | 91 |
| 91 if (state_ == kDrainingDecoder) { | 92 if (state_ == kDrainingDecoder) { |
| 92 base::MessageLoop::current()->PostTask( | 93 base::MessageLoop::current()->PostTask( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 DVLOG(1) << "Profile " << config.profile() << " or coded size " | 174 DVLOG(1) << "Profile " << config.profile() << " or coded size " |
| 174 << config.coded_size().ToString() << " not supported."; | 175 << config.coded_size().ToString() << " not supported."; |
| 175 bound_init_cb.Run(false); | 176 bound_init_cb.Run(false); |
| 176 return; | 177 return; |
| 177 } | 178 } |
| 178 | 179 |
| 179 config_ = config; | 180 config_ = config; |
| 180 needs_all_picture_buffers_to_decode_ = | 181 needs_all_picture_buffers_to_decode_ = |
| 181 capabilities.flags & | 182 capabilities.flags & |
| 182 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; | 183 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; |
| 184 copy_required_ = (capabilities.flags & |
| 185 VideoDecodeAccelerator::Capabilities::COPY_REQUIRED) == |
| 186 VideoDecodeAccelerator::Capabilities::COPY_REQUIRED; |
| 183 needs_bitstream_conversion_ = (config.codec() == kCodecH264); | 187 needs_bitstream_conversion_ = (config.codec() == kCodecH264); |
| 184 output_cb_ = BindToCurrentLoop(output_cb); | 188 output_cb_ = BindToCurrentLoop(output_cb); |
| 185 | 189 |
| 186 if (previously_initialized) { | 190 if (previously_initialized) { |
| 187 DVLOG(3) << __FUNCTION__ | 191 DVLOG(3) << __FUNCTION__ |
| 188 << " Expecting initialized VDA to detect in-stream config change."; | 192 << " Expecting initialized VDA to detect in-stream config change."; |
| 189 // Reinitialization with a different config (but same codec and profile). | 193 // Reinitialization with a different config (but same codec and profile). |
| 190 // VDA should handle it by detecting this in-stream by itself, | 194 // VDA should handle it by detecting this in-stream by itself, |
| 191 // no need to notify it. | 195 // no need to notify it. |
| 192 bound_init_cb.Run(true); | 196 bound_init_cb.Run(true); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), | 513 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), |
| 510 factories_, picture.picture_buffer_id(), pb.texture_id())), | 514 factories_, picture.picture_buffer_id(), pb.texture_id())), |
| 511 pb.size(), visible_rect, natural_size, timestamp)); | 515 pb.size(), visible_rect, natural_size, timestamp)); |
| 512 if (!frame) { | 516 if (!frame) { |
| 513 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); | 517 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); |
| 514 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 518 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 515 return; | 519 return; |
| 516 } | 520 } |
| 517 if (picture.allow_overlay()) | 521 if (picture.allow_overlay()) |
| 518 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); | 522 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); |
| 523 if (copy_required_) |
| 524 frame->metadata()->SetBoolean(VideoFrameMetadata::COPY_REQUIRED, true); |
| 519 CHECK_GT(available_pictures_, 0); | 525 CHECK_GT(available_pictures_, 0); |
| 520 --available_pictures_; | 526 --available_pictures_; |
| 521 bool inserted = | 527 bool inserted = |
| 522 picture_buffers_at_display_.insert(std::make_pair( | 528 picture_buffers_at_display_.insert(std::make_pair( |
| 523 picture.picture_buffer_id(), | 529 picture.picture_buffer_id(), |
| 524 pb.texture_id())).second; | 530 pb.texture_id())).second; |
| 525 DCHECK(inserted); | 531 DCHECK(inserted); |
| 526 | 532 |
| 527 DeliverFrame(frame); | 533 DeliverFrame(frame); |
| 528 } | 534 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 714 } |
| 709 return false; | 715 return false; |
| 710 } | 716 } |
| 711 | 717 |
| 712 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 718 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 713 const { | 719 const { |
| 714 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 720 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 715 } | 721 } |
| 716 | 722 |
| 717 } // namespace media | 723 } // namespace media |
| OLD | NEW |