diff mbox

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

Message ID 20181219182429.247347-1-rclaus@google.com
State Accepted
Headers show

Commit Message

Rene Claus Dec. 19, 2018, 6:24 p.m. UTC
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@google.com>
---
 doc/encoders.texi      | 4 ++++
 libavcodec/libvpxenc.c | 5 +++++
 2 files changed, 9 insertions(+)

Comments

James Zern Dec. 19, 2018, 7:01 p.m. UTC | #1
On Wed, Dec 19, 2018 at 10:24 AM Rene Claus
<rclaus-at-google.com@ffmpeg.org> wrote:
>
> 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@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.
>
> +@item sharpness @var{integer}
> +Set loop filter sharpness.

The behavior has changed in VP9 post-1.7.0, it still affects sharpness
but doesn't manipulate the loop filter. The documentation and vpxenc
output weren't updated unfortunately. There should be a change going
upstream to correct this, you can pick up that when it lands.

> [...]
>
> @@ -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},

This should be moved to COMMON_OPTIONS so it can be used with VP8.
Moritz Barsnick Dec. 19, 2018, 9:29 p.m. UTC | #2
On Wed, Dec 19, 2018 at 10:24:29 -0800, Rene Claus wrote:
> +        if (ctx->sharpness >= 0)

Can this ever be untrue?
Because:
> +    { "sharpness",       "Sharpness", OFFSET(sharpness), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 7, VE},
                                                                              ^^^^^^^^^^^^^^^

Moritz
diff mbox

Patch

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.
 
+@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 }
 };