Skip to content

Commit 3d6f517

Browse files
committed
v4l2_codec2/decoder: Enable zero-copy AVC decoding
Test video FULLHD@25FPS Before this patch: ffmpeg_codec2 - 75/400% CPU usage After this patch: v4l2_codec2 - 50/400% CPU usage CPU usage also contains additional processes, like bitstream read from disk software audio decoding. Signed-off-by: Roman Stratiienko <[email protected]>
1 parent 59f10c2 commit 3d6f517

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 0bed1ed5c32a03654362d4c9510878cc3a6c9ede Mon Sep 17 00:00:00 2001
2+
From: Roman Stratiienko <[email protected]>
3+
Date: Thu, 12 Oct 2023 01:33:39 +0300
4+
Subject: [PATCH 11/11] RPI4: v4l2_codec2/decoder: Enable zero-copy AVC
5+
decoding
6+
7+
1. Lower the rank, to override the ffmpeg_codec2.
8+
2. Keep only NV12. We do not want other formats.
9+
10+
Change-Id: I091b96dc1286409bb8077866f1d58afd98214721
11+
Signed-off-by: Roman Stratiienko <[email protected]>
12+
---
13+
components/V4L2ComponentStore.cpp | 2 +-
14+
components/V4L2Decoder.cpp | 3 +--
15+
2 files changed, 2 insertions(+), 3 deletions(-)
16+
17+
diff --git a/components/V4L2ComponentStore.cpp b/components/V4L2ComponentStore.cpp
18+
index 4004ce5..7bffff2 100644
19+
--- a/components/V4L2ComponentStore.cpp
20+
+++ b/components/V4L2ComponentStore.cpp
21+
@@ -22,7 +22,7 @@
22+
23+
namespace android {
24+
namespace {
25+
-const uint32_t kComponentRank = 0x80;
26+
+const uint32_t kComponentRank = 0x20;
27+
28+
std::string getMediaTypeFromComponentName(const std::string& name) {
29+
if (name == V4L2ComponentName::kH264Decoder || name == V4L2ComponentName::kH264SecureDecoder ||
30+
diff --git a/components/V4L2Decoder.cpp b/components/V4L2Decoder.cpp
31+
index aa59e91..88a6f55 100644
32+
--- a/components/V4L2Decoder.cpp
33+
+++ b/components/V4L2Decoder.cpp
34+
@@ -30,8 +30,7 @@ constexpr size_t kNumExtraOutputBuffers = 4;
35+
// Currently we only support flexible pixel 420 format YCBCR_420_888 in Android.
36+
// Here is the list of flexible 420 format.
37+
constexpr std::initializer_list<uint32_t> kSupportedOutputFourccs = {
38+
- Fourcc::YU12, Fourcc::YV12, Fourcc::YM12, Fourcc::YM21,
39+
- Fourcc::NV12, Fourcc::NV21, Fourcc::NM12, Fourcc::NM21,
40+
+ Fourcc::NV12,
41+
};
42+
43+
uint32_t VideoCodecToV4L2PixFmt(VideoCodec codec) {
44+
--
45+
2.39.2
46+

0 commit comments

Comments
 (0)