Skip to content

Commit

Permalink
lavf: split out ffio_limit()
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Dec 19, 2011
1 parent f85334f commit e39eeb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions libavformat/avio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions libavformat/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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);

Expand Down

0 comments on commit e39eeb1

Please sign in to comment.