new/yocto/meta-rockchip/dynamic-layers/recipes-browser/chromium/chromium_104.0.5112/0016-media-Enable-HEVC-by-default-for-V4L2VDA.patch

124 lines
5.1 KiB
Diff
Raw Permalink Normal View History

2025-05-10 21:58:58 +08:00
From 46f6f7985d38fa4e54ab272f29aaf6341f0b96d0 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 9 Sep 2022 16:06:58 +0800
Subject: [PATCH 16/17] media: Enable HEVC by default for V4L2VDA
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
media/base/media_switches.cc | 2 +-
media/gpu/v4l2/v4l2_device.cc | 9 +++++++++
media/gpu/v4l2/v4l2_vda_helpers.cc | 1 +
media/gpu/v4l2/v4l2_video_decode_accelerator.cc | 2 +-
media/gpu/v4l2/v4l2_video_decoder.cc | 3 ++-
media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc | 1 +
media/media_options.gni | 2 +-
7 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index 60c69224d..569c9691d 100644
--- a/media/base/media_switches.cc
+++ b/media/base/media_switches.cc
@@ -270,7 +270,7 @@ const base::Feature kPictureInPicture {
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
// Enables HEVC hardware accelerated decoding.
const base::Feature kPlatformHEVCDecoderSupport{
- "PlatformHEVCDecoderSupport", base::FEATURE_DISABLED_BY_DEFAULT};
+ "PlatformHEVCDecoderSupport", base::FEATURE_ENABLED_BY_DEFAULT};
#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
// Only decode preload=metadata elements upon visibility.
diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc
index e0489a104..1506a0a9a 100644
--- a/media/gpu/v4l2/v4l2_device.cc
+++ b/media/gpu/v4l2/v4l2_device.cc
@@ -1551,6 +1551,8 @@ uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile,
if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) {
return V4L2_PIX_FMT_H264;
+ } else if (profile >= HEVCPROFILE_MIN && profile <= HEVCPROFILE_MAX) {
+ return V4L2_PIX_FMT_HEVC;
} else if (profile >= VP8PROFILE_MIN && profile <= VP8PROFILE_MAX) {
return V4L2_PIX_FMT_VP8;
} else if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) {
@@ -1714,6 +1716,13 @@ std::vector<VideoCodecProfile> V4L2Device::V4L2PixFmtToVideoCodecProfiles(
H264PROFILE_HIGH,
};
break;
+ case V4L2_PIX_FMT_HEVC:
+ profiles = {
+ HEVCPROFILE_MAIN,
+ HEVCPROFILE_MAIN10,
+ HEVCPROFILE_MAIN_STILL_PICTURE,
+ };
+ break;
case V4L2_PIX_FMT_VP8:
profiles = {VP8PROFILE_ANY};
break;
diff --git a/media/gpu/v4l2/v4l2_vda_helpers.cc b/media/gpu/v4l2/v4l2_vda_helpers.cc
index f25619077..e2cb051c5 100644
--- a/media/gpu/v4l2/v4l2_vda_helpers.cc
+++ b/media/gpu/v4l2/v4l2_vda_helpers.cc
@@ -151,6 +151,7 @@ InputBufferFragmentSplitter::CreateFromProfile(
case VideoCodec::kH264:
return std::make_unique<
v4l2_vda_helpers::H264InputBufferFragmentSplitter>();
+ case VideoCodec::kHEVC:
case VideoCodec::kVP8:
case VideoCodec::kVP9:
// VP8/VP9 don't need any frame splitting, use the default implementation.
diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
index f39cc569a..51e610abb 100644
--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
@@ -83,7 +83,7 @@ bool IsVp9KSVCStream(uint32_t input_format_fourcc,
// static
const uint32_t V4L2VideoDecodeAccelerator::supported_input_fourccs_[] = {
- V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
+ V4L2_PIX_FMT_H264, V4L2_PIX_FMT_HEVC, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
};
// static
diff --git a/media/gpu/v4l2/v4l2_video_decoder.cc b/media/gpu/v4l2/v4l2_video_decoder.cc
index b95d84ad1..3d002dfdd 100644
--- a/media/gpu/v4l2/v4l2_video_decoder.cc
+++ b/media/gpu/v4l2/v4l2_video_decoder.cc
@@ -52,7 +52,8 @@ constexpr uint32_t kSupportedInputFourccs[] = {
#if !BUILDFLAG(USE_LINUX_V4L2)
V4L2_PIX_FMT_H264_SLICE, V4L2_PIX_FMT_VP8_FRAME, V4L2_PIX_FMT_VP9_FRAME,
#endif
- V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
+ V4L2_PIX_FMT_H264, V4L2_PIX_FMT_HEVC,
+ V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
};
// Number of output buffers to use for each VD stage above what's required by
diff --git a/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc b/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
index 87d4f153d..6ab11da86 100644
--- a/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
+++ b/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
@@ -731,6 +731,7 @@ bool V4L2StatefulVideoDecoderBackend::IsSupportedProfile(
if (supported_profiles_.empty()) {
constexpr uint32_t kSupportedInputFourccs[] = {
V4L2_PIX_FMT_H264,
+ V4L2_PIX_FMT_HEVC,
V4L2_PIX_FMT_VP8,
V4L2_PIX_FMT_VP9,
};
diff --git a/media/media_options.gni b/media/media_options.gni
index b3727203d..64c91692c 100644
--- a/media/media_options.gni
+++ b/media/media_options.gni
@@ -85,7 +85,7 @@ declare_args() {
enable_hevc_parser_and_hw_decoder =
proprietary_codecs &&
(use_fuzzing_engine || use_chromeos_protected_media || is_win || is_mac ||
- is_android)
+ is_android || is_linux)
}
# Use another declare_args() to allow dependence on
--
2.20.1