Message ID | GV1P250MB0737A3C15A0BD099059367808F302@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM |
---|---|
State | Accepted |
Commit | 5eda98f382103be8bc626fa36408b51a996b6518 |
Headers | show |
Series | [FFmpeg-devel,1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/mpegutils.c | 21 +++++---------------- > 1 file 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); > } > } Will apply this patchset tomorrow unless there are objections. - Andreas
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); } }
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpegutils.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)