| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 request_surface_cb_(request_surface_cb), | 81 request_surface_cb_(request_surface_cb), |
| 82 media_log_(media_log), | 82 media_log_(media_log), |
| 83 state_(kNormal), | 83 state_(kNormal), |
| 84 decoder_texture_target_(0), | 84 decoder_texture_target_(0), |
| 85 pixel_format_(PIXEL_FORMAT_UNKNOWN), | 85 pixel_format_(PIXEL_FORMAT_UNKNOWN), |
| 86 next_picture_buffer_id_(0), | 86 next_picture_buffer_id_(0), |
| 87 next_bitstream_buffer_id_(0), | 87 next_bitstream_buffer_id_(0), |
| 88 available_pictures_(0), | 88 available_pictures_(0), |
| 89 needs_all_picture_buffers_to_decode_(false), | 89 needs_all_picture_buffers_to_decode_(false), |
| 90 supports_deferred_initialization_(false), | 90 supports_deferred_initialization_(false), |
| 91 requires_texture_copy_(false), |
| 91 weak_factory_(this) { | 92 weak_factory_(this) { |
| 92 DCHECK(factories_); | 93 DCHECK(factories_); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void GpuVideoDecoder::Reset(const base::Closure& closure) { | 96 void GpuVideoDecoder::Reset(const base::Closure& closure) { |
| 96 DVLOG(3) << "Reset()"; | 97 DVLOG(3) << "Reset()"; |
| 97 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 98 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 98 | 99 |
| 99 if (state_ == kDrainingDecoder) { | 100 if (state_ == kDrainingDecoder) { |
| 100 base::ThreadTaskRunnerHandle::Get()->PostTask( | 101 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 << " is_encrypted: " << (config.is_encrypted() ? "yes." : "no."); | 213 << " is_encrypted: " << (config.is_encrypted() ? "yes." : "no."); |
| 213 bound_init_cb.Run(false); | 214 bound_init_cb.Run(false); |
| 214 return; | 215 return; |
| 215 } | 216 } |
| 216 | 217 |
| 217 config_ = config; | 218 config_ = config; |
| 218 needs_all_picture_buffers_to_decode_ = | 219 needs_all_picture_buffers_to_decode_ = |
| 219 capabilities.flags & | 220 capabilities.flags & |
| 220 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; | 221 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; |
| 221 needs_bitstream_conversion_ = (config.codec() == kCodecH264); | 222 needs_bitstream_conversion_ = (config.codec() == kCodecH264); |
| 223 requires_texture_copy_ = |
| 224 !!(capabilities.flags & |
| 225 VideoDecodeAccelerator::Capabilities::REQUIRES_TEXTURE_COPY); |
| 222 supports_deferred_initialization_ = !!( | 226 supports_deferred_initialization_ = !!( |
| 223 capabilities.flags & | 227 capabilities.flags & |
| 224 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION); | 228 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION); |
| 225 output_cb_ = output_cb; | 229 output_cb_ = output_cb; |
| 226 | 230 |
| 227 if (config.is_encrypted() && !supports_deferred_initialization_) { | 231 if (config.is_encrypted() && !supports_deferred_initialization_) { |
| 228 DVLOG(1) << __FUNCTION__ | 232 DVLOG(1) << __FUNCTION__ |
| 229 << " Encrypted stream requires deferred initialialization."; | 233 << " Encrypted stream requires deferred initialialization."; |
| 230 bound_init_cb.Run(false); | 234 bound_init_cb.Run(false); |
| 231 return; | 235 return; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (!frame) { | 603 if (!frame) { |
| 600 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); | 604 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); |
| 601 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 605 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 602 return; | 606 return; |
| 603 } | 607 } |
| 604 if (picture.allow_overlay()) | 608 if (picture.allow_overlay()) |
| 605 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); | 609 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); |
| 606 #if defined(OS_MACOSX) || defined(OS_WIN) | 610 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 607 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); | 611 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); |
| 608 #endif | 612 #endif |
| 613 |
| 614 if (requires_texture_copy_) |
| 615 frame->metadata()->SetBoolean(VideoFrameMetadata::COPY_REQUIRED, true); |
| 616 |
| 609 CHECK_GT(available_pictures_, 0); | 617 CHECK_GT(available_pictures_, 0); |
| 610 --available_pictures_; | 618 --available_pictures_; |
| 611 | 619 |
| 612 bool inserted = | 620 bool inserted = |
| 613 picture_buffers_at_display_ | 621 picture_buffers_at_display_ |
| 614 .insert(std::make_pair(picture.picture_buffer_id(), pb.texture_ids())) | 622 .insert(std::make_pair(picture.picture_buffer_id(), pb.texture_ids())) |
| 615 .second; | 623 .second; |
| 616 DCHECK(inserted); | 624 DCHECK(inserted); |
| 617 | 625 |
| 618 DeliverFrame(frame); | 626 DeliverFrame(frame); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 817 } |
| 810 return false; | 818 return false; |
| 811 } | 819 } |
| 812 | 820 |
| 813 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 821 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 814 const { | 822 const { |
| 815 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 823 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 816 } | 824 } |
| 817 | 825 |
| 818 } // namespace media | 826 } // namespace media |
| OLD | NEW |