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
@@ -290,10 +291,21 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
290291 H264RawPPS * pps = & priv -> raw_pps ;
291292 VAEncSequenceParameterBufferH264 * vseq = ctx -> codec_sequence_params ;
292293 VAEncPictureParameterBufferH264 * vpic = ctx -> codec_picture_params ;
294+ const AVPixFmtDescriptor * desc ;
295+ int bit_depth ;
293296
294297 memset (sps , 0 , sizeof (* sps ));
295298 memset (pps , 0 , sizeof (* pps ));
296299
300+ desc = av_pix_fmt_desc_get (priv -> common .input_frames -> sw_format );
301+ av_assert0 (desc );
302+ if (desc -> nb_components == 1 || desc -> log2_chroma_w != 1 || desc -> log2_chroma_h != 1 ) {
303+ av_log (avctx , AV_LOG_ERROR , "Chroma format of input pixel format "
304+ "%s is not supported.\n" , desc -> name );
305+ return AVERROR (EINVAL );
306+ }
307+ bit_depth = desc -> comp [0 ].depth ;
308+
297309 sps -> nal_unit_header .nal_ref_idc = 3 ;
298310 sps -> nal_unit_header .nal_unit_type = H264_NAL_SPS ;
299311
@@ -303,11 +315,11 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
303315 avctx -> profile == FF_PROFILE_H264_MAIN )
304316 sps -> constraint_set1_flag = 1 ;
305317
306- if (avctx -> profile == FF_PROFILE_H264_HIGH )
318+ if (avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 )
307319 sps -> constraint_set3_flag = ctx -> gop_size == 1 ;
308320
309321 if (avctx -> profile == FF_PROFILE_H264_MAIN ||
310- avctx -> profile == FF_PROFILE_H264_HIGH ) {
322+ avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 ) {
311323 sps -> constraint_set4_flag = 1 ;
312324 sps -> constraint_set5_flag = ctx -> b_per_p == 0 ;
313325 }
@@ -348,6 +360,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
348360
349361 sps -> seq_parameter_set_id = 0 ;
350362 sps -> chroma_format_idc = 1 ;
363+ sps -> bit_depth_luma_minus8 = bit_depth - 8 ;
364+ sps -> bit_depth_chroma_minus8 = bit_depth - 8 ;
351365
352366 sps -> log2_max_frame_num_minus4 = 4 ;
353367 sps -> pic_order_cnt_type = 0 ;
@@ -1111,6 +1125,9 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
11111125}
11121126
11131127static const VAAPIEncodeProfile vaapi_encode_h264_profiles [] = {
1128+ #if HAVE_VA_PROFILE_H264_HIGH10
1129+ { FF_PROFILE_H264_HIGH_10 , 10 , 3 , 1 , 1 , VAProfileH264High10 },
1130+ #endif
11141131 { FF_PROFILE_H264_HIGH , 8 , 3 , 1 , 1 , VAProfileH264High },
11151132 { FF_PROFILE_H264_MAIN , 8 , 3 , 1 , 1 , VAProfileH264Main },
11161133 { FF_PROFILE_H264_CONSTRAINED_BASELINE ,
@@ -1175,10 +1192,9 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
11751192 av_log (avctx , AV_LOG_ERROR , "H.264 extended profile "
11761193 "is not supported.\n" );
11771194 return AVERROR_PATCHWELCOME ;
1178- case FF_PROFILE_H264_HIGH_10 :
11791195 case FF_PROFILE_H264_HIGH_10_INTRA :
1180- av_log (avctx , AV_LOG_ERROR , "H.264 10-bit profiles "
1181- "are not supported.\n" );
1196+ av_log (avctx , AV_LOG_ERROR , "H.264 high 10 intra profile "
1197+ "is not supported.\n" );
11821198 return AVERROR_PATCHWELCOME ;
11831199 case FF_PROFILE_H264_HIGH_422 :
11841200 case FF_PROFILE_H264_HIGH_422_INTRA :
@@ -1267,6 +1283,7 @@ static const AVOption vaapi_encode_h264_options[] = {
12671283 { PROFILE ("constrained_baseline" , FF_PROFILE_H264_CONSTRAINED_BASELINE ) },
12681284 { PROFILE ("main" , FF_PROFILE_H264_MAIN ) },
12691285 { PROFILE ("high" , FF_PROFILE_H264_HIGH ) },
1286+ { PROFILE ("high10" , FF_PROFILE_H264_HIGH_10 ) },
12701287#undef PROFILE
12711288
12721289 { "level" , "Set level (level_idc)" ,
0 commit comments