Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint
@ 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 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint Andreas Rheinhardt
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-23 12:17 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: 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);
     }
 }
-- 
2.40.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] 3+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avcodec/mpegutils: Simplify indenting
  2024-03-23 12:17 [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint Andreas Rheinhardt
@ 2024-03-23 12:18 ` Andreas Rheinhardt
  2024-03-25  1:54 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint Andreas Rheinhardt
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-23 12:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegutils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index 7f499b3d0f..d94e8f422f 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -265,7 +265,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
             margin_left++;
 
         av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
-        av_bprintf(&buf, "%*s", margin_left, " ");
+        av_bprint_chars(&buf, ' ', margin_left);
 
         n = 0;
         if (avctx->debug & FF_DEBUG_SKIP)
-- 
2.40.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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint
  2024-03-23 12:17 [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint 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
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-03-25  1:54 UTC (permalink / raw)
  To: ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-25  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-23 12:17 [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint Andreas Rheinhardt
2024-03-23 12:18 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mpegutils: Simplify indenting Andreas Rheinhardt
2024-03-25  1:54 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint Andreas Rheinhardt

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