Commit 31e2e42a authored by Dan Sanders's avatar Dan Sanders Committed by Commit Bot

[media] Support parent thread decode in VdaVideoDecoder.

Bug: 522298
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I48b205e7b20cf512e953d5992be6ed507add688b
Reviewed-on: https://chromium-review.googlesource.com/1217716Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590479}
parent 2d79a618
...@@ -318,11 +318,13 @@ void VdaVideoDecoder::InitializeOnGpuThread() { ...@@ -318,11 +318,13 @@ void VdaVideoDecoder::InitializeOnGpuThread() {
return; return;
} }
// TODO(sandersd): TryToSetupDecodeOnSeparateThread().
gpu_weak_vda_factory_.reset( gpu_weak_vda_factory_.reset(
new base::WeakPtrFactory<VideoDecodeAccelerator>(vda_.get())); new base::WeakPtrFactory<VideoDecodeAccelerator>(vda_.get()));
gpu_weak_vda_ = gpu_weak_vda_factory_->GetWeakPtr(); gpu_weak_vda_ = gpu_weak_vda_factory_->GetWeakPtr();
vda_initialized_ = true; vda_initialized_ = true;
decode_on_parent_thread_ = vda_->TryToSetupDecodeOnSeparateThread(
parent_weak_this_, parent_task_runner_);
parent_task_runner_->PostTask(FROM_HERE, parent_task_runner_->PostTask(FROM_HERE,
base::BindOnce(&VdaVideoDecoder::InitializeDone, base::BindOnce(&VdaVideoDecoder::InitializeDone,
...@@ -374,6 +376,11 @@ void VdaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer, ...@@ -374,6 +376,11 @@ void VdaVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
timestamps_.Put(bitstream_buffer_id, buffer->timestamp()); timestamps_.Put(bitstream_buffer_id, buffer->timestamp());
decode_cbs_[bitstream_buffer_id] = decode_cb; decode_cbs_[bitstream_buffer_id] = decode_cb;
if (decode_on_parent_thread_) {
vda_->Decode(std::move(buffer), bitstream_buffer_id);
return;
}
gpu_task_runner_->PostTask( gpu_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&VdaVideoDecoder::DecodeOnGpuThread, gpu_weak_this_, base::BindOnce(&VdaVideoDecoder::DecodeOnGpuThread, gpu_weak_this_,
......
...@@ -187,16 +187,17 @@ class VdaVideoDecoder : public VideoDecoder, ...@@ -187,16 +187,17 @@ class VdaVideoDecoder : public VideoDecoder,
// large enough to account for any amount of frame reordering. // large enough to account for any amount of frame reordering.
base::MRUCache<int32_t, base::TimeDelta> timestamps_; base::MRUCache<int32_t, base::TimeDelta> timestamps_;
//
// GPU thread state.
//
std::unique_ptr<VideoDecodeAccelerator> vda_;
bool vda_initialized_ = false;
// //
// Shared state. // Shared state.
// //
// Only read on GPU thread during initialization, which is mutually exclusive
// with writes on the parent thread.
VideoDecoderConfig config_; VideoDecoderConfig config_;
// Only written on the GPU thread during initialization, which is mutually
// exclusive with reads on the parent thread.
std::unique_ptr<VideoDecodeAccelerator> vda_;
bool vda_initialized_ = false;
bool decode_on_parent_thread_ = false;
// //
// Weak pointers, prefixed by bound thread. // Weak pointers, prefixed by bound thread.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment