Commit 04f8f2c0 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/VEA unittest: Fill plane pointer and stride with NULL and 0 for 1-...

media/gpu/VEA unittest: Fill plane pointer and stride with NULL and 0 for 1- or 2- planes VideoFrame

When I enable VEA unittest to run any yuv format in crrev.com/c/1135106, I didn't
realize the code assumed the I420 when creating frame. Therefore, it passes
invalid pointer and wrong stride when the number of planes are less than 3.
This change fixes it by creating video frame, taking into account the number of
planes of input buffer format.

BUG=chromium:894381
TEST=VEA unittest for NV12 and I420 on kevin

Change-Id: I31e157ce9317139e7cc42a38ba77b34c13d70d70
Reviewed-on: https://chromium-review.googlesource.com/c/1293095
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601489}
parent d89a7262
...@@ -1743,19 +1743,28 @@ void VEAClient::InputNoLongerNeededCallback(int32_t input_id) { ...@@ -1743,19 +1743,28 @@ void VEAClient::InputNoLongerNeededCallback(int32_t input_id) {
scoped_refptr<VideoFrame> VEAClient::CreateFrame(off_t position) { scoped_refptr<VideoFrame> VEAClient::CreateFrame(off_t position) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
CHECK_GT(current_framerate_, 0U);
uint8_t* frame_data_y = size_t num_planes = VideoFrame::NumPlanes(test_stream_->pixel_format);
CHECK_LE(num_planes, 3u);
uint8_t* frame_data[3] = {};
size_t plane_stride[3] = {};
frame_data[0] =
reinterpret_cast<uint8_t*>(&test_stream_->aligned_in_file_data[0]) + reinterpret_cast<uint8_t*>(&test_stream_->aligned_in_file_data[0]) +
position; position;
uint8_t* frame_data_u = frame_data_y + test_stream_->aligned_plane_size[0]; for (size_t i = 1; i < num_planes; i++) {
uint8_t* frame_data_v = frame_data_u + test_stream_->aligned_plane_size[1]; frame_data[i] = frame_data[i - 1] + test_stream_->aligned_plane_size[i - 1];
CHECK_GT(current_framerate_, 0U); }
for (size_t i = 0; i < num_planes; i++) {
plane_stride[i] = VideoFrame::RowBytes(i, test_stream_->pixel_format,
input_coded_size_.width());
}
scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData( scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData(
test_stream_->pixel_format, input_coded_size_, test_stream_->pixel_format, input_coded_size_,
gfx::Rect(test_stream_->visible_size), test_stream_->visible_size, gfx::Rect(test_stream_->visible_size), test_stream_->visible_size,
input_coded_size_.width(), input_coded_size_.width() / 2, plane_stride[0], plane_stride[1], plane_stride[2], frame_data[0],
input_coded_size_.width() / 2, frame_data_y, frame_data_u, frame_data_v, frame_data[1], frame_data[2],
// Timestamp needs to avoid starting from 0. // Timestamp needs to avoid starting from 0.
base::TimeDelta().FromMilliseconds((next_input_id_ + 1) * base::TimeDelta().FromMilliseconds((next_input_id_ + 1) *
base::Time::kMillisecondsPerSecond / base::Time::kMillisecondsPerSecond /
...@@ -2279,22 +2288,24 @@ void VEACacheLineUnalignedInputClient::FeedEncoderWithOneInput( ...@@ -2279,22 +2288,24 @@ void VEACacheLineUnalignedInputClient::FeedEncoderWithOneInput(
return; return;
const VideoPixelFormat pixel_format = g_env->test_streams_[0]->pixel_format; const VideoPixelFormat pixel_format = g_env->test_streams_[0]->pixel_format;
size_t num_planes = VideoFrame::NumPlanes(pixel_format);
CHECK_LE(num_planes, 3);
std::vector<char, AlignedAllocator<char, kPlatformBufferAlignment>> std::vector<char, AlignedAllocator<char, kPlatformBufferAlignment>>
aligned_data_y, aligned_data_u, aligned_data_v; aligned_data[3];
aligned_data_y.resize( uint8_t* frame_data[3] = {};
VideoFrame::PlaneSize(pixel_format, 0, input_coded_size).GetArea()); uint8_t plane_stride[3] = {};
aligned_data_u.resize( for (size_t i = 0; i < num_planes; i++) {
VideoFrame::PlaneSize(pixel_format, 1, input_coded_size).GetArea()); aligned_data[i].resize(
aligned_data_v.resize( VideoFrame::PlaneSize(pixel_format, i, input_coded_size).GetArea());
VideoFrame::PlaneSize(pixel_format, 2, input_coded_size).GetArea()); frame_data[i] = reinterpret_cast<uint8_t*>(aligned_data[i].data());
uint8_t* frame_data_y = reinterpret_cast<uint8_t*>(&aligned_data_y[0]); plane_stride[i] =
uint8_t* frame_data_u = reinterpret_cast<uint8_t*>(&aligned_data_u[0]); VideoFrame::RowBytes(i, pixel_format, input_coded_size.width());
uint8_t* frame_data_v = reinterpret_cast<uint8_t*>(&aligned_data_v[0]); }
scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData( scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData(
pixel_format, input_coded_size, gfx::Rect(input_coded_size), pixel_format, input_coded_size, gfx::Rect(input_coded_size),
input_coded_size, input_coded_size.width(), input_coded_size.width() / 2, input_coded_size, plane_stride[0], plane_stride[1], plane_stride[2],
input_coded_size.width() / 2, frame_data_y, frame_data_u, frame_data_v, frame_data[0], frame_data[1], frame_data[2],
base::TimeDelta().FromMilliseconds(base::Time::kMillisecondsPerSecond / base::TimeDelta().FromMilliseconds(base::Time::kMillisecondsPerSecond /
fps_)); fps_));
......
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