This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 6b401344e80c72c726e2f82dce62d55eb0099a65
Author:     Nicolas Gaullier <[email protected]>
AuthorDate: Fri Jan 23 16:35:56 2026 +0100
Commit:     Jun Zhao <[email protected]>
CommitDate: Mon May 25 00:55:19 2026 +0000

    fftools/textformat: add support for decibel formatting
    
    Signed-off-by: Nicolas Gaullier <[email protected]>
---
 fftools/textformat/avtextformat.c | 28 +++++++++++++++++++++++-----
 fftools/textformat/avtextformat.h |  3 +++
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/fftools/textformat/avtextformat.c 
b/fftools/textformat/avtextformat.c
index db0cc83921..05459f6e30 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -366,15 +366,20 @@ struct unit_value {
     const char *unit;
 };
 
+static const char float_fmt_full[] = "%f";
+static const char float_fmt_singledigit[] = "%.1f";
 static char *value_string(const AVTextFormatContext *tctx, char *buf, int 
buf_size, struct unit_value uv)
 {
     double vald;
     int64_t vali = 0;
-    int show_float = 0;
+    const char *float_fmt = 0;
 
-    if (uv.fmt >= AV_TEXTFORMAT_VALUE_FMT_DOUBLE) {
+    if (uv.fmt == AV_TEXTFORMAT_VALUE_FMT_DECIBEL) {
+        vald = 20 * log10(uv.val.d);
+        float_fmt = float_fmt_singledigit;
+    } else if (uv.fmt >= AV_TEXTFORMAT_VALUE_FMT_DOUBLE) {
         vald = uv.val.d;
-        show_float = 1;
+        float_fmt = float_fmt_full;
     } else {
         vald = (double)uv.val.i;
         vali = uv.val.i;
@@ -409,8 +414,8 @@ static char *value_string(const AVTextFormatContext *tctx, 
char *buf, int buf_si
             vali = (int64_t)vald;
         }
 
-        if (show_float || (tctx->opts.use_value_prefix && vald != 
(int64_t)vald))
-            snprintf(buf, buf_size, "%f", vald);
+        if (float_fmt || (tctx->opts.use_value_prefix && vald != 
(int64_t)vald))
+            snprintf(buf, buf_size, float_fmt ? float_fmt : "%f", vald);
         else
             snprintf(buf, buf_size, "%"PRId64, vali);
 
@@ -436,6 +441,19 @@ void avtext_print_unit_integer(AVTextFormatContext *tctx, 
const char *key, int64
 }
 
 
+void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, 
double val, AVTextFormatValueFormat fmt, const char *unit)
+{
+    char val_str[128];
+    struct unit_value uv;
+
+    av_assert0(fmt >= AV_TEXTFORMAT_VALUE_FMT_DOUBLE);
+
+    uv.val.d = val;
+    uv.fmt = fmt;
+    uv.unit = unit;
+    avtext_print_string(tctx, key, value_string(tctx, val_str, 
sizeof(val_str), uv), 0);
+}
+
 int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char 
*val, int flags)
 {
     const AVTextFormatSection *section;
diff --git a/fftools/textformat/avtextformat.h 
b/fftools/textformat/avtextformat.h
index 36f53556ea..401544b146 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -166,6 +166,7 @@ typedef enum {
     AV_TEXTFORMAT_VALUE_FMT_BYTE,
     AV_TEXTFORMAT_VALUE_FMT_DOUBLE = 0x100,
     AV_TEXTFORMAT_VALUE_FMT_SECOND,
+    AV_TEXTFORMAT_VALUE_FMT_DECIBEL,
 } AVTextFormatValueFormat;
 
 #define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
@@ -187,6 +188,8 @@ int avtext_print_string(AVTextFormatContext *tctx, const 
char *key, const char *
 
 void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, 
int64_t val, AVTextFormatValueFormat fmt, const char *unit);
 
+void avtext_print_unit_double(AVTextFormatContext *tctx, const char *key, 
double val, AVTextFormatValueFormat fmt, const char *unit);
+
 void avtext_print_rational(AVTextFormatContext *tctx, const char *key, 
AVRational q, char sep);
 
 void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, 
const AVRational *time_base, int is_duration);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to