@@ -93,6 +93,8 @@ typedef struct VAAPIEncodeH264Options {
9393 int coder ;
9494 int aud ;
9595 int sei ;
96+ int profile ;
97+ int level ;
9698} VAAPIEncodeH264Options ;
9799
98100
@@ -886,6 +888,11 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
886888
887889 ctx -> codec = & vaapi_encode_type_h264 ;
888890
891+ if (avctx -> profile == FF_PROFILE_UNKNOWN )
892+ avctx -> profile = opt -> profile ;
893+ if (avctx -> level == FF_LEVEL_UNKNOWN )
894+ avctx -> level = opt -> level ;
895+
889896 switch (avctx -> profile ) {
890897 case FF_PROFILE_H264_BASELINE :
891898 av_log (avctx , AV_LOG_WARNING , "H.264 baseline profile is not "
@@ -1010,12 +1017,49 @@ static const AVOption vaapi_encode_h264_options[] = {
10101017 { "recovery_point" , "Include recovery points where appropriate" ,
10111018 0 , AV_OPT_TYPE_CONST , { .i64 = SEI_RECOVERY_POINT },
10121019 INT_MIN , INT_MAX , FLAGS , "sei" },
1020+
1021+ { "profile" , "Set profile (profile_idc and constraint_set*_flag)" ,
1022+ OFFSET (profile ), AV_OPT_TYPE_INT ,
1023+ { .i64 = FF_PROFILE_H264_HIGH }, 0x0000 , 0xffff , FLAGS , "profile" },
1024+
1025+ #define PROFILE (name , value ) name , NULL , 0 , AV_OPT_TYPE_CONST , \
1026+ { .i64 = value }, 0 , 0 , FLAGS , "profile"
1027+ { PROFILE ("constrained_baseline" , FF_PROFILE_H264_CONSTRAINED_BASELINE ) },
1028+ { PROFILE ("main" , FF_PROFILE_H264_MAIN ) },
1029+ { PROFILE ("high" , FF_PROFILE_H264_HIGH ) },
1030+ #undef PROFILE
1031+
1032+ { "level" , "Set level (level_idc)" ,
1033+ OFFSET (level ), AV_OPT_TYPE_INT ,
1034+ { .i64 = 51 }, 0x00 , 0xff , FLAGS , "level" },
1035+
1036+ #define LEVEL (name , value ) name , NULL , 0 , AV_OPT_TYPE_CONST , \
1037+ { .i64 = value }, 0 , 0 , FLAGS , "level"
1038+ { LEVEL ("1" , 10 ) },
1039+ { LEVEL ("1.1" , 11 ) },
1040+ { LEVEL ("1.2" , 12 ) },
1041+ { LEVEL ("1.3" , 13 ) },
1042+ { LEVEL ("2" , 20 ) },
1043+ { LEVEL ("2.1" , 21 ) },
1044+ { LEVEL ("2.2" , 22 ) },
1045+ { LEVEL ("3" , 30 ) },
1046+ { LEVEL ("3.1" , 31 ) },
1047+ { LEVEL ("3.2" , 32 ) },
1048+ { LEVEL ("4" , 40 ) },
1049+ { LEVEL ("4.1" , 41 ) },
1050+ { LEVEL ("4.2" , 42 ) },
1051+ { LEVEL ("5" , 50 ) },
1052+ { LEVEL ("5.1" , 51 ) },
1053+ { LEVEL ("5.2" , 52 ) },
1054+ { LEVEL ("6" , 60 ) },
1055+ { LEVEL ("6.1" , 61 ) },
1056+ { LEVEL ("6.2" , 62 ) },
1057+ #undef LEVEL
1058+
10131059 { NULL },
10141060};
10151061
10161062static const AVCodecDefault vaapi_encode_h264_defaults [] = {
1017- { "profile" , "100" },
1018- { "level" , "51" },
10191063 { "b" , "0" },
10201064 { "bf" , "2" },
10211065 { "g" , "120" },
0 commit comments