Commit 11dc307b authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

media/gpu: Use STORAGE_MOJO_SHARED_MEMORY for video frames in VEA test

For trogdor, it doesn't support I420 input format, so when we run that
test it needs to use the image processor to convert the format. To make
the formats match what we use in reality, they should be either GMBs or
STORAGE_MOJO_SHARED_MEMORY. This changes the tests and the V4L2VEA so
the formats match.

BUG=b:147411004
TEST=VEA SimpleEncode test passes on trogdor w/ I420 input

Change-Id: I259c39f8c7632fb0d97d0baf1672ac05acbba6b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050895
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746212}
parent 2c518ba7
......@@ -432,6 +432,7 @@ if (use_v4l2_codec || use_vaapi || is_mac || is_win) {
"//media:test_support",
"//media/gpu",
"//media/gpu/test:test_helpers",
"//media/mojo/common:mojo_shared_buffer_video_frame",
"//media/parsers",
"//mojo/core/embedder",
"//testing/gtest",
......
......@@ -352,15 +352,9 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor(
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
DCHECK_NE(input_layout.format(), output_layout.format());
// Convert from |config.input_format| + |input_visible_rect| to
// |device_input_layout_->format()| + |output_visible_rect|.
// The storage type of VideoFrame given on Encode() must be
// STORAGE_GPU_MEMORY_BUFFER if |input_storage_type| is
// STORAGE_GPU_MEMORY_BUFFER, but any VideoFrame::IsMappable() storage_type is
// allowed if |input_storage_type| is STORAGE_OWNED_MEMORY.
VideoFrame::StorageType input_storage_type =
native_input_mode_ ? VideoFrame::STORAGE_GPU_MEMORY_BUFFER
: VideoFrame::STORAGE_OWNED_MEMORY;
: VideoFrame::STORAGE_MOJO_SHARED_BUFFER;
auto input_config = VideoFrameLayoutToPortConfig(
input_layout, input_visible_rect, {input_storage_type});
......
......@@ -68,6 +68,7 @@
#include "media/gpu/macros.h"
#include "media/gpu/test/video_frame_helpers.h"
#include "media/gpu/test/video_test_helpers.h"
#include "media/mojo/common/mojo_shared_buffer_video_frame.h"
#include "media/parsers/vp8_parser.h"
#include "media/video/fake_video_encode_accelerator.h"
#include "media/video/h264_level_limits.h"
......@@ -2099,16 +2100,24 @@ scoped_refptr<VideoFrame> VEAClient::CreateFrame(off_t position) {
base::TimeDelta().FromMilliseconds(
(next_input_id_ + 1) * base::Time::kMillisecondsPerSecond /
current_framerate_));
if (video_frame && g_native_input) {
#if defined(OS_LINUX)
video_frame = test::CloneVideoFrame(
gpu_memory_buffer_factory_.get(), video_frame.get(),
video_frame->layout(), VideoFrame::STORAGE_GPU_MEMORY_BUFFER,
gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE);
if (video_frame) {
if (g_native_input) {
video_frame = test::CloneVideoFrame(
gpu_memory_buffer_factory_.get(), video_frame.get(),
video_frame->layout(), VideoFrame::STORAGE_GPU_MEMORY_BUFFER,
gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE);
} else {
// We want MOJO_SHARED_BUFFER memory for the Chrome OS VEA if it needs to
// use the image processor.
video_frame =
MojoSharedBufferVideoFrame::CreateFromYUVFrame(*video_frame);
}
}
#else
if (g_native_input)
video_frame = nullptr;
#endif
}
EXPECT_NE(nullptr, video_frame.get());
return video_frame;
......@@ -2647,6 +2656,9 @@ void VEACacheLineUnalignedInputClient::FeedEncoderWithOneInput(
base::TimeDelta().FromMilliseconds(base::Time::kMillisecondsPerSecond /
fps_),
true);
// We want MOJO_SHARED_BUFFER memory for the Chrome OS VEA if it needs to
// use the image processor.
video_frame = MojoSharedBufferVideoFrame::CreateFromYUVFrame(*video_frame);
encoder_->Encode(video_frame, false);
}
......
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