[FFmpeg-cvslog] avcodec/mpegutils: make debug_info2 thread safe
Zhao Zhili
git at videolan.org
Thu Jan 4 11:54:45 EET 2024
ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Sat Dec 30 01:20:15 2023 +0800| [bd48c08f80d225a8c7fbd7997f390018542b2c20] | committer: Zhao Zhili
avcodec/mpegutils: make debug_info2 thread safe
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd48c08f80d225a8c7fbd7997f390018542b2c20
---
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);
}
}
}
More information about the ffmpeg-cvslog
mailing list