Skip to content

Commit

Permalink
patch: update vtenc hevc rext, hevc profile warning
Browse files Browse the repository at this point in the history
profile value should be rext, conform the spec, see decode_profile_tier_level() in ps.c.

-c:v hevc_videotoolbox -profile:v main42210 or -c:v hevc_videotoolbox -profile:v rext
  • Loading branch information
wang-bin committed Oct 15, 2024
1 parent 6ce0a49 commit 22d3cc7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
From 01e9bfc1e2f8e2dddd66f4423c2e5e5b0363cdd2 Mon Sep 17 00:00:00 2001
From 5e6f730da38e65d23bc1e6bfb9369c3d4b4ef796 Mon Sep 17 00:00:00 2001
From: wang-bin <wbsecg1@gmail.com>
Date: Thu, 22 Dec 2022 10:39:29 +0800
Subject: [PATCH 28/29] lavc/videotoolboxenc: add hevc main42210 and p210
Subject: [PATCH 28/30] lavc/videotoolboxenc: add hevc main42210 and p210

supported by apple silicon
---
libavcodec/defs.h | 1 +
libavcodec/videotoolboxenc.c | 8 ++++++++
2 files changed, 9 insertions(+)
libavcodec/videotoolboxenc.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/libavcodec/defs.h b/libavcodec/defs.h
index 24250f8af5..15d1e1563a 100644
--- a/libavcodec/defs.h
+++ b/libavcodec/defs.h
@@ -160,6 +160,7 @@
#define AV_PROFILE_HEVC_MAIN_10 2
#define AV_PROFILE_HEVC_MAIN_STILL_PICTURE 3
#define AV_PROFILE_HEVC_REXT 4
+#define AV_PROFILE_HEVC_MAIN_10_422 5
#define AV_PROFILE_HEVC_MULTIVIEW_MAIN 6
#define AV_PROFILE_HEVC_SCC 9

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index da7b291b03..f03b160574 100644
index da7b291b03..9fce54e155 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -115,6 +115,7 @@ static struct{
Expand All @@ -41,33 +28,35 @@ index da7b291b03..f03b160574 100644

GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime");
GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha,
@@ -971,6 +973,10 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx,
@@ -971,6 +973,11 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx,
*profile_level_val =
compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel;
break;
+ case AV_PROFILE_HEVC_MAIN_10_422:
+ case AV_PROFILE_HEVC_REXT:
+ // only main42210 is supported, omit depth and chroma subsampling
+ *profile_level_val =
+ compat_keys.kVTProfileLevel_HEVC_Main42210_AutoLevel;
+ break;
}

if (!*profile_level_val) {
@@ -2839,6 +2845,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = {
@@ -2839,6 +2846,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = {
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_BGRA,
AV_PIX_FMT_P010LE,
+ AV_PIX_FMT_P210,
AV_PIX_FMT_NONE
};

@@ -2971,6 +2978,7 @@ static const AVOption hevc_options[] = {
@@ -2971,6 +2979,8 @@ static const AVOption hevc_options[] = {
{ "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, INT_MAX, VE, .unit = "profile" },
{ "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, .unit = "profile" },
{ "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
+ { "main42210","Main42210 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_MAIN_10_422 }, INT_MIN, INT_MAX, VE, .unit = "profile" },
+ { "main42210","Main 4:2:2 10 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_REXT }, INT_MIN, INT_MAX, VE, .unit = "profile" },
+ { "rext", "Main 4:2:2 10 Profile",0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_HEVC_REXT }, INT_MIN, INT_MAX, VE, .unit = "profile" },

{ "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },

--
2.39.3 (Apple Git-146)
2.39.5 (Apple Git-154)

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 476fb02d88e8d86c1883f81b40d5d9ba57f95487 Mon Sep 17 00:00:00 2001
From: wang-bin <wbsecg1@gmail.com>
Date: Tue, 15 Oct 2024 17:07:02 +0800
Subject: [PATCH 31/31] hevc: disable Unknown profile bitstream warning for
small configuration

---
libavcodec/hevc/ps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index a1d352eec5..0efb4bc393 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -254,9 +254,9 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
profile_name = ff_hevc_profiles[i].name;
break;
}
-#endif
av_log(avctx, profile_name ? AV_LOG_DEBUG : AV_LOG_WARNING,
"%s profile bitstream\n", profile_name ? profile_name : "Unknown");
+#endif

for (i = 0; i < 32; i++) {
ptl->profile_compatibility_flag[i] = get_bits1(gb);
--
2.39.5 (Apple Git-154)

0 comments on commit 22d3cc7

Please sign in to comment.