[FFmpeg-cvslog] avformat/amvenc: Avoid allocating packet

Andreas Rheinhardt git at videolan.org
Sun Oct 3 23:48:54 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Mar 18 06:58:05 2021 +0100| [4e6e14f49606b07896a8c512d9ea72d2c2656387] | committer: Andreas Rheinhardt

avformat/amvenc: Avoid allocating packet

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e6e14f49606b07896a8c512d9ea72d2c2656387
---

 libavformat/amvenc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/amvenc.c b/libavformat/amvenc.c
index cb03f00ed7..fece2f49b1 100644
--- a/libavformat/amvenc.c
+++ b/libavformat/amvenc.c
@@ -62,7 +62,7 @@ typedef struct AMVContext
 
     int32_t aframe_size;  /* Expected audio frame size.      */
     int32_t ablock_align; /* Expected audio block align.     */
-    AVPacket *apad;       /* Dummy audio packet for padding. */
+    AVPacket *apad;       /* Dummy audio packet for padding; not owned by us. */
     AVPacket *vpad;       /* Most recent video frame, for padding. */
 
     /*
@@ -183,9 +183,7 @@ static av_cold int amv_init(AVFormatContext *s)
     }
 
     /* Allocate and fill dummy packet so we can pad the audio. */
-    amv->apad = av_packet_alloc();
-    if (!amv->apad)
-        return AVERROR(ENOMEM);
+    amv->apad = ffformatcontext(s)->pkt;
     if ((ret = av_new_packet(amv->apad, amv->ablock_align)) < 0) {
         return ret;
     }
@@ -207,7 +205,6 @@ static void amv_deinit(AVFormatContext *s)
 {
     AMVContext *amv = s->priv_data;
 
-    av_packet_free(&amv->apad);
     av_packet_free(&amv->vpad);
 }
 



More information about the ffmpeg-cvslog mailing list