diff mbox series

[FFmpeg-devel,32/34] avcodec/libtheoraenc: Avoid copying packet data

Message ID HE1PR0301MB2154185F500120BD442BC88B8F439@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/libtheoraenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 16966ed433..5dd8c2084f 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -339,7 +339,8 @@  static int encode_frame(AVCodecContext* avc_context, AVPacket *pkt,
     }
 
     /* Copy ogg_packet content out to buffer */
-    if ((ret = ff_alloc_packet2(avc_context, pkt, o_packet.bytes, 0)) < 0)
+    if ((ret = ff_alloc_packet2(avc_context, pkt, o_packet.bytes,
+                                                  o_packet.bytes)) < 0)
         return ret;
     memcpy(pkt->data, o_packet.packet, o_packet.bytes);