[FFmpeg-cvslog] vaapi_encode: Add flag to mark encoders supporting only constant-quality

Mark Thompson git at videolan.org
Sat Oct 27 21:41:37 EEST 2018


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Sun Sep 23 22:53:00 2018 +0100| [fef2162b6ea752c76a1220f59ad962b65a400fc3] | committer: Mark Thompson

vaapi_encode: Add flag to mark encoders supporting only constant-quality

And set it for MJPEG.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fef2162b6ea752c76a1220f59ad962b65a400fc3
---

 libavcodec/vaapi_encode.c       | 3 ++-
 libavcodec/vaapi_encode.h       | 2 ++
 libavcodec/vaapi_encode_mjpeg.c | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index e01c3c112b..2fe8501287 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1277,7 +1277,8 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
         ctx->va_rc_mode = VA_RC_CQP;
         return 0;
     }
-    if (avctx->flags & AV_CODEC_FLAG_QSCALE ||
+    if (ctx->codec->flags & FLAG_CONSTANT_QUALITY_ONLY ||
+        avctx->flags & AV_CODEC_FLAG_QSCALE ||
         avctx->bit_rate <= 0) {
         if (rc_attr.value & VA_RC_CQP) {
             av_log(avctx, AV_LOG_VERBOSE, "Using constant-quality mode.\n");
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index 271d4ef518..965fe65c0b 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -251,6 +251,8 @@ typedef struct VAAPIEncodeContext {
 enum {
     // Codec supports controlling the subdivision of pictures into slices.
     FLAG_SLICE_CONTROL         = 1 << 0,
+    // Codec only supports constant quality (no rate control).
+    FLAG_CONSTANT_QUALITY_ONLY = 1 << 1,
 };
 
 typedef struct VAAPIEncodeType {
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
index fe8439ce88..79f43473f5 100644
--- a/libavcodec/vaapi_encode_mjpeg.c
+++ b/libavcodec/vaapi_encode_mjpeg.c
@@ -476,6 +476,8 @@ static const VAAPIEncodeProfile vaapi_encode_mjpeg_profiles[] = {
 static const VAAPIEncodeType vaapi_encode_type_mjpeg = {
     .profiles              = vaapi_encode_mjpeg_profiles,
 
+    .flags                 = FLAG_CONSTANT_QUALITY_ONLY,
+
     .configure             = &vaapi_encode_mjpeg_configure,
 
     .picture_params_size   = sizeof(VAEncPictureParameterBufferJPEG),



More information about the ffmpeg-cvslog mailing list