Patches attached. - Andreas
From e54f813ea94fad0081f79aad8c35daa858300176 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Mon, 14 Apr 2025 22:13:19 +0200 Subject: [PATCH 01/12] fftools/textformat/avtextformat: Simplify avtext_print_rational()
Use snprintf() directly instead of initializing an AVBPrint just for this. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- 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, -- 2.45.2
From d1464f9bbe1088b70493311b05ac159f7e516d51 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:38:44 +0200 Subject: [PATCH 02/12] fftools/textformat: Use "", not <> for lavu headers Also remove unused headers. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/tf_compact.c | 9 +++------ fftools/textformat/tf_default.c | 6 ++---- fftools/textformat/tf_flat.c | 9 +++------ fftools/textformat/tf_ini.c | 7 +++---- fftools/textformat/tf_json.c | 6 ++---- fftools/textformat/tf_xml.c | 9 +++------ 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/fftools/textformat/tf_compact.c b/fftools/textformat/tf_compact.c index 825b67bc6e..31bfc81513 100644 --- a/fftools/textformat/tf_compact.c +++ b/fftools/textformat/tf_compact.c @@ -25,12 +25,9 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/error.h> -#include <libavutil/macros.h> -#include <libavutil/opt.h> +#include "libavutil/bprint.h" +#include "libavutil/error.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) diff --git a/fftools/textformat/tf_default.c b/fftools/textformat/tf_default.c index 23575024c1..86582829e4 100644 --- a/fftools/textformat/tf_default.c +++ b/fftools/textformat/tf_default.c @@ -25,10 +25,8 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/opt.h> +#include "libavutil/bprint.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) #define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_) diff --git a/fftools/textformat/tf_flat.c b/fftools/textformat/tf_flat.c index 6971593c77..919d44bc6b 100644 --- a/fftools/textformat/tf_flat.c +++ b/fftools/textformat/tf_flat.c @@ -25,12 +25,9 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/error.h> -#include <libavutil/macros.h> -#include <libavutil/opt.h> +#include "libavutil/bprint.h" +#include "libavutil/error.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) #define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_) diff --git a/fftools/textformat/tf_ini.c b/fftools/textformat/tf_ini.c index 1f4216069f..d8099ff92e 100644 --- a/fftools/textformat/tf_ini.c +++ b/fftools/textformat/tf_ini.c @@ -25,10 +25,9 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/opt.h> + +#include "libavutil/bprint.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) #define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_) diff --git a/fftools/textformat/tf_json.c b/fftools/textformat/tf_json.c index de27a36e7e..c26a912435 100644 --- a/fftools/textformat/tf_json.c +++ b/fftools/textformat/tf_json.c @@ -25,10 +25,8 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/opt.h> +#include "libavutil/bprint.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) #define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_) diff --git a/fftools/textformat/tf_xml.c b/fftools/textformat/tf_xml.c index 57171c4cb3..6c89d01e9d 100644 --- a/fftools/textformat/tf_xml.c +++ b/fftools/textformat/tf_xml.c @@ -25,12 +25,9 @@ #include <string.h> #include "avtextformat.h" -#include <libavutil/mem.h> -#include <libavutil/avassert.h> -#include <libavutil/bprint.h> -#include <libavutil/error.h> -#include <libavutil/macros.h> -#include <libavutil/opt.h> +#include "libavutil/bprint.h" +#include "libavutil/error.h" +#include "libavutil/opt.h" #define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_) #define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_) -- 2.45.2
From a2d2782c580ea6a62b48b29ceca692afb118deb6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:42:42 +0200 Subject: [PATCH 03/12] fftools/textformat/tw_avio: Remove unused private class This AVTextWriter does not have any options. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/tw_avio.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c index d335d35a56..77f8521235 100644 --- a/fftools/textformat/tw_avio.c +++ b/fftools/textformat/tw_avio.c @@ -20,9 +20,11 @@ #include <limits.h> #include <stdarg.h> +#include <string.h> #include "avtextwriters.h" -#include "libavutil/opt.h" + +#include "libavutil/error.h" /* AVIO Writer */ @@ -34,16 +36,6 @@ typedef struct IOWriterContext { int close_on_uninit; } IOWriterContext; -static const char *iowriter_get_name(void *ctx) -{ - return WRITER_NAME; -} - -static const AVClass iowriter_class = { - .class_name = WRITER_NAME, - .item_name = iowriter_get_name, -}; - static av_cold void iowriter_uninit(AVTextWriterContext *wctx) { IOWriterContext *ctx = wctx->priv; @@ -81,7 +73,6 @@ const AVTextWriter avtextwriter_avio = { .name = WRITER_NAME, .priv_size = sizeof(IOWriterContext), .uninit = iowriter_uninit, - .priv_class = &iowriter_class, .writer_put_str = io_put_str, .writer_printf = io_printf, .writer_w8 = io_w8 -- 2.45.2
From f59c577e0bcbe6cc45de007b7a6aff81a160ca8a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:44:48 +0200 Subject: [PATCH 04/12] fftools/textformat/tw_avio: Don't flush unnecessarily avio_close() automatically flushes the AVIOContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/tw_avio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c index 77f8521235..f9fea24b19 100644 --- a/fftools/textformat/tw_avio.c +++ b/fftools/textformat/tw_avio.c @@ -41,7 +41,6 @@ static av_cold void iowriter_uninit(AVTextWriterContext *wctx) IOWriterContext *ctx = wctx->priv; if (ctx->close_on_uninit && ctx->avio_context) { - avio_flush(ctx->avio_context); avio_close(ctx->avio_context); } } -- 2.45.2
From c0fc389d1d702e3a350b62d19f3fe6434856ec3b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:46:37 +0200 Subject: [PATCH 05/12] fftools/textformat/tw_avio: Use avio_closep() Avoids leaving dangling pointers behind. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/tw_avio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c index f9fea24b19..a80b0d2588 100644 --- a/fftools/textformat/tw_avio.c +++ b/fftools/textformat/tw_avio.c @@ -40,9 +40,8 @@ static av_cold void iowriter_uninit(AVTextWriterContext *wctx) { IOWriterContext *ctx = wctx->priv; - if (ctx->close_on_uninit && ctx->avio_context) { - avio_close(ctx->avio_context); - } + if (ctx->close_on_uninit) + avio_closep(&ctx->avio_context); } static void io_w8(AVTextWriterContext *wctx, int b) -- 2.45.2
From 93199473dda9106405043f3191ddfb8e9567c7e1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:49:22 +0200 Subject: [PATCH 06/12] textformat/tw_avio: Remove close_on_uninit param from create_file avtextwriter_create_file() creates an AVIOContext whose pointer resides in its private context. If it were not always closed on uninit, the AVIOContext would leak, so it makes no sense to have this parameter. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/ffprobe.c | 2 +- fftools/textformat/avtextwriters.h | 2 +- fftools/textformat/tw_avio.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index e0a7322523..0953a029a0 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3161,7 +3161,7 @@ int main(int argc, char **argv) } if (output_filename) { - ret = avtextwriter_create_file(&wctx, output_filename, 1); + ret = avtextwriter_create_file(&wctx, output_filename); } else ret = avtextwriter_create_stdout(&wctx); diff --git a/fftools/textformat/avtextwriters.h b/fftools/textformat/avtextwriters.h index a62f2c8906..87b0024ba1 100644 --- a/fftools/textformat/avtextwriters.h +++ b/fftools/textformat/avtextwriters.h @@ -61,7 +61,7 @@ int avtextwriter_create_stdout(AVTextWriterContext **pwctx); int avtextwriter_create_avio(AVTextWriterContext **pwctx, AVIOContext *avio_ctx, int close_on_uninit); -int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_filename, int close_on_uninit); +int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_filename); int avtextwriter_create_buffer(AVTextWriterContext **pwctx, AVBPrint *buffer); diff --git a/fftools/textformat/tw_avio.c b/fftools/textformat/tw_avio.c index a80b0d2588..6034f74ec9 100644 --- a/fftools/textformat/tw_avio.c +++ b/fftools/textformat/tw_avio.c @@ -76,7 +76,7 @@ const AVTextWriter avtextwriter_avio = { .writer_w8 = io_w8 }; -int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_filename, int close_on_uninit) +int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_filename) { IOWriterContext *ctx; int ret; @@ -95,7 +95,7 @@ int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_fil return ret; } - ctx->close_on_uninit = close_on_uninit; + ctx->close_on_uninit = 1; return ret; } -- 2.45.2
From b66ba6f7269bcb4d90740c948113c86cdd359db1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 00:57:42 +0200 Subject: [PATCH 07/12] fftools/textformat: Use av_default_item_name() Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/tf_compact.c | 6 +----- fftools/textformat/tf_default.c | 6 +----- fftools/textformat/tf_flat.c | 6 +----- fftools/textformat/tf_ini.c | 6 +----- fftools/textformat/tf_json.c | 6 +----- fftools/textformat/tf_xml.c | 6 +----- 6 files changed, 6 insertions(+), 30 deletions(-) diff --git a/fftools/textformat/tf_compact.c b/fftools/textformat/tf_compact.c index 31bfc81513..c72f401afc 100644 --- a/fftools/textformat/tf_compact.c +++ b/fftools/textformat/tf_compact.c @@ -36,13 +36,9 @@ #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } diff --git a/fftools/textformat/tf_default.c b/fftools/textformat/tf_default.c index 86582829e4..17dc12168e 100644 --- a/fftools/textformat/tf_default.c +++ b/fftools/textformat/tf_default.c @@ -33,13 +33,9 @@ #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__) #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } diff --git a/fftools/textformat/tf_flat.c b/fftools/textformat/tf_flat.c index 919d44bc6b..05aae262ab 100644 --- a/fftools/textformat/tf_flat.c +++ b/fftools/textformat/tf_flat.c @@ -34,13 +34,9 @@ #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__) #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } diff --git a/fftools/textformat/tf_ini.c b/fftools/textformat/tf_ini.c index d8099ff92e..4c694bc78a 100644 --- a/fftools/textformat/tf_ini.c +++ b/fftools/textformat/tf_ini.c @@ -34,13 +34,9 @@ #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__) #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } diff --git a/fftools/textformat/tf_json.c b/fftools/textformat/tf_json.c index c26a912435..0a4c9f8b25 100644 --- a/fftools/textformat/tf_json.c +++ b/fftools/textformat/tf_json.c @@ -33,13 +33,9 @@ #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__) #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } diff --git a/fftools/textformat/tf_xml.c b/fftools/textformat/tf_xml.c index 6c89d01e9d..96751433ed 100644 --- a/fftools/textformat/tf_xml.c +++ b/fftools/textformat/tf_xml.c @@ -34,13 +34,9 @@ #define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__) #define DEFINE_FORMATTER_CLASS(name) \ -static const char *name##_get_name(void *ctx) \ -{ \ - return #name ; \ -} \ static const AVClass name##_class = { \ .class_name = #name, \ - .item_name = name##_get_name, \ + .item_name = av_default_item_name, \ .option = name##_options \ } -- 2.45.2
From 0a182581f6f18a476be2957402c66545681afb9f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 01:45:54 +0200 Subject: [PATCH 08/12] fftools/textformat/avtextformat: Fix segfault upon allocation error Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/avtextformat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index c1b5eefab4..7edf7901e4 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -590,10 +590,12 @@ int avtextwriter_context_close(AVTextWriterContext **pwctx) if (!wctx) return EINVAL; - if (wctx->writer->uninit) - wctx->writer->uninit(wctx); - if (wctx->writer->priv_class) - av_opt_free(wctx->priv); + if (wctx->writer) { + if (wctx->writer->uninit) + wctx->writer->uninit(wctx); + if (wctx->writer->priv_class) + av_opt_free(wctx->priv); + } av_freep(&wctx->priv); av_freep(pwctx); return ret; -- 2.45.2
From 36bd91e6fbdd5609dc6995fa8bc1e5b38eb5fc1a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 02:11:57 +0200 Subject: [PATCH 09/12] fftools/textformat/avtextformat: Fix segfault upon allocation error Would happen if an AVTextFormatContext's private context could not be allocated. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/avtextformat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index 7edf7901e4..5e225825ba 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -112,12 +112,14 @@ int avtext_context_close(AVTextFormatContext **ptctx) av_hash_freep(&tctx->hash); - if (tctx->formatter->uninit) - tctx->formatter->uninit(tctx); + if (tctx->formatter) { + if (tctx->formatter->uninit) + tctx->formatter->uninit(tctx); + if (tctx->formatter->priv_class) + av_opt_free(tctx->priv); + } for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) av_bprint_finalize(&tctx->section_pbuf[i], NULL); - if (tctx->formatter->priv_class) - av_opt_free(tctx->priv); av_freep(&tctx->priv); av_opt_free(tctx); av_freep(ptctx); -- 2.45.2
From 11cb1279b5f754901bd91e2f576f7b50129c528c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 02:15:20 +0200 Subject: [PATCH 10/12] fftools/textformat/avtextformat: Initialize stuff earlier avtext_context_close() calls av_opt_free() on an AVTextFormatContext as well as av_bprint_finalize() on the containing section_pbuf AvBPrints, yet it can happen that the AVBPrints have not been initialized (only zeroed) and that av_opt_set_defaults() has not been called. This works, but it is not really documented to do so. So ensure that the options and the AVBPrints have been initialized when avtext_context_close() is called. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/avtextformat.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index 5e225825ba..4a90d8664f 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -144,6 +144,12 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form goto fail; } + for (int i = 0; i < SECTION_MAX_NB_LEVELS; i++) + av_bprint_init(&tctx->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED); + + tctx->class = &textcontext_class; + av_opt_set_defaults(tctx); + if (!(tctx->priv = av_mallocz(formatter->priv_size))) { ret = AVERROR(ENOMEM); goto fail; @@ -161,15 +167,12 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form goto fail; } - tctx->class = &textcontext_class; tctx->formatter = formatter; tctx->level = -1; tctx->sections = sections; tctx->nb_sections = nb_sections; tctx->writer = writer_context; - av_opt_set_defaults(tctx); - if (formatter->priv_class) { void *priv_ctx = tctx->priv; *(const AVClass **)priv_ctx = formatter->priv_class; @@ -232,9 +235,6 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form } } - for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) - av_bprint_init(&tctx->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED); - if (tctx->formatter->init) ret = tctx->formatter->init(tctx); if (ret < 0) -- 2.45.2
From fee234c193f37d86835766f3354b9663e64060d0 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 02:30:48 +0200 Subject: [PATCH 11/12] fftools/textformat/avtextformat: Add missing AVERROR() Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/textformat/avtextformat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index 4a90d8664f..5abf81194e 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -106,7 +106,7 @@ int avtext_context_close(AVTextFormatContext **ptctx) int ret = 0; if (!tctx) - return EINVAL; + return AVERROR(EINVAL); av_hash_freep(&tctx->hash); @@ -590,7 +590,7 @@ int avtextwriter_context_close(AVTextWriterContext **pwctx) int ret = 0; if (!wctx) - return EINVAL; + return AVERROR(EINVAL); if (wctx->writer) { if (wctx->writer->uninit) -- 2.45.2
From 7902c892dadffb1a2ef560047df740842c551498 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinha...@outlook.com> Date: Tue, 15 Apr 2025 02:31:28 +0200 Subject: [PATCH 12/12] fftools/textformat/avtextformat: Make close functions return void Just like normal close functions. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- fftools/ffprobe.c | 14 +++----------- fftools/textformat/avtextformat.c | 11 ++++------- fftools/textformat/avtextformat.h | 2 +- fftools/textformat/avtextwriters.h | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 0953a029a0..f5c83925b9 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3077,7 +3077,7 @@ int main(int argc, char **argv) AVTextWriterContext *wctx; char *buf; char *f_name = NULL, *f_args = NULL; - int ret, input_ret, i; + int ret, i; init_dynload(); @@ -3197,19 +3197,11 @@ int main(int argc, char **argv) show_error(tctx, ret); } - input_ret = ret; - avtext_print_section_footer(tctx); - ret = avtextwriter_context_close(&wctx); - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing writer): %s\n", av_err2str(ret)); - - ret = avtext_context_close(&tctx); - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "Writing output failed (closing formatter): %s\n", av_err2str(ret)); + avtextwriter_context_close(&wctx); - ret = FFMIN(ret, input_ret); + avtext_context_close(&tctx); } end: diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index 5abf81194e..44085fc87a 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -99,14 +99,13 @@ static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size) av_bprintf(bp, "%02X", ubuf[i]); } -int avtext_context_close(AVTextFormatContext **ptctx) +void avtext_context_close(AVTextFormatContext **ptctx) { AVTextFormatContext *tctx = *ptctx; int i; - int ret = 0; if (!tctx) - return AVERROR(EINVAL); + return; av_hash_freep(&tctx->hash); @@ -123,7 +122,6 @@ int avtext_context_close(AVTextFormatContext **ptctx) av_freep(&tctx->priv); av_opt_free(tctx); av_freep(ptctx); - return ret; } @@ -584,13 +582,13 @@ static const AVClass textwriter_class = { }; -int avtextwriter_context_close(AVTextWriterContext **pwctx) +void avtextwriter_context_close(AVTextWriterContext **pwctx) { AVTextWriterContext *wctx = *pwctx; int ret = 0; if (!wctx) - return AVERROR(EINVAL); + return; if (wctx->writer) { if (wctx->writer->uninit) @@ -600,7 +598,6 @@ int avtextwriter_context_close(AVTextWriterContext **pwctx) } av_freep(&wctx->priv); av_freep(pwctx); - return ret; } diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h index 9fad3caae5..c2c56dc1a7 100644 --- a/fftools/textformat/avtextformat.h +++ b/fftools/textformat/avtextformat.h @@ -132,7 +132,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form int show_optional_fields, char *show_data_hash); -int avtext_context_close(AVTextFormatContext **tctx); +void avtext_context_close(AVTextFormatContext **tctx); void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id); diff --git a/fftools/textformat/avtextwriters.h b/fftools/textformat/avtextwriters.h index 87b0024ba1..c99d6b3548 100644 --- a/fftools/textformat/avtextwriters.h +++ b/fftools/textformat/avtextwriters.h @@ -55,7 +55,7 @@ typedef struct AVTextWriterContext { int avtextwriter_context_open(AVTextWriterContext **pwctx, const AVTextWriter *writer); -int avtextwriter_context_close(AVTextWriterContext **pwctx); +void avtextwriter_context_close(AVTextWriterContext **pwctx); int avtextwriter_create_stdout(AVTextWriterContext **pwctx); -- 2.45.2
_______________________________________________ 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".