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

Ho Ming Shun cyph1984 at gmail.com
Fri Sep 24 12:04:36 EEST 2021


Use spare packet allocated in DecodeSimpleContext to handle packet
submission into ffmmal_add_packet.

Signed-off-by: Ho Ming Shun <cyph1984 at gmail.com>
---
 libavcodec/mmaldec.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index d4788b33f3..a8a568d239 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -781,10 +781,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);
@@ -795,9 +797,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;
-- 
2.33.0



More information about the ffmpeg-devel mailing list