diff options
| author | Rick Kern <[email protected]> | 2023-06-03 15:50:51 -0400 | 
|---|---|---|
| committer | Rick Kern <[email protected]> | 2023-06-03 17:29:06 -0400 | 
| commit | cab6d7bd718f9987eb2d73af363f268e94b7582b (patch) | |
| tree | 199ca0f60e002f09589af16b46b6fb4dc668218d | |
| parent | 2342c05e43573d3045e1648c586c613b95766080 (diff) | |
lavc/videotoolboxenc: use ffmpeg profile constants
Signed-off-by: Rick Kern <[email protected]>
| -rw-r--r-- | libavcodec/videotoolboxenc.c | 57 | 
1 files changed, 22 insertions, 35 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index b017c90c36..55a4019575 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -190,14 +190,7 @@ static void loadVTEncSymbols(void){                  "EnableLowLatencyRateControl");  } -typedef enum VT_H264Profile { -    H264_PROF_AUTO, -    H264_PROF_BASELINE, -    H264_PROF_MAIN, -    H264_PROF_HIGH, -    H264_PROF_EXTENDED, -    H264_PROF_COUNT -} VT_H264Profile; +#define AUTO_PROFILE 0  typedef enum VTH264Entropy{      VT_ENTROPY_NOT_SET, @@ -205,13 +198,6 @@ typedef enum VTH264Entropy{      VT_CABAC  } VTH264Entropy; -typedef enum VT_HEVCProfile { -    HEVC_PROF_AUTO, -    HEVC_PROF_MAIN, -    HEVC_PROF_MAIN10, -    HEVC_PROF_COUNT -} VT_HEVCProfile; -  static const uint8_t start_code[] = { 0, 0, 0, 1 };  typedef struct ExtraSEI { @@ -730,18 +716,18 @@ static bool get_vt_h264_profile_level(AVCodecContext *avctx,      VTEncContext *vtctx = avctx->priv_data;      int64_t profile = vtctx->profile; -    if (profile == H264_PROF_AUTO && vtctx->level) { +    if (profile == AUTO_PROFILE && vtctx->level) {          //Need to pick a profile if level is not auto-selected. -        profile = vtctx->has_b_frames ? H264_PROF_MAIN : H264_PROF_BASELINE; +        profile = vtctx->has_b_frames ? FF_PROFILE_H264_MAIN : FF_PROFILE_H264_BASELINE;      }      *profile_level_val = NULL;      switch (profile) { -        case H264_PROF_AUTO: +        case AUTO_PROFILE:              return true; -        case H264_PROF_BASELINE: +        case FF_PROFILE_H264_BASELINE:              switch (vtctx->level) {                  case  0: *profile_level_val =                                    compat_keys.kVTProfileLevel_H264_Baseline_AutoLevel; break; @@ -763,7 +749,7 @@ static bool get_vt_h264_profile_level(AVCodecContext *avctx,              }              break; -        case H264_PROF_MAIN: +        case FF_PROFILE_H264_MAIN:              switch (vtctx->level) {                  case  0: *profile_level_val =                                    compat_keys.kVTProfileLevel_H264_Main_AutoLevel; break; @@ -782,7 +768,7 @@ static bool get_vt_h264_profile_level(AVCodecContext *avctx,              }              break; -        case H264_PROF_HIGH: +        case FF_PROFILE_H264_HIGH:              switch (vtctx->level) {                  case  0: *profile_level_val =                                    compat_keys.kVTProfileLevel_H264_High_AutoLevel; break; @@ -805,7 +791,7 @@ static bool get_vt_h264_profile_level(AVCodecContext *avctx,                                    compat_keys.kVTProfileLevel_H264_High_5_2;       break;              }              break; -        case H264_PROF_EXTENDED: +        case FF_PROFILE_H264_EXTENDED:              switch (vtctx->level) {                  case  0: *profile_level_val =                                    compat_keys.kVTProfileLevel_H264_Extended_AutoLevel; break; @@ -838,13 +824,13 @@ static bool get_vt_hevc_profile_level(AVCodecContext *avctx,      *profile_level_val = NULL;      switch (profile) { -        case HEVC_PROF_AUTO: +        case AUTO_PROFILE:              return true; -        case HEVC_PROF_MAIN: +        case FF_PROFILE_HEVC_MAIN:              *profile_level_val =                  compat_keys.kVTProfileLevel_HEVC_Main_AutoLevel;              break; -        case HEVC_PROF_MAIN10: +        case FF_PROFILE_HEVC_MAIN_10:              *profile_level_val =                  compat_keys.kVTProfileLevel_HEVC_Main10_AutoLevel;              break; @@ -1515,12 +1501,12 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)          vtctx->get_param_set_func = CMVideoFormatDescriptionGetH264ParameterSetAtIndex;          vtctx->has_b_frames = avctx->max_b_frames > 0; -        if(vtctx->has_b_frames && vtctx->profile == H264_PROF_BASELINE){ +        if(vtctx->has_b_frames && (0xFF & vtctx->profile) == FF_PROFILE_H264_BASELINE){              av_log(avctx, AV_LOG_WARNING, "Cannot use B-frames with baseline profile. Output will not contain B-frames.\n");              vtctx->has_b_frames = 0;          } -        if (vtctx->entropy == VT_CABAC && vtctx->profile == H264_PROF_BASELINE) { +        if (vtctx->entropy == VT_CABAC && (0xFF & vtctx->profile) == FF_PROFILE_H264_BASELINE) {              av_log(avctx, AV_LOG_WARNING, "CABAC entropy requires 'main' or 'high' profile, but baseline was requested. Encode will not use CABAC entropy.\n");              vtctx->entropy = VT_ENTROPY_NOT_SET;          } @@ -2756,11 +2742,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" }, +    { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = AUTO_PROFILE }, 0, INT_MAX, VE, "profile" }, +    { "constrained_baseline", "Constrained Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_CONSTRAINED_BASELINE }, INT_MIN, INT_MAX, VE, "profile" }, +    { "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_BASELINE }, INT_MIN, INT_MAX, VE, "profile" }, +    { "main",     "Main Profile",     0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_MAIN     }, INT_MIN, INT_MAX, VE, "profile" }, +    { "high",     "High Profile",     0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_HIGH     }, INT_MIN, INT_MAX, VE, "profile" }, +    { "extended", "Extend Profile",   0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_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" }, @@ -2811,9 +2798,9 @@ const FFCodec ff_h264_videotoolbox_encoder = {  };  static const AVOption hevc_options[] = { -    { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = HEVC_PROF_AUTO }, HEVC_PROF_AUTO, HEVC_PROF_COUNT, VE, "profile" }, -    { "main",     "Main Profile",     0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN   }, INT_MIN, INT_MAX, VE, "profile" }, -    { "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" }, +    { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = AUTO_PROFILE }, 0, INT_MAX, VE, "profile" }, +    { "main",     "Main Profile",     0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_HEVC_MAIN    }, INT_MIN, INT_MAX, VE, "profile" }, +    { "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_HEVC_MAIN_10 }, INT_MIN, INT_MAX, VE, "profile" },      { "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },  | 
