diff mbox

[FFmpeg-devel,1/2] libvpxenc: Support targeting a VP9 level

Message ID 1479506517-731-1-git-send-email-alex.converse@gmail.com
State Accepted
Commit 3ee59939a1c128b65fb65fcba1640786789f88c0
Headers show

Commit Message

Alex Converse Nov. 18, 2016, 10:01 p.m. UTC
Levels are specified at https://www.webmproject.org/vp9/levels/
---
 libavcodec/libvpxenc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

James Zern Nov. 18, 2016, 11:44 p.m. UTC | #1
On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote:
> Levels are specified at https://www.webmproject.org/vp9/levels/
> ---
>  libavcodec/libvpxenc.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>

lgtm

> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 68f25a4..51f423a 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -107,6 +107,7 @@ typedef struct VPxEncoderContext {
>      int drop_threshold;
>      int noise_sensitivity;
>      int vpx_cs;
> +    float level;
>  } VPxContext;
>
>  /** String mappings for enum vp8e_enc_control_id */
> @@ -134,6 +135,9 @@ static const char *const ctlidstr[] = {
>  #if VPX_ENCODER_ABI_VERSION >= 11
>      [VP9E_SET_COLOR_RANGE]             = "VP9E_SET_COLOR_RANGE",
>  #endif
> +#if VPX_ENCODER_ABI_VERSION >= 12
>

you can check VPX_CTRL_VP9E_SET_TARGET_LEVEL for this.
Alex Converse Nov. 22, 2016, 7:34 p.m. UTC | #2
On Fri, Nov 18, 2016 at 3:44 PM, James Zern
<jzern-at-google.com@ffmpeg.org> wrote:
>
> On Fri, Nov 18, 2016 at 2:01 PM, Alex Converse <alex.converse@gmail.com> wrote:
> > Levels are specified at https://www.webmproject.org/vp9/levels/
> > ---
> >  libavcodec/libvpxenc.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
>
> lgtm

Pushed
diff mbox

Patch

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 68f25a4..51f423a 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -107,6 +107,7 @@  typedef struct VPxEncoderContext {
     int drop_threshold;
     int noise_sensitivity;
     int vpx_cs;
+    float level;
 } VPxContext;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -134,6 +135,9 @@  static const char *const ctlidstr[] = {
 #if VPX_ENCODER_ABI_VERSION >= 11
     [VP9E_SET_COLOR_RANGE]             = "VP9E_SET_COLOR_RANGE",
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 12
+    [VP9E_SET_TARGET_LEVEL]            = "VP9E_SET_TARGET_LEVEL",
+#endif
 #endif
 };
 
@@ -680,6 +684,9 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #if VPX_ENCODER_ABI_VERSION >= 11
         set_color_range(avctx);
 #endif
+#if VPX_ENCODER_ABI_VERSION >= 12
+        codecctl_int(avctx, VP9E_SET_TARGET_LEVEL, ctx->level < 0 ? 255 : lrint(ctx->level * 10));
+#endif
     }
 #endif
 
@@ -1089,6 +1096,9 @@  static const AVOption vp9_options[] = {
     { "variance",        "Variance based Aq",   0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode" },
     { "complexity",      "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode" },
     { "cyclic",          "Cyclic Refresh Aq",   0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode" },
+#if VPX_ENCODER_ABI_VERSION >= 12
+    {"level", "Specify level", OFFSET(level), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 6.2, VE},
+#endif
     LEGACY_OPTIONS
     { NULL }
 };