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

Phillip Burr phil.burr at gmail.com
Fri May 31 17:48:38 EEST 2019


---
 libavcodec/vaapi_encode_mpeg2.c | 6 ++++++
 1 file changed, 6 insertions(+)

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" },
-- 
2.20.1



More information about the ffmpeg-devel mailing list