Commit a51545b0 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/V4L2VEA: Create ImageProcessor with multi-planar input layout

The input VideoFrame of ImageProcessor on V4L2VEA is the one given
by the VEA client. The input config of the ImageProcessor should
be multi-planar layout so that ImageProcessor can deal with
arbitrary offsets of the VideoFrame.

Bug: 1033799
Test: appr.tc on kukui
Change-Id: I43df37bb4c2dc9ab1221acd14d19d2413f2c4402
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102938
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751223}
parent 42c724cd
......@@ -117,6 +117,15 @@ base::Optional<ImageProcessor::PortConfig> VideoFrameLayoutToPortConfig(
layout.planes(), visible_rect,
preferred_storage_types);
}
// Create Layout from |layout| with is_multi_planar = true.
base::Optional<VideoFrameLayout> AsMultiPlanarLayout(
const VideoFrameLayout& layout) {
if (layout.is_multi_planar())
return base::make_optional<VideoFrameLayout>(layout);
return VideoFrameLayout::CreateMultiPlanar(
layout.format(), layout.coded_size(), layout.planes());
}
} // namespace
struct V4L2VideoEncodeAccelerator::BitstreamBufferRef {
......@@ -282,8 +291,6 @@ void V4L2VideoEncodeAccelerator::InitializeTask(const Config& config,
VLOGF(2) << "Input format: " << config.input_format << " is not supported "
<< "by the HW. Will try to convert to "
<< device_input_layout_->format();
// TODO(hiroh): Decide the appropriate planar in some way.
auto input_layout = VideoFrameLayout::CreateMultiPlanar(
config.input_format, encoder_input_visible_rect_.size(),
std::vector<ColorPlaneLayout>(
......@@ -354,12 +361,15 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor(
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
DCHECK_NE(input_layout.format(), output_layout.format());
auto ip_input_layout = AsMultiPlanarLayout(std::move(input_layout));
if (!ip_input_layout)
return false;
VideoFrame::StorageType input_storage_type =
native_input_mode_ ? VideoFrame::STORAGE_GPU_MEMORY_BUFFER
: VideoFrame::STORAGE_MOJO_SHARED_BUFFER;
auto input_config = VideoFrameLayoutToPortConfig(
input_layout, input_visible_rect, {input_storage_type});
*ip_input_layout, input_visible_rect, {input_storage_type});
if (!input_config)
return false;
auto output_config =
......
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