diff mov.c @ 5061:5ff6a72c9686 libavformat

In mov_read_packet remember the AVStream we want to demux next instead of the MOVStreamContext. We need the AVStream anyway and it is easier to get the MOVStreamContext from the AVStream than the other way around.
author reimar
date Wed, 24 Jun 2009 08:23:40 +0000
parents 0bac77c4a578
children 8d81bf3822ac
line wrap: on
line diff
--- a/mov.c	Wed Jun 24 03:38:47 2009 +0000
+++ b/mov.c	Wed Jun 24 08:23:40 2009 +0000
@@ -2060,14 +2060,15 @@
     MOVContext *mov = s->priv_data;
     MOVStreamContext *sc = 0;
     AVIndexEntry *sample = 0;
+    AVStream *st = NULL;
     int64_t best_dts = INT64_MAX;
     int i, ret;
  retry:
     for (i = 0; i < s->nb_streams; i++) {
-        AVStream *st = s->streams[i];
-        MOVStreamContext *msc = st->priv_data;
-        if (st->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < st->nb_index_entries) {
-            AVIndexEntry *current_sample = &st->index_entries[msc->current_sample];
+        AVStream *avst = s->streams[i];
+        MOVStreamContext *msc = avst->priv_data;
+        if (avst->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < avst->nb_index_entries) {
+            AVIndexEntry *current_sample = &avst->index_entries[msc->current_sample];
             int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);
             dprintf(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
             if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) ||
@@ -2077,7 +2078,7 @@
                   (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
                 sample = current_sample;
                 best_dts = dts;
-                sc = msc;
+                st = avst;
             }
         }
     }
@@ -2090,6 +2091,7 @@
         dprintf(s, "read fragments, offset 0x%llx\n", url_ftell(s->pb));
         goto retry;
     }
+    sc = st->priv_data;
     /* must be done just before reading, to avoid infinite loop on sample */
     sc->current_sample++;
     if (url_fseek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
@@ -2123,7 +2125,6 @@
         if (sc->wrong_dts)
             pkt->dts = AV_NOPTS_VALUE;
     } else {
-        AVStream *st = s->streams[sc->ffindex];
         int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
             st->index_entries[sc->current_sample].timestamp : st->duration;
         pkt->duration = next_dts - pkt->dts;