vaapi_encode_mpeg2: Use common slice sizing code

This commit is contained in:
Mark Thompson 2018-09-23 22:52:57 +01:00
parent 2923ed247e
commit 29816e278f
1 changed files with 8 additions and 10 deletions

View File

@ -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;
}