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

Showing the changes to libavcodec/vaapi_encode_mpeg2.c (1 of 1 file). Show all

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
521 return err;521 return err;
522 522
523 if (ctx->va_rc_mode == VA_RC_CQP) {523 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);
525 if (avctx->i_quant_factor > 0.0)525 if (avctx->i_quant_factor > 0.0)
526 priv->quant_i = av_clip((avctx->global_quality *526 priv->quant_i =
527 avctx->i_quant_factor +527 av_clip((avctx->i_quant_factor * priv->quant_p +
528 avctx->i_quant_offset) + 0.5,528 avctx->i_quant_offset) + 0.5, 1, 31);
529 1, 31);
530 else529 else
531 priv->quant_i = priv->quant_p;530 priv->quant_i = priv->quant_p;
532 if (avctx->b_quant_factor > 0.0)531 if (avctx->b_quant_factor > 0.0)
533 priv->quant_b = av_clip((avctx->global_quality *532 priv->quant_b =
534 avctx->b_quant_factor +533 av_clip((avctx->b_quant_factor * priv->quant_p +
535 avctx->b_quant_offset) + 0.5,534 avctx->b_quant_offset) + 0.5, 1, 31);
536 1, 31);
537 else535 else
538 priv->quant_b = priv->quant_p;536 priv->quant_b = priv->quant_p;
539 537
@@ -542,7 +540,9 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) · 2 unmodified lines
542 priv->quant_i, priv->quant_p, priv->quant_b);540 priv->quant_i, priv->quant_p, priv->quant_b);
543 541
544 } else {542 } else {
545 av_assert0(0 && "Invalid RC mode.");543 priv->quant_i = 16;
544 priv->quant_p = 16;
545 priv->quant_b = 16;
546 }546 }
547 547
548 ctx->slice_block_rows = FFALIGN(avctx->height, 16) / 16;548 ctx->slice_block_rows = FFALIGN(avctx->height, 16) / 16;
@@ -567,6 +567,8 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = { · 18 unmodified lines
567 567
568 .configure = &vaapi_encode_mpeg2_configure,568 .configure = &vaapi_encode_mpeg2_configure,
569 569
570 .default_quality = 10,
571
570 .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2),572 .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2),
571 .init_sequence_params = &vaapi_encode_mpeg2_init_sequence_params,573 .init_sequence_params = &vaapi_encode_mpeg2_init_sequence_params,
572 574
@@ -638,6 +640,7 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx) · 65 unmodified lines
638#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)640#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
639static const AVOption vaapi_encode_mpeg2_options[] = {641static const AVOption vaapi_encode_mpeg2_options[] = {
640 VAAPI_ENCODE_COMMON_OPTIONS,642 VAAPI_ENCODE_COMMON_OPTIONS,
643 VAAPI_ENCODE_RC_OPTIONS,
641 644
642 { "profile", "Set profile (in profile_and_level_indication)",645 { "profile", "Set profile (in profile_and_level_indication)",
643 OFFSET(profile), AV_OPT_TYPE_INT,646 OFFSET(profile), AV_OPT_TYPE_INT,
@@ -672,7 +675,6 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { · 28 unmodified lines
672 { "i_qoffset", "0" },675 { "i_qoffset", "0" },
673 { "b_qfactor", "6/5" },676 { "b_qfactor", "6/5" },
674 { "b_qoffset", "0" },677 { "b_qoffset", "0" },
675 { "global_quality", "10" },
676 { "qmin", "-1" },678 { "qmin", "-1" },
677 { "qmax", "-1" },679 { "qmax", "-1" },
678 { NULL },680 { 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