Mercurial > libavformat.hg
changeset 1612:a6eaa0762191 libavformat
seekless filesize retrieving support in 7 lines of code, also doesnt break compatibility
author | michael |
---|---|
date | Mon, 01 Jan 2007 21:49:09 +0000 |
parents | cab8434bfeab |
children | 387dc458ba37 |
files | avio.c avio.h aviobuf.c |
diffstat | 3 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/avio.c Mon Jan 01 21:17:14 2007 +0000 +++ b/avio.c Mon Jan 01 21:49:09 2007 +0000 @@ -148,9 +148,12 @@ { offset_t pos, size; + size= url_seek(h, 0, AVSEEK_SIZE); + if(size<0){ pos = url_seek(h, 0, SEEK_CUR); size = url_seek(h, -1, SEEK_END)+1; url_seek(h, pos, SEEK_SET); + } return size; }
--- a/avio.h Mon Jan 01 21:17:14 2007 +0000 +++ b/avio.h Mon Jan 01 21:49:09 2007 +0000 @@ -69,6 +69,8 @@ /* not implemented */ int url_poll(URLPollEntry *poll_table, int n, int timeout); +#define AVSEEK_SIZE 0x10000 + typedef struct URLProtocol { const char *name; int (*url_open)(URLContext *h, const char *filename, int flags);
--- a/aviobuf.c Mon Jan 01 21:17:14 2007 +0000 +++ b/aviobuf.c Mon Jan 01 21:49:09 2007 +0000 @@ -170,8 +170,11 @@ if (!s->seek) return -EPIPE; + size = s->seek(s->opaque, 0, AVSEEK_SIZE); + if(size<0){ size = s->seek(s->opaque, -1, SEEK_END) + 1; s->seek(s->opaque, s->pos, SEEK_SET); + } return size; }