diff mbox series

[FFmpeg-devel,v2,3/4] avcodec/mmaldec: re-use AVPacket for extra_data

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

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Ming Shun Ho Sept. 24, 2021, 9:04 a.m. UTC
extra_data and normal packets (from ff_decode_get_packet) processing do
not overlap, thus we can re-use the spare AVPacket to send to
ffmmal_add_packet.

Furthermore, this removes allocation of AVPacket on the stack and stops
using deprecated av_init_packet.

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

Patch

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index a8a568d239..6dbb991ae1 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -788,12 +788,10 @@  static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
     AVPacket *avpkt = avctx->internal->ds.in_pkt;
 
     if (avctx->extradata_size && !ctx->extradata_sent) {
-        AVPacket pkt = {0};
-        av_init_packet(&pkt);
-        pkt.data = avctx->extradata;
-        pkt.size = avctx->extradata_size;
+        avpkt->data = avctx->extradata;
+        avpkt->size = avctx->extradata_size;
         ctx->extradata_sent = 1;
-        if ((ret = ffmmal_add_packet(avctx, &pkt, 1)) < 0)
+        if ((ret = ffmmal_add_packet(avctx, avpkt, 1)) < 0)
             return ret;
     }