* [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: make debug_info2 thread safe
@ 2023-12-29 17:20 Zhao Zhili
0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2023-12-29 17:20 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
---
libavcodec/mpegutils.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 5e76d7ac66..a565773c5e 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -20,6 +20,7 @@
#include <stdint.h>
+#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/emms.h"
#include "libavutil/frame.h"
@@ -250,31 +251,41 @@ 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;
av_log(avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
av_get_picture_type_char(pict->pict_type));
for (y = 0; y < mb_height; y++) {
+ av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
for (x = 0; x < mb_width; x++) {
if (avctx->debug & FF_DEBUG_SKIP) {
int count = mbskip_table ? mbskip_table[x + y * mb_stride] : 0;
if (count > 9)
count = 9;
- av_log(avctx, AV_LOG_DEBUG, "%1d", count);
+ av_bprintf(&buf, "%1d", count);
}
if (avctx->debug & FF_DEBUG_QP) {
- av_log(avctx, AV_LOG_DEBUG, "%2d",
- qscale_table[x + y * mb_stride]);
+ av_bprintf(&buf, "%2d", qscale_table[x + y * mb_stride]);
}
if (avctx->debug & FF_DEBUG_MB_TYPE) {
int mb_type = mbtype_table[x + y * mb_stride];
- av_log(avctx, AV_LOG_DEBUG, "%c%c%c",
+ av_bprintf(&buf, "%c%c%c",
get_type_mv_char(mb_type),
get_segmentation_char(mb_type),
get_interlacement_char(mb_type));
}
}
- av_log(avctx, AV_LOG_DEBUG, "\n");
+
+ 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);
}
}
}
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-29 9:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 17:20 [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: make debug_info2 thread safe Zhao Zhili
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git