[FFmpeg-cvslog] siff: simplify code by using ffio_limit()

Michael Niedermayer git at videolan.org
Tue Dec 20 00:15:28 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Dec 19 19:23:56 2011 +0100| [b08a742526d05bcf300af820da5c79d2a05f9959] | committer: Michael Niedermayer

siff: simplify code by using ffio_limit()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/siff.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/siff.c b/libavformat/siff.c
index 51dc694..1a3f0a4 100644
--- a/libavformat/siff.c
+++ b/libavformat/siff.c
@@ -22,6 +22,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
+#include "avio_internal.h"
 
 enum SIFFTags{
     TAG_SIFF = MKTAG('S', 'I', 'F', 'F'),
@@ -201,18 +202,16 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
         }
 
         if (!c->curstrm){
-            int64_t fsize= avio_size(s->pb);
-            size = c->pktsize - c->sndsize;
-            if(fsize>0)
-                size= FFMIN(size, fsize - avio_tell(s->pb) + c->gmcsize + 3);
-            if(size < 2 + c->gmcsize || c->pktsize < c->sndsize)
+            size = c->pktsize - c->sndsize - c->gmcsize - 2;
+            size = ffio_limit(s->pb, size);
+            if(size < 0 || c->pktsize < c->sndsize)
                 return AVERROR_INVALIDDATA;
-            if (av_new_packet(pkt, size) < 0)
+            if (av_new_packet(pkt, size + c->gmcsize + 2) < 0)
                 return AVERROR(ENOMEM);
             AV_WL16(pkt->data, c->flags);
             if (c->gmcsize)
                 memcpy(pkt->data + 2, c->gmc, c->gmcsize);
-            avio_read(s->pb, pkt->data + 2 + c->gmcsize, size - c->gmcsize - 2);
+            avio_read(s->pb, pkt->data + 2 + c->gmcsize, size);
             pkt->stream_index = 0;
             c->curstrm = -1;
         }else{



More information about the ffmpeg-cvslog mailing list