Mercurial > libavformat.hg
comparison oggdec.c @ 5434:68c8e7affd44 libavformat
Fix PTS for OGM codecs.
Fixes issue251
author | conrad |
---|---|
date | Sat, 12 Dec 2009 20:18:43 +0000 |
parents | 5de92e352cf9 |
children | 60671fac35ad |
comparison
equal
deleted
inserted
replaced
5433:3e568c0b36d3 | 5434:68c8e7affd44 |
---|---|
114 struct ogg_stream *os = ogg->streams + i; | 114 struct ogg_stream *os = ogg->streams + i; |
115 os->bufpos = 0; | 115 os->bufpos = 0; |
116 os->pstart = 0; | 116 os->pstart = 0; |
117 os->psize = 0; | 117 os->psize = 0; |
118 os->granule = -1; | 118 os->granule = -1; |
119 os->lastgp = -1; | 119 os->lastpts = AV_NOPTS_VALUE; |
120 os->nsegs = 0; | 120 os->nsegs = 0; |
121 os->segp = 0; | 121 os->segp = 0; |
122 } | 122 } |
123 | 123 |
124 ogg->curidx = -1; | 124 ogg->curidx = -1; |
286 } | 286 } |
287 | 287 |
288 if (get_buffer (bc, os->buf + os->bufpos, size) < size) | 288 if (get_buffer (bc, os->buf + os->bufpos, size) < size) |
289 return -1; | 289 return -1; |
290 | 290 |
291 os->lastgp = os->granule; | |
292 os->bufpos += size; | 291 os->bufpos += size; |
293 os->granule = gp; | 292 os->granule = gp; |
294 os->flags = flags; | 293 os->flags = flags; |
295 | 294 |
296 if (str) | 295 if (str) |
301 | 300 |
302 static int | 301 static int |
303 ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize) | 302 ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize) |
304 { | 303 { |
305 struct ogg *ogg = s->priv_data; | 304 struct ogg *ogg = s->priv_data; |
306 int idx; | 305 int idx, i; |
307 struct ogg_stream *os; | 306 struct ogg_stream *os; |
308 int complete = 0; | 307 int complete = 0; |
309 int segp = 0, psize = 0; | 308 int segp = 0, psize = 0; |
310 | 309 |
311 #if 0 | 310 #if 0 |
391 *dsize = os->psize; | 390 *dsize = os->psize; |
392 os->pstart += os->psize; | 391 os->pstart += os->psize; |
393 os->psize = 0; | 392 os->psize = 0; |
394 } | 393 } |
395 | 394 |
395 // determine whether there are more complete packets in this page | |
396 // if not, the page's granule will apply to this packet | |
397 os->page_end = 1; | |
398 for (i = os->segp; i < os->nsegs; i++) | |
399 if (os->segments[i] < 255) { | |
400 os->page_end = 0; | |
401 break; | |
402 } | |
403 | |
396 os->seq++; | 404 os->seq++; |
397 if (os->segp == os->nsegs) | 405 if (os->segp == os->nsegs) |
398 ogg->curidx = -1; | 406 ogg->curidx = -1; |
399 | 407 |
400 return 0; | 408 return 0; |
517 //Alloc a pkt | 525 //Alloc a pkt |
518 if (av_new_packet (pkt, psize) < 0) | 526 if (av_new_packet (pkt, psize) < 0) |
519 return AVERROR(EIO); | 527 return AVERROR(EIO); |
520 pkt->stream_index = idx; | 528 pkt->stream_index = idx; |
521 memcpy (pkt->data, os->buf + pstart, psize); | 529 memcpy (pkt->data, os->buf + pstart, psize); |
522 if (os->lastgp != -1LL){ | 530 |
523 pkt->pts = ogg_gptopts (s, idx, os->lastgp); | 531 if (os->lastpts != AV_NOPTS_VALUE) { |
524 os->lastgp = -1; | 532 pkt->pts = os->lastpts; |
533 os->lastpts = AV_NOPTS_VALUE; | |
534 } | |
535 if (os->page_end) { | |
536 if (os->granule != -1LL) { | |
537 if (os->codec && os->codec->granule_is_start) | |
538 pkt->pts = ogg_gptopts(s, idx, os->granule); | |
539 else | |
540 os->lastpts = ogg_gptopts(s, idx, os->granule); | |
541 os->granule = -1LL; | |
542 } else | |
543 av_log(s, AV_LOG_WARNING, "Packet is missing granule\n"); | |
525 } | 544 } |
526 | 545 |
527 pkt->flags = os->pflags; | 546 pkt->flags = os->pflags; |
528 pkt->duration = os->pduration; | 547 pkt->duration = os->pduration; |
529 | 548 |