2323
2424#include "libavutil/avassert.h"
2525#include "libavutil/common.h"
26+ #include "libavutil/pixdesc.h"
2627#include "libavutil/internal.h"
2728#include "libavutil/opt.h"
2829
@@ -301,10 +302,21 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
301302 H264RawPPS * pps = & priv -> raw_pps ;
302303 VAEncSequenceParameterBufferH264 * vseq = ctx -> codec_sequence_params ;
303304 VAEncPictureParameterBufferH264 * vpic = ctx -> codec_picture_params ;
305+ const AVPixFmtDescriptor * desc ;
306+ int bit_depth ;
304307
305308 memset (sps , 0 , sizeof (* sps ));
306309 memset (pps , 0 , sizeof (* pps ));
307310
311+ desc = av_pix_fmt_desc_get (priv -> common .input_frames -> sw_format );
312+ av_assert0 (desc );
313+ if (desc -> nb_components == 1 || desc -> log2_chroma_w != 1 || desc -> log2_chroma_h != 1 ) {
314+ av_log (avctx , AV_LOG_ERROR , "Chroma format of input pixel format "
315+ "%s is not supported.\n" , desc -> name );
316+ return AVERROR (EINVAL );
317+ }
318+ bit_depth = desc -> comp [0 ].depth ;
319+
308320 sps -> nal_unit_header .nal_ref_idc = 3 ;
309321 sps -> nal_unit_header .nal_unit_type = H264_NAL_SPS ;
310322
@@ -314,11 +326,11 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
314326 avctx -> profile == FF_PROFILE_H264_MAIN )
315327 sps -> constraint_set1_flag = 1 ;
316328
317- if (avctx -> profile == FF_PROFILE_H264_HIGH )
329+ if (avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 )
318330 sps -> constraint_set3_flag = ctx -> gop_size == 1 ;
319331
320332 if (avctx -> profile == FF_PROFILE_H264_MAIN ||
321- avctx -> profile == FF_PROFILE_H264_HIGH ) {
333+ avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 ) {
322334 sps -> constraint_set4_flag = 1 ;
323335 sps -> constraint_set5_flag = ctx -> b_per_p == 0 ;
324336 }
@@ -359,6 +371,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
359371
360372 sps -> seq_parameter_set_id = 0 ;
361373 sps -> chroma_format_idc = 1 ;
374+ sps -> bit_depth_luma_minus8 = bit_depth - 8 ;
375+ sps -> bit_depth_chroma_minus8 = bit_depth - 8 ;
362376
363377 sps -> log2_max_frame_num_minus4 = 4 ;
364378 sps -> pic_order_cnt_type = ctx -> max_b_depth ? 0 : 2 ;
@@ -1144,6 +1158,9 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
11441158}
11451159
11461160static const VAAPIEncodeProfile vaapi_encode_h264_profiles [] = {
1161+ #if VA_CHECK_VERSION (1 , 18 , 0 )
1162+ { FF_PROFILE_H264_HIGH_10 , 10 , 3 , 1 , 1 , VAProfileH264High10 },
1163+ #endif
11471164 { FF_PROFILE_H264_HIGH , 8 , 3 , 1 , 1 , VAProfileH264High },
11481165 { FF_PROFILE_H264_MAIN , 8 , 3 , 1 , 1 , VAProfileH264Main },
11491166 { FF_PROFILE_H264_CONSTRAINED_BASELINE ,
@@ -1208,10 +1225,9 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
12081225 av_log (avctx , AV_LOG_ERROR , "H.264 extended profile "
12091226 "is not supported.\n" );
12101227 return AVERROR_PATCHWELCOME ;
1211- case FF_PROFILE_H264_HIGH_10 :
12121228 case FF_PROFILE_H264_HIGH_10_INTRA :
1213- av_log (avctx , AV_LOG_ERROR , "H.264 10-bit profiles "
1214- "are not supported.\n" );
1229+ av_log (avctx , AV_LOG_ERROR , "H.264 high 10 intra profile "
1230+ "is not supported.\n" );
12151231 return AVERROR_PATCHWELCOME ;
12161232 case FF_PROFILE_H264_HIGH_422 :
12171233 case FF_PROFILE_H264_HIGH_422_INTRA :
@@ -1304,6 +1320,7 @@ static const AVOption vaapi_encode_h264_options[] = {
13041320 { PROFILE ("constrained_baseline" , FF_PROFILE_H264_CONSTRAINED_BASELINE ) },
13051321 { PROFILE ("main" , FF_PROFILE_H264_MAIN ) },
13061322 { PROFILE ("high" , FF_PROFILE_H264_HIGH ) },
1323+ { PROFILE ("high10" , FF_PROFILE_H264_HIGH_10 ) },
13071324#undef PROFILE
13081325
13091326 { "level" , "Set level (level_idc)" ,
0 commit comments