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
@@ -290,10 +291,21 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
290
291
H264RawPPS * pps = & priv -> raw_pps ;
291
292
VAEncSequenceParameterBufferH264 * vseq = ctx -> codec_sequence_params ;
292
293
VAEncPictureParameterBufferH264 * vpic = ctx -> codec_picture_params ;
294
+ const AVPixFmtDescriptor * desc ;
295
+ int bit_depth ;
293
296
294
297
memset (sps , 0 , sizeof (* sps ));
295
298
memset (pps , 0 , sizeof (* pps ));
296
299
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
+
297
309
sps -> nal_unit_header .nal_ref_idc = 3 ;
298
310
sps -> nal_unit_header .nal_unit_type = H264_NAL_SPS ;
299
311
@@ -303,11 +315,11 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
303
315
avctx -> profile == FF_PROFILE_H264_MAIN )
304
316
sps -> constraint_set1_flag = 1 ;
305
317
306
- if (avctx -> profile == FF_PROFILE_H264_HIGH )
318
+ if (avctx -> profile == FF_PROFILE_H264_HIGH || avctx -> profile == FF_PROFILE_H264_HIGH_10 )
307
319
sps -> constraint_set3_flag = ctx -> gop_size == 1 ;
308
320
309
321
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 ) {
311
323
sps -> constraint_set4_flag = 1 ;
312
324
sps -> constraint_set5_flag = ctx -> b_per_p == 0 ;
313
325
}
@@ -348,6 +360,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
348
360
349
361
sps -> seq_parameter_set_id = 0 ;
350
362
sps -> chroma_format_idc = 1 ;
363
+ sps -> bit_depth_luma_minus8 = bit_depth - 8 ;
364
+ sps -> bit_depth_chroma_minus8 = bit_depth - 8 ;
351
365
352
366
sps -> log2_max_frame_num_minus4 = 4 ;
353
367
sps -> pic_order_cnt_type = 0 ;
@@ -1111,6 +1125,9 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
1111
1125
}
1112
1126
1113
1127
static 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
1114
1131
{ FF_PROFILE_H264_HIGH , 8 , 3 , 1 , 1 , VAProfileH264High },
1115
1132
{ FF_PROFILE_H264_MAIN , 8 , 3 , 1 , 1 , VAProfileH264Main },
1116
1133
{ FF_PROFILE_H264_CONSTRAINED_BASELINE ,
@@ -1175,10 +1192,9 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
1175
1192
av_log (avctx , AV_LOG_ERROR , "H.264 extended profile "
1176
1193
"is not supported.\n" );
1177
1194
return AVERROR_PATCHWELCOME ;
1178
- case FF_PROFILE_H264_HIGH_10 :
1179
1195
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" );
1182
1198
return AVERROR_PATCHWELCOME ;
1183
1199
case FF_PROFILE_H264_HIGH_422 :
1184
1200
case FF_PROFILE_H264_HIGH_422_INTRA :
@@ -1267,6 +1283,7 @@ static const AVOption vaapi_encode_h264_options[] = {
1267
1283
{ PROFILE ("constrained_baseline" , FF_PROFILE_H264_CONSTRAINED_BASELINE ) },
1268
1284
{ PROFILE ("main" , FF_PROFILE_H264_MAIN ) },
1269
1285
{ PROFILE ("high" , FF_PROFILE_H264_HIGH ) },
1286
+ { PROFILE ("high10" , FF_PROFILE_H264_HIGH_10 ) },
1270
1287
#undef PROFILE
1271
1288
1272
1289
{ "level" , "Set level (level_idc)" ,
0 commit comments