[FFmpeg-devel] [PATCH 04/34] avcodec/bmpenc: Avoid copying packet data

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Apr 26 01:34:18 EEST 2021


When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data.

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

diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index e829d68475..867a53bd12 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -118,7 +118,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #define SIZE_BITMAPINFOHEADER 40
     hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER + (pal_entries << 2);
     n_bytes = n_bytes_image + hsize;
-    if ((ret = ff_alloc_packet2(avctx, pkt, n_bytes, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avctx, pkt, n_bytes, n_bytes)) < 0)
         return ret;
     buf = pkt->data;
     bytestream_put_byte(&buf, 'B');                   // BITMAPFILEHEADER.bfType
-- 
2.27.0



More information about the ffmpeg-devel mailing list