Commit 35867609 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2vd: allocate as many buffers as possible in DMABUF mode

If we are operating in DMABUF mode, then we will try to keep the same
frame assigned to the same V4L2 buffer. However we don't know for sure
how many different frames the decoder will actually use, and if we
undershoot then we will spend a lot of time in-kernel
unmapping/remapping DMABUFs.

Try to prevent this by allocating as many buffers as allowed by the V4L2
API (32) when operating in DMABUF mode. Since these buffers won't have
backing memory unless we attach a DMABUF to them, they are virtually
free if unused.

BUG=b:159688625
BUG=b:167412992
TEST=video.DecodeAccel.h264 passes on Kukui.
TEST=video.DecodeAccel.h264 passes on Trogdor.

Change-Id: Icd6282c3902654a54958d6346c60affd45555e7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434113
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813503}
parent 32546b41
......@@ -544,14 +544,17 @@ void V4L2VideoDecoder::ContinueChangeResolution(
return;
}
v4l2_memory type =
const v4l2_memory type =
client_->GetVideoFramePool() ? V4L2_MEMORY_DMABUF : V4L2_MEMORY_MMAP;
if (output_queue_->AllocateBuffers(num_output_frames_, type) == 0) {
const size_t v4l2_num_buffers =
(type == V4L2_MEMORY_DMABUF) ? VIDEO_MAX_FRAME : num_output_frames_;
if (output_queue_->AllocateBuffers(v4l2_num_buffers, type) == 0) {
VLOGF(1) << "Failed to request output buffers.";
SetState(State::kError);
return;
}
if (output_queue_->AllocatedBuffersCount() != num_output_frames_) {
if (output_queue_->AllocatedBuffersCount() < num_output_frames_) {
VLOGF(1) << "Could not allocate requested number of output buffers.";
SetState(State::kError);
return;
......
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