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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "media/base/decoder_buffer.h" |
11 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
12 #include "media/base/filter_host.h" | 13 #include "media/base/filter_host.h" |
13 #include "media/base/pipeline.h" | 14 #include "media/base/pipeline.h" |
14 #include "media/base/video_decoder_config.h" | 15 #include "media/base/video_decoder_config.h" |
15 #include "media/ffmpeg/ffmpeg_common.h" | 16 #include "media/ffmpeg/ffmpeg_common.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 GpuVideoDecoder::Factories::~Factories() {} | 20 GpuVideoDecoder::Factories::~Factories() {} |
20 | 21 |
21 // Size of shared-memory segments we allocate. Since we reuse them we let them | 22 // Size of shared-memory segments we allocate. Since we reuse them we let them |
22 // be on the beefy side. | 23 // be on the beefy side. |
23 static const size_t kSharedMemorySegmentBytes = 100 << 10; | 24 static const size_t kSharedMemorySegmentBytes = 100 << 10; |
24 | 25 |
25 GpuVideoDecoder::SHMBuffer::SHMBuffer(base::SharedMemory* m, size_t s) | 26 GpuVideoDecoder::SHMBuffer::SHMBuffer(base::SharedMemory* m, size_t s) |
26 : shm(m), size(s) { | 27 : shm(m), size(s) { |
27 } | 28 } |
28 | 29 |
29 GpuVideoDecoder::SHMBuffer::~SHMBuffer() {} | 30 GpuVideoDecoder::SHMBuffer::~SHMBuffer() {} |
30 | 31 |
31 GpuVideoDecoder::BufferPair::BufferPair( | 32 GpuVideoDecoder::BufferPair::BufferPair( |
32 SHMBuffer* s, const scoped_refptr<Buffer>& b) : shm_buffer(s), buffer(b) { | 33 SHMBuffer* s, const scoped_refptr<DecoderBuffer>& b) |
| 34 : shm_buffer(s), buffer(b) { |
33 } | 35 } |
34 | 36 |
35 GpuVideoDecoder::BufferPair::~BufferPair() {} | 37 GpuVideoDecoder::BufferPair::~BufferPair() {} |
36 | 38 |
37 GpuVideoDecoder::BufferTimeData::BufferTimeData( | 39 GpuVideoDecoder::BufferTimeData::BufferTimeData( |
38 int32 bbid, base::TimeDelta ts, base::TimeDelta dur) | 40 int32 bbid, base::TimeDelta ts, base::TimeDelta dur) |
39 : bitstream_buffer_id(bbid), timestamp(ts), duration(dur) { | 41 : bitstream_buffer_id(bbid), timestamp(ts), duration(dur) { |
40 } | 42 } |
41 | 43 |
42 GpuVideoDecoder::BufferTimeData::~BufferTimeData() {} | 44 GpuVideoDecoder::BufferTimeData::~BufferTimeData() {} |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 case kNormal: | 188 case kNormal: |
187 EnsureDemuxOrDecode(); | 189 EnsureDemuxOrDecode(); |
188 break; | 190 break; |
189 case kDrainingDecoder: | 191 case kDrainingDecoder: |
190 // Do nothing. Will be satisfied either by a PictureReady or | 192 // Do nothing. Will be satisfied either by a PictureReady or |
191 // NotifyFlushDone below. | 193 // NotifyFlushDone below. |
192 break; | 194 break; |
193 } | 195 } |
194 } | 196 } |
195 | 197 |
196 void GpuVideoDecoder::RequestBufferDecode(const scoped_refptr<Buffer>& buffer) { | 198 void GpuVideoDecoder::RequestBufferDecode( |
| 199 const scoped_refptr<DecoderBuffer>& buffer) { |
197 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 200 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
198 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 201 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
199 &GpuVideoDecoder::RequestBufferDecode, this, buffer)); | 202 &GpuVideoDecoder::RequestBufferDecode, this, buffer)); |
200 return; | 203 return; |
201 } | 204 } |
202 demuxer_read_in_progress_ = false; | 205 demuxer_read_in_progress_ = false; |
203 | 206 |
204 if (!buffer) { | 207 if (!buffer) { |
205 if (pending_read_cb_.is_null()) | 208 if (pending_read_cb_.is_null()) |
206 return; | 209 return; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 436 |
434 std::map<int32, BufferPair>::iterator it = | 437 std::map<int32, BufferPair>::iterator it = |
435 bitstream_buffers_in_decoder_.find(id); | 438 bitstream_buffers_in_decoder_.find(id); |
436 if (it == bitstream_buffers_in_decoder_.end()) { | 439 if (it == bitstream_buffers_in_decoder_.end()) { |
437 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 440 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
438 NOTREACHED() << "Missing bitstream buffer: " << id; | 441 NOTREACHED() << "Missing bitstream buffer: " << id; |
439 return; | 442 return; |
440 } | 443 } |
441 | 444 |
442 PutSHM(it->second.shm_buffer); | 445 PutSHM(it->second.shm_buffer); |
443 const scoped_refptr<Buffer>& buffer = it->second.buffer; | 446 const scoped_refptr<DecoderBuffer>& buffer = it->second.buffer; |
444 if (buffer->GetDataSize()) { | 447 if (buffer->GetDataSize()) { |
445 PipelineStatistics statistics; | 448 PipelineStatistics statistics; |
446 statistics.video_bytes_decoded = buffer->GetDataSize(); | 449 statistics.video_bytes_decoded = buffer->GetDataSize(); |
447 statistics_cb_.Run(statistics); | 450 statistics_cb_.Run(statistics); |
448 } | 451 } |
449 bitstream_buffers_in_decoder_.erase(it); | 452 bitstream_buffers_in_decoder_.erase(it); |
450 | 453 |
451 if (!pending_read_cb_.is_null() && pending_reset_cb_.is_null() && | 454 if (!pending_read_cb_.is_null() && pending_reset_cb_.is_null() && |
452 state_ != kDrainingDecoder && | 455 state_ != kDrainingDecoder && |
453 bitstream_buffers_in_decoder_.empty()) { | 456 bitstream_buffers_in_decoder_.empty()) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 532 |
530 error_occured_ = true; | 533 error_occured_ = true; |
531 | 534 |
532 if (!pending_read_cb_.is_null()) { | 535 if (!pending_read_cb_.is_null()) { |
533 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 536 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
534 return; | 537 return; |
535 } | 538 } |
536 } | 539 } |
537 | 540 |
538 } // namespace media | 541 } // namespace media |
OLD | NEW |