[FFmpeg-devel] libavcodec/vaapi_encode_mpeg2: enable constant QP setting

Submitted by Phillip Burr on May 31, 2019, 2:48 p.m.

Details

Message ID 20190531144838.1719-1-phil.burr@gmail.com
State New
Headers show

Commit Message

Phillip Burr May 31, 2019, 2:48 p.m.
---
 libavcodec/vaapi_encode_mpeg2.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c
index fb1ef71fdc..bd754001d5 100644
--- a/libavcodec/vaapi_encode_mpeg2.c
+++ b/libavcodec/vaapi_encode_mpeg2.c
@@ -31,6 +31,7 @@  typedef struct VAAPIEncodeMPEG2Context {
     VAAPIEncodeContext common;
 
     // User options.
+    int qp;
     int profile;
     int level;
 
@@ -624,6 +625,9 @@  static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)
     ctx->surface_width  = FFALIGN(avctx->width,  16);
     ctx->surface_height = FFALIGN(avctx->height, 16);
 
+    if (priv->qp > 0)
+        ctx->explicit_qp = priv->qp;
+
     return ff_vaapi_encode_init(avctx);
 }
 
@@ -643,6 +647,8 @@  static const AVOption vaapi_encode_mpeg2_options[] = {
     VAAPI_ENCODE_COMMON_OPTIONS,
     VAAPI_ENCODE_RC_OPTIONS,
 
+    { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
+      OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
     { "profile", "Set profile (in profile_and_level_indication)",
       OFFSET(profile), AV_OPT_TYPE_INT,
       { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 7, FLAGS, "profile" },