diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-19 11:46:34 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-03 19:49:56 +0100 |
commit | 3461d275063a4fe47e0dfc90cebe4cb54b69cca1 (patch) | |
tree | 0abcb04e25115d137db2939e979b5dba0561b486 | |
parent | 9c338b7c4ceef726c6e8064fe5fbcee325c3d3f2 (diff) | |
download | ffmpeg-3461d275063a4fe47e0dfc90cebe4cb54b69cca1.tar.gz |
lavf: split out ffio_limit()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit e39eeb10d1b36b5681e42a7539d5b168fa292d61)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/avio_internal.h | 2 | ||||
-rw-r--r-- | libavformat/utils.c | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index f140897c5d..df614b22d9 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -71,6 +71,8 @@ uint64_t ffio_read_varlen(AVIOContext *bc); /** @warning must be called before any I/O */ int ffio_set_buf_size(AVIOContext *s, int buf_size); +int ffio_limit(AVIOContext *s, int size); + void ffio_init_checksum(AVIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); diff --git a/libavformat/utils.c b/libavformat/utils.c index 308d0cdf46..5ed85dc857 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -264,11 +264,8 @@ AVInputFormat *av_find_input_format(const char *short_name) return NULL; } - -int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) +int ffio_limit(AVIOContext *s, int size) { - int ret; - if(s->maxsize>=0){ int64_t remaining= s->maxsize - avio_tell(s); if(remaining < size){ @@ -283,6 +280,13 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) size= remaining+1; } } + return size; +} + +int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) +{ + int ret; + size= ffio_limit(s, size); ret= av_new_packet(pkt, size); |