Commit 79dda366 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/IP: Specify planes in ImageProcessor initialization

This is a follow up CL of crrev.com/c/1855142. The CL causes failures in
image_processor_test, because a layout of planes is not specified in
ImageProcessor initialization, and the adjusted planes are not exposed in
LibyuvImageProcessor. This CL fixes those mistakes.

Bug: 1005636
Test: image_processor_test on atlas
Change-Id: I481d0ca8d276721103030a9ba89d2b590050885d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863065
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarChih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706794}
parent 013f9398
...@@ -89,12 +89,17 @@ class ImageProcessorParamTest ...@@ -89,12 +89,17 @@ class ImageProcessorParamTest
Fourcc::FromVideoPixelFormat(input_image.PixelFormat()); Fourcc::FromVideoPixelFormat(input_image.PixelFormat());
Fourcc output_fourcc = Fourcc output_fourcc =
Fourcc::FromVideoPixelFormat(output_image.PixelFormat()); Fourcc::FromVideoPixelFormat(output_image.PixelFormat());
ImageProcessor::PortConfig input_config(input_fourcc, input_image.Size(), auto input_layout = test::CreateVideoFrameLayout(input_image.PixelFormat(),
{}, input_image.Size(), input_image.Size());
input_storage_types); auto output_layout = test::CreateVideoFrameLayout(
ImageProcessor::PortConfig output_config(output_fourcc, output_image.Size(), output_image.PixelFormat(), output_image.Size());
{}, output_image.Size(), LOG_ASSERT(input_layout && output_layout);
output_storage_types); ImageProcessor::PortConfig input_config(
input_fourcc, input_image.Size(), input_layout->planes(),
input_image.Size(), input_storage_types);
ImageProcessor::PortConfig output_config(
output_fourcc, output_image.Size(), output_layout->planes(),
output_image.Size(), output_storage_types);
// TODO(crbug.com/917951): Select more appropriate number of buffers. // TODO(crbug.com/917951): Select more appropriate number of buffers.
constexpr size_t kNumBuffers = 1; constexpr size_t kNumBuffers = 1;
LOG_ASSERT(output_image.IsMetadataLoaded()); LOG_ASSERT(output_image.IsMetadataLoaded());
......
...@@ -126,12 +126,12 @@ std::unique_ptr<LibYUVImageProcessor> LibYUVImageProcessor::Create( ...@@ -126,12 +126,12 @@ std::unique_ptr<LibYUVImageProcessor> LibYUVImageProcessor::Create(
} }
auto processor = base::WrapUnique(new LibYUVImageProcessor( auto processor = base::WrapUnique(new LibYUVImageProcessor(
ImageProcessor::PortConfig(input_config.fourcc, input_config.size, {}, ImageProcessor::PortConfig(input_config.fourcc, input_config.size,
input_config.visible_size, input_config.planes, input_config.visible_size,
{input_storage_type}), {input_storage_type}),
ImageProcessor::PortConfig(output_config.fourcc, output_config.size, {}, ImageProcessor::PortConfig(
output_config.visible_size, output_config.fourcc, output_config.size, output_config.planes,
{output_storage_type}), output_config.visible_size, {output_storage_type}),
std::move(video_frame_mapper), std::move(video_frame_mapper),
media::BindToCurrentLoop(std::move(error_cb)))); media::BindToCurrentLoop(std::move(error_cb))));
if (res == SupportResult::SupportedWithPivot) { if (res == SupportResult::SupportedWithPivot) {
......
...@@ -31,6 +31,28 @@ ...@@ -31,6 +31,28 @@
namespace media { namespace media {
namespace test { namespace test {
namespace {
base::Optional<VideoFrameLayout> CreateLayout(
const ImageProcessor::PortConfig& config) {
// V4L2 specific format hack:
// If VDA's output format is V4L2_PIX_FMT_MT21C, which is a platform specific
// format and now is only used for MT8173 VDA output and its image processor
// input, we set VideoFrameLayout for image processor's input with format
// PIXEL_FORMAT_NV12 as NV12's layout is the same as MT21.
const VideoPixelFormat pixel_format = config.fourcc.ToVideoPixelFormat();
if (config.planes.empty())
return base::nullopt;
// TODO(hiroh): Check if config is multi planar by Fourcc.
if (config.planes.size() == 1) {
return VideoFrameLayout::CreateWithPlanes(pixel_format, config.size,
config.planes);
} else {
return VideoFrameLayout::CreateMultiPlanar(pixel_format, config.size,
config.planes);
}
}
} // namespace
// static // static
std::unique_ptr<ImageProcessorClient> ImageProcessorClient::Create( std::unique_ptr<ImageProcessorClient> ImageProcessorClient::Create(
...@@ -108,25 +130,6 @@ void ImageProcessorClient::CreateImageProcessorTask( ...@@ -108,25 +130,6 @@ void ImageProcessorClient::CreateImageProcessorTask(
done->Signal(); done->Signal();
} }
namespace {
base::Optional<VideoFrameLayout> CreateLayout(
const ImageProcessor::PortConfig& config) {
// V4L2 specific format hack:
// If VDA's output format is V4L2_PIX_FMT_MT21C, which is a platform specific
// format and now is only used for MT8173 VDA output and its image processor
// input, we set VideoFrameLayout for image processor's input with format
// PIXEL_FORMAT_NV12 as NV12's layout is the same as MT21.
const VideoPixelFormat pixel_format = config.fourcc.ToVideoPixelFormat();
if (config.planes.size() <= 1) {
return VideoFrameLayout::Create(pixel_format, config.size);
}
return VideoFrameLayout::CreateMultiPlanar(pixel_format, config.size,
config.planes);
}
} // namespace
scoped_refptr<VideoFrame> ImageProcessorClient::CreateInputFrame( scoped_refptr<VideoFrame> ImageProcessorClient::CreateInputFrame(
const Image& input_image) const { const Image& input_image) const {
DCHECK_CALLED_ON_VALID_THREAD(test_main_thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(test_main_thread_checker_);
......
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