History

vaapi_encode_mpeg2: Enable support for more RC modes

Fixes #7650.

Mark Thompson committed 7 years ago

Commit 1e0fac71 parent d237b6b1 file · +13 −11Browse files

Unified · Split

libavcodec/vaapi_encode_mpeg2.c+13−11
@@ -521,19 +521,17 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) · 520 unmodified lines
521521 return err;
522522
523523 if (ctx->va_rc_mode == VA_RC_CQP) {
524− priv->quant_p = av_clip(avctx->global_quality, 1, 31);
524+ priv->quant_p = av_clip(ctx->rc_quality, 1, 31);
525525 if (avctx->i_quant_factor > 0.0)
526− priv->quant_i = av_clip((avctx->global_quality *
527− avctx->i_quant_factor +
528− avctx->i_quant_offset) + 0.5,
529− 1, 31);
526+ priv->quant_i =
527+ av_clip((avctx->i_quant_factor * priv->quant_p +
528+ avctx->i_quant_offset) + 0.5, 1, 31);
530529 else
531530 priv->quant_i = priv->quant_p;
532531 if (avctx->b_quant_factor > 0.0)
533− priv->quant_b = av_clip((avctx->global_quality *
534− avctx->b_quant_factor +
535− avctx->b_quant_offset) + 0.5,
536− 1, 31);
532+ priv->quant_b =
533+ av_clip((avctx->b_quant_factor * priv->quant_p +
534+ avctx->b_quant_offset) + 0.5, 1, 31);
537535 else
538536 priv->quant_b = priv->quant_p;
539537
@@ -542,7 +540,9 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) · 2 unmodified lines
542540 priv->quant_i, priv->quant_p, priv->quant_b);
543541
544542 } else {
545− av_assert0(0 && "Invalid RC mode.");
543+ priv->quant_i = 16;
544+ priv->quant_p = 16;
545+ priv->quant_b = 16;
546546 }
547547
548548 ctx->slice_block_rows = FFALIGN(avctx->height, 16) / 16;
@@ -567,6 +567,8 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = { · 18 unmodified lines
567567
568568 .configure = &vaapi_encode_mpeg2_configure,
569569
570+ .default_quality = 10,
571+
570572 .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2),
571573 .init_sequence_params = &vaapi_encode_mpeg2_init_sequence_params,
572574
@@ -638,6 +640,7 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx) · 65 unmodified lines
638640 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
639641 static const AVOption vaapi_encode_mpeg2_options[] = {
640642 VAAPI_ENCODE_COMMON_OPTIONS,
643+ VAAPI_ENCODE_RC_OPTIONS,
641644
642645 { "profile", "Set profile (in profile_and_level_indication)",
643646 OFFSET(profile), AV_OPT_TYPE_INT,
@@ -672,7 +675,6 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { · 28 unmodified lines
672675 { "i_qoffset", "0" },
673676 { "b_qfactor", "6/5" },
674677 { "b_qoffset", "0" },
675− { "global_quality", "10" },
676678 { "qmin", "-1" },
677679 { "qmax", "-1" },
678680 { NULL },

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