aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2023-12-30 01:20:15 +0800
committerZhao Zhili <zhilizhao@tencent.com>2024-01-04 17:33:56 +0800
commitbd48c08f80d225a8c7fbd7997f390018542b2c20 (patch)
tree8f869049c423468d528c08440fa0ab6598c2c822
parent7f900a737f9592f93e7cc3be1bc9b45704371ecd (diff)
downloadffmpeg-bd48c08f80d225a8c7fbd7997f390018542b2c20.tar.gz
avcodec/mpegutils: make debug_info2 thread safe
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--libavcodec/mpegutils.c21
1 files 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);
}
}
}