diff mbox series

[FFmpeg-devel,3/9] avcodec/libxevd: Avoid cloning AVPacket

Message ID AS8P250MB07446A3903E3E978FA4CF1E18F592@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 85fc5a0c3f39a00d18af2fb9e2d25a3471052684
Headers show
Series [FFmpeg-devel,1/9] avcodec/libxevd: Remove FF_CODEC_CAP_SETS_PKT_DTS cap | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 27, 2024, 7:58 p.m. UTC
Cloning a packet whose source is going to be unreferenced
immediately afterwards is wasteful.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/libxevd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff mbox series

Patch

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