History

vaapi_encode_h265: Enable multiple-slice support

Mark Thompson committed 8 years ago

Commit a7eda761 parent a769e721 file · +11 −18Browse files

Unified · Split

libavcodec/vaapi_encode_h265.c+11−18
@@ -54,9 +54,6 @@ typedef struct VAAPIEncodeH265Context { · 53 unmodified lines
5454 int sei;
5555
5656 // Derived settings.
57− unsigned int ctu_width;
58− unsigned int ctu_height;
59−
6057 int fixed_qp_idr;
6158 int fixed_qp_p;
6259 int fixed_qp_b;
@@ -349,7 +346,8 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) · 286 unmodified lines
349346
350347 level = ff_h265_guess_level(ptl, avctx->bit_rate,
351348 ctx->surface_width, ctx->surface_height,
352− 1, 1, 1, (ctx->b_per_p > 0) + 1);
349+ ctx->nb_slices, 1, 1,
350+ (ctx->b_per_p > 0) + 1);
353351 if (level) {
354352 av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
355353 ptl->general_level_idc = level->level_idc;
@@ -850,8 +848,6 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, · 494 unmodified lines
850848 av_assert0(0 && "invalid picture type");
851849 }
852850
853− pic->nb_slices = 1;
854−
855851 return 0;
856852 }
857853
@@ -876,9 +872,8 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, · 18 unmodified lines
876872
877873 sh->slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id;
878874
879− // Currently we only support one slice per frame.
880− sh->first_slice_segment_in_pic_flag = 1;
881− sh->slice_segment_address = 0;
875+ sh->first_slice_segment_in_pic_flag = slice->index == 0;
876+ sh->slice_segment_address = slice->block_start;
882877
883878 sh->slice_type = priv->slice_type;
884879
@@ -968,7 +963,7 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, · 83 unmodified lines
968963
969964 *vslice = (VAEncSliceParameterBufferHEVC) {
970965 .slice_segment_address = sh->slice_segment_address,
971− .num_ctu_in_slice = priv->ctu_width * priv->ctu_height,
966+ .num_ctu_in_slice = slice->block_size,
972967
973968 .slice_type = sh->slice_type,
974969 .slice_pic_parameter_set_id = sh->slice_pic_parameter_set_id,
@@ -989,7 +984,7 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, · 14 unmodified lines
989984 .slice_tc_offset_div2 = sh->slice_tc_offset_div2,
990985
991986 .slice_fields.bits = {
992− .last_slice_of_pic_flag = 1,
987+ .last_slice_of_pic_flag = slice->index == pic->nb_slices - 1,
993988 .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,
994989 .colour_plane_id = sh->colour_plane_id,
995990 .slice_temporal_mvp_enabled_flag =
@@ -1041,13 +1036,6 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) · 45 unmodified lines
10411036 if (err < 0)
10421037 return err;
10431038
1044− priv->ctu_width = FFALIGN(ctx->surface_width, 32) / 32;
1045− priv->ctu_height = FFALIGN(ctx->surface_height, 32) / 32;
1046−
1047− av_log(avctx, AV_LOG_VERBOSE, "Input %ux%u -> Surface %ux%u -> CTU %ux%u.\n",
1048− avctx->width, avctx->height, ctx->surface_width,
1049− ctx->surface_height, priv->ctu_width, priv->ctu_height);
1050−
10511039 if (ctx->va_rc_mode == VA_RC_CQP) {
10521040 priv->fixed_qp_p = priv->qp;
10531041 if (avctx->i_quant_factor > 0.0)
@@ -1092,6 +1080,8 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { · 38 unmodified lines
10921080 static const VAAPIEncodeType vaapi_encode_type_h265 = {
10931081 .profiles = vaapi_encode_h265_profiles,
10941082
1083+ .flags = FLAG_SLICE_CONTROL,
1084+
10951085 .configure = &vaapi_encode_h265_configure,
10961086
10971087 .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),
@@ -1138,6 +1128,9 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) · 40 unmodified lines
11381128 ctx->surface_width = FFALIGN(avctx->width, 16);
11391129 ctx->surface_height = FFALIGN(avctx->height, 16);
11401130
1131+ // CTU size is currently hard-coded to 32.
1132+ ctx->slice_block_width = ctx->slice_block_height = 32;
1133+
11411134 return ff_vaapi_encode_init(avctx);
11421135 }
11431136

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t