Commit a5e3717b authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

media/gpu/v4l2: Fix DCHECK in V4L2 coded size estimation

The math on this line was using integers, which means it could end up
dropping fractional parts so that the DCHECK against sizeimage could
fail. This fixes that problem.

BUG=b:147411004
TEST=Fixes DCHECK on trogdor vea tests

Change-Id: Ia4034e790268323a9decdfffe0815b69da8cefbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2086193
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Auto-Submit: Jeffrey Kardatzke <jkardatzke@google.com>
Cr-Commit-Position: refs/heads/master@{#748763}
parent 511f83e2
......@@ -1552,8 +1552,11 @@ gfx::Size V4L2Device::AllocatedSizeFromV4L2Format(
// which in V4L2 always applies to the first component in physical plane
// buffer.
int coded_width = bytesperline * 8 / plane_horiz_bits_per_pixel;
// Sizeimage is coded_width * coded_height * total_bpp.
int coded_height = sizeimage * 8 / coded_width / total_bpp;
// Sizeimage is coded_width * coded_height * total_bpp. In the case that we
// don't have exact alignment due to padding in the driver, round up so that
// the buffer is large enough.
std::div_t res = std::div(sizeimage * 8, coded_width * total_bpp);
int coded_height = res.quot + std::min(res.rem, 1);
coded_size.SetSize(coded_width, coded_height);
DVLOGF(3) << "coded_size=" << coded_size.ToString();
......
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