23
23
24
24
#include "libavutil/avassert.h"
25
25
#include "libavutil/common.h"
26
+ #include "libavutil/pixdesc.h"
26
27
#include "libavutil/internal.h"
27
28
#include "libavutil/opt.h"
28
29
@@ -301,10 +302,21 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
301
302
H264RawPPS * pps = & priv -> raw_pps ;
302
303
VAEncSequenceParameterBufferH264 * vseq = ctx -> codec_sequence_params ;
303
304
VAEncPictureParameterBufferH264 * vpic = ctx -> codec_picture_params ;
305
+ const AVPixFmtDescriptor * desc ;
306
+ int bit_depth ;
304
307
305
308
memset (sps , 0 , sizeof (* sps ));
306
309
memset (pps , 0 , sizeof (* pps ));
307
310
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
+
308
320
sps -> nal_unit_header .nal_ref_idc = 3 ;
309
321
sps -> nal_unit_header .nal_unit_type = H264_NAL_SPS ;
310
322
@@ -314,11 +326,11 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
314
326
avctx -> profile == FF_PROFILE_H264_MAIN )
315
327
sps -> constraint_set1_flag = 1 ;
316
328
317
- if (avctx -> profile == FF_PROFILE_H264_HIGH )
329
+ if (avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 )
318
330
sps -> constraint_set3_flag = ctx -> gop_size == 1 ;
319
331
320
332
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 ) {
322
334
sps -> constraint_set4_flag = 1 ;
323
335
sps -> constraint_set5_flag = ctx -> b_per_p == 0 ;
324
336
}
@@ -359,6 +371,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
359
371
360
372
sps -> seq_parameter_set_id = 0 ;
361
373
sps -> chroma_format_idc = 1 ;
374
+ sps -> bit_depth_luma_minus8 = bit_depth - 8 ;
375
+ sps -> bit_depth_chroma_minus8 = bit_depth - 8 ;
362
376
363
377
sps -> log2_max_frame_num_minus4 = 4 ;
364
378
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)
1144
1158
}
1145
1159
1146
1160
static 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
1147
1164
{ FF_PROFILE_H264_HIGH , 8 , 3 , 1 , 1 , VAProfileH264High },
1148
1165
{ FF_PROFILE_H264_MAIN , 8 , 3 , 1 , 1 , VAProfileH264Main },
1149
1166
{ FF_PROFILE_H264_CONSTRAINED_BASELINE ,
@@ -1208,10 +1225,9 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
1208
1225
av_log (avctx , AV_LOG_ERROR , "H.264 extended profile "
1209
1226
"is not supported.\n" );
1210
1227
return AVERROR_PATCHWELCOME ;
1211
- case FF_PROFILE_H264_HIGH_10 :
1212
1228
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" );
1215
1231
return AVERROR_PATCHWELCOME ;
1216
1232
case FF_PROFILE_H264_HIGH_422 :
1217
1233
case FF_PROFILE_H264_HIGH_422_INTRA :
@@ -1304,6 +1320,7 @@ static const AVOption vaapi_encode_h264_options[] = {
1304
1320
{ PROFILE ("constrained_baseline" , FF_PROFILE_H264_CONSTRAINED_BASELINE ) },
1305
1321
{ PROFILE ("main" , FF_PROFILE_H264_MAIN ) },
1306
1322
{ PROFILE ("high" , FF_PROFILE_H264_HIGH ) },
1323
+ { PROFILE ("high10" , FF_PROFILE_H264_HIGH_10 ) },
1307
1324
#undef PROFILE
1308
1325
1309
1326
{ "level" , "Set level (level_idc)" ,
0 commit comments