[FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: add CBP/CHP profile

Rick Kern kernrj at gmail.com
Sun Jun 4 00:39:56 EEST 2023


On Fri, May 26, 2023 at 7:37 AM 徐福隆 <839789740 at qq.com> wrote:

> Kern, please help to review this patch, which has added CBP profile with
> profile options.
> As for the VT_H264Profile replacement, let you take over, follow up this
> patch.
>
Thanks. Pushed with minor modifications.


>
> Thanks
>
> ------------------ 原始邮件 ------------------
> *发件人:* "xufuji456" <839789740 at qq.com>;
> *发送时间:* 2023年5月23日(星期二) 上午10:27
> *收件人:* "ffmpeg-devel"<ffmpeg-devel at ffmpeg.org>;
> *抄送:* "徐福隆"<839789740 at qq.com>;
> *主题:* [PATCH] avcodec/videotoolboxenc: add CBP/CHP profile
>
> The Constrained_Baseline and Constrained_High profile of H264 has
> available in iOS 15.0
>
> Signed-off-by: xufuji456 <839789740 at qq.com>
> ---
>  libavcodec/videotoolboxenc.c | 25 +++++++++++++++++++++----
>  1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index b017c90c36..028095cd04 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -108,6 +108,8 @@ static struct{
>      CFStringRef kVTProfileLevel_H264_High_AutoLevel;
>      CFStringRef kVTProfileLevel_H264_Extended_5_0;
>      CFStringRef kVTProfileLevel_H264_Extended_AutoLevel;
> +    CFStringRef kVTProfileLevel_H264_ConstrainedBaseline_AutoLevel;
> +    CFStringRef kVTProfileLevel_H264_ConstrainedHigh_AutoLevel;
>
>      CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel;
>      CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel;
> @@ -171,6 +173,8 @@ static void loadVTEncSymbols(void){
>      GET_SYM(kVTProfileLevel_H264_High_AutoLevel,
> "H264_High_AutoLevel");
>      GET_SYM(kVTProfileLevel_H264_Extended_5_0,       "H264_Extended_5_0");
>      GET_SYM(kVTProfileLevel_H264_Extended_AutoLevel,
> "H264_Extended_AutoLevel");
> +    GET_SYM(kVTProfileLevel_H264_ConstrainedBaseline_AutoLevel,
> "H264_ConstrainedBaseline_AutoLevel");
> +    GET_SYM(kVTProfileLevel_H264_ConstrainedHigh_AutoLevel,
> "H264_ConstrainedHigh_AutoLevel");
>
>      GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel,
> "HEVC_Main_AutoLevel");
>      GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel,
> "HEVC_Main10_AutoLevel");
> @@ -193,8 +197,10 @@ static void loadVTEncSymbols(void){
>  typedef enum VT_H264Profile {
>      H264_PROF_AUTO,
>      H264_PROF_BASELINE,
> +    H264_PROF_CONSTRAINED_BASELINE,
>      H264_PROF_MAIN,
>      H264_PROF_HIGH,
> +    H264_PROF_CONSTRAINED_HIGH,
>      H264_PROF_EXTENDED,
>      H264_PROF_COUNT
>  } VT_H264Profile;
> @@ -763,6 +769,10 @@ static bool get_vt_h264_profile_level(AVCodecContext
> *avctx,
>              }
>              break;
>
> +        case H264_PROF_CONSTRAINED_BASELINE:
> +            *profile_level_val =
> compat_keys.kVTProfileLevel_H264_ConstrainedBaseline_AutoLevel;
> +            break;
> +
>          case H264_PROF_MAIN:
>              switch (vtctx->level) {
>                  case  0: *profile_level_val =
> @@ -805,6 +815,11 @@ static bool get_vt_h264_profile_level(AVCodecContext
> *avctx,
>
> compat_keys.kVTProfileLevel_H264_High_5_2;       break;
>              }
>              break;
> +
> +        case H264_PROF_CONSTRAINED_HIGH:
> +            *profile_level_val =
> compat_keys.kVTProfileLevel_H264_ConstrainedHigh_AutoLevel;
> +            break;
> +
>          case H264_PROF_EXTENDED:
>              switch (vtctx->level) {
>                  case  0: *profile_level_val =
> @@ -2757,10 +2772,12 @@ static const enum AVPixelFormat prores_pix_fmts[]
> = {
>  #define OFFSET(x) offsetof(VTEncContext, x)
>  static const AVOption h264_options[] = {
>      { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 =
> H264_PROF_AUTO }, H264_PROF_AUTO, H264_PROF_COUNT, VE, "profile" },
> -    { "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 =
> H264_PROF_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
> -    { "main",     "Main Profile",     0, AV_OPT_TYPE_CONST, { .i64 =
> H264_PROF_MAIN     }, INT_MIN, INT_MAX, VE, "profile" },
> -    { "high",     "High Profile",     0, AV_OPT_TYPE_CONST, { .i64 =
> H264_PROF_HIGH     }, INT_MIN, INT_MAX, VE, "profile" },
> -    { "extended", "Extend Profile",   0, AV_OPT_TYPE_CONST, { .i64 =
> H264_PROF_EXTENDED }, INT_MIN, INT_MAX, VE, "profile" },
> +    { "baseline",             "Baseline Profile",             0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_BASELINE             }, INT_MIN,
> INT_MAX, VE, "profile" },
> +    { "constrained_baseline", "Constrained_Baseline Profile", 0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_CONSTRAINED_BASELINE }, INT_MIN,
> INT_MAX, VE, "profile" },
> +    { "main",                 "Main Profile",                 0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_MAIN                 }, INT_MIN,
> INT_MAX, VE, "profile" },
> +    { "high",                 "High Profile",                 0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_HIGH                 }, INT_MIN,
> INT_MAX, VE, "profile" },
> +    { "constrained_high",     "Constrained_High Profile",     0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_CONSTRAINED_HIGH     }, INT_MIN,
> INT_MAX, VE, "profile" },
> +    { "extended",             "Extend Profile",               0,
> AV_OPT_TYPE_CONST, { .i64 = H264_PROF_EXTENDED             }, INT_MIN,
> INT_MAX, VE, "profile" },
>
>      { "level", "Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0,
> 52, VE, "level" },
>      { "1.3", "Level 1.3, only available with Baseline Profile", 0,
> AV_OPT_TYPE_CONST, { .i64 = 13 }, INT_MIN, INT_MAX, VE, "level" },
> --
> 2.32.0 (Apple Git-132)
>
>


More information about the ffmpeg-devel mailing list