vaapi_encode_mpeg2: Use common slice sizing code
This commit is contained in:
@@ -35,9 +35,6 @@ typedef struct VAAPIEncodeMPEG2Context {
|
|||||||
int level;
|
int level;
|
||||||
|
|
||||||
// Derived settings.
|
// Derived settings.
|
||||||
int mb_width;
|
|
||||||
int mb_height;
|
|
||||||
|
|
||||||
int quant_i;
|
int quant_i;
|
||||||
int quant_p;
|
int quant_p;
|
||||||
int quant_b;
|
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][0] = pce->f_code[1][0];
|
||||||
vpic->f_code[1][1] = pce->f_code[1][1];
|
vpic->f_code[1][1] = pce->f_code[1][1];
|
||||||
|
|
||||||
pic->nb_slices = priv->mb_height;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,8 +485,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx,
|
|||||||
VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params;
|
VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params;
|
||||||
int qp;
|
int qp;
|
||||||
|
|
||||||
vslice->macroblock_address = priv->mb_width * slice->index;
|
vslice->macroblock_address = slice->block_start;
|
||||||
vslice->num_macroblocks = priv->mb_width;
|
vslice->num_macroblocks = slice->block_size;
|
||||||
|
|
||||||
switch (pic->type) {
|
switch (pic->type) {
|
||||||
case PICTURE_TYPE_IDR:
|
case PICTURE_TYPE_IDR:
|
||||||
@@ -525,9 +520,6 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
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) {
|
if (ctx->va_rc_mode == VA_RC_CQP) {
|
||||||
priv->quant_p = av_clip(avctx->global_quality, 1, 31);
|
priv->quant_p = av_clip(avctx->global_quality, 1, 31);
|
||||||
if (avctx->i_quant_factor > 0.0)
|
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.");
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user