[FFmpeg-devel] [PATCH v5 06/14] fftools/textformat: AVTextWriter change writer_printf signature

softworkz ffmpegagent at gmail.com
Wed Apr 23 00:55:35 EEST 2025


From: softworkz <softworkz at hotmail.com>

Using va_list provides greater flebility

Signed-off-by: softworkz <softworkz at hotmail.com>
---
 fftools/textformat/avtextwriters.h | 2 +-
 fftools/textformat/tw_avio.c       | 7 ++-----
 fftools/textformat/tw_buffer.c     | 7 ++-----
 fftools/textformat/tw_stdout.c     | 8 ++------
 4 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/fftools/textformat/avtextwriters.h b/fftools/textformat/avtextwriters.h
index 34db3f1832..fd6da747eb 100644
--- a/fftools/textformat/avtextwriters.h
+++ b/fftools/textformat/avtextwriters.h
@@ -41,7 +41,7 @@ typedef struct AVTextWriter {
     void (*uninit)(AVTextWriterContext *wctx);
     void (*writer_w8)(AVTextWriterContext *wctx, int b);
     void (*writer_put_str)(AVTextWriterContext *wctx, const char *str);
-    void (*writer_printf)(AVTextWriterContext *wctx, const char *fmt, ...);
+    void (*writer_printf)(AVTextWriterContext *wctx, const char *fmt, va_list vl);
 } AVTextWriter;
 
 typedef struct AVTextWriterContext {
diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c
index 29889598bb..7d52dc4cf5 100644
--- a/fftools/textformat/tw_avio.c
+++ b/fftools/textformat/tw_avio.c
@@ -57,14 +57,11 @@ static void io_put_str(AVTextWriterContext *wctx, const char *str)
     avio_write(ctx->avio_context, (const unsigned char *)str, (int)strlen(str));
 }
 
-static void io_printf(AVTextWriterContext *wctx, const char *fmt, ...)
+static void io_printf(AVTextWriterContext *wctx, const char *fmt, va_list vl)
 {
     IOWriterContext *ctx = wctx->priv;
-    va_list ap;
 
-    va_start(ap, fmt);
-    avio_vprintf(ctx->avio_context, fmt, ap);
-    va_end(ap);
+    avio_vprintf(ctx->avio_context, fmt, vl);
 }
 
 
diff --git a/fftools/textformat/tw_buffer.c b/fftools/textformat/tw_buffer.c
index f8b38414a6..f861722247 100644
--- a/fftools/textformat/tw_buffer.c
+++ b/fftools/textformat/tw_buffer.c
@@ -56,14 +56,11 @@ static void buffer_put_str(AVTextWriterContext *wctx, const char *str)
     av_bprintf(ctx->buffer, "%s", str);
 }
 
-static void buffer_printf(AVTextWriterContext *wctx, const char *fmt, ...)
+static void buffer_printf(AVTextWriterContext *wctx, const char *fmt, va_list vl)
 {
     BufferWriterContext *ctx = wctx->priv;
 
-    va_list vargs;
-    va_start(vargs, fmt);
-    av_vbprintf(ctx->buffer, fmt, vargs);
-    va_end(vargs);
+    av_vbprintf(ctx->buffer, fmt, vl);
 }
 
 
diff --git a/fftools/textformat/tw_stdout.c b/fftools/textformat/tw_stdout.c
index 23de6f671f..dace55f38a 100644
--- a/fftools/textformat/tw_stdout.c
+++ b/fftools/textformat/tw_stdout.c
@@ -53,13 +53,9 @@ static inline void stdout_put_str(AVTextWriterContext *wctx, const char *str)
     printf("%s", str);
 }
 
-static inline void stdout_printf(AVTextWriterContext *wctx, const char *fmt, ...)
+static inline void stdout_printf(AVTextWriterContext *wctx, const char *fmt, va_list vl)
 {
-    va_list ap;
-
-    va_start(ap, fmt);
-    vprintf(fmt, ap);
-    va_end(ap);
+    vprintf(fmt, vl);
 }
 
 
-- 
ffmpeg-codebot



More information about the ffmpeg-devel mailing list