| 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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 91 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 | 94 |
| 95 DCHECK(pending_reset_cb_.is_null()); | 95 DCHECK(pending_reset_cb_.is_null()); |
| 96 pending_reset_cb_ = BindToCurrentLoop(closure); | 96 pending_reset_cb_ = BindToCurrentLoop(closure); |
| 97 | 97 |
| 98 vda_->Reset(); | 98 vda_->Reset(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void GpuVideoDecoder::Stop() { | |
| 102 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | |
| 103 if (vda_) | |
| 104 DestroyVDA(); | |
| 105 DCHECK(bitstream_buffers_in_decoder_.empty()); | |
| 106 if (!pending_reset_cb_.is_null()) | |
| 107 base::ResetAndReturn(&pending_reset_cb_).Run(); | |
| 108 } | |
| 109 | |
| 110 static bool IsCodedSizeSupported(const gfx::Size& coded_size) { | 101 static bool IsCodedSizeSupported(const gfx::Size& coded_size) { |
| 111 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 112 // Windows Media Foundation H.264 decoding does not support decoding videos | 103 // Windows Media Foundation H.264 decoding does not support decoding videos |
| 113 // with any dimension smaller than 48 pixels: | 104 // with any dimension smaller than 48 pixels: |
| 114 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 | 105 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 |
| 115 if (coded_size.width() < 48 || coded_size.height() < 48) | 106 if (coded_size.width() < 48 || coded_size.height() < 48) |
| 116 return false; | 107 return false; |
| 117 #endif | 108 #endif |
| 118 | 109 |
| 119 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. | 110 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 return; | 544 return; |
| 554 } | 545 } |
| 555 | 546 |
| 556 PutSHM(it->second.shm_buffer); | 547 PutSHM(it->second.shm_buffer); |
| 557 it->second.done_cb.Run(state_ == kError ? kDecodeError : kOk); | 548 it->second.done_cb.Run(state_ == kError ? kDecodeError : kOk); |
| 558 bitstream_buffers_in_decoder_.erase(it); | 549 bitstream_buffers_in_decoder_.erase(it); |
| 559 } | 550 } |
| 560 | 551 |
| 561 GpuVideoDecoder::~GpuVideoDecoder() { | 552 GpuVideoDecoder::~GpuVideoDecoder() { |
| 562 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 553 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 563 // Stop should have been already called. | 554 if (vda_) |
| 564 DCHECK(!vda_.get() && assigned_picture_buffers_.empty()); | 555 DestroyVDA(); |
| 565 DCHECK(bitstream_buffers_in_decoder_.empty()); | 556 DCHECK(bitstream_buffers_in_decoder_.empty()); |
| 557 DCHECK(assigned_picture_buffers_.empty()); |
| 558 |
| 559 if (!pending_reset_cb_.is_null()) |
| 560 base::ResetAndReturn(&pending_reset_cb_).Run(); |
| 561 |
| 566 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { | 562 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { |
| 567 available_shm_segments_[i]->shm->Close(); | 563 available_shm_segments_[i]->shm->Close(); |
| 568 delete available_shm_segments_[i]; | 564 delete available_shm_segments_[i]; |
| 569 } | 565 } |
| 570 available_shm_segments_.clear(); | 566 available_shm_segments_.clear(); |
| 567 |
| 571 for (std::map<int32, PendingDecoderBuffer>::iterator it = | 568 for (std::map<int32, PendingDecoderBuffer>::iterator it = |
| 572 bitstream_buffers_in_decoder_.begin(); | 569 bitstream_buffers_in_decoder_.begin(); |
| 573 it != bitstream_buffers_in_decoder_.end(); ++it) { | 570 it != bitstream_buffers_in_decoder_.end(); ++it) { |
| 574 it->second.shm_buffer->shm->Close(); | 571 it->second.shm_buffer->shm->Close(); |
| 575 } | 572 } |
| 576 bitstream_buffers_in_decoder_.clear(); | 573 bitstream_buffers_in_decoder_.clear(); |
| 577 } | 574 } |
| 578 | 575 |
| 579 void GpuVideoDecoder::NotifyFlushDone() { | 576 void GpuVideoDecoder::NotifyFlushDone() { |
| 580 DVLOG(3) << "NotifyFlushDone()"; | 577 DVLOG(3) << "NotifyFlushDone()"; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 607 DLOG(ERROR) << "VDA Error: " << error; | 604 DLOG(ERROR) << "VDA Error: " << error; |
| 608 DestroyVDA(); | 605 DestroyVDA(); |
| 609 } | 606 } |
| 610 | 607 |
| 611 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 608 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 612 const { | 609 const { |
| 613 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 610 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 614 } | 611 } |
| 615 | 612 |
| 616 } // namespace media | 613 } // namespace media |
| OLD | NEW |