| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 822 } |
| 823 | 823 |
| 824 bool size_changed = false; | 824 bool size_changed = false; |
| 825 if (i->second.size() != size_) { | 825 if (i->second.size() != size_) { |
| 826 // Size may have changed due to resolution change since the last time this | 826 // Size may have changed due to resolution change since the last time this |
| 827 // PictureBuffer was used. | 827 // PictureBuffer was used. |
| 828 strategy_->UpdatePictureBufferSize(&i->second, size_); | 828 strategy_->UpdatePictureBufferSize(&i->second, size_); |
| 829 size_changed = true; | 829 size_changed = true; |
| 830 } | 830 } |
| 831 | 831 |
| 832 // Connect the PictureBuffer to the decoded frame, via whatever | |
| 833 // mechanism the strategy likes. | |
| 834 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); | |
| 835 | |
| 836 const bool allow_overlay = strategy_->ArePicturesOverlayable(); | 832 const bool allow_overlay = strategy_->ArePicturesOverlayable(); |
| 837 | |
| 838 media::Picture picture(picture_buffer_id, bitstream_id, gfx::Rect(size_), | 833 media::Picture picture(picture_buffer_id, bitstream_id, gfx::Rect(size_), |
| 839 allow_overlay); | 834 allow_overlay); |
| 840 picture.set_size_changed(size_changed); | 835 picture.set_size_changed(size_changed); |
| 841 | 836 |
| 842 base::MessageLoop::current()->PostTask( | 837 // Notify picture ready before calling UseCodecBufferForPictureBuffer() since |
| 843 FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, | 838 // that process may be slow and shouldn't delay delivery of the frame to the |
| 844 weak_this_factory_.GetWeakPtr(), picture)); | 839 // renderer. The picture is only used on the same thread as this method is |
| 840 // called, so it is safe to do this. |
| 841 NotifyPictureReady(picture); |
| 842 |
| 843 // Connect the PictureBuffer to the decoded frame, via whatever mechanism the |
| 844 // strategy likes. |
| 845 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); |
| 845 } | 846 } |
| 846 | 847 |
| 847 void AndroidVideoDecodeAccelerator::Decode( | 848 void AndroidVideoDecodeAccelerator::Decode( |
| 848 const media::BitstreamBuffer& bitstream_buffer) { | 849 const media::BitstreamBuffer& bitstream_buffer) { |
| 849 DCHECK(thread_checker_.CalledOnValidThread()); | 850 DCHECK(thread_checker_.CalledOnValidThread()); |
| 850 | 851 |
| 851 if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) { | 852 if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) { |
| 852 DecodeBuffer(bitstream_buffer); | 853 DecodeBuffer(bitstream_buffer); |
| 853 return; | 854 return; |
| 854 } | 855 } |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1459 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
| 1459 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1460 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
| 1460 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1461 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
| 1461 } | 1462 } |
| 1462 } | 1463 } |
| 1463 | 1464 |
| 1464 return capabilities; | 1465 return capabilities; |
| 1465 } | 1466 } |
| 1466 | 1467 |
| 1467 } // namespace content | 1468 } // namespace content |
| OLD | NEW |