Skip to content

Commit

Permalink
media/gpu/v4l2/V4l2StatefulVD: use 16 CAPTURE queue buffers on Hana
Browse files Browse the repository at this point in the history
This seems to improve quite a bit the results, and it basically
replicates the behaviour of ToT's V4L2VideoDecodeAccelerator [1].

[1] https://source.chromium.org/chromium/chromium/src/+/main:media/gpu/v4l2/legacy/v4l2_video_decode_accelerator.cc;l=2541-2551;drc=93a61df1e41b3e76b6050acca627731d81490d61

Bug: b:298777648
Change-Id: I9d07173086694335ddfff903ca591f73bc2fe4b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4960849
Commit-Queue: Hang Nguyen <hnt@chromium.org>
Reviewed-by: Hang Nguyen <hnt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1213092}
  • Loading branch information
yellowdoge authored and Chromium LUCI CQ committed Oct 21, 2023
1 parent 1188e6b commit 1e67d89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion media/gpu/v4l2/v4l2_stateful_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ void V4L2StatefulVideoDecoder::Initialize(const VideoDecoderConfig& config,
std::move(init_cb).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}

struct v4l2_capability caps = {};
if (HandledIoctl(device_fd_.get(), VIDIOC_QUERYCAP, &caps) != kIoctlOk) {
PLOG(ERROR) << "Failed querying caps";
std::move(init_cb).Run(DecoderStatus::Codes::kFailedToCreateDecoder);
return;
}

is_mtk8173_ = base::Contains(
std::string(reinterpret_cast<const char*>(caps.card)), "8173");
DVLOGF_IF(1, is_mtk8173_) << "This is an MTK8173 device (Hana, Oak)";
}

// If we've been Initialize()d before, destroy state members.
Expand Down Expand Up @@ -775,7 +786,10 @@ size_t V4L2StatefulVideoDecoder::GetNumberOfReferenceFrames() {
// ITU-T codecs, it depends on the bitstream. Here we query it from the
// driver anyway.
constexpr size_t kDefaultNumReferenceFrames = 8;
size_t num_codec_reference_frames = kDefaultNumReferenceFrames;
constexpr size_t kDefaultNumReferenceFramesMTK8173 = 16;
size_t num_codec_reference_frames = is_mtk8173_
? kDefaultNumReferenceFramesMTK8173
: kDefaultNumReferenceFrames;

struct v4l2_ext_control ctrl = {.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE};
struct v4l2_ext_controls ext_ctrls = {.count = 1, .controls = &ctrl};
Expand Down
2 changes: 2 additions & 0 deletions media/gpu/v4l2/v4l2_stateful_video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class MEDIA_GPU_EXPORT V4L2StatefulVideoDecoder : public VideoDecoderMixin {
VideoAspectRatio aspect_ratio_ GUARDED_BY_CONTEXT(sequence_checker_);
OutputCB output_cb_ GUARDED_BY_CONTEXT(sequence_checker_);
DecodeCB flush_cb_ GUARDED_BY_CONTEXT(sequence_checker_);
// Set to true when the driver identifies itself as a Mediatek 8173.
bool is_mtk8173_ GUARDED_BY_CONTEXT(sequence_checker_) = false;

// Used only on V4L2_MEMORY_MMAP queues (e.g. Hana MT8173) to grab the visible
// rectangle upon |CAPTURE_queue_| configuration in InitializeCAPTUREQueue().
Expand Down

0 comments on commit 1e67d89

Please sign in to comment.