diff mbox series

[FFmpeg-devel,02/34] avcodec/adxenc: Avoid copying packet data

Message ID HE1PR0301MB21541A232DB1268ED28179288F439@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel,01/34] avcodec/adpcmenc: Avoid copying packet data | expand

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

Andreas Rheinhardt April 25, 2021, 10:34 p.m. UTC
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@outlook.com>
---
 libavcodec/adxenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index 93b902b0e1..fabbc00aa6 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -148,7 +148,7 @@  static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     if (!samples) {
         if (c->eof)
             return 0;
-        if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 0)) < 0)
+        if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 18)) < 0)
             return ret;
         c->eof = 1;
         dst = avpkt->data;
@@ -162,7 +162,7 @@  static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     }
 
     out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * HEADER_SIZE;
-    if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, out_size)) < 0)
         return ret;
     dst = avpkt->data;