[FFmpeg-devel] [PATCH v4 30/38] vaapi_encode_h264: Enable multiple-slice support
mypopy at gmail.com
mypopy at gmail.com
Wed Sep 19 06:20:41 EEST 2018
On Wed, Sep 19, 2018 at 6:35 AM Mark Thompson <sw at jkqxz.net> wrote:
>
> ---
> libavcodec/vaapi_encode_h264.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 8feae0d42f..7bb77cfba2 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -733,8 +733,6 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
> vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR);
> vpic->pic_fields.bits.reference_pic_flag = (pic->type != PICTURE_TYPE_B);
>
> - pic->nb_slices = 1;
> -
> return 0;
> }
>
> @@ -758,8 +756,7 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
> sh->nal_unit_header.nal_ref_idc = pic->type != PICTURE_TYPE_B;
> }
>
> - // Only one slice per frame.
> - sh->first_mb_in_slice = 0;
> + sh->first_mb_in_slice = slice->block_start;
> sh->slice_type = priv->slice_type;
>
> sh->pic_parameter_set_id = pps->pic_parameter_set_id;
> @@ -780,8 +777,8 @@ static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
> sh->slice_qp_delta = priv->fixed_qp_idr - (pps->pic_init_qp_minus26 + 26);
>
>
> - vslice->macroblock_address = sh->first_mb_in_slice;
> - vslice->num_macroblocks = priv->mb_width * priv->mb_height;
> + vslice->macroblock_address = slice->block_start;
> + vslice->num_macroblocks = slice->block_size;
>
> vslice->macroblock_info = VA_INVALID_ID;
>
> @@ -903,6 +900,8 @@ static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = {
> static const VAAPIEncodeType vaapi_encode_type_h264 = {
> .profiles = vaapi_encode_h264_profiles,
>
> + .flags = FLAG_SLICE_CONTROL,
> +
> .configure = &vaapi_encode_h264_configure,
>
> .sequence_params_size = sizeof(VAEncSequenceParameterBufferH264),
> @@ -978,6 +977,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
> ctx->surface_width = FFALIGN(avctx->width, 16);
> ctx->surface_height = FFALIGN(avctx->height, 16);
>
> + ctx->slice_block_height = ctx->slice_block_width = 16;
> +
> return ff_vaapi_encode_init(avctx);
> }
>
Missing “slices” option in doc/encoder VA-API part, I think. other part LGTM
More information about the ffmpeg-devel
mailing list