[FFmpeg-soc] [soc]: r4502 - seek_api/mpeg.c

spyfeng subversion at mplayerhq.hu
Tue Jun 23 18:55:11 CEST 2009


Author: spyfeng
Date: Tue Jun 23 18:55:11 2009
New Revision: 4502

Log:
because we built index entries correctly, we seek to the target frame by indexes.

Modified:
   seek_api/mpeg.c

Modified: seek_api/mpeg.c
==============================================================================
--- seek_api/mpeg.c	Mon Jun 22 11:21:00 2009	(r4501)
+++ seek_api/mpeg.c	Tue Jun 23 18:55:11 2009	(r4502)
@@ -652,33 +652,31 @@ static int mpegps_read_seek(struct AVFor
         AVIndexEntry *e;
         index = av_index_search_timestamp(st, ts, flags);
 
-        if (index >= 0) {
-            e = &st->index_entries[index];
-            pos = e->pos;
-            pts = e->timestamp;
-            av_log(s, AV_LOG_DEBUG, "the seek pos = %"PRId64", pts  = %"PRId64", targe timestamp = %"PRId64"\n", pos, pts, ts);
-
-            if (pts == ts || (ts < pts && index == 0)) { // find the target timestamp
-                url_fseek(s->pb, pos, SEEK_SET);
-                goto success;
-            }
+        if (index == -1)
+            return -1;
 
-            if (flags & AVSEEK_FLAG_ANY) {
+        e = &st->index_entries[index];
+        pos = e->pos;
+        pts = e->timestamp;
+        av_log(s, AV_LOG_DEBUG, "the seek pos = %"PRId64", pts  = %"PRId64", targe timestamp = %"PRId64"\n", pos, pts, ts);
+        if (flags & AVSEEK_FLAG_ANY) {
 
-                while(pts > ts) { // find the index timestamp smaller than target timestamp
-                    index--;
-                    pts = st->index_entries[index].timestamp;
-                    pos = st->index_entries[index].pos;
-                }
+            while(pts > ts) { // find the index timestamp smaller than target timestamp
+                index--;
+                pts = st->index_entries[index].timestamp;
+                pos = st->index_entries[index].pos;
+            }
 
-                if (find_keyframe(s, stream_index, &pos, &pts, ts, flags) == 0) {
-                    goto success;
-                } else {
-                    return -1;
-                }
+            if (find_keyframe(s, stream_index, &pos, &pts, ts, flags) == 0) {
+                goto success;
+            } else {
+                return -1;
             }
+        } else {
+            url_fseek(s->pb, pos, SEEK_SET);
+            goto success;
         }
-     }
+    }
     // search the scr use binary search
     ts_max =
     ts_min = AV_NOPTS_VALUE;
@@ -694,6 +692,7 @@ static int mpegps_read_seek(struct AVFor
         pos = ret_pos;
         pts = ret_ts;
     }
+
     if (find_keyframe(s, stream_index, &pos, &pts, ts, flags) == 0) {
         goto success;
     } else {


More information about the FFmpeg-soc mailing list