summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorDavid Conrad <lessen42@gmail.com>2009-12-12 20:18:43 +0000
committerDavid Conrad <lessen42@gmail.com>2009-12-12 20:18:43 +0000
commit5e15c7d95be456e9dafbcca7cb0d936cc331dbae (patch)
tree8643ef620e2b65b6a388d317fbce837beafde1e1 /libavformat/oggdec.c
parent7a14430ed75a2eaaa430e46c2f54a7a9a8b71804 (diff)
Fix PTS for OGM codecs.
Fixes issue251 Originally committed as revision 20815 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 129268b390..75afc84099 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -116,7 +116,7 @@ ogg_reset (struct ogg * ogg)
os->pstart = 0;
os->psize = 0;
os->granule = -1;
- os->lastgp = -1;
+ os->lastpts = AV_NOPTS_VALUE;
os->nsegs = 0;
os->segp = 0;
}
@@ -288,7 +288,6 @@ ogg_read_page (AVFormatContext * s, int *str)
if (get_buffer (bc, os->buf + os->bufpos, size) < size)
return -1;
- os->lastgp = os->granule;
os->bufpos += size;
os->granule = gp;
os->flags = flags;
@@ -303,7 +302,7 @@ static int
ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize)
{
struct ogg *ogg = s->priv_data;
- int idx;
+ int idx, i;
struct ogg_stream *os;
int complete = 0;
int segp = 0, psize = 0;
@@ -393,6 +392,15 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize)
os->psize = 0;
}
+ // determine whether there are more complete packets in this page
+ // if not, the page's granule will apply to this packet
+ os->page_end = 1;
+ for (i = os->segp; i < os->nsegs; i++)
+ if (os->segments[i] < 255) {
+ os->page_end = 0;
+ break;
+ }
+
os->seq++;
if (os->segp == os->nsegs)
ogg->curidx = -1;
@@ -519,9 +527,20 @@ ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
return AVERROR(EIO);
pkt->stream_index = idx;
memcpy (pkt->data, os->buf + pstart, psize);
- if (os->lastgp != -1LL){
- pkt->pts = ogg_gptopts (s, idx, os->lastgp);
- os->lastgp = -1;
+
+ if (os->lastpts != AV_NOPTS_VALUE) {
+ pkt->pts = os->lastpts;
+ os->lastpts = AV_NOPTS_VALUE;
+ }
+ if (os->page_end) {
+ if (os->granule != -1LL) {
+ if (os->codec && os->codec->granule_is_start)
+ pkt->pts = ogg_gptopts(s, idx, os->granule);
+ else
+ os->lastpts = ogg_gptopts(s, idx, os->granule);
+ os->granule = -1LL;
+ } else
+ av_log(s, AV_LOG_WARNING, "Packet is missing granule\n");
}
pkt->flags = os->pflags;