Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/gpu/arc_gpu_video_decode_accelerator.cc

Issue 1953683002: Add stride for imported Dmabuf in ArcVideoAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address kcwu's comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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];
371 if (info.handle.is_valid()) {
372 gfx::GpuMemoryBufferHandle handle;
373 #if defined(USE_OZONE)
374 handle.native_pixmap_handle.fd =
375 base::FileDescriptor(info.handle.release(), true);
dcheng 2016/05/07 06:22:56 (My question about how this fd ends up getting fre
Owen Lin 2016/05/09 07:30:16 As the reply in the other CL. The fd will be manag
376 handle.native_pixmap_handle.stride = info.stride;
377 #endif
365 std::vector<gfx::GpuMemoryBufferHandle> buffers; 378 std::vector<gfx::GpuMemoryBufferHandle> buffers;
dcheng 2016/05/07 06:22:56 I have good news. Just write: std::vector<gfx::Gp
Owen Lin 2016/05/09 07:30:16 Thanks. It's really nice.
366 buffers.push_back(gfx::GpuMemoryBufferHandle()); 379 buffers.push_back(handle);
367 #if defined(USE_OZONE)
368 buffers.back().native_pixmap_handle.fd =
369 base::FileDescriptor(buffers_pending_import_[index].release(), true);
370 #endif
371 vda_->ImportBufferForPicture(index, buffers); 380 vda_->ImportBufferForPicture(index, buffers);
372 } else { 381 } else {
373 vda_->ReusePictureBuffer(index); 382 vda_->ReusePictureBuffer(index);
374 } 383 }
375 } 384 }
376 } 385 }
377 386
378 void ArcGpuVideoDecodeAccelerator::CreateInputRecord( 387 void ArcGpuVideoDecodeAccelerator::CreateInputRecord(
379 int32_t bitstream_buffer_id, 388 int32_t bitstream_buffer_id,
380 uint32_t buffer_index, 389 uint32_t buffer_index,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 426 }
418 return true; 427 return true;
419 default: 428 default:
420 DLOG(ERROR) << "Invalid port: " << port; 429 DLOG(ERROR) << "Invalid port: " << port;
421 return false; 430 return false;
422 } 431 }
423 } 432 }
424 433
425 } // namespace arc 434 } // namespace arc
426 } // namespace chromeos 435 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698