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
54 int sei;54 int sei;
55 55
56 // Derived settings.56 // Derived settings.
57 unsigned int ctu_width;
58 unsigned int ctu_height;
59
60 int fixed_qp_idr;57 int fixed_qp_idr;
61 int fixed_qp_p;58 int fixed_qp_p;
62 int fixed_qp_b;59 int fixed_qp_b;
@@ -349,7 +346,8 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) · 286 unmodified lines
349 346
350 level = ff_h265_guess_level(ptl, avctx->bit_rate,347 level = ff_h265_guess_level(ptl, avctx->bit_rate,
351 ctx->surface_width, ctx->surface_height,348 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);
353 if (level) {351 if (level) {
354 av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);352 av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
355 ptl->general_level_idc = level->level_idc;353 ptl->general_level_idc = level->level_idc;
@@ -850,8 +848,6 @@ static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, · 494 unmodified lines
850 av_assert0(0 && "invalid picture type");848 av_assert0(0 && "invalid picture type");
851 }849 }
852 850
853 pic->nb_slices = 1;
854
855 return 0;851 return 0;
856}852}
857 853
@@ -876,9 +872,8 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, · 18 unmodified lines
876 872
877 sh->slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id;873 sh->slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id;
878 874
879 // Currently we only support one slice per frame.875 sh->first_slice_segment_in_pic_flag = slice->index == 0;
880 sh->first_slice_segment_in_pic_flag = 1;876 sh->slice_segment_address = slice->block_start;
881 sh->slice_segment_address = 0;
882 877
883 sh->slice_type = priv->slice_type;878 sh->slice_type = priv->slice_type;
884 879
@@ -968,7 +963,7 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, · 83 unmodified lines
968 963
969 *vslice = (VAEncSliceParameterBufferHEVC) {964 *vslice = (VAEncSliceParameterBufferHEVC) {
970 .slice_segment_address = sh->slice_segment_address,965 .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,
972 967
973 .slice_type = sh->slice_type,968 .slice_type = sh->slice_type,
974 .slice_pic_parameter_set_id = sh->slice_pic_parameter_set_id,969 .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
989 .slice_tc_offset_div2 = sh->slice_tc_offset_div2,984 .slice_tc_offset_div2 = sh->slice_tc_offset_div2,
990 985
991 .slice_fields.bits = {986 .slice_fields.bits = {
992 .last_slice_of_pic_flag = 1,987 .last_slice_of_pic_flag = slice->index == pic->nb_slices - 1,
993 .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,988 .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,
994 .colour_plane_id = sh->colour_plane_id,989 .colour_plane_id = sh->colour_plane_id,
995 .slice_temporal_mvp_enabled_flag =990 .slice_temporal_mvp_enabled_flag =
@@ -1041,13 +1036,6 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) · 45 unmodified lines
1041 if (err < 0)1036 if (err < 0)
1042 return err;1037 return err;
1043 1038
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
1051 if (ctx->va_rc_mode == VA_RC_CQP) {1039 if (ctx->va_rc_mode == VA_RC_CQP) {
1052 priv->fixed_qp_p = priv->qp;1040 priv->fixed_qp_p = priv->qp;
1053 if (avctx->i_quant_factor > 0.0)1041 if (avctx->i_quant_factor > 0.0)
@@ -1092,6 +1080,8 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { · 38 unmodified lines
1092static const VAAPIEncodeType vaapi_encode_type_h265 = {1080static const VAAPIEncodeType vaapi_encode_type_h265 = {
1093 .profiles = vaapi_encode_h265_profiles,1081 .profiles = vaapi_encode_h265_profiles,
1094 1082
1083 .flags = FLAG_SLICE_CONTROL,
1084
1095 .configure = &vaapi_encode_h265_configure,1085 .configure = &vaapi_encode_h265_configure,
1096 1086
1097 .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),1087 .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),
@@ -1138,6 +1128,9 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) · 40 unmodified lines
1138 ctx->surface_width = FFALIGN(avctx->width, 16);1128 ctx->surface_width = FFALIGN(avctx->width, 16);
1139 ctx->surface_height = FFALIGN(avctx->height, 16);1129 ctx->surface_height = FFALIGN(avctx->height, 16);
1140 1130
1131 // CTU size is currently hard-coded to 32.
1132 ctx->slice_block_width = ctx->slice_block_height = 32;
1133
1141 return ff_vaapi_encode_init(avctx);1134 return ff_vaapi_encode_init(avctx);
1142}1135}
1143 1136

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