Commit 8e96110f authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/v4l2/V4L2JEA: Execute S_FMT for YUV420M and YUV420 separately

Formerly, V4L2JEA calls S_FMT one time for YUV420M and checks if the pixel
format filled by driver is either YUV420 or YUV420M. Then, a driver can fill
NV12 even if it supports YUV420. V4L2JEA would rather execute S_FMT for
YUV420M and YUV420 separately and check if the returned format is exactly same
as the specified one.

Bug: 908357
Test: VEA unittest on kevin
Change-Id: I15b5bae4f8d1c728f0db0bb961a1f5d39fed3c53
Reviewed-on: https://chromium-review.googlesource.com/c/1352074
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarRicky Liang <jcliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612084}
parent 4ea1d565
......@@ -370,28 +370,36 @@ bool V4L2JpegEncodeAccelerator::EncodedInstance::SetInputBufferFormat(
DCHECK(!input_streamon_);
DCHECK(input_job_queue_.empty());
struct v4l2_format format;
memset(&format, 0, sizeof(format));
format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
format.fmt.pix_mp.num_planes = kMaxI420Plane;
format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_YUV420M;
format.fmt.pix_mp.field = V4L2_FIELD_ANY;
format.fmt.pix_mp.width = coded_size.width();
format.fmt.pix_mp.height = coded_size.height();
// TODO(crbug.com/908357): Execute S_FMT with YUV420 and YUV420M separately
// and check format.fmt.pix_mp.pixelformat value.
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format);
constexpr uint32_t input_pix_fmt_candidates[] = {
V4L2_PIX_FMT_YUV420M,
V4L2_PIX_FMT_YUV420,
};
// Save V4L2 returned values.
input_buffer_pixelformat_ = format.fmt.pix_mp.pixelformat;
input_buffer_num_planes_ = format.fmt.pix_mp.num_planes;
input_buffer_height_ = format.fmt.pix_mp.height;
struct v4l2_format format;
input_buffer_pixelformat_ = 0;
for (const auto input_pix_fmt : input_pix_fmt_candidates) {
DCHECK_EQ(V4L2Device::V4L2PixFmtToVideoPixelFormat(input_pix_fmt),
PIXEL_FORMAT_I420);
memset(&format, 0, sizeof(format));
format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
format.fmt.pix_mp.num_planes = kMaxI420Plane;
format.fmt.pix_mp.pixelformat = input_pix_fmt;
format.fmt.pix_mp.field = V4L2_FIELD_ANY;
format.fmt.pix_mp.width = coded_size.width();
format.fmt.pix_mp.height = coded_size.height();
if (device_->Ioctl(VIDIOC_S_FMT, &format) == 0 &&
format.fmt.pix_mp.pixelformat == input_pix_fmt) {
// Save V4L2 returned values.
input_buffer_pixelformat_ = format.fmt.pix_mp.pixelformat;
input_buffer_num_planes_ = format.fmt.pix_mp.num_planes;
input_buffer_height_ = format.fmt.pix_mp.height;
break;
}
}
if (input_buffer_pixelformat_ != V4L2_PIX_FMT_YUV420 &&
input_buffer_pixelformat_ != V4L2_PIX_FMT_YUV420M) {
VLOGF(1) << "unsupported input V4L2 pixel format: "
<< input_buffer_pixelformat_;
if (input_buffer_pixelformat_ == 0) {
VLOGF(1) << "Neither YUV420 nor YUV420M is supported.";
return 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