diff mbox

[FFmpeg-devel] lavc/libvpxenc: add -row-mt option

Message ID 66bb75d0-c6e9-aa22-bdda-a83ca09dbc9b@genshiken.org
State Superseded
Headers show

Commit Message

Kagami Hiiragi March 2, 2017, 7 p.m. UTC
From ae3856c302284d60761c3ad122ff49b7b9b68114 Mon Sep 17 00:00:00 2001
From: Kagami Hiiragi <kagami@genshiken.org>
Date: Thu, 2 Mar 2017 21:19:09 +0300
Subject: [PATCH] lavc/libvpxenc: add -row-mt option

---
 libavcodec/libvpxenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Moritz Barsnick March 2, 2017, 10:16 p.m. UTC | #1
On Thu, Mar 02, 2017 at 22:00:36 +0300, Kagami Hiiragi wrote:
> +    {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
                                                                           ^
Woudn't a _BOOL type accept exactly the same ranges and defaults, with
the same behavior, but document itself more nicely?

It would result in
 -row-mt  <boolean>    E....... Row based multi-threading (default auto)
instead of
 -row-mt  <int>        E....... Row based multi-threading (from -1 to 1) (default -1)

(Guessing, untested.)

Moritz
Kagami Hiiragi March 2, 2017, 10:30 p.m. UTC | #2
On 03/03/17 01:16, Moritz Barsnick wrote:
> On Thu, Mar 02, 2017 at 22:00:36 +0300, Kagami Hiiragi wrote:
>> +    {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
>                                                                            ^
> Woudn't a _BOOL type accept exactly the same ranges and defaults, with
> the same behavior, but document itself more nicely?
> 
> It would result in
>  -row-mt  <boolean>    E....... Row based multi-threading (default auto)
> instead of
>  -row-mt  <int>        E....... Row based multi-threading (from -1 to 1) (default -1)
> 
> (Guessing, untested.)
> 
> Moritz

I copied description of "lossless" flag, but "frame-parallel" and other
encoders seems to prefer BOOL, you are right.

I'm leaving it up to commiter, it's just s/_INT/_BOOL/.
James Zern March 3, 2017, 7:18 a.m. UTC | #3
On Thu, Mar 2, 2017 at 11:00 AM, Kagami Hiiragi <kagami@genshiken.org> wrote:
> From ae3856c302284d60761c3ad122ff49b7b9b68114 Mon Sep 17 00:00:00 2001
> From: Kagami Hiiragi <kagami@genshiken.org>
> Date: Thu, 2 Mar 2017 21:19:09 +0300
> Subject: [PATCH] lavc/libvpxenc: add -row-mt option
>
> ---
>  libavcodec/libvpxenc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> [...]
>      [VP9E_SET_TARGET_LEVEL]            = "VP9E_SET_TARGET_LEVEL",
>      [VP9E_GET_LEVEL]                   = "VP9E_GET_LEVEL",
>  #endif
> +#if VPX_ENCODER_ABI_VERSION >= 13

Better to use #ifdef VPX_CTRL_VP9E_SET_ROW_MT.

> [...]
> +#if VPX_ENCODER_ABI_VERSION >= 13
> +    {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
> +#endif

We could use -thread_type/-slices here, though this is in line with
vpxenc. I'll leave this open to comment.
diff mbox

Patch

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index de0d0b6bcb..8eefda5b5b 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -108,6 +108,7 @@  typedef struct VPxEncoderContext {
     int noise_sensitivity;
     int vpx_cs;
     float level;
+    int row_mt;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -139,6 +140,9 @@  static const char *const ctlidstr[] = {
     [VP9E_SET_TARGET_LEVEL]            = "VP9E_SET_TARGET_LEVEL",
     [VP9E_GET_LEVEL]                   = "VP9E_GET_LEVEL",
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 13
+    [VP9E_SET_ROW_MT]                  = "VP9E_SET_ROW_MT",
+#endif
 #endif
 };
 
@@ -720,6 +724,10 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #if VPX_ENCODER_ABI_VERSION >= 12
         codecctl_int(avctx, VP9E_SET_TARGET_LEVEL, ctx->level < 0 ? 255 : lrint(ctx->level * 10));
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 13
+        if (ctx->row_mt >= 0)
+            codecctl_int(avctx, VP9E_SET_ROW_MT, ctx->row_mt);
+#endif
     }
 #endif
 
@@ -1132,6 +1140,9 @@  static const AVOption vp9_options[] = {
 #if VPX_ENCODER_ABI_VERSION >= 12
     {"level", "Specify level", OFFSET(level), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 6.2, VE},
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 13
+    {"row-mt", "Row based multi-threading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
+#endif
     LEGACY_OPTIONS
     { NULL }
 };