[FFmpeg-cvslog] fftools/textformat/avtextformat: Simplify avtext_print_rational()

Andreas Rheinhardt git at videolan.org
Wed Apr 16 07:25:09 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Apr 14 22:13:19 2025 +0200| [2ab10212647bd8cce73f4ff98879691e6ff5916c] | committer: Andreas Rheinhardt

fftools/textformat/avtextformat: Simplify avtext_print_rational()

Use snprintf() directly instead of initializing an AVBPrint
just for this.

Reviewed-by: softworkz . <softworkz-at-hotmail.com at ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ab10212647bd8cce73f4ff98879691e6ff5916c
---

 fftools/textformat/avtextformat.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 6c09f9d2cd..c1b5eefab4 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -460,10 +460,9 @@ int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *
 void avtext_print_rational(AVTextFormatContext *tctx,
                                          const char *key, AVRational q, char sep)
 {
-    AVBPrint buf;
-    av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
-    av_bprintf(&buf, "%d%c%d", q.num, sep, q.den);
-    avtext_print_string(tctx, key, buf.str, 0);
+    char buf[44];
+    snprintf(buf, sizeof(buf), "%d%c%d", q.num, sep, q.den);
+    avtext_print_string(tctx, key, buf, 0);
 }
 
 void avtext_print_time(AVTextFormatContext *tctx, const char *key,



More information about the ffmpeg-cvslog mailing list