Small memory reduction which uses approx 6/7th total memory.
Assuming \n is 2bytes, we first need {32+33+40+5}=110
but we also need to include the terminating zero => 110+1 = 111 (bug-fix).

Then assuming \n is 2bytes, data requires => height * (linesize * 6 + 2)
For example, " 0x00, 0x11, 0x22,\n"
From 81436261e6de8ddaf1ce3c6f010ab2c018f92eb8 Mon Sep 17 00:00:00 2001
From: Joe Da Silva <digi...@joescat.com>
Date: Sun, 10 Jan 2021 01:35:05 -0800
Subject: [PATCH] avcodec/xbmenc: Better xbm memory use

Small memory reduction which uses approx 6/7th total memory.
Assuming \n is 2bytes, we first need {32+33+40+5}=110
but we also need to include the terminating zero => 110+1 = 111

Assuming \n is 2bytes, data requires => height * (linesize * 6 + 2)
For example, " 0x00, 0x11, 0x22,\n"

Signed-off-by: Joe Da Silva <digi...@joescat.com>
---
 libavcodec/xbmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index b25615f2a4..9222947893 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -31,7 +31,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint8_t *ptr, *buf;
 
     linesize = (avctx->width + 7) / 8;
-    size     = avctx->height * (linesize * 7 + 2) + 110;
+    size     = avctx->height * (linesize * 6 + 2) + 111;
     if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0)
         return ret;
 
-- 
2.30.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to