Commit d0395b61 authored by Miguel Casas's avatar Miguel Casas Committed by Chromium LUCI CQ

media::V4L2VideoDecoder: more decoder instances, less input buffers

crrev.com/c/2628069 introduced to the V4L2VideoDecoder a limitation
on the maximum number of decoder instances at a given time, making it
behave like the legacy V4L2VideoDecodeAccelerator.

That provision avoided the OOM observed on MS Teams (see bug). But
the max number of instances (10) is too restrictive. A deeper look
showed that every instance allocates all the necessary input buffers
(i.e. those for the encoded chunks that go into the v4l OUTPUT q).
V4L2VideoDecoder allocates 16 [1] whereas the legacy one only 8 [2].
FTR each buffer is relatively large: 4MB for platforms that support
more than 1080p decoding, 1MB otherwise; MS Teams can successfully
allocate 32 decoders on kukui, which gives us 32 * 16 * 1MB = 512MB
of allocated memory; on trogdor this would be 2GB (!!).

This CL tweaks a bit ToT numbers so we can allocate more decoder
instances (32, good for kukui) and have a smaller number of input
buffers allocated, aligning V4L2VideoDecoder with the legacy.

[1] https://source.chromium.org/chromium/chromium/src/+/master:media/gpu/v4l2/v4l2_video_decoder.cc;l=34;drc=1bba741f920278b78341175ef888c19a6affd664
[2] https://source.chromium.org/chromium/chromium/src/+/master:media/gpu/v4l2/v4l2_video_decode_accelerator.h;l=145;drc=82e2036e3aadce02f587769c7ab6fc644953e008


Bug: b/170870476
Change-Id: If610ffe7c339ae3d883d893e41c92cc725e6fdaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2633784Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844951}
parent 56042f5a
......@@ -31,7 +31,7 @@ constexpr int k1080pArea = 1920 * 1088;
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 kNumInputBuffers = 8;
// Input format V4L2 fourccs this class supports.
constexpr uint32_t kSupportedInputFourccs[] = {
......
......@@ -141,7 +141,7 @@ class MEDIA_GPU_EXPORT V4L2VideoDecoder
// decoder instances for now. |num_instances_| tracks the number of
// simultaneous decoders. |can_use_decoder_| is true iff we haven't reached
// the maximum number of instances at the time this decoder is created.
static constexpr int kMaxNumOfInstances = 10;
static constexpr int kMaxNumOfInstances = 32;
static base::AtomicRefCount num_instances_;
const bool can_use_decoder_;
......
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