diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2007-12-16 18:08:06 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2007-12-16 18:08:06 +0000 |
commit | 687f35f384df61b56ac7bbce6366f8648e9439ec (patch) | |
tree | 835c432c42abb71bb32e2d7396e2da47171c57e9 /libavformat/mov.c | |
parent | 5cb4b82a176e00cec9d7174a4bae07d194b8b61a (diff) | |
download | ffmpeg-687f35f384df61b56ac7bbce6366f8648e9439ec.tar.gz |
support streamed mov/mp4
Originally committed as revision 11234 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 545564b3cb..555bd266b7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -193,6 +193,8 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) offset_t start_pos = url_ftell(pb); int64_t left; err = (c->parse_table[i].func)(c, pb, a); + if (c->found_moov && c->found_mdat) + break; left = a.size - url_ftell(pb) + start_pos; if (left > 0) /* skip garbage at atom end */ url_fskip(pb, left); @@ -1511,9 +1513,10 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale); dprintf(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); - if (!sample || - ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || - (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts))) { + if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) || + (!url_is_streamed(s->pb) && + ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || + (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))) { sample = current_sample; best_dts = dts; sc = msc; @@ -1524,7 +1527,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) return -1; /* must be done just before reading, to avoid infinite loop on sample */ sc->current_sample++; - if (sample->pos >= url_fsize(s->pb)) { + if (url_fseek(s->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos); return -1; } @@ -1534,7 +1537,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) dprintf(s, "dv audio pkt size %d\n", pkt->size); } else { #endif - url_fseek(s->pb, sample->pos, SEEK_SET); av_get_packet(s->pb, pkt, sample->size); #ifdef CONFIG_DV_DEMUXER if (mov->dv_demux) { |