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 "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer( | 439 void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer( |
440 const media::BitstreamBuffer& bitstream_buffer) { | 440 const media::BitstreamBuffer& bitstream_buffer) { |
441 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 441 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
442 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id", | 442 TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id", |
443 bitstream_buffer.id()); | 443 bitstream_buffer.id()); |
444 | 444 |
445 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() | 445 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() |
446 << " size: " << (int)bitstream_buffer.size(); | 446 << " size: " << (int)bitstream_buffer.size(); |
447 | 447 |
448 scoped_ptr<base::SharedMemory> shm( | 448 scoped_ptr<SharedMemoryRegion> shm( |
449 new base::SharedMemory(bitstream_buffer.handle(), true)); | 449 new SharedMemoryRegion(bitstream_buffer, true)); |
450 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(bitstream_buffer.size()), | 450 RETURN_AND_NOTIFY_ON_FAILURE(shm->Map(), "Failed to map input buffer", |
451 "Failed to map input buffer", UNREADABLE_INPUT,); | 451 UNREADABLE_INPUT, ); |
452 | 452 |
453 base::AutoLock auto_lock(lock_); | 453 base::AutoLock auto_lock(lock_); |
454 | 454 |
455 // Set up a new input buffer and queue it for later. | 455 // Set up a new input buffer and queue it for later. |
456 linked_ptr<InputBuffer> input_buffer(new InputBuffer()); | 456 linked_ptr<InputBuffer> input_buffer(new InputBuffer()); |
457 input_buffer->shm.reset(shm.release()); | 457 input_buffer->shm.reset(shm.release()); |
458 input_buffer->id = bitstream_buffer.id(); | 458 input_buffer->id = bitstream_buffer.id(); |
459 input_buffer->size = bitstream_buffer.size(); | |
460 | 459 |
461 ++num_stream_bufs_at_decoder_; | 460 ++num_stream_bufs_at_decoder_; |
462 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder", | 461 TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder", |
463 num_stream_bufs_at_decoder_); | 462 num_stream_bufs_at_decoder_); |
464 | 463 |
465 input_buffers_.push(input_buffer); | 464 input_buffers_.push(input_buffer); |
466 input_ready_.Signal(); | 465 input_ready_.Signal(); |
467 } | 466 } |
468 | 467 |
469 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { | 468 bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() { |
(...skipping 24 matching lines...) Expand all Loading... |
494 | 493 |
495 curr_input_buffer_ = input_buffers_.front(); | 494 curr_input_buffer_ = input_buffers_.front(); |
496 input_buffers_.pop(); | 495 input_buffers_.pop(); |
497 | 496 |
498 DVLOG(4) << "New current bitstream buffer, id: " | 497 DVLOG(4) << "New current bitstream buffer, id: " |
499 << curr_input_buffer_->id | 498 << curr_input_buffer_->id |
500 << " size: " << curr_input_buffer_->size; | 499 << " size: " << curr_input_buffer_->size; |
501 | 500 |
502 decoder_->SetStream( | 501 decoder_->SetStream( |
503 static_cast<uint8*>(curr_input_buffer_->shm->memory()), | 502 static_cast<uint8*>(curr_input_buffer_->shm->memory()), |
504 curr_input_buffer_->size); | 503 curr_input_buffer_->shm->size()); |
505 return true; | 504 return true; |
506 | 505 |
507 default: | 506 default: |
508 // We got woken up due to being destroyed/reset, ignore any already | 507 // We got woken up due to being destroyed/reset, ignore any already |
509 // queued inputs. | 508 // queued inputs. |
510 return false; | 509 return false; |
511 } | 510 } |
512 } | 511 } |
513 | 512 |
514 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { | 513 void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() { |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 return vaapi_pic->dec_surface(); | 1738 return vaapi_pic->dec_surface(); |
1740 } | 1739 } |
1741 | 1740 |
1742 // static | 1741 // static |
1743 media::VideoDecodeAccelerator::SupportedProfiles | 1742 media::VideoDecodeAccelerator::SupportedProfiles |
1744 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { | 1743 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { |
1745 return VaapiWrapper::GetSupportedDecodeProfiles(); | 1744 return VaapiWrapper::GetSupportedDecodeProfiles(); |
1746 } | 1745 } |
1747 | 1746 |
1748 } // namespace content | 1747 } // namespace content |
OLD | NEW |