diff mbox series

[FFmpeg-devel,25/34] avcodec/libx264: Avoid copying packet data

Message ID HE1PR0301MB21540C6750201C0B4E591A718F439@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 fail Make fate failed
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

Andreas Rheinhardt April 25, 2021, 10:34 p.m. UTC
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can pass this information to ff_alloc_packet2() to
avoid the implicit use of another intermediate buffer for the packet data.

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

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 4ddc4973a4..b23471a809 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -144,7 +144,7 @@  static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
     for (i = 0; i < nnal; i++)
         size += nals[i].i_payload;
 
-    if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0)
+    if ((ret = ff_alloc_packet2(ctx, pkt, size, size)) < 0)
         return ret;
 
     p = pkt->data;