Sliding window control is a feature to reduce the instant bitrate
fluctuation, and occasional big frame size for intra and scene
change frames are allowed. And the fluctuation level can be
controlled by max bit rate.

Signed-off-by: Jun Zhao <jun.z...@intel.com>
---
 libavcodec/vaapi_encode_h264.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 060277b..5219522 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -59,6 +59,7 @@ typedef struct VAAPIEncodeH264Context {
     int profile;
     int level;
     int mb_rate_control;
+    int sliding_window;
 
     // Derived settings.
     int mb_width;
@@ -903,6 +904,16 @@ static av_cold int 
vaapi_encode_h264_bit_rate_control(AVCodecContext *avctx)
                "supported with this VAAPI version.\n");
  #endif
     }
+
+    if (priv->sliding_window) {
+#if VA_CHECK_VERSION(1, 1, 0)
+        ctx->rc_params.rc.rc_flags.bits.frame_tolerance_mode = 
priv->sliding_window;
+#else
+        av_log(avctx, AV_LOG_WARNING, "The sliding window is not "
+               "supported with this VAAPI version.\n");
+#endif
+    }
+
     return 0;
 }
 
@@ -1022,6 +1033,8 @@ static const AVOption vaapi_encode_h264_options[] = {
       OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
     { "mb_rate_control", "MB level bitrate control (only supported on GEN9+)",
       OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, 
"mb_rate_control" },
+    { "sliding_window", "Use sliding window to reduce the instant bitrate 
fluctuations",
+      OFFSET(sliding_window), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, 
"sliding_window" },
     { "coder", "Entropy coder type",
       OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
         { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, 
FLAGS, "coder" },
-- 
1.7.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to