avcodec/mmaldec: re-use AVPacket for extra_data

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.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
This commit is contained in:
Ho Ming Shun 2021-09-24 17:04:37 +08:00 committed by Andreas Rheinhardt
parent b54377b3a7
commit 6f0e8b998a

View File

@ -782,12 +782,10 @@ static int ffmmal_receive_frame(AVCodecContext *avctx, AVFrame *frame)
int got_frame = 0; int got_frame = 0;
if (avctx->extradata_size && !ctx->extradata_sent) { if (avctx->extradata_size && !ctx->extradata_sent) {
AVPacket pkt = {0}; avpkt->data = avctx->extradata;
av_init_packet(&pkt); avpkt->size = avctx->extradata_size;
pkt.data = avctx->extradata;
pkt.size = avctx->extradata_size;
ctx->extradata_sent = 1; ctx->extradata_sent = 1;
if ((ret = ffmmal_add_packet(avctx, &pkt, 1)) < 0) if ((ret = ffmmal_add_packet(avctx, avpkt, 1)) < 0)
return ret; return ret;
} }