Commit 1edbfe77 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

Revert "media/gpu/v4l2: add rudimentary V4L2Queue::SetFormat() method"

This reverts commit 173e2342.

Reason for revert: Suspicious about causing failures at:
https://ci.chromium.org/p/chromium/builders/ci/chromeos-kevin-rel/16980

Original change's description:
> media/gpu/v4l2: add rudimentary V4L2Queue::SetFormat() method
> 
> Having information about the format currently set on a queue is
> valuable, e.g. to validate queued buffers. Rewrite the output queue
> format setting method of V4L2SliceVideoDecoder into an equivalent method
> of V4L2Queue, and use it from there.
> 
> Bug: 1003223
> Test: video_decode_accelerator_tests passing on Kevin.
> 
> Change-Id: Iaaf56809a46a0c193bf890c73b4bcfac4988374f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1839319
> Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#703198}

TBR=akahuang@chromium.org,hiroh@chromium.org,acourbot@chromium.org

Change-Id: I57a064a5b334aa2eba7175ae958dddc188c2120f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1003223
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844007Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703210}
parent c74dcba7
......@@ -791,26 +791,6 @@ V4L2Queue::~V4L2Queue() {
std::move(destroy_cb_).Run();
}
base::Optional<struct v4l2_format> V4L2Queue::SetFormat(uint32_t fourcc,
const gfx::Size& size,
size_t buffer_size) {
struct v4l2_format format = {};
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
format.fmt.pix_mp.pixelformat = fourcc;
format.fmt.pix_mp.width = size.width();
format.fmt.pix_mp.height = size.height();
format.fmt.pix_mp.num_planes = V4L2Device::GetNumPlanesOfV4L2PixFmt(fourcc);
format.fmt.pix_mp.plane_fmt[0].sizeimage = buffer_size;
if (device_->Ioctl(VIDIOC_S_FMT, &format) != 0 ||
format.fmt.pix_mp.pixelformat != fourcc) {
VPLOGF(2) << "Failed to set output format. format_fourcc=" << fourcc;
return base::nullopt;
}
current_format_ = format;
return current_format_;
}
size_t V4L2Queue::AllocateBuffers(size_t count, enum v4l2_memory memory) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!free_buffers_);
......
......@@ -257,21 +257,6 @@ class V4L2Buffer;
class MEDIA_GPU_EXPORT V4L2Queue
: public base::RefCountedThreadSafe<V4L2Queue> {
public:
// Set |fourcc| as the current format on this queue. |size| corresponds to the
// desired buffer's dimensions (i.e. width and height members of
// v4l2_pix_format_mplane (if not applicable, pass gfx::Size()).
// |buffer_size| is the desired size in bytes of the buffer for single-planar
// formats (i.e. sizeimage of the first plane). It can be set to 0 if not
// relevant for the desired format.
// If the format could be set, then the |v4l2_format| reflecting the actual
// format is returned. It is guaranteed to feature the specified |fourcc|,
// but any other parameter (including |size| and |buffer_size| may have been
// adjusted by the driver, so the caller must check their values.
base::Optional<struct v4l2_format> SetFormat(uint32_t fourcc,
const gfx::Size& size,
size_t buffer_size)
WARN_UNUSED_RESULT;
// Allocate |count| buffers for the current format of this queue, with a
// specific |memory| allocation, and returns the number of buffers allocated
// or zero if an error occurred, or if references to any previously allocated
......@@ -348,8 +333,6 @@ class MEDIA_GPU_EXPORT V4L2Queue
enum v4l2_memory memory_ = V4L2_MEMORY_MMAP;
bool is_streaming_ = false;
size_t planes_count_ = 0;
// Current format as set by SetFormat.
base::Optional<struct v4l2_format> current_format_;
std::vector<std::unique_ptr<V4L2Buffer>> buffers_;
......
......@@ -38,6 +38,7 @@ constexpr size_t kInputBufferMaxSizeFor1080p = 1024 * 1024;
// Input bitstream buffer size for up to 4k streams.
constexpr size_t kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p;
constexpr size_t kNumInputBuffers = 16;
constexpr size_t kNumInputPlanes = 1;
// Size of the timestamp cache, needs to be large enough for frame-reordering.
constexpr size_t kTimestampCacheSize = 128;
......@@ -492,17 +493,41 @@ bool V4L2SliceVideoDecoder::SetupInputFormat(uint32_t input_format_fourcc) {
: kInputBufferMaxSizeFor1080p;
// Setup the input format.
auto format =
input_queue_->SetFormat(input_format_fourcc, gfx::Size(), input_size);
if (!format) {
struct v4l2_format format;
memset(&format, 0, sizeof(format));
format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
format.fmt.pix_mp.pixelformat = input_format_fourcc;
format.fmt.pix_mp.plane_fmt[0].sizeimage = input_size;
format.fmt.pix_mp.num_planes = kNumInputPlanes;
if (device_->Ioctl(VIDIOC_S_FMT, &format) != 0) {
VPLOGF(1) << "Failed to call IOCTL to set input format.";
return false;
}
DCHECK_EQ(format->fmt.pix_mp.pixelformat, input_format_fourcc);
DCHECK_EQ(format.fmt.pix_mp.pixelformat, input_format_fourcc);
return true;
}
base::Optional<struct v4l2_format>
V4L2SliceVideoDecoder::SetV4L2FormatOnOutputQueue(uint32_t format_fourcc,
const gfx::Size& size) {
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
struct v4l2_format format = {};
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
format.fmt.pix_mp.pixelformat = format_fourcc;
format.fmt.pix_mp.width = size.width();
format.fmt.pix_mp.height = size.height();
format.fmt.pix_mp.num_planes =
V4L2Device::GetNumPlanesOfV4L2PixFmt(format_fourcc);
if (device_->Ioctl(VIDIOC_S_FMT, &format) != 0 ||
format.fmt.pix_mp.pixelformat != format_fourcc) {
VPLOGF(2) << "Failed to set output format. format_fourcc=" << format_fourcc;
return base::nullopt;
}
return format;
}
base::Optional<VideoFrameLayout> V4L2SliceVideoDecoder::SetupOutputFormat(
const gfx::Size& size,
const gfx::Rect& visible_rect) {
......@@ -516,12 +541,12 @@ base::Optional<VideoFrameLayout> V4L2SliceVideoDecoder::SetupOutputFormat(
continue;
base::Optional<struct v4l2_format> format =
output_queue_->SetFormat(format_fourcc, size, 0);
SetV4L2FormatOnOutputQueue(format_fourcc, size);
if (!format)
continue;
// SetFormat is successful. Next make sure VFPool can allocate video frames
// with width and height adjusted by a video driver.
// S_FMT is successful. Next make sure VFPool can allocate video frames with
// width and height adjusted by a video driver.
gfx::Size adjusted_size(format->fmt.pix_mp.width,
format->fmt.pix_mp.height);
......
......@@ -161,6 +161,12 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
// Setup format for input queue.
bool SetupInputFormat(uint32_t input_format_fourcc);
// Call VIDIOC_S_FMT with |format_fourcc| and |size|. Returns v4l2_format
// returned by VIDIOC_S_FMT on success, otherwise returns base::nullopt.
// This should be called only from SetupOutputFormat().
base::Optional<struct v4l2_format> SetV4L2FormatOnOutputQueue(
uint32_t format_fourcc,
const gfx::Size& size);
// Setup format for output queue. This function sets output format on output
// queue that is supported by a v4l2 driver, can be allocatable by
// VideoFramePool and can be composited by chrome. This also updates format
......
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