Commit a50ed7d0 authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Commit Bot

V4L2VEA: Reject flushes when using the image processor.

This CL makes the V4L2VideoEncodeAccelerator reject flush requests when
using the image processor. This is because flush requests are only
expected to come from Android clients and such clients don't need an
image processor. Thus, instead of adding special code to handle flushes,
we simply reject them.

Test coverage is added to exercise the image processor path. This is
done by introducing another parameter, 'scale', in the unit tests. If
this parameter is true and the input mode is native (i.e., zero-copy
path), we request that the VideoEncodeAccelerator scales the input
frames to 75% prior to encoding which triggers the image processor.
Unfortunately, platform_video_frame_utils.cc and video_frame_helpers.cc
had to be fixed to correctly propagate a video frame's natural size
which is necessary to convey the desired scaling.

Note that it is not necessary to reject flushes in the
VaapiVideoEncodeAccelerator because it does not yet use an
ImageProcessor.

Bug: 1090220
Test: video.EncodeAccel.* on scarlet, veyron_tiger, eve, and kukui.
Change-Id: I3b3fee03cb7d35c0bc027cf9686e4a0535457dea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226086
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775820}
parent 53c6a5fb
......@@ -131,8 +131,7 @@ scoped_refptr<VideoFrame> CreatePlatformVideoFrame(
dmabuf_fds.emplace_back(plane.fd.release());
auto frame = VideoFrame::WrapExternalDmabufs(
*layout, visible_rect, visible_rect.size(), std::move(dmabuf_fds),
timestamp);
*layout, visible_rect, natural_size, std::move(dmabuf_fds), timestamp);
if (!frame)
return nullptr;
......
......@@ -241,8 +241,7 @@ scoped_refptr<VideoFrame> CloneVideoFrame(
dst_frame = CreatePlatformVideoFrame(
gpu_memory_buffer_factory, dst_layout.format(),
dst_layout.coded_size(), src_frame->visible_rect(),
src_frame->visible_rect().size(), src_frame->timestamp(),
*dst_buffer_usage);
src_frame->natural_size(), src_frame->timestamp(), *dst_buffer_usage);
break;
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
case VideoFrame::STORAGE_OWNED_MEMORY:
......
......@@ -381,7 +381,6 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor(
const gfx::Rect& output_visible_rect) {
VLOGF(2);
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
DCHECK_NE(input_layout.format(), output_format);
auto ip_input_layout = AsMultiPlanarLayout(input_layout);
if (!ip_input_layout) {
......@@ -750,6 +749,16 @@ void V4L2VideoEncodeAccelerator::EncodeTask(scoped_refptr<VideoFrame> frame,
return;
if (image_processor_) {
if (!frame) {
DCHECK(!flush_callback_.is_null());
NOTREACHED()
<< "Flushing is not supported when using an image processor and this "
"situation should not happen for well behaved clients.";
NOTIFY_ERROR(kIllegalStateError);
child_task_runner_->PostTask(
FROM_HERE, base::BindOnce(std::move(flush_callback_), false));
return;
}
image_processor_input_queue_.emplace(std::move(frame), force_keyframe);
InputImageProcessorTask();
} else {
......@@ -779,7 +788,7 @@ bool V4L2VideoEncodeAccelerator::ReconfigureFormatIfNeeded(
VLOGF(1) << "Encoder resolution is changed during encoding"
<< ", frame.natural_size()=" << frame.natural_size().ToString()
<< ", encoder_input_visible_rect_="
<< input_frame_size_.ToString();
<< encoder_input_visible_rect_.ToString();
return false;
}
if (frame.coded_size() == input_frame_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