[FFmpeg-devel] [PATCH v3 2/5] avcodec/mmaldec: re-use AVPacket for extra_data
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Thu Dec 9 15:08:02 EET 2021
From: Ho Ming Shun <cyph1984 at gmail.com>
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 at gmail.com>
---
libavcodec/mmaldec.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index d336f10350..68ecc68f17 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -782,12 +782,10 @@ static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
int got_frame = 0;
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;
}
--
2.32.0
More information about the ffmpeg-devel
mailing list