Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint
Date: Mon, 25 Mar 2024 02:54:20 +0100
Message-ID: <GV1P250MB073748086299D3F4BFA6D0788F362@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737A3C15A0BD099059367808F302@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

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

_______________________________________________
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".

      parent reply	other threads:[~2024-03-25  1:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23 12:17 Andreas Rheinhardt
2024-03-23 12:18 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mpegutils: Simplify indenting Andreas Rheinhardt
2024-03-25  1:54 ` Andreas Rheinhardt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=GV1P250MB073748086299D3F4BFA6D0788F362@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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