[FFmpeg-cvslog] avformat/evcdec: remove unnecessary av_packet_unref() calls

James Almer git at videolan.org
Wed Jun 21 19:51:05 EEST 2023


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Jun 19 23:35:37 2023 -0300| [43ace56c7e79aa94aa5437911e4a3424821d7ab6] | committer: James Almer

avformat/evcdec: remove unnecessary av_packet_unref() calls

And return proper error codes.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43ace56c7e79aa94aa5437911e4a3424821d7ab6
---

 libavformat/evcdec.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 9c4969e78f..68f3a91e53 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -186,11 +186,8 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     EVCDemuxContext *const c = s->priv_data;
 
-    int eof = avio_feof (s->pb);
-    if(eof) {
-        av_packet_unref(pkt);
+    if (avio_feof(s->pb))
         return AVERROR_EOF;
-    }
 
     while(!au_end_found) {
         uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
@@ -200,16 +197,12 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
             return ret;
 
         ret = avio_read(s->pb, (unsigned char *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE);
-        if (ret < 0) {
-            av_packet_unref(pkt);
+        if (ret < 0)
             return ret;
-        }
 
         nalu_size = read_nal_unit_length((const uint8_t *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE);
-        if(nalu_size <= 0) {
-            av_packet_unref(pkt);
-            return -1;
-        }
+        if (nalu_size <= 0)
+            return AVERROR_INVALIDDATA;
 
         avio_seek(s->pb, -EVC_NALU_LENGTH_PREFIX_SIZE, SEEK_CUR);
 
@@ -217,7 +210,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (ret < 0)
             return ret;
         if (ret != (nalu_size + EVC_NALU_LENGTH_PREFIX_SIZE))
-            return AVERROR(EIO);
+            return AVERROR_INVALIDDATA;
 
         ret = av_bsf_send_packet(c->bsf, pkt);
         if (ret < 0) {



More information about the ffmpeg-cvslog mailing list