Commit 2092ff59 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

Use plane.stirde rather than plane.size as gbm buffer width for BLOB

format

We use {width: data_size, height: 1} as size of gbm buffer to store
data for BLOB format. Since height might be aligned and makes
plane.size bigger than the actual data_size, we change to use
plane.stride to represent the data size. Doing so, it won't fail for
NativePixmapHandle validation.

Bug: b/142105578
Test: ./jpeg_encode_accelerator_unittest
Change-Id: Iaf93b0ae7834d2310e1bdfe9cf76be489a3747f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868931Reviewed-by: default avatarRicky Liang <jcliang@chromium.org>
Commit-Queue: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707306}
parent 3f949687
......@@ -1501,9 +1501,17 @@ size_t V4L2JpegEncodeAccelerator::EncodedInstanceDmaBuf::FinalizeJpegImage(
auto output_gmb_handle = CreateGpuMemoryBufferHandle(output_frame.get());
DCHECK(!output_gmb_handle.is_null());
// In this case, we use the R_8 buffer with height == 1 to represent a data
// container. As a result, we use plane.stride as size of the data here since
// plane.size might be larger due to height alignment.
const gfx::Size output_gmb_buffer_size(
base::checked_cast<int32_t>(output_frame->layout().planes()[0].stride),
1);
auto output_gmb_buffer =
gpu_memory_buffer_support_->CreateGpuMemoryBufferImplFromHandle(
std::move(output_gmb_handle), output_frame->coded_size(),
std::move(output_gmb_handle), output_gmb_buffer_size,
gfx::BufferFormat::R_8, gfx::BufferUsage::SCANOUT_CAMERA_READ_WRITE,
base::DoNothing());
......
......@@ -243,8 +243,13 @@ void VaapiJpegEncodeAccelerator::Encoder::EncodeWithDmaBufTask(
// size, where buffer_size can be obtained from the first plane's size.
auto output_gmb_handle = CreateGpuMemoryBufferHandle(output_frame.get());
DCHECK(!output_gmb_handle.is_null());
// In this case, we use the R_8 buffer with height == 1 to represent a data
// container. As a result, we use plane.stride as size of the data here since
// plane.size might be larger due to height alignment.
const gfx::Size output_gmb_buffer_size(
base::checked_cast<int32_t>(output_frame->layout().planes()[0].size), 1);
base::checked_cast<int32_t>(output_frame->layout().planes()[0].stride),
1);
auto output_gmb_buffer =
gpu_memory_buffer_support_->CreateGpuMemoryBufferImplFromHandle(
std::move(output_gmb_handle), output_gmb_buffer_size,
......
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