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

v4l2: Allocate extra buffers for the rest of the pipeline

When allocating buffers for the output (capture) queue with the new VD,
we should add extra buffers to what the driver says we need to account
for delays with the rest of Chrome's rendering pipeline.

BUG=b:165647432,b:157703889
TEST=Playback no longer stutters on trogdor

Change-Id: I782377dd10e3ac0c63ce12d12b6ac3c49c370b8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2433591
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Auto-Submit: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811508}
parent 86e68fc6
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "media/base/limits.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
#include "media/base/video_util.h" #include "media/base/video_util.h"
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h" #include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
...@@ -38,6 +39,11 @@ constexpr uint32_t kSupportedInputFourccs[] = { ...@@ -38,6 +39,11 @@ constexpr uint32_t kSupportedInputFourccs[] = {
V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9, V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
}; };
// Number of output buffers to use for each VD stage above what's required by
// the decoder (e.g. DPB size, in H264). We need limits::kMaxVideoFrames to
// fill up the GpuVideoDecode pipeline, and +1 for a frame in transit.
constexpr size_t kDpbOutputBufferExtraCount = limits::kMaxVideoFrames + 1;
} // namespace } // namespace
// static // static
...@@ -514,7 +520,8 @@ void V4L2VideoDecoder::ContinueChangeResolution( ...@@ -514,7 +520,8 @@ void V4L2VideoDecoder::ContinueChangeResolution(
base::BindOnce(&V4L2VideoDecoderBackend::OnChangeResolutionDone, base::BindOnce(&V4L2VideoDecoderBackend::OnChangeResolutionDone,
base::Unretained(backend_.get()), false)); base::Unretained(backend_.get()), false));
num_output_frames_ = num_output_frames; DCHECK_GT(num_output_frames, 0u);
num_output_frames_ = num_output_frames + kDpbOutputBufferExtraCount;
// Stateful decoders require the input queue to keep running during resolution // Stateful decoders require the input queue to keep running during resolution
// changes, but stateless ones require it to be stopped. // changes, but stateless ones require it to be stopped.
...@@ -525,9 +532,8 @@ void V4L2VideoDecoder::ContinueChangeResolution( ...@@ -525,9 +532,8 @@ void V4L2VideoDecoder::ContinueChangeResolution(
SetState(State::kError); SetState(State::kError);
return; return;
} }
DCHECK_GT(num_output_frames, 0u);
if (!backend_->ApplyResolution(pic_size, visible_rect, num_output_frames)) { if (!backend_->ApplyResolution(pic_size, visible_rect, num_output_frames_)) {
SetState(State::kError); SetState(State::kError);
return; return;
} }
......
...@@ -498,7 +498,7 @@ void V4L2StatefulVideoDecoderBackend::ChangeResolution() { ...@@ -498,7 +498,7 @@ void V4L2StatefulVideoDecoderBackend::ChangeResolution() {
} }
auto ctrl = device_->GetCtrl(V4L2_CID_MIN_BUFFERS_FOR_CAPTURE); auto ctrl = device_->GetCtrl(V4L2_CID_MIN_BUFFERS_FOR_CAPTURE);
constexpr size_t DEFAULT_NUM_OUTPUT_BUFFERS = 12; constexpr size_t DEFAULT_NUM_OUTPUT_BUFFERS = 7;
const size_t num_output_buffers = const size_t num_output_buffers =
ctrl ? ctrl->value : DEFAULT_NUM_OUTPUT_BUFFERS; ctrl ? ctrl->value : DEFAULT_NUM_OUTPUT_BUFFERS;
if (!ctrl) if (!ctrl)
......
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