Commit 76866c76 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/V4L2VEA: Use width/height adjusted by driver if native input mode

An encoder driver may expect extra data size between planes in an input
buffer. We currently don't use width and height adjusted by the driver,
but a large-enough width and height computed from the buffer size in bytes.
Therefore, a VEA client is asked to allocate a larger width/height buffer
in the case.

A backend for graphics buffer allocation (e.g. minigbm) is
able to allocate a buffer that has extra data properly from width and height
adjusted by the encoder driver. A client using a backend like minigbm wrongly
allocates a buffer unexpected by the encoder driver due to a large width and
height requested by VEA. ARC++ encoder hits this issue.

This CL resolves the issue by requesting width and height adjusted by the
encoder driver if native_input_mode, that is, a client will feed a buffer
allocated by a backend like minigbm.

Bug: b:144135251
Test: ARC++ encoder on kukui
Change-Id: I5bfbd0169bbff2ad3801a4561d546fbfe290902d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906864Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714802}
parent 6c203281
...@@ -147,6 +147,7 @@ V4L2VideoEncodeAccelerator::InputFrameInfo::~InputFrameInfo() {} ...@@ -147,6 +147,7 @@ V4L2VideoEncodeAccelerator::InputFrameInfo::~InputFrameInfo() {}
V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator( V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator(
const scoped_refptr<V4L2Device>& device) const scoped_refptr<V4L2Device>& device)
: child_task_runner_(base::ThreadTaskRunnerHandle::Get()), : child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
native_input_mode_(false),
output_buffer_byte_size_(0), output_buffer_byte_size_(0),
output_format_fourcc_(0), output_format_fourcc_(0),
encoder_state_(kUninitialized), encoder_state_(kUninitialized),
...@@ -232,6 +233,10 @@ void V4L2VideoEncodeAccelerator::InitializeTask(const Config& config, ...@@ -232,6 +233,10 @@ void V4L2VideoEncodeAccelerator::InitializeTask(const Config& config,
base::BindOnce(&base::WaitableEvent::Signal, base::Unretained(done))); base::BindOnce(&base::WaitableEvent::Signal, base::Unretained(done)));
*result = false; *result = false;
native_input_mode_ =
config.storage_type.value_or(Config::StorageType::kShmem) ==
Config::StorageType::kDmabuf;
input_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); input_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
if (!input_queue_ || !output_queue_) { if (!input_queue_ || !output_queue_) {
...@@ -1407,10 +1412,16 @@ bool V4L2VideoEncodeAccelerator::NegotiateInputFormat( ...@@ -1407,10 +1412,16 @@ bool V4L2VideoEncodeAccelerator::NegotiateInputFormat(
<< device_input_layout_->coded_size().ToString(); << device_input_layout_->coded_size().ToString();
return false; return false;
} }
// TODO(crbug.com/914700): Remove this once if (native_input_mode_) {
// Client::RequireBitstreamBuffers uses input's VideoFrameLayout to input_allocated_size_ =
// allocate input buffer. gfx::Size(device_input_layout_->planes()[0].stride,
input_allocated_size_ = V4L2Device::AllocatedSizeFromV4L2Format(format); device_input_layout_->coded_size().height());
} else {
// TODO(crbug.com/914700): Remove this once
// Client::RequireBitstreamBuffers uses input's VideoFrameLayout to
// allocate input buffer.
input_allocated_size_ = V4L2Device::AllocatedSizeFromV4L2Format(format);
}
return true; return true;
} }
} }
......
...@@ -260,6 +260,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -260,6 +260,10 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
gfx::Size visible_size_; gfx::Size visible_size_;
// Layout of device accepted input VideoFrame. // Layout of device accepted input VideoFrame.
base::Optional<VideoFrameLayout> device_input_layout_; base::Optional<VideoFrameLayout> device_input_layout_;
// Stands for whether an input buffer is native graphic buffer.
bool native_input_mode_;
// Input allocated size calculated by // Input allocated size calculated by
// V4L2Device::AllocatedSizeFromV4L2Format(). // V4L2Device::AllocatedSizeFromV4L2Format().
// TODO(crbug.com/914700): Remove this once Client::RequireBitstreamBuffers // TODO(crbug.com/914700): Remove this once Client::RequireBitstreamBuffers
......
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