| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_encode_accelerator.h" | 5 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "base/numerics/safe_conversions.h" | 14 #include "base/numerics/safe_conversions.h" |
| 14 #include "content/common/gpu/media/h264_dpb.h" | 15 #include "content/common/gpu/media/h264_dpb.h" |
| 15 #include "media/base/bind_to_current_loop.h" | 16 #include "media/base/bind_to_current_loop.h" |
| 16 #include "third_party/libva/va/va_enc_h264.h" | 17 #include "third_party/libva/va/va_enc_h264.h" |
| 17 | 18 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 bool force_keyframe) | 96 bool force_keyframe) |
| 96 : frame(frame), force_keyframe(force_keyframe) {} | 97 : frame(frame), force_keyframe(force_keyframe) {} |
| 97 const scoped_refptr<media::VideoFrame> frame; | 98 const scoped_refptr<media::VideoFrame> frame; |
| 98 const bool force_keyframe; | 99 const bool force_keyframe; |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { | 102 struct VaapiVideoEncodeAccelerator::BitstreamBufferRef { |
| 102 BitstreamBufferRef(int32_t id, | 103 BitstreamBufferRef(int32_t id, |
| 103 scoped_ptr<base::SharedMemory> shm, | 104 scoped_ptr<base::SharedMemory> shm, |
| 104 size_t size) | 105 size_t size) |
| 105 : id(id), shm(shm.Pass()), size(size) {} | 106 : id(id), shm(std::move(shm)), size(size) {} |
| 106 const int32_t id; | 107 const int32_t id; |
| 107 const scoped_ptr<base::SharedMemory> shm; | 108 const scoped_ptr<base::SharedMemory> shm; |
| 108 const size_t size; | 109 const size_t size; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 media::VideoEncodeAccelerator::SupportedProfiles | 112 media::VideoEncodeAccelerator::SupportedProfiles |
| 112 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { | 113 VaapiVideoEncodeAccelerator::GetSupportedProfiles() { |
| 113 return VaapiWrapper::GetSupportedEncodeProfiles(); | 114 return VaapiWrapper::GetSupportedEncodeProfiles(); |
| 114 } | 115 } |
| 115 | 116 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 670 } |
| 670 | 671 |
| 671 scoped_ptr<base::SharedMemory> shm( | 672 scoped_ptr<base::SharedMemory> shm( |
| 672 new base::SharedMemory(buffer.handle(), false)); | 673 new base::SharedMemory(buffer.handle(), false)); |
| 673 if (!shm->Map(buffer.size())) { | 674 if (!shm->Map(buffer.size())) { |
| 674 NOTIFY_ERROR(kPlatformFailureError, "Failed mapping shared memory."); | 675 NOTIFY_ERROR(kPlatformFailureError, "Failed mapping shared memory."); |
| 675 return; | 676 return; |
| 676 } | 677 } |
| 677 | 678 |
| 678 scoped_ptr<BitstreamBufferRef> buffer_ref( | 679 scoped_ptr<BitstreamBufferRef> buffer_ref( |
| 679 new BitstreamBufferRef(buffer.id(), shm.Pass(), buffer.size())); | 680 new BitstreamBufferRef(buffer.id(), std::move(shm), buffer.size())); |
| 680 | 681 |
| 681 encoder_thread_task_runner_->PostTask( | 682 encoder_thread_task_runner_->PostTask( |
| 682 FROM_HERE, | 683 FROM_HERE, |
| 683 base::Bind(&VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask, | 684 base::Bind(&VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask, |
| 684 base::Unretained(this), base::Passed(&buffer_ref))); | 685 base::Unretained(this), base::Passed(&buffer_ref))); |
| 685 } | 686 } |
| 686 | 687 |
| 687 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask( | 688 void VaapiVideoEncodeAccelerator::UseOutputBitstreamBufferTask( |
| 688 scoped_ptr<BitstreamBufferRef> buffer_ref) { | 689 scoped_ptr<BitstreamBufferRef> buffer_ref) { |
| 689 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); | 690 DCHECK(encoder_thread_task_runner_->BelongsToCurrentThread()); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 } | 1058 } |
| 1058 | 1059 |
| 1059 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1060 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1060 : coded_buffer(VA_INVALID_ID), keyframe(false) { | 1061 : coded_buffer(VA_INVALID_ID), keyframe(false) { |
| 1061 } | 1062 } |
| 1062 | 1063 |
| 1063 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { | 1064 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() { |
| 1064 } | 1065 } |
| 1065 | 1066 |
| 1066 } // namespace content | 1067 } // namespace content |
| OLD | NEW |