[FFmpeg-devel] [PATCH 31/34] avcodec/libgsmenc: Avoid copying packet data

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Apr 26 01:34:45 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>
---
These encoders have the most unorthodox way of using their private data
that I have ever seen. Will fix it later.

 libavcodec/libgsmenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c
index fdb11c705e..eeaa5b2a10 100644
--- a/libavcodec/libgsmenc.c
+++ b/libavcodec/libgsmenc.c
@@ -98,7 +98,8 @@ static int libgsm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     gsm_signal *samples = (gsm_signal *)frame->data[0];
     struct gsm_state *state = avctx->priv_data;
 
-    if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align,
+                                              avctx->block_align)) < 0)
         return ret;
 
     switch(avctx->codec_id) {
-- 
2.27.0



More information about the ffmpeg-devel mailing list