[FFmpeg-cvslog] lavf: move generic index generation code to a later point

Michael Niedermayer git at videolan.org
Thu Jul 26 03:10:02 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Jul 24 18:00:11 2012 +0200| [2cd491a47cdf217c89ba5445bbe6e9b10ecd1ca0] | committer: Michael Niedermayer

lavf: move generic index generation code to a later point

By moving it to a later point relative and unknown timestamps
are more likely to have been corrected

similar patch reviewed-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

Conflicts:

	libavformat/utils.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2cd491a47cdf217c89ba5445bbe6e9b10ecd1ca0
---

 libavformat/utils.c    |   14 ++++++--------
 tests/ref/seek/mp2_mp2 |   14 +++++---------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index d7aba39..124476d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1233,14 +1233,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
 
         compute_pkt_fields(s, st, st->parser, &out_pkt);
 
-        if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
-            out_pkt.flags & AV_PKT_FLAG_KEY) {
-            int64_t pos= out_pkt.pos;
-            ff_reduce_index(s, st->index);
-            av_add_index_entry(st, pos, out_pkt.dts,
-                               0, 0, AVINDEX_KEYFRAME);
-        }
-
         if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
             out_pkt.destruct = pkt->destruct;
             pkt->destruct = NULL;
@@ -1468,10 +1460,16 @@ return_packet:
         st->skip_samples = 0;
     }
 
+    if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY) {
+        ff_reduce_index(s, st->index);
+        av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);
+    }
+
     if (is_relative(pkt->dts))
         pkt->dts -= RELATIVE_TS_BASE;
     if (is_relative(pkt->pts))
         pkt->pts -= RELATIVE_TS_BASE;
+
     return ret;
 }
 
diff --git a/tests/ref/seek/mp2_mp2 b/tests/ref/seek/mp2_mp2
index 6166cb3..8de3676 100644
--- a/tests/ref/seek/mp2_mp2
+++ b/tests/ref/seek/mp2_mp2
@@ -1,20 +1,18 @@
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.026122 pts: 0.026122 pos:    417 size:   418
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
 ret: 0         st:-1 flags:1  ts: 1.894167
 ret: 0         st: 0 flags:1 dts: 1.880816 pts: 1.880816 pos:  30093 size:   418
 ret: 0         st: 0 flags:0  ts: 0.788334
 ret: 0         st: 0 flags:1 dts: 0.809796 pts: 0.809796 pos:  12956 size:   418
-ret: 0         st: 0 flags:1  ts:-0.317499
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
+ret:-1         st: 0 flags:1  ts:-0.317499
 ret: 0         st:-1 flags:0  ts: 2.576668
 ret: 0         st: 0 flags:1 dts: 2.586122 pts: 2.586122 pos:  41377 size:   418
 ret: 0         st:-1 flags:1  ts: 1.470835
 ret: 0         st: 0 flags:1 dts: 1.462857 pts: 1.462857 pos:  23405 size:   418
 ret: 0         st: 0 flags:0  ts: 0.365002
 ret: 0         st: 0 flags:1 dts: 0.365714 pts: 0.365714 pos:   5851 size:   418
-ret: 0         st: 0 flags:1  ts:-0.740831
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
+ret:-1         st: 0 flags:1  ts:-0.740831
 ret: 0         st:-1 flags:0  ts: 2.153336
 ret: 0         st: 0 flags:1 dts: 2.168163 pts: 2.168163 pos:  34690 size:   418
 ret: 0         st:-1 flags:1  ts: 1.047503
@@ -41,13 +39,11 @@ ret: 0         st: 0 flags:1  ts: 1.989173
 ret: 0         st: 0 flags:1 dts: 1.985306 pts: 1.985306 pos:  31764 size:   418
 ret: 0         st:-1 flags:0  ts: 0.883340
 ret: 0         st: 0 flags:1 dts: 0.888163 pts: 0.888163 pos:  14210 size:   418
-ret: 0         st:-1 flags:1  ts:-0.222493
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
+ret:-1         st:-1 flags:1  ts:-0.222493
 ret: 0         st: 0 flags:0  ts: 2.671674
 ret: 0         st: 0 flags:1 dts: 2.690612 pts: 2.690612 pos:  43049 size:   418
 ret: 0         st: 0 flags:1  ts: 1.565841
 ret: 0         st: 0 flags:1 dts: 1.541224 pts: 1.541224 pos:  24659 size:   418
 ret: 0         st:-1 flags:0  ts: 0.460008
 ret: 0         st: 0 flags:1 dts: 0.470204 pts: 0.470204 pos:   7523 size:   418
-ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   417
+ret:-1         st:-1 flags:1  ts:-0.645825



More information about the ffmpeg-cvslog mailing list