diff mbox series

[FFmpeg-devel,2/4] avcodec/mmaldec: use avpkt from DecodeSimpleContext

Message ID 20210924062838.7461-3-cyph1984@gmail.com
State New
Headers show
Series Switch mmaldec to decoupled dataflow
Related show

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Ming Shun Ho Sept. 24, 2021, 6:28 a.m. UTC
Use spare packet allocated in DecodeSimpleContext to handle packet
submission into ffmmal_add_packet.
---
 libavcodec/mmaldec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index b97cc6ff5e..aab107d325 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -786,10 +786,12 @@  done:
 static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 {
     MMALDecodeContext *ctx = avctx->priv_data;
-    AVPacket avpkt = {0};
     int ret = 0;
     int got_frame = 0;
 
+    // use spare packet from DecodeSimpleContext meant for simple API
+    AVPacket *avpkt = avctx->internal->ds.in_pkt;
+
     if (avctx->extradata_size && !ctx->extradata_sent) {
         AVPacket pkt = {0};
         av_init_packet(&pkt);
@@ -800,9 +802,9 @@  static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
             return ret;
     }
 
-    ret = ff_decode_get_packet(avctx, &avpkt);
+    ret = ff_decode_get_packet(avctx, avpkt);
     if(ret == 0) {
-        if ((ret = ffmmal_add_packet(avctx, &avpkt, 0)) < 0)
+        if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
             return ret;
     } else if(ret < 0 && !(ret == AVERROR(EAGAIN)))
         return ret;