[FFmpeg-devel] [PATCH] avcodec/libvpxenc: add VP8/9 sharpness config option

Rene Claus rclaus at google.com
Wed Dec 19 20:24:29 EET 2018


This commit adds configuration options to libvpxenc.c that can be used to
tune the sharpness parameter of the loop filter for VP8 and VP9.

Signed-off-by: Rene Claus <rclaus at google.com>
---
 doc/encoders.texi      | 4 ++++
 libavcodec/libvpxenc.c | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index ca3892d682..4d06bbe4bf 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1767,6 +1767,10 @@ Set number of frames to look ahead for frametype and ratecontrol.
 @item error-resilient
 Enable error resiliency features.
 
+ at item sharpness @var{integer}
+Set loop filter sharpness.
+The valid range is [0, 7]. Default: 0
+
 @item VP8-specific options
 @table @option
 @item ts-parameters
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 39af586790..174e0b9b0e 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -115,6 +115,7 @@ typedef struct VPxEncoderContext {
     int tune_content;
     int corpus_complexity;
     int tpl_model;
+    int sharpness;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -130,6 +131,7 @@ static const char *const ctlidstr[] = {
     [VP8E_SET_TUNING]            = "VP8E_SET_TUNING",
     [VP8E_SET_CQ_LEVEL]          = "VP8E_SET_CQ_LEVEL",
     [VP8E_SET_MAX_INTRA_BITRATE_PCT] = "VP8E_SET_MAX_INTRA_BITRATE_PCT",
+    [VP8E_SET_SHARPNESS]               = "VP8E_SET_SHARPNESS",
 #if CONFIG_LIBVPX_VP9_ENCODER
     [VP9E_SET_LOSSLESS]                = "VP9E_SET_LOSSLESS",
     [VP9E_SET_TILE_COLUMNS]            = "VP9E_SET_TILE_COLUMNS",
@@ -798,6 +800,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
         if (ctx->tpl_model >= 0)
             codecctl_int(avctx, VP9E_SET_TPL, ctx->tpl_model);
 #endif
+        if (ctx->sharpness >= 0)
+            codecctl_int(avctx, VP8E_SET_SHARPNESS, ctx->sharpness);
     }
 #endif
 
@@ -1251,6 +1255,7 @@ static const AVOption vp9_options[] = {
 #ifdef VPX_CTRL_VP9E_SET_TPL
     { "enable-tpl",      "Enable temporal dependency model", OFFSET(tpl_model), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },
 #endif
+    { "sharpness",       "Sharpness", OFFSET(sharpness), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 7, VE},
     LEGACY_OPTIONS
     { NULL }
 };
-- 
2.20.1.415.g653613c723-goog



More information about the ffmpeg-devel mailing list