[FFmpeg-cvslog] oggdec: resync from the last page.

Michael Niedermayer git at videolan.org
Tue Jan 15 21:14:32 CET 2013


ffmpeg | branch: release/1.1 | Michael Niedermayer <michaelni at gmx.at> | Sun Jan 13 21:23:11 2013 +0100| [66a3112100083f85ebd3ffbbb992e5fe53b2dfb8] | committer: Carl Eugen Hoyos

oggdec: resync from the last page.

Previously we re synced from where we where which cam lead
to loosing pages.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit c5cf58d4b9b04cee1487a3095b83300791c21f15)

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

 libavformat/oggdec.c |   10 ++++++++++
 libavformat/oggdec.h |    1 +
 2 files changed, 11 insertions(+)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index c3291cf..6195747 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -102,6 +102,7 @@ static int ogg_restore(AVFormatContext *s, int discard)
             av_free(ogg->streams[i].buf);
 
         avio_seek(bc, ost->pos, SEEK_SET);
+        ogg->page_pos = -1;
         ogg->curidx   = ost->curidx;
         ogg->nstreams = ost->nstreams;
         ogg->streams  = av_realloc(ogg->streams,
@@ -146,6 +147,7 @@ static int ogg_reset(AVFormatContext *s)
         }
     }
 
+    ogg->page_pos = -1;
     ogg->curidx = -1;
 
     return 0;
@@ -297,6 +299,12 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
             sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
             break;
 
+        if(!i && bc->seekable && ogg->page_pos > 0) {
+            memset(sync, 0, 4);
+            avio_seek(bc, ogg->page_pos+4, SEEK_SET);
+            ogg->page_pos = -1;
+        }
+
         c = avio_r8(bc);
 
         if (url_feof(bc))
@@ -335,6 +343,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid)
     }
 
     os = ogg->streams + idx;
+    ogg->page_pos =
     os->page_pos = avio_tell(bc) - 27;
 
     if (os->psize > 0)
@@ -559,6 +568,7 @@ static int ogg_get_length(AVFormatContext *s)
 
     ogg_save(s);
     avio_seek(s->pb, end, SEEK_SET);
+    ogg->page_pos = -1;
 
     while (!ogg_read_page(s, &i)) {
         if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index febf8cb..4b0ba4f 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -99,6 +99,7 @@ struct ogg {
     int nstreams;
     int headers;
     int curidx;
+    int64_t page_pos;                   ///< file offset of the current page
     struct ogg_state *state;
 };
 



More information about the ffmpeg-cvslog mailing list