summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-13 21:23:11 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-15 20:19:28 +0100
commitc5cf58d4b9b04cee1487a3095b83300791c21f15 (patch)
treeba6d882ca65915f67899061d00a3ee062a8df1f2 /libavformat/oggdec.c
parent778069c8325514518712d194749577b3451b4125 (diff)
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@gmx.at>
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 30583c495d..eec45380bb 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -101,6 +101,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,
@@ -145,6 +146,7 @@ static int ogg_reset(AVFormatContext *s)
}
}
+ ogg->page_pos = -1;
ogg->curidx = -1;
return 0;
@@ -296,6 +298,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))
@@ -334,6 +342,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)
@@ -558,6 +567,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 &&