Commit 74c15592 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/chromeos/LibyuvIP: Support Cropping on scaling

This enables LibyuvImageProcessor to crop (on scaling).

Bug: 1033799
Test: ip test
Change-Id: I5849a2c382e6828588a90f3b5272b24e7e11ae3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079779
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748522}
parent 1937fafe
...@@ -195,11 +195,8 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create( ...@@ -195,11 +195,8 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create(
if (input_config.fourcc.ToVideoPixelFormat() == if (input_config.fourcc.ToVideoPixelFormat() ==
output_config.fourcc.ToVideoPixelFormat()) { output_config.fourcc.ToVideoPixelFormat()) {
if (input_config.visible_rect.origin() != gfx::Point(0, 0) || if (output_config.visible_rect.origin() != gfx::Point(0, 0)) {
output_config.visible_rect.origin() != gfx::Point(0, 0)) { VLOGF(2) << "Output visible rectangle is not (0, 0), "
VLOGF(2) << "Visible rectangle is not (0, 0), "
<< "input_config.visible_rect="
<< input_config.visible_rect.ToString()
<< "output_config.visible_rect=" << "output_config.visible_rect="
<< output_config.visible_rect.ToString(); << output_config.visible_rect.ToString();
return nullptr; return nullptr;
...@@ -208,8 +205,12 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create( ...@@ -208,8 +205,12 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create(
// This restriction is to simplify |intermediate_frame_| creation. It is // This restriction is to simplify |intermediate_frame_| creation. It is
// used as |tmp_buffer| in NV12Scale(). // used as |tmp_buffer| in NV12Scale().
// TODO(hiroh): Remove this restriction once libyuv:NV12Scale() is arrived. // TODO(hiroh): Remove this restriction once libyuv:NV12Scale() is arrived.
if (!input_config.visible_rect.Contains(output_config.visible_rect)) { if (!gfx::Rect(input_config.visible_rect.size())
VLOGF(2) << "Down-scaling support only"; .Contains(gfx::Rect(output_config.visible_rect.size()))) {
VLOGF(2) << "Down-scaling support only, input_config.visible_rect="
<< input_config.visible_rect.ToString()
<< ", output_config.visible_rect="
<< output_config.visible_rect.ToString();
return nullptr; return nullptr;
} }
} }
...@@ -218,8 +219,8 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create( ...@@ -218,8 +219,8 @@ std::unique_ptr<ImageProcessorBackend> LibYUVImageProcessorBackend::Create(
if (res == SupportResult::SupportedWithPivot) { if (res == SupportResult::SupportedWithPivot) {
intermediate_frame = VideoFrame::CreateFrame( intermediate_frame = VideoFrame::CreateFrame(
PIXEL_FORMAT_I420, input_config.visible_rect.size(), PIXEL_FORMAT_I420, input_config.visible_rect.size(),
input_config.visible_rect, input_config.visible_rect.size(), gfx::Rect(input_config.visible_rect.size()),
base::TimeDelta()); input_config.visible_rect.size(), base::TimeDelta());
if (!intermediate_frame) { if (!intermediate_frame) {
VLOGF(1) << "Failed to create intermediate frame"; VLOGF(1) << "Failed to create intermediate frame";
return nullptr; return nullptr;
...@@ -357,7 +358,11 @@ int LibYUVImageProcessorBackend::DoConversion(const VideoFrame* const input, ...@@ -357,7 +358,11 @@ int LibYUVImageProcessorBackend::DoConversion(const VideoFrame* const input,
// output_visible_rect().GetArea() / 2. Although |intermediate_frame_| // output_visible_rect().GetArea() / 2. Although |intermediate_frame_|
// is much larger than the required size, we use the frame to simplify // is much larger than the required size, we use the frame to simplify
// the code. // the code.
NV12Scale(intermediate_frame_->data(0), Y_UV_DATA(input), NV12Scale(intermediate_frame_->data(0),
input->visible_data(VideoFrame::kYPlane),
input->stride(VideoFrame::kYPlane),
input->visible_data(VideoFrame::kUPlane),
input->stride(VideoFrame::kUPlane),
input->visible_rect().width(), input->visible_rect().height(), input->visible_rect().width(), input->visible_rect().height(),
Y_UV_DATA(output), output->visible_rect().width(), Y_UV_DATA(output), output->visible_rect().width(),
output->visible_rect().height()); output->visible_rect().height());
......
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