aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorAaron Colwell <acolwell@chromium.org>2010-11-29 19:02:28 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-11-29 19:02:28 +0000
commit365d8e471d59356bc8ebacc29ef00e9d839588f1 (patch)
tree89fe1ece0eeda5fd6092349d61ab3faf2d802b8f /libavformat/oggdec.c
parent82f19afefe4f28db0e2eefbc2d06eee0def74a53 (diff)
downloadffmpeg-365d8e471d59356bc8ebacc29ef00e9d839588f1.tar.gz
Ensure that data_offset is set correctly when there are partial
data packets before the first complete one. Patch by Aaron Colwell [acolwell chromium org]. Originally committed as revision 25846 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 5e52bb3c97..4fcf8ad58c 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -373,9 +373,27 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo
if (!os->header){
os->segp = segp;
os->psize = psize;
- if (!ogg->headers)
- s->data_offset = os->sync_pos;
+
+ // We have reached the first non-header packet. All header
+ // packets must be complete before the first non-header
+ // one, so everything that follows must be non-header.
ogg->headers = 1;
+
+ // Update the header state for all streams and
+ // compute the data_offset.
+ s->data_offset = os->sync_pos;
+ for (i = 0; i < ogg->nstreams; i++) {
+ struct ogg_stream *cur_os = ogg->streams + i;
+ // Set stream header state to 0 if its last packet
+ // was a header.
+ if (cur_os->header > 0)
+ cur_os->header = 0;
+
+ // if we have a partial non-header packet, its start is
+ // obviously at or after the data start
+ if (cur_os->incomplete)
+ s->data_offset = FFMIN(s->data_offset, cur_os->sync_pos);
+ }
}else{
os->pstart += os->psize;
os->psize = 0;