diff mbox

[FFmpeg-devel] lavc/libvpxenc: add tune-content option

Message ID 20171114000114.177470-1-jzern@google.com
State New
Headers show

Commit Message

James Zern Nov. 14, 2017, 12:01 a.m. UTC
Signed-off-by: James Zern <jzern@google.com>
---
 doc/encoders.texi      |  2 ++
 libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

Comments

James Almer Nov. 14, 2017, 12:43 a.m. UTC | #1
On 11/13/2017 9:01 PM, James Zern wrote:
> Signed-off-by: James Zern <jzern@google.com>
> ---
>  doc/encoders.texi      |  2 ++
>  libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 431777c457..23451b7b92 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1681,6 +1681,8 @@ colorspaces:
>  @end table
>  @item row-mt @var{boolean}
>  Enable row based multi-threading.
> +@item tune-content

How about "tune" instead? That's what libx264 and libx265 use.

Also, it may be a good time to resurrect your patch to bump the minimum
required version to 1.4.0, to clean some of the oldest ifdeffery. Debian
stable ships 1.6.1 now.

> +Set content type: default (0), screen (1), film (2).
>  @end table
>  
>  @end table
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index d720301cd1..fbb842499b 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -109,6 +109,7 @@ typedef struct VPxEncoderContext {
>      int vpx_cs;
>      float level;
>      int row_mt;
> +    int tune_content;
>  } VPxContext;
>  
>  /** String mappings for enum vp8e_enc_control_id */
> @@ -143,6 +144,9 @@ static const char *const ctlidstr[] = {
>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>      [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
>  #endif
> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
> +    [VP9E_SET_TUNE_CONTENT]            = "VP9E_SET_TUNE_CONTENT",
> +#endif
>  #endif
>  };
>  
> @@ -709,6 +713,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>          if (ctx->row_mt >= 0)
>              codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
> +#endif
> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
> +        if (ctx->tune_content >= 0)
> +            codecctl_int(avctx, VP9E_SET_TUNE_CONTENT, ctx->tune_content);
>  #endif
>      }
>  #endif
> @@ -1139,6 +1147,18 @@ static const AVOption vp9_options[] = {
>  #endif
>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>      {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> +#endif
> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
> +#if VPX_ENCODER_ABI_VERSION >= 14
> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
> +#else
> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
> +#endif
> +    { "default",         "Regular video content",                  0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
> +    { "screen",          "Screen capture content",                 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
> +#if VPX_ENCODER_ABI_VERSION >= 14
> +    { "film",            "Film content; improves grain retention", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
> +#endif
>  #endif
>      LEGACY_OPTIONS
>      { NULL }
>
James Zern Nov. 14, 2017, 2:05 a.m. UTC | #2
On Mon, Nov 13, 2017 at 4:43 PM, James Almer <jamrial@gmail.com> wrote:
> On 11/13/2017 9:01 PM, James Zern wrote:
>> Signed-off-by: James Zern <jzern@google.com>
>> ---
>>  doc/encoders.texi      |  2 ++
>>  libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>> index 431777c457..23451b7b92 100644
>> --- a/doc/encoders.texi
>> +++ b/doc/encoders.texi
>> @@ -1681,6 +1681,8 @@ colorspaces:
>>  @end table
>>  @item row-mt @var{boolean}
>>  Enable row based multi-threading.
>> +@item tune-content
>
> How about "tune" instead? That's what libx264 and libx265 use.
>

Unfortunately that exists too (psnr/ssim), this was forked for vp9 [1].

[1] https://chromium.googlesource.com/webm/libvpx/+/v1.6.1/vpx/vp8cx.h#765

> Also, it may be a good time to resurrect your patch to bump the minimum
> required version to 1.4.0, to clean some of the oldest ifdeffery. Debian
> stable ships 1.6.1 now.
>

I can bring up the minimum in a followup if it's a good time.

>> +Set content type: default (0), screen (1), film (2).
>>  @end table
>>
>>  @end table
>> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
>> index d720301cd1..fbb842499b 100644
>> --- a/libavcodec/libvpxenc.c
>> +++ b/libavcodec/libvpxenc.c
>> @@ -109,6 +109,7 @@ typedef struct VPxEncoderContext {
>>      int vpx_cs;
>>      float level;
>>      int row_mt;
>> +    int tune_content;
>>  } VPxContext;
>>
>>  /** String mappings for enum vp8e_enc_control_id */
>> @@ -143,6 +144,9 @@ static const char *const ctlidstr[] = {
>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>      [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
>>  #endif
>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>> +    [VP9E_SET_TUNE_CONTENT]            = "VP9E_SET_TUNE_CONTENT",
>> +#endif
>>  #endif
>>  };
>>
>> @@ -709,6 +713,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>          if (ctx->row_mt >= 0)
>>              codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
>> +#endif
>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>> +        if (ctx->tune_content >= 0)
>> +            codecctl_int(avctx, VP9E_SET_TUNE_CONTENT, ctx->tune_content);
>>  #endif
>>      }
>>  #endif
>> @@ -1139,6 +1147,18 @@ static const AVOption vp9_options[] = {
>>  #endif
>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>      {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
>> +#endif
>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>> +#if VPX_ENCODER_ABI_VERSION >= 14
>> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
>> +#else
>> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
>> +#endif
>> +    { "default",         "Regular video content",                  0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
>> +    { "screen",          "Screen capture content",                 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
>> +#if VPX_ENCODER_ABI_VERSION >= 14
>> +    { "film",            "Film content; improves grain retention", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
>> +#endif
>>  #endif
>>      LEGACY_OPTIONS
>>      { NULL }
>>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
James Zern Nov. 15, 2017, 2:53 a.m. UTC | #3
On Mon, Nov 13, 2017 at 6:05 PM, James Zern <jzern@google.com> wrote:
> On Mon, Nov 13, 2017 at 4:43 PM, James Almer <jamrial@gmail.com> wrote:
>> On 11/13/2017 9:01 PM, James Zern wrote:
>>> Signed-off-by: James Zern <jzern@google.com>
>>> ---
>>>  doc/encoders.texi      |  2 ++
>>>  libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
>>>  2 files changed, 22 insertions(+)
>>>
>>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>>> index 431777c457..23451b7b92 100644
>>> --- a/doc/encoders.texi
>>> +++ b/doc/encoders.texi
>>> @@ -1681,6 +1681,8 @@ colorspaces:
>>>  @end table
>>>  @item row-mt @var{boolean}
>>>  Enable row based multi-threading.
>>> +@item tune-content
>>
>> How about "tune" instead? That's what libx264 and libx265 use.
>>
>
> Unfortunately that exists too (psnr/ssim), this was forked for vp9 [1].
>

That one is mapped already too [2]. Recently we've been trying to
match the vpxenc options.

> [1] https://chromium.googlesource.com/webm/libvpx/+/v1.6.1/vpx/vp8cx.h#765
>

[2] https://github.com/FFmpeg/FFmpeg/blob/release/3.4/libavcodec/libvpxenc.c#L1096

>> Also, it may be a good time to resurrect your patch to bump the minimum
>> required version to 1.4.0, to clean some of the oldest ifdeffery. Debian
>> stable ships 1.6.1 now.
>>
>
> I can bring up the minimum in a followup if it's a good time.
>
>>> +Set content type: default (0), screen (1), film (2).
>>>  @end table
>>>
>>>  @end table
>>> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
>>> index d720301cd1..fbb842499b 100644
>>> --- a/libavcodec/libvpxenc.c
>>> +++ b/libavcodec/libvpxenc.c
>>> @@ -109,6 +109,7 @@ typedef struct VPxEncoderContext {
>>>      int vpx_cs;
>>>      float level;
>>>      int row_mt;
>>> +    int tune_content;
>>>  } VPxContext;
>>>
>>>  /** String mappings for enum vp8e_enc_control_id */
>>> @@ -143,6 +144,9 @@ static const char *const ctlidstr[] = {
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>      [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
>>>  #endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +    [VP9E_SET_TUNE_CONTENT]            = "VP9E_SET_TUNE_CONTENT",
>>> +#endif
>>>  #endif
>>>  };
>>>
>>> @@ -709,6 +713,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>          if (ctx->row_mt >= 0)
>>>              codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
>>> +#endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +        if (ctx->tune_content >= 0)
>>> +            codecctl_int(avctx, VP9E_SET_TUNE_CONTENT, ctx->tune_content);
>>>  #endif
>>>      }
>>>  #endif
>>> @@ -1139,6 +1147,18 @@ static const AVOption vp9_options[] = {
>>>  #endif
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>      {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
>>> +#endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +#if VPX_ENCODER_ABI_VERSION >= 14
>>> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
>>> +#else
>>> +    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
>>> +#endif
>>> +    { "default",         "Regular video content",                  0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
>>> +    { "screen",          "Screen capture content",                 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
>>> +#if VPX_ENCODER_ABI_VERSION >= 14
>>> +    { "film",            "Film content; improves grain retention", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
>>> +#endif
>>>  #endif
>>>      LEGACY_OPTIONS
>>>      { NULL }
>>>
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
James Zern Nov. 16, 2017, 8:10 a.m. UTC | #4
On Nov 14, 2017 18:53, "James Zern" <jzern@google.com> wrote:

On Mon, Nov 13, 2017 at 6:05 PM, James Zern <jzern@google.com> wrote:
> On Mon, Nov 13, 2017 at 4:43 PM, James Almer <jamrial@gmail.com> wrote:
>> On 11/13/2017 9:01 PM, James Zern wrote:
>>> Signed-off-by: James Zern <jzern@google.com>
>>> ---
>>>  doc/encoders.texi      |  2 ++
>>>  libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
>>>  2 files changed, 22 insertions(+)
>>>
>>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>>> index 431777c457..23451b7b92 100644
>>> --- a/doc/encoders.texi
>>> +++ b/doc/encoders.texi
>>> @@ -1681,6 +1681,8 @@ colorspaces:
>>>  @end table
>>>  @item row-mt @var{boolean}
>>>  Enable row based multi-threading.
>>> +@item tune-content
>>
>> How about "tune" instead? That's what libx264 and libx265 use.
>>
>
> Unfortunately that exists too (psnr/ssim), this was forked for vp9 [1].
>

That one is mapped already too [2]. Recently we've been trying to
match the vpxenc options.


Any more comments on this one?


> [1] https://chromium.googlesource.com/webm/libvpx/+/v1.6.1/vpx/vp8cx.h#765
>

[2] https://github.com/FFmpeg/FFmpeg/blob/release/3.4/
libavcodec/libvpxenc.c#L1096

>> Also, it may be a good time to resurrect your patch to bump the minimum
>> required version to 1.4.0, to clean some of the oldest ifdeffery. Debian
>> stable ships 1.6.1 now.
>>
>
> I can bring up the minimum in a followup if it's a good time.
>
>>> +Set content type: default (0), screen (1), film (2).
>>>  @end table
>>>
>>>  @end table
>>> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
>>> index d720301cd1..fbb842499b 100644
>>> --- a/libavcodec/libvpxenc.c
>>> +++ b/libavcodec/libvpxenc.c
>>> @@ -109,6 +109,7 @@ typedef struct VPxEncoderContext {
>>>      int vpx_cs;
>>>      float level;
>>>      int row_mt;
>>> +    int tune_content;
>>>  } VPxContext;
>>>
>>>  /** String mappings for enum vp8e_enc_control_id */
>>> @@ -143,6 +144,9 @@ static const char *const ctlidstr[] = {
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>      [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
>>>  #endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +    [VP9E_SET_TUNE_CONTENT]            = "VP9E_SET_TUNE_CONTENT",
>>> +#endif
>>>  #endif
>>>  };
>>>
>>> @@ -709,6 +713,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>          if (ctx->row_mt >= 0)
>>>              codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
>>> +#endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +        if (ctx->tune_content >= 0)
>>> +            codecctl_int(avctx, VP9E_SET_TUNE_CONTENT,
ctx->tune_content);
>>>  #endif
>>>      }
>>>  #endif
>>> @@ -1139,6 +1147,18 @@ static const AVOption vp9_options[] = {
>>>  #endif
>>>  #ifdef VPX_CTRL_VP9E_SET_ROW_MT
>>>      {"row-mt", "Row based multi-threading", OFFSET(row_mt),
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
>>> +#endif
>>> +#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
>>> +#if VPX_ENCODER_ABI_VERSION >= 14
>>> +    { "tune-content",    "Tune content type", OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
>>> +#else
>>> +    { "tune-content",    "Tune content type", OFFSET(tune_content),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
>>> +#endif
>>> +    { "default",         "Regular video content",                  0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
>>> +    { "screen",          "Screen capture content",                 0,
AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
>>> +#if VPX_ENCODER_ABI_VERSION >= 14
>>> +    { "film",            "Film content; improves grain retention", 0,
AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
>>> +#endif
>>>  #endif
>>>      LEGACY_OPTIONS
>>>      { NULL }
>>>
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
James Zern Nov. 17, 2017, 8:09 p.m. UTC | #5
On Mon, Nov 13, 2017 at 4:01 PM, James Zern <jzern@google.com> wrote:
> Signed-off-by: James Zern <jzern@google.com>
> ---
>  doc/encoders.texi      |  2 ++
>  libavcodec/libvpxenc.c | 20 ++++++++++++++++++++
>  2 files changed, 22 insertions(+)
>

Applied with an additional note in the commit message about the
parameter matching vpxenc.
diff mbox

Patch

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 431777c457..23451b7b92 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1681,6 +1681,8 @@  colorspaces:
 @end table
 @item row-mt @var{boolean}
 Enable row based multi-threading.
+@item tune-content
+Set content type: default (0), screen (1), film (2).
 @end table
 
 @end table
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index d720301cd1..fbb842499b 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -109,6 +109,7 @@  typedef struct VPxEncoderContext {
     int vpx_cs;
     float level;
     int row_mt;
+    int tune_content;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -143,6 +144,9 @@  static const char *const ctlidstr[] = {
 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
     [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
 #endif
+#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
+    [VP9E_SET_TUNE_CONTENT]            = "VP9E_SET_TUNE_CONTENT",
+#endif
 #endif
 };
 
@@ -709,6 +713,10 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
         if (ctx->row_mt >= 0)
             codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
+#endif
+#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
+        if (ctx->tune_content >= 0)
+            codecctl_int(avctx, VP9E_SET_TUNE_CONTENT, ctx->tune_content);
 #endif
     }
 #endif
@@ -1139,6 +1147,18 @@  static const AVOption vp9_options[] = {
 #endif
 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
     {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
+#endif
+#ifdef VPX_CTRL_VP9E_SET_TUNE_CONTENT
+#if VPX_ENCODER_ABI_VERSION >= 14
+    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE, "tune_content" },
+#else
+    { "tune-content",    "Tune content type", OFFSET(tune_content), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE, "tune_content" },
+#endif
+    { "default",         "Regular video content",                  0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, "tune_content" },
+    { "screen",          "Screen capture content",                 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "tune_content" },
+#if VPX_ENCODER_ABI_VERSION >= 14
+    { "film",            "Film content; improves grain retention", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "tune_content" },
+#endif
 #endif
     LEGACY_OPTIONS
     { NULL }