aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-03-23 13:01:11 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-03-26 06:30:45 +0100
commit5eda98f382103be8bc626fa36408b51a996b6518 (patch)
treeadab601cb9fe3454f4a323bb14e68a17c023ef23
parent0963ef4996ca94eb37c0c29d9b9e18ac00fe5f29 (diff)
downloadffmpeg-5eda98f382103be8bc626fa36408b51a996b6518.tar.gz
avcodec/mpegutils: Avoid allocations when using AVBPrint
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/mpegutils.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index fc3e270631..7f499b3d0f 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -252,7 +252,6 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
if (avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
int x,y;
AVBPrint buf;
- char *str = NULL;
int n;
int margin_left;
int x_step;
@@ -278,16 +277,11 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
x_step = (mb_width * 16 > 999) ? 8 : 4;
for (x = 0; x < mb_width; x += x_step)
av_bprintf(&buf, "%-*d", n * x_step, x << 4);
- n = av_bprint_finalize(&buf, &str);
- if (n < 0) {
- av_log(avctx, AV_LOG_ERROR, "%s failed, %s\n", __func__, av_err2str(n));
- return;
- }
- av_log(avctx, AV_LOG_DEBUG, "%s\n", str);
- av_freep(&str);
+
+ av_log(avctx, AV_LOG_DEBUG, "%s\n", buf.str);
for (y = 0; y < mb_height; y++) {
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
for (x = 0; x < mb_width; x++) {
if (x == 0)
av_bprintf(&buf, "%*d ", margin_left - 1, y << 4);
@@ -310,13 +304,8 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
}
}
- n = av_bprint_finalize(&buf, &str);
- if (n < 0) {
- av_log(avctx, AV_LOG_ERROR, "%s failed, %s\n", __func__, av_err2str(n));
- return;
- }
- av_log(avctx, AV_LOG_DEBUG, "%s\n", str);
- av_freep(&str);
+ av_log(avctx, AV_LOG_DEBUG, "%s\n", buf.str);
}
+ av_bprint_finalize(&buf, NULL);
}
}