0

media/gpu/test/Video: Fix the plane size computation for decoded frames

Video::Decode() decodes compressed videos and fills decoded frames
to the buffer. Originally, the plane size of filled frames is
computed by VideoFrame::PlaneSize().GetArea(). However, this
aligns resolutions by two and thus the computed plane size is not
the succinct area. For instance, when a resolution is 641x361,
PlaneSize().GetArea() returns 232404=642x362 for the first plane,
but the test demands a plane size is 231401=641x361. This CL
fixes the mismatch.
This enables video_encode_accelerator_tests to run odd resolution
videos.

Bug: b:174318867
Test: video_encode_accelerator_tests crowd-641x361.vp9.webm --codec=vp9 on atlas
Change-Id: I5d2d9fa31ae838abd501e60e19509d667f70821c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563186
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834128}
This commit is contained in:
Hirokazu Honda
2020-12-07 05:34:17 +00:00
committed by Chromium LUCI CQ
parent 05df6aa42e
commit 7960f912a2

@ -598,8 +598,10 @@ void Video::OnFrameDecoded(const gfx::Size& resolution,
VideoFrame::Rows(plane, frame->format(), resolution.height());
const int row_bytes =
VideoFrame::RowBytes(plane, frame->format(), resolution.width());
const size_t plane_size =
VideoFrame::PlaneSize(frame->format(), plane, resolution).GetArea();
// VideoFrame::PlaneSize() cannot be used because it computes the plane size
// with resolutions aligned by two while our test code works with a succinct
// buffer size.
const int plane_size = row_bytes * rows;
const size_t current_pos = data->size();
// TODO(dstaessens): Avoid resizing.
data->resize(data->size() + plane_size);