diff mbox series

[FFmpeg-devel] avcodec/xbmenc: Better xbm memory use

Message ID 202101101411.39756.digital@joescat.com
State New
Headers show
Series [FFmpeg-devel] avcodec/xbmenc: Better xbm memory use
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Jose Da Silva Jan. 10, 2021, 10:11 p.m. UTC
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"
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 <digital@joescat.com>
---
 libavcodec/xbmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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;