OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/gpu/arc_gpu_video_decode_accelerator.h" | 5 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/public/gpu/gpu_video_decode_accelerator_factory.h" | 10 #include "content/public/gpu/gpu_video_decode_accelerator_factory.h" |
11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 namespace arc { | 14 namespace arc { |
15 | 15 |
16 ArcGpuVideoDecodeAccelerator::InputRecord::InputRecord( | 16 ArcGpuVideoDecodeAccelerator::InputRecord::InputRecord( |
17 int32_t bitstream_buffer_id, | 17 int32_t bitstream_buffer_id, |
18 uint32_t buffer_index, | 18 uint32_t buffer_index, |
19 int64_t timestamp) | 19 int64_t timestamp) |
20 : bitstream_buffer_id(bitstream_buffer_id), | 20 : bitstream_buffer_id(bitstream_buffer_id), |
21 buffer_index(buffer_index), | 21 buffer_index(buffer_index), |
22 timestamp(timestamp) {} | 22 timestamp(timestamp) {} |
23 | 23 |
24 ArcGpuVideoDecodeAccelerator::InputBufferInfo::InputBufferInfo() | 24 ArcGpuVideoDecodeAccelerator::InputBufferInfo::InputBufferInfo() = default; |
25 : offset(0), length(0) {} | |
26 | 25 |
27 ArcGpuVideoDecodeAccelerator::InputBufferInfo::InputBufferInfo( | 26 ArcGpuVideoDecodeAccelerator::InputBufferInfo::InputBufferInfo( |
28 InputBufferInfo&& other) | 27 InputBufferInfo&& other) = default; |
29 : handle(std::move(other.handle)), | |
30 offset(other.offset), | |
31 length(other.length) {} | |
32 | 28 |
33 ArcGpuVideoDecodeAccelerator::InputBufferInfo::~InputBufferInfo() {} | 29 ArcGpuVideoDecodeAccelerator::InputBufferInfo::~InputBufferInfo() = default; |
| 30 |
| 31 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo() = default; |
| 32 |
| 33 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo( |
| 34 OutputBufferInfo&& other) = default; |
| 35 |
| 36 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::~OutputBufferInfo() = default; |
34 | 37 |
35 ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator() | 38 ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator() |
36 : pending_eos_output_buffer_(false), | 39 : pending_eos_output_buffer_(false), |
37 arc_client_(nullptr), | 40 arc_client_(nullptr), |
38 next_bitstream_buffer_id_(0), | 41 next_bitstream_buffer_id_(0), |
39 output_buffer_size_(0) {} | 42 output_buffer_size_(0) {} |
40 | 43 |
41 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() {} | 44 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() {} |
42 | 45 |
43 namespace { | 46 namespace { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return; | 152 return; |
150 } | 153 } |
151 InputBufferInfo* input_info = &input_buffer_info_[index]; | 154 InputBufferInfo* input_info = &input_buffer_info_[index]; |
152 input_info->handle = std::move(ashmem_fd); | 155 input_info->handle = std::move(ashmem_fd); |
153 input_info->offset = offset; | 156 input_info->offset = offset; |
154 input_info->length = length; | 157 input_info->length = length; |
155 } | 158 } |
156 | 159 |
157 void ArcGpuVideoDecodeAccelerator::BindDmabuf(PortType port, | 160 void ArcGpuVideoDecodeAccelerator::BindDmabuf(PortType port, |
158 uint32_t index, | 161 uint32_t index, |
159 base::ScopedFD dmabuf_fd) { | 162 base::ScopedFD dmabuf_fd, |
| 163 int32_t stride) { |
160 DCHECK(thread_checker_.CalledOnValidThread()); | 164 DCHECK(thread_checker_.CalledOnValidThread()); |
161 | 165 |
162 if (!vda_) { | 166 if (!vda_) { |
163 DLOG(ERROR) << "VDA not initialized"; | 167 DLOG(ERROR) << "VDA not initialized"; |
164 return; | 168 return; |
165 } | 169 } |
166 | 170 |
167 if (port != PORT_OUTPUT) { | 171 if (port != PORT_OUTPUT) { |
168 DLOG(ERROR) << "Dmabuf is only supported for input"; | 172 DLOG(ERROR) << "Dmabuf is only supported for input"; |
169 arc_client_->OnError(INVALID_ARGUMENT); | 173 arc_client_->OnError(INVALID_ARGUMENT); |
170 return; | 174 return; |
171 } | 175 } |
172 if (!ValidatePortAndIndex(port, index)) { | 176 if (!ValidatePortAndIndex(port, index)) { |
173 arc_client_->OnError(INVALID_ARGUMENT); | 177 arc_client_->OnError(INVALID_ARGUMENT); |
174 return; | 178 return; |
175 } | 179 } |
176 buffers_pending_import_[index] = std::move(dmabuf_fd); | 180 OutputBufferInfo& info = buffers_pending_import_[index]; |
| 181 info.handle = std::move(dmabuf_fd); |
| 182 info.stride = stride; |
177 } | 183 } |
178 | 184 |
179 void ArcGpuVideoDecodeAccelerator::UseBuffer(PortType port, | 185 void ArcGpuVideoDecodeAccelerator::UseBuffer(PortType port, |
180 uint32_t index, | 186 uint32_t index, |
181 const BufferMetadata& metadata) { | 187 const BufferMetadata& metadata) { |
182 DVLOG(5) << "UseBuffer(port=" << port << ", index=" << index | 188 DVLOG(5) << "UseBuffer(port=" << port << ", index=" << index |
183 << ", metadata=(bytes_used=" << metadata.bytes_used | 189 << ", metadata=(bytes_used=" << metadata.bytes_used |
184 << ", timestamp=" << metadata.timestamp << ")"; | 190 << ", timestamp=" << metadata.timestamp << ")"; |
185 DCHECK(thread_checker_.CalledOnValidThread()); | 191 DCHECK(thread_checker_.CalledOnValidThread()); |
186 if (!vda_) { | 192 if (!vda_) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 360 } |
355 | 361 |
356 void ArcGpuVideoDecodeAccelerator::SendEosIfNeededOrReusePicture( | 362 void ArcGpuVideoDecodeAccelerator::SendEosIfNeededOrReusePicture( |
357 uint32_t index) { | 363 uint32_t index) { |
358 if (pending_eos_output_buffer_) { | 364 if (pending_eos_output_buffer_) { |
359 BufferMetadata metadata; | 365 BufferMetadata metadata; |
360 metadata.flags = BUFFER_FLAG_EOS; | 366 metadata.flags = BUFFER_FLAG_EOS; |
361 arc_client_->OnBufferDone(PORT_OUTPUT, index, metadata); | 367 arc_client_->OnBufferDone(PORT_OUTPUT, index, metadata); |
362 pending_eos_output_buffer_ = false; | 368 pending_eos_output_buffer_ = false; |
363 } else { | 369 } else { |
364 if (buffers_pending_import_[index].is_valid()) { | 370 OutputBufferInfo& info = buffers_pending_import_[index]; |
365 std::vector<gfx::GpuMemoryBufferHandle> buffers; | 371 if (info.handle.is_valid()) { |
366 buffers.push_back(gfx::GpuMemoryBufferHandle()); | 372 gfx::GpuMemoryBufferHandle handle; |
367 #if defined(USE_OZONE) | 373 #if defined(USE_OZONE) |
368 buffers.back().native_pixmap_handle.fd = | 374 handle.native_pixmap_handle.fd = |
369 base::FileDescriptor(buffers_pending_import_[index].release(), true); | 375 base::FileDescriptor(info.handle.release(), true); |
| 376 handle.native_pixmap_handle.stride = info.stride; |
370 #endif | 377 #endif |
371 vda_->ImportBufferForPicture(index, buffers); | 378 vda_->ImportBufferForPicture(index, {handle}); |
372 } else { | 379 } else { |
373 vda_->ReusePictureBuffer(index); | 380 vda_->ReusePictureBuffer(index); |
374 } | 381 } |
375 } | 382 } |
376 } | 383 } |
377 | 384 |
378 void ArcGpuVideoDecodeAccelerator::CreateInputRecord( | 385 void ArcGpuVideoDecodeAccelerator::CreateInputRecord( |
379 int32_t bitstream_buffer_id, | 386 int32_t bitstream_buffer_id, |
380 uint32_t buffer_index, | 387 uint32_t buffer_index, |
381 int64_t timestamp) { | 388 int64_t timestamp) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 424 } |
418 return true; | 425 return true; |
419 default: | 426 default: |
420 DLOG(ERROR) << "Invalid port: " << port; | 427 DLOG(ERROR) << "Invalid port: " << port; |
421 return false; | 428 return false; |
422 } | 429 } |
423 } | 430 } |
424 | 431 |
425 } // namespace arc | 432 } // namespace arc |
426 } // namespace chromeos | 433 } // namespace chromeos |
OLD | NEW |