diff options
author | Mark Thompson <sw@jkqxz.net> | 2018-09-23 22:52:57 +0100 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2018-10-27 19:35:35 +0100 |
commit | 29816e278f4ff22f50d9c831e3cf5f4d1b0e0214 (patch) | |
tree | adbfa4f5cf0220419c0c3d695cb0920fd03d7011 /libavcodec | |
parent | 2923ed247ee2f507f32b34aeddd6785bab173a71 (diff) | |
download | ffmpeg-29816e278f4ff22f50d9c831e3cf5f4d1b0e0214.tar.gz |
vaapi_encode_mpeg2: Use common slice sizing code
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/vaapi_encode_mpeg2.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index 1377eeb9bb..99a8b43237 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -35,9 +35,6 @@ typedef struct VAAPIEncodeMPEG2Context { int level; // Derived settings. - int mb_width; - int mb_height; - int quant_i; int quant_p; int quant_b; @@ -477,8 +474,6 @@ static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx, vpic->f_code[1][0] = pce->f_code[1][0]; vpic->f_code[1][1] = pce->f_code[1][1]; - pic->nb_slices = priv->mb_height; - return 0; } @@ -490,8 +485,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx, VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params; int qp; - vslice->macroblock_address = priv->mb_width * slice->index; - vslice->num_macroblocks = priv->mb_width; + vslice->macroblock_address = slice->block_start; + vslice->num_macroblocks = slice->block_size; switch (pic->type) { case PICTURE_TYPE_IDR: @@ -525,9 +520,6 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) if (err < 0) return err; - priv->mb_width = FFALIGN(avctx->width, 16) / 16; - priv->mb_height = FFALIGN(avctx->height, 16) / 16; - if (ctx->va_rc_mode == VA_RC_CQP) { priv->quant_p = av_clip(avctx->global_quality, 1, 31); if (avctx->i_quant_factor > 0.0) @@ -553,6 +545,12 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) av_assert0(0 && "Invalid RC mode."); } + ctx->slice_block_rows = FFALIGN(avctx->width, 16) / 16; + ctx->slice_block_cols = FFALIGN(avctx->height, 16) / 16; + + ctx->nb_slices = ctx->slice_block_rows; + ctx->slice_size = 1; + return 0; } |