Fixes #7650.
Unified · Split
| @@ -521,19 +521,17 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) · 520 unmodified lines | ||
| 521 | 521 | return err; |
| 522 | 522 | |
| 523 | 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 | 525 | 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); | |
| 530 | 529 | else |
| 531 | 530 | priv->quant_i = priv->quant_p; |
| 532 | 531 | 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); | |
| 537 | 535 | else |
| 538 | 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 | 540 | priv->quant_i, priv->quant_p, priv->quant_b); |
| 543 | 541 | |
| 544 | 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 | 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 | 568 | .configure = &vaapi_encode_mpeg2_configure, |
| 569 | 569 | |
| 570 | + .default_quality = 10, | |
| 571 | + | |
| 570 | 572 | .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2), |
| 571 | 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 | 640 | #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) |
| 639 | 641 | static const AVOption vaapi_encode_mpeg2_options[] = { |
| 640 | 642 | VAAPI_ENCODE_COMMON_OPTIONS, |
| 643 | + VAAPI_ENCODE_RC_OPTIONS, | |
| 641 | 644 | |
| 642 | 645 | { "profile", "Set profile (in profile_and_level_indication)", |
| 643 | 646 | OFFSET(profile), AV_OPT_TYPE_INT, |
| @@ -672,7 +675,6 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { · 28 unmodified lines | ||
| 672 | 675 | { "i_qoffset", "0" }, |
| 673 | 676 | { "b_qfactor", "6/5" }, |
| 674 | 677 | { "b_qoffset", "0" }, |
| 675 | − { "global_quality", "10" }, | |
| 676 | 678 | { "qmin", "-1" }, |
| 677 | 679 | { "qmax", "-1" }, |
| 678 | 680 | { NULL }, |