-
Notifications
You must be signed in to change notification settings - Fork 60
/
enable-hevc-ffmpeg-decoding.patch
122 lines (112 loc) · 4.84 KB
/
enable-hevc-ffmpeg-decoding.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From 71024c860e2d86c2ff02d5cb78bea617f466d7a7 Mon Sep 17 00:00:00 2001
From: Sta Zhu <zhusidayoyo@hotmail.com>
Date: Tue, 30 Jul 2024 22:45:31 +0800
Subject: [PATCH] Video: Enable HEVC ffmpeg decoding
This will consider all HEVC profile as to supported, let FFMpegVideoDecoder
handle SW fallback and help you be able to play video's like HEVC Rext, SCC
etc... as long as ffmpeg support it.
---
media/base/supported_types.cc | 29 ++++++---------------------
media/filters/ffmpeg_glue.cc | 2 +-
media/filters/ffmpeg_video_decoder.cc | 8 +++++---
3 files changed, 12 insertions(+), 27 deletions(-)
diff --git a/media/base/supported_types.cc b/media/base/supported_types.cc
index 31c77aff03d0d..0599bbd7be607 100644
--- a/media/base/supported_types.cc
+++ b/media/base/supported_types.cc
@@ -222,33 +222,14 @@ bool IsAudioCodecProprietary(AudioCodec codec) {
#endif // !BUILDFLAG(USE_PROPRIETARY_CODECS)
bool IsHevcProfileSupported(const VideoType& type) {
- if (!IsColorSpaceSupported(type.color_space))
- return false;
-
-#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
-#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- // TODO(b/171813538): For Lacros, the supplemental profile cache will be
- // asking lacros-gpu, but we will be doing decoding in ash-gpu. Until the
- // codec detection is plumbed through to ash-gpu we can do this extra check
- // for HEVC support.
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kLacrosEnablePlatformHevc)) {
+#if BUILDFLAG(IS_ANDROID)
+ if (base::FeatureList::IsEnabled(kBuiltInH264Decoder)) {
return true;
}
-#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- if (!base::FeatureList::IsEnabled(kPlatformHEVCDecoderSupport)) {
- return false;
- }
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return GetSupplementalProfileCache()->IsProfileSupported(type.profile);
#else
return true;
-#endif // BUIDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
-#else
- return false;
-#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
+#endif // BUILDFLAG(IS_ANDROID)
}
bool IsVp9ProfileSupported(const VideoType& type) {
@@ -441,7 +422,9 @@ bool IsDefaultSupportedAudioType(const AudioType& type) {
bool IsBuiltInVideoCodec(VideoCodec codec) {
#if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS) && BUILDFLAG(USE_PROPRIETARY_CODECS)
- if (codec == VideoCodec::kH264 &&
+ // Android does bundle `FFMpegVideoDecoder` for `non-arm32` devices,
+ // but not enabled by default.
+ if ((codec == VideoCodec::kH264 || codec == VideoCodec::kHEVC) &&
base::FeatureList::IsEnabled(kBuiltInH264Decoder)) {
return true;
}
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index 7d5c6e63b1906..8c08b5ae93cc2 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -164,7 +164,7 @@ const char* FFmpegGlue::GetAllowedAudioDecoders() {
const char* FFmpegGlue::GetAllowedVideoDecoders() {
// This should match the configured lists in //third_party/ffmpeg.
#if BUILDFLAG(USE_PROPRIETARY_CODECS) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
- return IsBuiltInVideoCodec(VideoCodec::kH264) ? "h264" : "";
+ return IsBuiltInVideoCodec(VideoCodec::kH264) ? "h264,hevc" : "";
#else
return "";
#endif
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index 3f9cef0391af5..a5954f298ca38 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "media/base/video_codecs.h"
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
@@ -82,7 +83,6 @@ static int GetFFmpegVideoDecoderThreadCount(const VideoDecoderConfig& config) {
case VideoCodec::kUnknown:
case VideoCodec::kVC1:
case VideoCodec::kMPEG2:
- case VideoCodec::kHEVC:
case VideoCodec::kVP9:
case VideoCodec::kAV1:
case VideoCodec::kDolbyVision:
@@ -93,6 +93,7 @@ static int GetFFmpegVideoDecoderThreadCount(const VideoDecoderConfig& config) {
NOTREACHED();
case VideoCodec::kH264:
+ case VideoCodec::kHEVC:
// Normalize to three threads for 1080p content, then scale linearly
// with number of pixels.
// Examples:
@@ -126,8 +127,9 @@ static void ReleaseVideoBufferImpl(void* opaque, uint8_t* data) {
// static
bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) {
- // We only build support for H.264.
- return codec == VideoCodec::kH264 && IsBuiltInVideoCodec(codec);
+ // We only build support for H.264 / H.264.
+ return (codec == VideoCodec::kH264 || codec == VideoCodec::kHEVC) &&
+ IsBuiltInVideoCodec(codec);
}
FFmpegVideoDecoder::FFmpegVideoDecoder(MediaLog* media_log)
--
2.39.3 (Apple Git-146)