The libshine encoder already uses an internal buffer, so that the
packet size is already known before allocating the packet; therefore
one can avoid another (implicit) intermediate buffer by setting
the min_size parameter in ff_alloc_packet2().

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
---
 libavcodec/libshine.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c
index 7056fcd2e3..dcda996ad1 100644
--- a/libavcodec/libshine.c
+++ b/libavcodec/libshine.c
@@ -102,7 +102,7 @@ static int libshine_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
     len = hdr.frame_size;
     if (len <= s->buffer_index) {
-        if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0)))
+        if ((ret = ff_alloc_packet2(avctx, avpkt, len, len)))
             return ret;
         memcpy(avpkt->data, s->buffer, len);
         s->buffer_index -= len;
@@ -111,7 +111,6 @@ static int libshine_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
         ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
                            &avpkt->duration);
 
-        avpkt->size = len;
         *got_packet_ptr = 1;
     }
     return 0;
-- 
2.27.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to