Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-29 Thread James Almer
On 3/29/2019 1:58 PM, Sam John via ffmpeg-devel wrote:
> The following are the newly added options:
> arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
> denoise_block_size,
> rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
> frame_parallel,
> enable_cdef, enable_global_motion, and intrabc.
> 
> Also added macros for compiling for aom 1.0.0 and fixed the default values.
> ---
>  libavcodec/libaomenc.c | 97 --
>  1 file changed, 93 insertions(+), 4 deletions(-)

Applied. Please send a patch documenting the new options in
encoders.texi as Gyan requested.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-29 Thread Gyan



On 29-03-2019 10:28 PM, Sam John via ffmpeg-devel wrote:

The following are the newly added options:
arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
denoise_block_size,
rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
frame_parallel,
enable_cdef, enable_global_motion, and intrabc.



Docs update missing.

Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-29 Thread Sam John via ffmpeg-devel
The following are the newly added options:
arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
denoise_block_size,
rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
frame_parallel,
enable_cdef, enable_global_motion, and intrabc.

Also added macros for compiling for aom 1.0.0 and fixed the default values.
---
 libavcodec/libaomenc.c | 97 --
 1 file changed, 93 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index faec61cacd..6d2441b4ed 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -66,36 +66,69 @@ typedef struct AOMEncoderContext {
 struct FrameListData *coded_frame_list;
 int cpu_used;
 int auto_alt_ref;
+int arnr_max_frames;
+int arnr_strength;
+int aq_mode;
 int lag_in_frames;
 int error_resilient;
 int crf;
 int static_thresh;
 int drop_threshold;
+int denoise_noise_level;
+int denoise_block_size;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
+int rc_undershoot_pct;
+int rc_overshoot_pct;
+int minsection_pct;
+int maxsection_pct;
+int frame_parallel;
 int tile_cols, tile_rows;
 int tile_cols_log2, tile_rows_log2;
 aom_superblock_size_t superblock_size;
 int uniform_tiles;
 int row_mt;
+int enable_cdef;
+int enable_global_motion;
+int enable_intrabc;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
 [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
 [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
 [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
+[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
+[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
 [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
 [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
 [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
+[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
+[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
 [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
 [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
 #ifdef AOM_CTRL_AV1E_SET_ROW_MT
 [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
 #endif
+#ifdef AV1E_SET_DENOISE_NOISE_LEVEL
+[AV1E_SET_DENOISE_NOISE_LEVEL] =  "AV1E_SET_DENOISE_NOISE_LEVEL",
+#endif
+#ifdef AV1E_SET_DENOISE_BLOCK_SIZE
+[AV1E_SET_DENOISE_BLOCK_SIZE] =   "AV1E_SET_DENOISE_BLOCK_SIZE",
+#endif
+#ifdef AV1E_SET_MAX_REFERENCE_FRAMES
+[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
+#endif
+#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION
+[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
+#endif
+#ifdef AV1E_SET_ENABLE_INTRABC
+[AV1E_SET_ENABLE_INTRABC] = "AV1E_SET_ENABLE_INTRABC",
+#endif
+[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -567,10 +600,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 // 0-100 (0 => CBR, 100 => VBR)
 enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
-if (avctx->bit_rate)
+if (ctx->minsection_pct >= 0)
+enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
+else if (avctx->bit_rate)
 enccfg.rc_2pass_vbr_minsection_pct =
 avctx->rc_min_rate * 100LL / avctx->bit_rate;
-if (avctx->rc_max_rate)
+if (ctx->maxsection_pct >= 0)
+enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
+else if (avctx->rc_max_rate)
 enccfg.rc_2pass_vbr_maxsection_pct =
 avctx->rc_max_rate * 100LL / avctx->bit_rate;
 
@@ -582,6 +619,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
 avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
 
+if (ctx->rc_undershoot_pct >= 0)
+enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
+if (ctx->rc_overshoot_pct >= 0)
+enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
+
 // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
 if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
 enccfg.kf_min_dist = avctx->keyint_min;
@@ -643,7 +685,12 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
 if (ctx->auto_alt_ref >= 0)
 codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
-
+if (ctx->arnr_max_frames >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES,   ctx->arnr_max_frames);
+if (ctx->arnr_strength >= 

[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-13 Thread Sam John
The following are the newly added options:
arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
denoise_block_size,
rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
frame_parallel,
enable_cdef, and enable_global_motion.

Also added macros for compiling for aom 1.0.0 and fixed the default values.
---
 libavcodec/libaomenc.c | 88 --
 1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index faec61cacd..7d4a5ac447 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -66,36 +66,65 @@ typedef struct AOMEncoderContext {
 struct FrameListData *coded_frame_list;
 int cpu_used;
 int auto_alt_ref;
+int arnr_max_frames;
+int arnr_strength;
+int aq_mode;
 int lag_in_frames;
 int error_resilient;
 int crf;
 int static_thresh;
 int drop_threshold;
+int denoise_noise_level;
+int denoise_block_size;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
+int rc_undershoot_pct;
+int rc_overshoot_pct;
+int minsection_pct;
+int maxsection_pct;
+int frame_parallel;
 int tile_cols, tile_rows;
 int tile_cols_log2, tile_rows_log2;
 aom_superblock_size_t superblock_size;
 int uniform_tiles;
 int row_mt;
+int enable_cdef;
+int enable_global_motion;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
 [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
 [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
 [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
+[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
+[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
 [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
 [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
 [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
+[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
+[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
 [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
 [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
 #ifdef AOM_CTRL_AV1E_SET_ROW_MT
 [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
 #endif
+#ifdef AV1E_SET_DENOISE_NOISE_LEVEL
+[AV1E_SET_DENOISE_NOISE_LEVEL] =  "AV1E_SET_DENOISE_NOISE_LEVEL",
+#endif
+#ifdef AV1E_SET_DENOISE_BLOCK_SIZE
+[AV1E_SET_DENOISE_BLOCK_SIZE] =   "AV1E_SET_DENOISE_BLOCK_SIZE",
+#endif
+#ifdef AV1E_SET_MAX_REFERENCE_FRAMES
+[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
+#endif
+#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION
+[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
+#endif
+[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -567,10 +596,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 // 0-100 (0 => CBR, 100 => VBR)
 enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
-if (avctx->bit_rate)
+if (ctx->minsection_pct >= 0)
+enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
+else if (avctx->bit_rate)
 enccfg.rc_2pass_vbr_minsection_pct =
 avctx->rc_min_rate * 100LL / avctx->bit_rate;
-if (avctx->rc_max_rate)
+if (ctx->maxsection_pct >= 0)
+enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
+else if (avctx->rc_max_rate)
 enccfg.rc_2pass_vbr_maxsection_pct =
 avctx->rc_max_rate * 100LL / avctx->bit_rate;
 
@@ -582,6 +615,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
 avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
 
+if (ctx->rc_undershoot_pct >= 0)
+enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
+if (ctx->rc_overshoot_pct >= 0)
+enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
+
 // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
 if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
 enccfg.kf_min_dist = avctx->keyint_min;
@@ -643,7 +681,12 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
 if (ctx->auto_alt_ref >= 0)
 codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
-
+if (ctx->arnr_max_frames >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES,   ctx->arnr_max_frames);
+if (ctx->arnr_strength >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength);
+if (ctx->enable_cdef >= 0)
+

Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-12 Thread Sam John
Thank you James and Moritz.

For many of these parameters, the default value within the codec is '1'. So
we want to add the option for disabling it also.

I would like to follow the method used for "frame-parallel",  after
changing the default value to -1.

{ "frame-parallel",   "Enable frame parallel decodability features",
OFFSET(frame_parallel),  AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1, VE},

if (frame_parallel >= 0) {
..
}

I will send the updated patch soon.




On Tue, Mar 12, 2019 at 9:14 AM Moritz Barsnick  wrote:

> On Tue, Mar 12, 2019 at 11:45:06 -0300, James Almer wrote:
> > > +{ "frame-parallel",   "Enable frame parallel decodability
> features", OFFSET(frame_parallel),  AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1,
> VE},
> >
> > A bool with three values is weird. If this is meant to be disabled by
> > default, then just make it 0 and remove the >= 0 condition above.
>
> It's actually quite common with ffmpeg options. Such an option can only
> be assigned true or false, but if it isn't assigned, it will be e.g. -1
> and can be used to trigger a default mode, as is apparently done here
> (by not setting this option through the API, probably letting the
> library do whatever it considers default).
>
> Cheers,
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-12 Thread Moritz Barsnick
On Tue, Mar 12, 2019 at 11:45:06 -0300, James Almer wrote:
> > +{ "frame-parallel",   "Enable frame parallel decodability features", 
> > OFFSET(frame_parallel),  AV_OPT_TYPE_BOOL,{.i64 = -1}, -1, 1, VE},
> 
> A bool with three values is weird. If this is meant to be disabled by
> default, then just make it 0 and remove the >= 0 condition above.

It's actually quite common with ffmpeg options. Such an option can only
be assigned true or false, but if it isn't assigned, it will be e.g. -1
and can be used to trigger a default mode, as is apparently done here
(by not setting this option through the API, probably letting the
library do whatever it considers default).

Cheers,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-12 Thread James Almer
On 3/8/2019 10:21 PM, Sam John wrote:
> The following are the newly added options:
> arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
> denoise_block_size,
> rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
> frame_parallel,
> enable_cdef, and enable_global_motion.
> 
> Also added macros for compiling for aom 1.0.0.
> ---
>  libavcodec/libaomenc.c | 86 --
>  1 file changed, 83 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index faec61cacd..8e0ba7241e 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -66,36 +66,65 @@ typedef struct AOMEncoderContext {
>  struct FrameListData *coded_frame_list;
>  int cpu_used;
>  int auto_alt_ref;
> +int arnr_max_frames;
> +int arnr_strength;
> +int aq_mode;
>  int lag_in_frames;
>  int error_resilient;
>  int crf;
>  int static_thresh;
>  int drop_threshold;
> +int denoise_noise_level;
> +int denoise_block_size;
>  uint64_t sse[4];
>  int have_sse; /**< true if we have pending sse[] */
>  uint64_t frame_number;
> +int rc_undershoot_pct;
> +int rc_overshoot_pct;
> +int minsection_pct;
> +int maxsection_pct;
> +int frame_parallel;
>  int tile_cols, tile_rows;
>  int tile_cols_log2, tile_rows_log2;
>  aom_superblock_size_t superblock_size;
>  int uniform_tiles;
>  int row_mt;
> +int enable_cdef;
> +int enable_global_motion;
>  } AOMContext;
>  
>  static const char *const ctlidstr[] = {
>  [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
>  [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
>  [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
> +[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
> +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
>  [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
>  [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
>  [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
>  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
>  [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
> "AV1E_SET_TRANSFER_CHARACTERISTICS",
> +[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
> +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
>  [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
>  [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
>  [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
>  #ifdef AOM_CTRL_AV1E_SET_ROW_MT
>  [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
>  #endif
> +#ifdef AV1E_SET_DENOISE_NOISE_LEVEL
> +[AV1E_SET_DENOISE_NOISE_LEVEL] =  "AV1E_SET_DENOISE_NOISE_LEVEL",
> +#endif
> +#ifdef AV1E_SET_DENOISE_BLOCK_SIZE
> +[AV1E_SET_DENOISE_BLOCK_SIZE] =   "AV1E_SET_DENOISE_BLOCK_SIZE",
> +#endif
> +#ifdef AV1E_SET_MAX_REFERENCE_FRAMES
> +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
> +#endif
> +#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION
> +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
> +#endif
> +[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
>  };
>  
>  static av_cold void log_encoder_error(AVCodecContext *avctx, const char 
> *desc)
> @@ -567,10 +596,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  
>  // 0-100 (0 => CBR, 100 => VBR)
>  enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
> -if (avctx->bit_rate)
> +if (ctx->minsection_pct >= 0)
> +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
> +else if (avctx->bit_rate)
>  enccfg.rc_2pass_vbr_minsection_pct =
>  avctx->rc_min_rate * 100LL / avctx->bit_rate;
> -if (avctx->rc_max_rate)
> +if (ctx->maxsection_pct >= 0)
> +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
> +else if (avctx->rc_max_rate)
>  enccfg.rc_2pass_vbr_maxsection_pct =
>  avctx->rc_max_rate * 100LL / avctx->bit_rate;
>  
> @@ -582,6 +615,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
>  enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
>  
> +if (ctx->rc_undershoot_pct >= 0)
> +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
> +if (ctx->rc_overshoot_pct >= 0)
> +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
> +
>  // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
>  if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
>  enccfg.kf_min_dist = avctx->keyint_min;
> @@ -643,7 +681,12 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
>  if (ctx->auto_alt_ref >= 0)
>  codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
> -
> +if (ctx->arnr_max_frames 

[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-08 Thread Sam John
The following are the newly added options:
arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
denoise_block_size,
rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
frame_parallel,
enable_cdef, and enable_global_motion.

Also added macros for compiling for aom 1.0.0.
---
 libavcodec/libaomenc.c | 86 --
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index faec61cacd..8e0ba7241e 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -66,36 +66,65 @@ typedef struct AOMEncoderContext {
 struct FrameListData *coded_frame_list;
 int cpu_used;
 int auto_alt_ref;
+int arnr_max_frames;
+int arnr_strength;
+int aq_mode;
 int lag_in_frames;
 int error_resilient;
 int crf;
 int static_thresh;
 int drop_threshold;
+int denoise_noise_level;
+int denoise_block_size;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
+int rc_undershoot_pct;
+int rc_overshoot_pct;
+int minsection_pct;
+int maxsection_pct;
+int frame_parallel;
 int tile_cols, tile_rows;
 int tile_cols_log2, tile_rows_log2;
 aom_superblock_size_t superblock_size;
 int uniform_tiles;
 int row_mt;
+int enable_cdef;
+int enable_global_motion;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
 [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
 [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
 [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
+[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
+[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
 [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
 [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
 [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
+[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
+[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
 [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
 [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
 #ifdef AOM_CTRL_AV1E_SET_ROW_MT
 [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
 #endif
+#ifdef AV1E_SET_DENOISE_NOISE_LEVEL
+[AV1E_SET_DENOISE_NOISE_LEVEL] =  "AV1E_SET_DENOISE_NOISE_LEVEL",
+#endif
+#ifdef AV1E_SET_DENOISE_BLOCK_SIZE
+[AV1E_SET_DENOISE_BLOCK_SIZE] =   "AV1E_SET_DENOISE_BLOCK_SIZE",
+#endif
+#ifdef AV1E_SET_MAX_REFERENCE_FRAMES
+[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
+#endif
+#ifdef AV1E_SET_ENABLE_GLOBAL_MOTION
+[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
+#endif
+[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -567,10 +596,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 // 0-100 (0 => CBR, 100 => VBR)
 enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
-if (avctx->bit_rate)
+if (ctx->minsection_pct >= 0)
+enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
+else if (avctx->bit_rate)
 enccfg.rc_2pass_vbr_minsection_pct =
 avctx->rc_min_rate * 100LL / avctx->bit_rate;
-if (avctx->rc_max_rate)
+if (ctx->maxsection_pct >= 0)
+enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
+else if (avctx->rc_max_rate)
 enccfg.rc_2pass_vbr_maxsection_pct =
 avctx->rc_max_rate * 100LL / avctx->bit_rate;
 
@@ -582,6 +615,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
 avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
 
+if (ctx->rc_undershoot_pct >= 0)
+enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
+if (ctx->rc_overshoot_pct >= 0)
+enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
+
 // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
 if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
 enccfg.kf_min_dist = avctx->keyint_min;
@@ -643,7 +681,12 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
 if (ctx->auto_alt_ref >= 0)
 codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
-
+if (ctx->arnr_max_frames >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES,   ctx->arnr_max_frames);
+if (ctx->arnr_strength >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength);
+if (ctx->enable_cdef >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_CDEF, 

Re: [FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-06 Thread James Almer
On 3/6/2019 9:56 PM, Sam John wrote:
> The following are the newly added options:
> arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
> denoise_block_size,
> rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
> frame_parallel,
> enable_cdef, and enable_global_motion.

We're currently allowing compilation of libavcodec with libaom 1.0.0 as
the oldest version. If any of these options or aom_codec_enc_cfg entries
were added after 1.0.0 was tagged, then you need to wrap the relevant
lines in ctlidstr[] and aom_init() with the related AOM_CTRL_*,
AOM_ENCODER_ABI_VERSION, or whichever preprocessor check.

> ---
>  libavcodec/libaomenc.c | 71 --
>  1 file changed, 68 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index faec61cacd..687ea5f2c7 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -66,36 +66,57 @@ typedef struct AOMEncoderContext {
>  struct FrameListData *coded_frame_list;
>  int cpu_used;
>  int auto_alt_ref;
> +int arnr_max_frames;
> +int arnr_strength;
> +int aq_mode;
>  int lag_in_frames;
>  int error_resilient;
>  int crf;
>  int static_thresh;
>  int drop_threshold;
> +int denoise_noise_level;
> +int denoise_block_size;
>  uint64_t sse[4];
>  int have_sse; /**< true if we have pending sse[] */
>  uint64_t frame_number;
> +int rc_undershoot_pct;
> +int rc_overshoot_pct;
> +int minsection_pct;
> +int maxsection_pct;
> +int frame_parallel;
>  int tile_cols, tile_rows;
>  int tile_cols_log2, tile_rows_log2;
>  aom_superblock_size_t superblock_size;
>  int uniform_tiles;
>  int row_mt;
> +int enable_cdef;
> +int enable_global_motion;
>  } AOMContext;
>  
>  static const char *const ctlidstr[] = {
>  [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
>  [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
>  [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
> +[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
> +[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
>  [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
>  [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
>  [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
> +[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL",
> +[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE",
>  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
>  [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
> "AV1E_SET_TRANSFER_CHARACTERISTICS",
> +[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
> +[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
>  [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
>  [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
>  [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
> +[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
>  #ifdef AOM_CTRL_AV1E_SET_ROW_MT
>  [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
>  #endif
> +[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
> +[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
>  };
>  
>  static av_cold void log_encoder_error(AVCodecContext *avctx, const char 
> *desc)
> @@ -567,10 +588,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  
>  // 0-100 (0 => CBR, 100 => VBR)
>  enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
> -if (avctx->bit_rate)
> +if (ctx->minsection_pct >= 0)
> +enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
> +else if (avctx->bit_rate)
>  enccfg.rc_2pass_vbr_minsection_pct =
>  avctx->rc_min_rate * 100LL / avctx->bit_rate;
> -if (avctx->rc_max_rate)
> +if (ctx->maxsection_pct >= 0)
> +enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
> +else if (avctx->rc_max_rate)
>  enccfg.rc_2pass_vbr_maxsection_pct =
>  avctx->rc_max_rate * 100LL / avctx->bit_rate;
>  
> @@ -582,6 +607,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
>  enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
>  
> +if (ctx->rc_undershoot_pct >= 0)
> +enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
> +if (ctx->rc_overshoot_pct >= 0)
> +enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
> +
>  // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
>  if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
>  enccfg.kf_min_dist = avctx->keyint_min;
> @@ -643,14 +673,30 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
>  if (ctx->auto_alt_ref >= 0)
>  

[FFmpeg-devel] [PATCH] Added more commandline options for libaom encoder.

2019-03-06 Thread Sam John
The following are the newly added options:
arnr_max_frames, arnr_strength, aq_mode, denoise_noise_level, 
denoise_block_size,
rc_undershoot_pct, rc_overshoot_pct, minsection_pct, maxsection_pct, 
frame_parallel,
enable_cdef, and enable_global_motion.
---
 libavcodec/libaomenc.c | 71 --
 1 file changed, 68 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index faec61cacd..687ea5f2c7 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -66,36 +66,57 @@ typedef struct AOMEncoderContext {
 struct FrameListData *coded_frame_list;
 int cpu_used;
 int auto_alt_ref;
+int arnr_max_frames;
+int arnr_strength;
+int aq_mode;
 int lag_in_frames;
 int error_resilient;
 int crf;
 int static_thresh;
 int drop_threshold;
+int denoise_noise_level;
+int denoise_block_size;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
+int rc_undershoot_pct;
+int rc_overshoot_pct;
+int minsection_pct;
+int maxsection_pct;
+int frame_parallel;
 int tile_cols, tile_rows;
 int tile_cols_log2, tile_rows_log2;
 aom_superblock_size_t superblock_size;
 int uniform_tiles;
 int row_mt;
+int enable_cdef;
+int enable_global_motion;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
 [AOME_SET_CPUUSED]  = "AOME_SET_CPUUSED",
 [AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
 [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
+[AOME_SET_ARNR_MAXFRAMES]   = "AOME_SET_ARNR_MAXFRAMES",
+[AOME_SET_ARNR_STRENGTH]= "AOME_SET_ARNR_STRENGTH",
 [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
 [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
 [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
+[AV1E_SET_DENOISE_NOISE_LEVEL] = "AV1E_SET_DENOISE_NOISE_LEVEL",
+[AV1E_SET_DENOISE_BLOCK_SIZE] = "AV1E_SET_DENOISE_BLOCK_SIZE",
 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
+[AV1E_SET_AQ_MODE]  = "AV1E_SET_AQ_MODE",
+[AV1E_SET_FRAME_PARALLEL_DECODING] = "AV1E_SET_FRAME_PARALLEL_DECODING",
 [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
 [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
+[AV1E_SET_MAX_REFERENCE_FRAMES] = "AV1E_SET_MAX_REFERENCE_FRAMES",
 #ifdef AOM_CTRL_AV1E_SET_ROW_MT
 [AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
 #endif
+[AV1E_SET_ENABLE_CDEF]  = "AV1E_SET_ENABLE_CDEF",
+[AV1E_SET_ENABLE_GLOBAL_MOTION] = "AV1E_SET_ENABLE_GLOBAL_MOTION",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -567,10 +588,14 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 // 0-100 (0 => CBR, 100 => VBR)
 enccfg.rc_2pass_vbr_bias_pct   = round(avctx->qcompress * 100);
-if (avctx->bit_rate)
+if (ctx->minsection_pct >= 0)
+enccfg.rc_2pass_vbr_minsection_pct = ctx->minsection_pct;
+else if (avctx->bit_rate)
 enccfg.rc_2pass_vbr_minsection_pct =
 avctx->rc_min_rate * 100LL / avctx->bit_rate;
-if (avctx->rc_max_rate)
+if (ctx->maxsection_pct >= 0)
+enccfg.rc_2pass_vbr_maxsection_pct = ctx->maxsection_pct;
+else if (avctx->rc_max_rate)
 enccfg.rc_2pass_vbr_maxsection_pct =
 avctx->rc_max_rate * 100LL / avctx->bit_rate;
 
@@ -582,6 +607,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
 avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
 enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
 
+if (ctx->rc_undershoot_pct >= 0)
+enccfg.rc_undershoot_pct = ctx->rc_undershoot_pct;
+if (ctx->rc_overshoot_pct >= 0)
+enccfg.rc_overshoot_pct = ctx->rc_overshoot_pct;
+
 // _enc_init() will balk if kf_min_dist differs from max w/AOM_KF_AUTO
 if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
 enccfg.kf_min_dist = avctx->keyint_min;
@@ -643,14 +673,30 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AOME_SET_CPUUSED, ctx->cpu_used);
 if (ctx->auto_alt_ref >= 0)
 codecctl_int(avctx, AOME_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
-
+if (ctx->arnr_max_frames >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_MAXFRAMES,   ctx->arnr_max_frames);
+if (ctx->arnr_strength >= 0)
+codecctl_int(avctx, AOME_SET_ARNR_STRENGTH,ctx->arnr_strength);
+if (ctx->enable_cdef >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_CDEF, ctx->enable_cdef);
+if (ctx->enable_global_motion >= 0)
+codecctl_int(avctx, AV1E_SET_ENABLE_GLOBAL_MOTION, 
ctx->enable_global_motion);
 codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
 if