diff mbox series

[FFmpeg-devel,v1,2/4] avfilter/af_loudnorm: Add compact mode to simplify stats parsing

Message ID 20200409110720.6965-2-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v1,1/4] avfilter/af_loudnorm: Add file option for the measured stats
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Limin Wang April 9, 2020, 11:07 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 doc/filters.texi          |  2 +-
 libavfilter/af_loudnorm.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 738a40df4e..19171d48dc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4283,7 +4283,7 @@  Multi-channel input files are not affected by this option.
 Options are true or false. Default is false.
 
 @item print_format
-Set print format for stats. Options are summary, json, or none.
+Set print format for stats. Options are summary, json, compact or none.
 Default value is none.
 
 @item file, f
diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index bf530195e4..3012aa2471 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -48,6 +48,7 @@  enum PrintFormat {
     NONE,
     JSON,
     SUMMARY,
+    COMPACT,
     PF_NB
 };
 
@@ -124,6 +125,7 @@  static const AVOption loudnorm_options[] = {
     {     "none",         0,                                   0,                        AV_OPT_TYPE_CONST,   {.i64 =  NONE},     0,         0,  FLAGS, "print_format" },
     {     "json",         0,                                   0,                        AV_OPT_TYPE_CONST,   {.i64 =  JSON},     0,         0,  FLAGS, "print_format" },
     {     "summary",      0,                                   0,                        AV_OPT_TYPE_CONST,   {.i64 =  SUMMARY},  0,         0,  FLAGS, "print_format" },
+    {     "compact",      0,                                   0,                        AV_OPT_TYPE_CONST,   {.i64 =  COMPACT},  0,         0,  FLAGS, "print_format" },
     { "file", "set file path for the measured stats",          OFFSET(filename),         AV_OPT_TYPE_STRING,  {.str=NULL},                       FLAGS },
     { "f",    "set file path for the measured stats",          OFFSET(filename),         AV_OPT_TYPE_STRING,  {.str=NULL},                       FLAGS },
     { NULL }
@@ -909,6 +911,16 @@  static av_cold void uninit(AVFilterContext *ctx)
         );
         break;
 
+    case COMPACT:
+        s->print(ctx, "input_i: %.2f, input_tp: %.2f, input_lra: %.2f, input_thresh: %.2f, "
+                 "output_i: %.2f, output_tp: %.2f, output_lra: %.2f, output_thresh: %.2f, "
+                  "normalization_type: %s, target_offset: %.2f\n",
+                  i_in, 20. * log10(tp_in), lra_in, thresh_in,
+                  i_out, 20. * log10(tp_out), lra_out, thresh_out,
+                  s->frame_type == LINEAR_MODE ? "linear" : "dynamic",
+                  s->target_i - i_out);
+        break;
+
     case SUMMARY:
         s->print(ctx,
             "\n"