diff mbox series

[FFmpeg-devel,3/3] avcodec/libopusenc: Remove redundant av_packet_unref()

Message ID AS8P250MB0744BB17AEC0F4B331DC5B848FB99@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit adb5f7b41faf354a3e0bf722f44aeb230aefa310
Headers show
Series [FFmpeg-devel,1/3] avcodec/libmp3lame: Remove redundant av_packet_unref() | 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 March 13, 2023, 4:15 a.m. UTC
The AVPacket given to an encoder's encode callback
is unreferenced generically on error.

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

Patch

diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 75bc491c9e..5a0786f32f 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -512,18 +512,14 @@  static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
 
     discard_padding = opus->opts.packet_size - avpkt->duration;
     // Check if subtraction resulted in an overflow
-    if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
-        av_packet_unref(avpkt);
+    if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0))
         return AVERROR(EINVAL);
-    }
     if (discard_padding > 0) {
         uint8_t* side_data = av_packet_new_side_data(avpkt,
                                                      AV_PKT_DATA_SKIP_SAMPLES,
                                                      10);
-        if(!side_data) {
-            av_packet_unref(avpkt);
+        if (!side_data)
             return AVERROR(ENOMEM);
-        }
         AV_WL32(side_data + 4, discard_padding);
     }