Last active
May 14, 2024 08:22
-
-
Save amazingfate/c9b5d558d1f0f4f756348b7e4c43be3c to your computer and use it in GitHub Desktop.
Chromium v124 v4l2 patches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1e51ff38f62b1cf41fda6c3067914096ee58933e Mon Sep 17 00:00:00 2001 | |
From: Jianfeng Liu <[email protected]> | |
Date: Sun, 31 Mar 2024 10:37:12 +0800 | |
Subject: [PATCH 1/3] enable v4l2 av1 decoder for linux | |
--- | |
media/gpu/v4l2/BUILD.gn | 4 ++-- | |
media/gpu/v4l2/v4l2_utils.cc | 8 ++++---- | |
media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc | 2 +- | |
3 files changed, 7 insertions(+), 7 deletions(-) | |
diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn | |
index cf469a68cd..7d98203842 100644 | |
--- a/media/gpu/v4l2/BUILD.gn | |
+++ b/media/gpu/v4l2/BUILD.gn | |
@@ -69,6 +69,8 @@ source_set("v4l2") { | |
"v4l2_video_decoder_delegate_vp9.h", | |
"v4l2_vp9_helpers.cc", | |
"v4l2_vp9_helpers.h", | |
+ "v4l2_video_decoder_delegate_av1.cc", | |
+ "v4l2_video_decoder_delegate_av1.h", | |
] | |
if (enable_hevc_parser_and_hw_decoder) { | |
@@ -93,8 +95,6 @@ source_set("v4l2") { | |
# AV1 delegate depends on header files only in ChromeOS SDK | |
"stateless/av1_delegate.cc", | |
"stateless/av1_delegate.h", | |
- "v4l2_video_decoder_delegate_av1.cc", | |
- "v4l2_video_decoder_delegate_av1.h", | |
# TODO(crbug.com/901264): Encoders use hack for passing offset | |
# within a DMA-buf, which is not supported upstream. | |
diff --git a/media/gpu/v4l2/v4l2_utils.cc b/media/gpu/v4l2/v4l2_utils.cc | |
index 88dc5e7e1a..2afd091965 100644 | |
--- a/media/gpu/v4l2/v4l2_utils.cc | |
+++ b/media/gpu/v4l2/v4l2_utils.cc | |
@@ -195,7 +195,7 @@ VideoCodecProfile V4L2ProfileToVideoCodecProfile(uint32_t v4l2_codec, | |
} | |
break; | |
#endif | |
-#if BUILDFLAG(IS_CHROMEOS) | |
+#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) | |
case V4L2_CID_MPEG_VIDEO_AV1_PROFILE: | |
switch (v4l2_profile) { | |
case V4L2_MPEG_VIDEO_AV1_PROFILE_MAIN: | |
@@ -328,7 +328,7 @@ static const std::map<v4l2_enum_type, v4l2_enum_type> | |
{V4L2_PIX_FMT_VP8_FRAME, V4L2_CID_MPEG_VIDEO_VP8_PROFILE}, | |
{V4L2_PIX_FMT_VP9, V4L2_CID_MPEG_VIDEO_VP9_PROFILE}, | |
{V4L2_PIX_FMT_VP9_FRAME, V4L2_CID_MPEG_VIDEO_VP9_PROFILE}, | |
-#if BUILDFLAG(IS_CHROMEOS) | |
+#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) | |
{V4L2_PIX_FMT_AV1, V4L2_CID_MPEG_VIDEO_AV1_PROFILE}, | |
{V4L2_PIX_FMT_AV1_FRAME, V4L2_CID_MPEG_VIDEO_AV1_PROFILE}, | |
#endif | |
@@ -349,7 +349,7 @@ static const std::map<v4l2_enum_type, std::vector<VideoCodecProfile>> | |
#endif // BUILDFLAG(ENABLE_HEVC_PARSER_AND_HW_DECODER) | |
{V4L2_CID_MPEG_VIDEO_VP8_PROFILE, {VP8PROFILE_ANY}}, | |
{V4L2_CID_MPEG_VIDEO_VP9_PROFILE, {VP9PROFILE_PROFILE0}}, | |
-#if BUILDFLAG(IS_CHROMEOS) | |
+#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) | |
{V4L2_CID_MPEG_VIDEO_AV1_PROFILE, {AV1PROFILE_PROFILE_MAIN}}, | |
#endif | |
}; | |
@@ -368,7 +368,7 @@ static const std::map<VideoCodecProfile, | |
#endif // BUILDFLAG(ENABLE_HEVC_PARSER_AND_HW_DECODER) | |
{VP8PROFILE_ANY, MAKE_V4L2_CODEC_PAIR(V4L2_PIX_FMT_VP8, FRAME)}, | |
{VP9PROFILE_PROFILE0, MAKE_V4L2_CODEC_PAIR(V4L2_PIX_FMT_VP9, FRAME)}, | |
-#if BUILDFLAG(IS_CHROMEOS) | |
+#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) | |
{AV1PROFILE_PROFILE_MAIN, | |
MAKE_V4L2_CODEC_PAIR(V4L2_PIX_FMT_AV1, FRAME)}, | |
#endif | |
diff --git a/media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc b/media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc | |
index 6d201f4cb7..ac70f1b61c 100644 | |
--- a/media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc | |
+++ b/media/gpu/v4l2/v4l2_video_decoder_backend_stateless.cc | |
@@ -740,7 +740,7 @@ bool V4L2StatelessVideoDecoderBackend::CreateDecoder() { | |
decoder_ = std::make_unique<VP9Decoder>( | |
std::make_unique<V4L2VideoDecoderDelegateVP9>(this, device_.get()), | |
profile_, color_space_); | |
-#if BUILDFLAG(IS_CHROMEOS) | |
+#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) | |
} else if (profile_ >= AV1PROFILE_MIN && profile_ <= AV1PROFILE_MAX) { | |
decoder_ = std::make_unique<AV1Decoder>( | |
std::make_unique<V4L2VideoDecoderDelegateAV1>(this, device_.get()), | |
-- | |
2.34.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 953435581defeb8a97139ee14f26262a3a43b26a Mon Sep 17 00:00:00 2001 | |
From: Jianfeng Liu <[email protected]> | |
Date: Sun, 31 Mar 2024 10:38:01 +0800 | |
Subject: [PATCH 2/3] support multi v4l2 decoder devices | |
--- | |
media/gpu/chromeos/video_decoder_pipeline.cc | 2 +- | |
1 file changed, 1 insertion(+), 1 deletion(-) | |
diff --git a/media/gpu/chromeos/video_decoder_pipeline.cc b/media/gpu/chromeos/video_decoder_pipeline.cc | |
index d3bf14250b..01aed591b7 100644 | |
--- a/media/gpu/chromeos/video_decoder_pipeline.cc | |
+++ b/media/gpu/chromeos/video_decoder_pipeline.cc | |
@@ -278,7 +278,7 @@ VideoDecoderPipeline::GetSupportedConfigs( | |
break; | |
#elif BUILDFLAG(USE_V4L2_CODEC) | |
case VideoDecoderType::kV4L2: | |
- configs = GetSupportedV4L2DecoderConfigs(); | |
+ configs = V4L2VideoDecoder::GetSupportedConfigs(); | |
break; | |
#endif | |
default: | |
-- | |
2.34.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 68fcb089e196c904449c88b49d0f7cc70249efd9 Mon Sep 17 00:00:00 2001 | |
From: Jianfeng Liu <[email protected]> | |
Date: Thu, 25 Apr 2024 11:20:13 +0800 | |
Subject: [PATCH 3/3] media: enable NV12 direct rendering | |
--- | |
.../mojo/services/gpu_mojo_media_client_linux.cc | 15 ++++++++++++--- | |
1 file changed, 12 insertions(+), 3 deletions(-) | |
diff --git a/media/mojo/services/gpu_mojo_media_client_linux.cc b/media/mojo/services/gpu_mojo_media_client_linux.cc | |
index 9b67a02635..80051ad5ec 100644 | |
--- a/media/mojo/services/gpu_mojo_media_client_linux.cc | |
+++ b/media/mojo/services/gpu_mojo_media_client_linux.cc | |
@@ -43,7 +43,8 @@ VideoDecoderType GetPreferredLinuxDecoderImplementation() { | |
} | |
std::vector<Fourcc> GetPreferredRenderableFourccs( | |
- const gpu::GpuPreferences& gpu_preferences) { | |
+ const gpu::GpuPreferences& gpu_preferences, | |
+ const gpu::GpuFeatureInfo& gpu_feature_info) { | |
std::vector<Fourcc> renderable_fourccs; | |
#if BUILDFLAG(ENABLE_VULKAN) | |
// Support for zero-copy NV12 textures preferentially. | |
@@ -52,6 +53,14 @@ std::vector<Fourcc> GetPreferredRenderableFourccs( | |
} | |
#endif // BUILDFLAG(ENABLE_VULKAN) | |
+ if (gpu_preferences.gr_context_type == gpu::GrContextType::kGL) { | |
+ if (base::Contains( | |
+ gpu_feature_info.supported_buffer_formats_for_allocation_and_texturing, | |
+ gfx::BufferFormat::YUV_420_BIPLANAR)) { | |
+ renderable_fourccs.emplace_back(Fourcc::NV12); | |
+ } | |
+ } | |
+ | |
// Support 1-copy argb textures. | |
renderable_fourccs.emplace_back(Fourcc::AR24); | |
@@ -145,7 +154,7 @@ std::unique_ptr<VideoDecoder> CreatePlatformVideoDecoder( | |
return VideoDecoderPipeline::Create( | |
*traits.gpu_workarounds, traits.task_runner, std::move(frame_pool), | |
std::move(frame_converter), | |
- GetPreferredRenderableFourccs(traits.gpu_preferences), | |
+ GetPreferredRenderableFourccs(traits.gpu_preferences, traits.gpu_feature_info), | |
traits.media_log->Clone(), std::move(traits.oop_video_decoder), | |
/*in_video_decoder_process=*/false); | |
} | |
@@ -157,7 +166,7 @@ std::unique_ptr<VideoDecoder> CreatePlatformVideoDecoder( | |
return VideoDecoderPipeline::Create( | |
*traits.gpu_workarounds, traits.task_runner, std::move(frame_pool), | |
std::move(frame_converter), | |
- GetPreferredRenderableFourccs(traits.gpu_preferences), | |
+ GetPreferredRenderableFourccs(traits.gpu_preferences, traits.gpu_feature_info), | |
traits.media_log->Clone(), /*oop_video_decoder=*/{}, | |
/*in_video_decoder_process=*/false); | |
} | |
-- | |
2.34.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment