diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2023-10-12 20:49:34 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2023-10-18 23:05:14 +0800 |
commit | 236197088059b8e86becb7c3fe5d2cb14466bf25 (patch) | |
tree | 093382be9a6f6291ff4cbda4c053333528d553c6 | |
parent | cbb6199ff864c6985efad1bb63cdad6e8a650b9b (diff) | |
download | ffmpeg-236197088059b8e86becb7c3fe5d2cb14466bf25.tar.gz |
avcodec/videotoolboxenc: Check and set hevc profile
1. If user don't specify the profile, set it to main10 when pixel
format is 10 bits. Before the patch, videotoolbox output main
profile bitstream with 10 bit input, which can be confusing.
2. Warning when user set profile to main explicitly with 10 bit
input. It works, but not the best choice.
3. Reject main 10 profile with 8 bit input, it doesn't work.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r-- | libavcodec/videotoolboxenc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index b685bf4cc4..b0e827d14a 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -894,17 +894,35 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx, { VTEncContext *vtctx = avctx->priv_data; int profile = vtctx->profile; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get( + avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ? avctx->sw_pix_fmt + : avctx->pix_fmt); + int bit_depth = desc ? desc->comp[0].depth : 0; *profile_level_val = NULL; switch (profile) { case AV_PROFILE_UNKNOWN: + // Set profile automatically if user don't specify + if (bit_depth == 10) { + *profile_level_val = + compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel; + break; + } return true; case AV_PROFILE_HEVC_MAIN: + if (bit_depth > 0 && bit_depth != 8) + av_log(avctx, AV_LOG_WARNING, + "main profile with %d bit input\n", bit_depth); *profile_level_val = compat_keys.kVTProfileLevel_HEVC_Main_AutoLevel; break; case AV_PROFILE_HEVC_MAIN_10: + if (bit_depth > 0 && bit_depth != 10) { + av_log(avctx, AV_LOG_ERROR, + "Invalid main10 profile with %d bit input\n", bit_depth); + return false; + } *profile_level_val = compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel; break; |