| 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 "media/gpu/vaapi_video_encode_accelerator.h" | 5 #include "media/gpu/vaapi_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
| 17 #include "base/single_thread_task_runner.h" |
| 17 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/gpu/h264_dpb.h" | 19 #include "media/gpu/h264_dpb.h" |
| 19 #include "media/gpu/shared_memory_region.h" | 20 #include "media/gpu/shared_memory_region.h" |
| 20 #include "third_party/libva/va/va_enc_h264.h" | 21 #include "third_party/libva/va/va_enc_h264.h" |
| 21 | 22 |
| 22 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " | 23 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " |
| 23 | 24 |
| 24 #define NOTIFY_ERROR(error, msg) \ | 25 #define NOTIFY_ERROR(error, msg) \ |
| 25 do { \ | 26 do { \ |
| 26 SetState(kError); \ | 27 SetState(kError); \ |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 746 |
| 746 void VaapiVideoEncodeAccelerator::Destroy() { | 747 void VaapiVideoEncodeAccelerator::Destroy() { |
| 747 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 748 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 748 | 749 |
| 749 // Can't call client anymore after Destroy() returns. | 750 // Can't call client anymore after Destroy() returns. |
| 750 client_ptr_factory_.reset(); | 751 client_ptr_factory_.reset(); |
| 751 weak_this_ptr_factory_.InvalidateWeakPtrs(); | 752 weak_this_ptr_factory_.InvalidateWeakPtrs(); |
| 752 | 753 |
| 753 // Early-exit encoder tasks if they are running and join the thread. | 754 // Early-exit encoder tasks if they are running and join the thread. |
| 754 if (encoder_thread_.IsRunning()) { | 755 if (encoder_thread_.IsRunning()) { |
| 755 encoder_thread_.message_loop()->PostTask( | 756 encoder_thread_.task_runner()->PostTask( |
| 756 FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::DestroyTask, | 757 FROM_HERE, base::Bind(&VaapiVideoEncodeAccelerator::DestroyTask, |
| 757 base::Unretained(this))); | 758 base::Unretained(this))); |
| 758 encoder_thread_.Stop(); | 759 encoder_thread_.Stop(); |
| 759 } | 760 } |
| 760 | 761 |
| 761 delete this; | 762 delete this; |
| 762 } | 763 } |
| 763 | 764 |
| 764 void VaapiVideoEncodeAccelerator::DestroyTask() { | 765 void VaapiVideoEncodeAccelerator::DestroyTask() { |
| 765 DVLOGF(2); | 766 DVLOGF(2); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 client_ptr_factory_.reset(); | 1050 client_ptr_factory_.reset(); |
| 1050 } | 1051 } |
| 1051 } | 1052 } |
| 1052 | 1053 |
| 1053 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() | 1054 VaapiVideoEncodeAccelerator::EncodeJob::EncodeJob() |
| 1054 : coded_buffer(VA_INVALID_ID), keyframe(false) {} | 1055 : coded_buffer(VA_INVALID_ID), keyframe(false) {} |
| 1055 | 1056 |
| 1056 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {} | 1057 VaapiVideoEncodeAccelerator::EncodeJob::~EncodeJob() {} |
| 1057 | 1058 |
| 1058 } // namespace media | 1059 } // namespace media |
| OLD | NEW |