Mercurial > libavformat.hg
changeset 764:cdb845a57ae4 libavformat
drop most url_fileno() calls (allows to use ByteIOContext directly in caller apps instead of URLProtocol)
author | aurel |
---|---|
date | Thu, 19 May 2005 00:06:27 +0000 |
parents | 635cd38a1e87 |
children | 769c2a9062c1 |
files | avidec.c avio.h aviobuf.c dv.c ffm.c img2.c mov.c mp3.c ogg2.c utils.c yuv.c |
diffstat | 11 files changed, 26 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/avidec.c Tue May 17 22:47:34 2005 +0000 +++ b/avidec.c Thu May 19 00:06:27 2005 +0000 @@ -125,7 +125,7 @@ if (tag1 == MKTAG('m', 'o', 'v', 'i')) { avi->movi_list = url_ftell(pb) - 4; if(size) avi->movi_end = avi->movi_list + size; - else avi->movi_end = url_filesize(url_fileno(pb)); + else avi->movi_end = url_fsize(pb); #ifdef DEBUG printf("movi end=%Lx\n", avi->movi_end); #endif @@ -486,7 +486,7 @@ if (i >= avi->movi_end) { if (avi->is_odml) { url_fskip(pb, avi->riff_end - i); - avi->riff_end = avi->movi_end = url_filesize(url_fileno(pb)); + avi->riff_end = avi->movi_end = url_fsize(pb); } else break; }
--- a/avio.h Tue May 17 22:47:34 2005 +0000 +++ b/avio.h Thu May 19 00:06:27 2005 +0000 @@ -109,6 +109,7 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence); void url_fskip(ByteIOContext *s, offset_t offset); offset_t url_ftell(ByteIOContext *s); +offset_t url_fsize(ByteIOContext *s); int url_feof(ByteIOContext *s); int url_ferror(ByteIOContext *s);
--- a/aviobuf.c Tue May 17 22:47:34 2005 +0000 +++ b/aviobuf.c Thu May 19 00:06:27 2005 +0000 @@ -172,6 +172,17 @@ return url_fseek(s, 0, SEEK_CUR); } +offset_t url_fsize(ByteIOContext *s) +{ + offset_t size; + + if (!s->seek) + return -EPIPE; + size = s->seek(s->opaque, -1, SEEK_END) + 1; + s->seek(s->opaque, s->pos, SEEK_SET); + return size; +} + int url_feof(ByteIOContext *s) { return s->eof_reached;
--- a/dv.c Tue May 17 22:47:34 2005 +0000 +++ b/dv.c Thu May 19 00:06:27 2005 +0000 @@ -815,7 +815,7 @@ // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) const DVprofile* sys = dv_codec_profile(&c->vst->codec); int64_t offset; - int64_t size = url_filesize(url_fileno(&s->pb)); + int64_t size = url_fsize(&s->pb); int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; offset = sys->frame_size * timestamp;
--- a/ffm.c Tue May 17 22:47:34 2005 +0000 +++ b/ffm.c Thu May 19 00:06:27 2005 +0000 @@ -462,7 +462,7 @@ ffm->write_index = get_be64(pb); /* get also filesize */ if (!url_is_streamed(pb)) { - ffm->file_size = url_filesize(url_fileno(pb)); + ffm->file_size = url_fsize(pb); adjust_write_index(s); } else { ffm->file_size = (uint64_t_C(1) << 63) - 1;
--- a/img2.c Tue May 17 22:47:34 2005 +0000 +++ b/img2.c Thu May 19 00:06:27 2005 +0000 @@ -244,7 +244,7 @@ for(i=0; i<3; i++){ if (url_fopen(f[i], filename, URL_RDONLY) < 0) return AVERROR_IO; - size[i]= url_filesize(url_fileno(f[i])); + size[i]= url_fsize(f[i]); if(codec->codec_id != CODEC_ID_RAWVIDEO) break;
--- a/mov.c Tue May 17 22:47:34 2005 +0000 +++ b/mov.c Thu May 19 00:06:27 2005 +0000 @@ -1740,7 +1740,7 @@ mov->mp4 = 1; #endif if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ - atom.size = url_filesize(url_fileno(pb)); + atom.size = url_fsize(pb); else atom.size = 0x7FFFFFFFFFFFFFFFLL;
--- a/mp3.c Tue May 17 22:47:34 2005 +0000 +++ b/mp3.c Thu May 19 00:06:27 2005 +0000 @@ -258,7 +258,7 @@ /* try to get the TAG */ if (!url_is_streamed(&s->pb)) { /* XXX: change that */ - filesize = url_filesize(url_fileno(&s->pb)); + filesize = url_fsize(&s->pb); if (filesize > 128) { url_fseek(&s->pb, filesize - 128, SEEK_SET); ret = get_buffer(&s->pb, buf, ID3_TAG_SIZE);
--- a/ogg2.c Tue May 17 22:47:34 2005 +0000 +++ b/ogg2.c Thu May 19 00:06:27 2005 +0000 @@ -449,7 +449,6 @@ ogg_get_length (AVFormatContext * s) { ogg_t *ogg = s->priv_data; - URLContext *h = url_fileno (&s->pb); int idx = -1, i; //FIXME: get the right ctx flag to know if is seekable or not // if(ogg->f->flags & URL_FLAG_STREAMED) @@ -460,7 +459,7 @@ return 0; ogg_save (s); - url_seek (h, -MAX_PAGE_SIZE, SEEK_END); + url_fseek (&s->pb, -MAX_PAGE_SIZE, SEEK_END); while (!ogg_read_page (s, &i)){ if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0) @@ -472,7 +471,7 @@ ogg_gptopts (s, idx, ogg->streams[idx].granule); } - ogg->size = url_filesize(h); + ogg->size = url_fsize(&s->pb); ogg_restore (s, 0); return 0;
--- a/utils.c Tue May 17 22:47:34 2005 +0000 +++ b/utils.c Thu May 19 00:06:27 2005 +0000 @@ -1192,7 +1192,7 @@ if(ts_max == AV_NOPTS_VALUE){ int step= 1024; - pos_max = url_filesize(url_fileno(&s->pb)) - 1; + pos_max = url_fsize(&s->pb) - 1; do{ pos_max -= step; ts_max = avif->read_timestamp(s, stream_index, &pos_max, pos_max + step); @@ -1289,7 +1289,7 @@ #endif pos_min = s->data_offset; - pos_max = url_filesize(url_fileno(&s->pb)) - 1; + pos_max = url_fsize(&s->pb) - 1; if (pos < pos_min) pos= pos_min; else if(pos > pos_max) pos= pos_max; @@ -1586,15 +1586,13 @@ static void av_estimate_timings(AVFormatContext *ic) { - URLContext *h; int64_t file_size; /* get the file size, if possible */ if (ic->iformat->flags & AVFMT_NOFILE) { file_size = 0; } else { - h = url_fileno(&ic->pb); - file_size = url_filesize(h); + file_size = url_fsize(&ic->pb); if (file_size < 0) file_size = 0; }
--- a/yuv.c Tue May 17 22:47:34 2005 +0000 +++ b/yuv.c Thu May 19 00:06:27 2005 +0000 @@ -54,9 +54,10 @@ URLContext *h; AVImageInfo info1, *info = &info1; + img_size = url_fsize(f); + /* XXX: hack hack */ h = url_fileno(f); - img_size = url_seek(h, 0, SEEK_END); url_get_filename(h, fname, sizeof(fname)); if (infer_size(&info->width, &info->height, img_size) < 0) {