avcodec/libxevd: Avoid cloning AVPacket

Cloning a packet whose source is going to be unreferenced
immediately afterwards is wasteful.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2024-02-27 19:22:37 +01:00
parent 4e14a8e6be
commit 85fc5a0c3f

View File

@@ -286,17 +286,14 @@ static int libxevd_receive_frame(AVCodecContext *avctx, AVFrame *frame)
XEVD_STAT stat; XEVD_STAT stat;
XEVD_BITB bitb; XEVD_BITB bitb;
int nalu_size; int nalu_size;
AVPacket* pkt_au; AVPacket *pkt_au = av_packet_alloc();
imgb = NULL; imgb = NULL;
pkt_au = av_packet_clone(pkt);
if (!pkt_au) { if (!pkt_au) {
av_log(avctx, AV_LOG_ERROR, "Cannot clone AVPacket\n");
av_packet_unref(pkt); av_packet_unref(pkt);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
FFSWAP(AVPacket*, pkt_au, xectx->pkt);
av_packet_unref(pkt);
// get all nal units from AU // get all nal units from AU
while(pkt_au->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) { while(pkt_au->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) {