diff mbox series

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

Message ID 20210305163339.63164-5-jamrial@gmail.com
State New
Headers show
Series deprecate av_init_packet() and sizeof(AVPacket) as part of the ABI | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer March 5, 2021, 4:32 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/mmaldec.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

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;
     }