aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-16 15:40:21 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-16 16:58:12 +0100
commit559ae20dda9e84abf878ee10f8dcea78dacfd0cc (patch)
treeb8b178b1fdb3613beed2c765ee126b89a688b052 /libavformat
parent39f59a8da7f024532b0d62ad429a7a8ffaa2d631 (diff)
downloadffmpeg-559ae20dda9e84abf878ee10f8dcea78dacfd0cc.tar.gz
lavf: Update AVIOContext.maxsize when hitting the end.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 10cd6f3066..379ee2b34b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -269,10 +269,17 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
- if(s->maxsize>0){
+ if(s->maxsize>=0){
int64_t remaining= s->maxsize - avio_tell(s);
- if(remaining>=0)
- size= FFMIN(size, remaining);
+ if(remaining < size){
+ int64_t newsize= avio_size(s);
+ if(!s->maxsize || s->maxsize<newsize)
+ s->maxsize= newsize;
+ remaining= s->maxsize - avio_tell(s);
+ }
+
+ if(s->maxsize>=0 && remaining>=0)
+ size= FFMIN(size, remaining+1);
}
ret= av_new_packet(pkt, size);