1From c84f1f0f1df5be16b32eec0340e11022e228f38f Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 9 Sep 2022 16:06:58 +0800
4Subject: [PATCH 15/17] media: Support HEVC in V4L2 VDA
5
6Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
7---
8 media/gpu/v4l2/v4l2_device.cc                         | 9 +++++++++
9 media/gpu/v4l2/v4l2_vda_helpers.cc                    | 1 +
10 media/gpu/v4l2/v4l2_video_decode_accelerator.cc       | 2 +-
11 media/gpu/v4l2/v4l2_video_decoder.cc                  | 1 +
12 media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc | 1 +
13 5 files changed, 13 insertions(+), 1 deletion(-)
14
15diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc
16index d8e5526fe..50886548f 100644
17--- a/media/gpu/v4l2/v4l2_device.cc
18+++ b/media/gpu/v4l2/v4l2_device.cc
19@@ -1599,6 +1599,8 @@ uint32_t V4L2Device::VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile,
20
21   if (profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX) {
22     return V4L2_PIX_FMT_H264;
23+  } else if (profile >= HEVCPROFILE_MIN && profile <= HEVCPROFILE_MAX) {
24+    return V4L2_PIX_FMT_HEVC;
25   } else if (profile >= VP8PROFILE_MIN && profile <= VP8PROFILE_MAX) {
26     return V4L2_PIX_FMT_VP8;
27   } else if (profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX) {
28@@ -1792,6 +1794,13 @@ std::vector<VideoCodecProfile> V4L2Device::V4L2PixFmtToVideoCodecProfiles(
29           H264PROFILE_HIGH,
30       };
31       break;
32+    case V4L2_PIX_FMT_HEVC:
33+      profiles = {
34+          HEVCPROFILE_MAIN,
35+          HEVCPROFILE_MAIN10,
36+          HEVCPROFILE_MAIN_STILL_PICTURE,
37+      };
38+      break;
39     case V4L2_PIX_FMT_VP8:
40       profiles = {VP8PROFILE_ANY};
41       break;
42diff --git a/media/gpu/v4l2/v4l2_vda_helpers.cc b/media/gpu/v4l2/v4l2_vda_helpers.cc
43index baaca9c0a..71983d372 100644
44--- a/media/gpu/v4l2/v4l2_vda_helpers.cc
45+++ b/media/gpu/v4l2/v4l2_vda_helpers.cc
46@@ -149,6 +149,7 @@ InputBufferFragmentSplitter::CreateFromProfile(
47     case VideoCodec::kH264:
48       return std::make_unique<
49           v4l2_vda_helpers::H264InputBufferFragmentSplitter>();
50+    case VideoCodec::kHEVC:
51     case VideoCodec::kVP8:
52     case VideoCodec::kVP9:
53       // VP8/VP9 don't need any frame splitting, use the default implementation.
54diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
55index 05b87395f..08da713c9 100644
56--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
57+++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
58@@ -87,7 +87,7 @@ bool IsVp9KSVCStream(uint32_t input_format_fourcc,
59
60 // static
61 const uint32_t V4L2VideoDecodeAccelerator::supported_input_fourccs_[] = {
62-    V4L2_PIX_FMT_H264, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
63+    V4L2_PIX_FMT_H264, V4L2_PIX_FMT_HEVC, V4L2_PIX_FMT_VP8, V4L2_PIX_FMT_VP9,
64 };
65
66 // static
67diff --git a/media/gpu/v4l2/v4l2_video_decoder.cc b/media/gpu/v4l2/v4l2_video_decoder.cc
68index f6304210c..ca84857e6 100644
69--- a/media/gpu/v4l2/v4l2_video_decoder.cc
70+++ b/media/gpu/v4l2/v4l2_video_decoder.cc
71@@ -57,6 +57,7 @@ constexpr uint32_t kSupportedInputFourccs[] = {
72 #endif
73     // V4L2 stateful formats
74     V4L2_PIX_FMT_H264,
75+    V4L2_PIX_FMT_HEVC,
76     V4L2_PIX_FMT_VP8,
77     V4L2_PIX_FMT_VP9,
78     V4L2_PIX_FMT_AV1,
79diff --git a/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc b/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
80index a95bf0093..e9edcbef3 100644
81--- a/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
82+++ b/media/gpu/v4l2/v4l2_video_decoder_backend_stateful.cc
83@@ -768,6 +768,7 @@ bool V4L2StatefulVideoDecoderBackend::IsSupportedProfile(
84   if (supported_profiles_.empty()) {
85     constexpr uint32_t kSupportedInputFourccs[] = {
86         V4L2_PIX_FMT_H264,
87+        V4L2_PIX_FMT_HEVC,
88         V4L2_PIX_FMT_VP8,
89         V4L2_PIX_FMT_VP9,
90     };
91--
922.20.1
93
94