[FFmpeg-devel] [PATCH 04/48] avcodec/mmal: use av_packet_alloc() to allocate packets

James Almer jamrial at gmail.com
Fri Mar 5 18:32:55 EET 2021


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/mmaldec.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index cb15ac072a..ed51d74de5 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -776,12 +776,17 @@ static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
     int ret = 0;
 
     if (avctx->extradata_size && !ctx->extradata_sent) {
-        AVPacket pkt = {0};
-        av_init_packet(&pkt);
-        pkt.data = avctx->extradata;
-        pkt.size = avctx->extradata_size;
+        AVPacket *pkt;
+
+        pkt = av_packet_alloc();
+        if (!pkt)
+            return AVERROR(ENOMEM);
+        pkt->data = avctx->extradata;
+        pkt->size = avctx->extradata_size;
         ctx->extradata_sent = 1;
-        if ((ret = ffmmal_add_packet(avctx, &pkt, 1)) < 0)
+        ret = ffmmal_add_packet(avctx, pkt, 1);
+        av_packet_free(&pkt);
+        if (ret < 0)
             return ret;
     }
 
-- 
2.30.1



More information about the ffmpeg-devel mailing list