Revision 6abaa272 libavformat/oggdec.c
libavformat/oggdec.c | ||
---|---|---|
493 | 493 |
return 0; |
494 | 494 |
} |
495 | 495 |
|
496 |
static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts) |
|
497 |
{ |
|
498 |
struct ogg *ogg = s->priv_data; |
|
499 |
struct ogg_stream *os = ogg->streams + idx; |
|
500 |
int64_t pts = AV_NOPTS_VALUE; |
|
501 |
|
|
502 |
if (dts) |
|
503 |
*dts = AV_NOPTS_VALUE; |
|
504 |
|
|
505 |
if (os->lastpts != AV_NOPTS_VALUE) { |
|
506 |
pts = os->lastpts; |
|
507 |
os->lastpts = AV_NOPTS_VALUE; |
|
508 |
} |
|
509 |
if (os->lastdts != AV_NOPTS_VALUE) { |
|
510 |
if (dts) |
|
511 |
*dts = os->lastdts; |
|
512 |
os->lastdts = AV_NOPTS_VALUE; |
|
513 |
} |
|
514 |
if (os->page_end) { |
|
515 |
if (os->granule != -1LL) { |
|
516 |
if (os->codec && os->codec->granule_is_start) |
|
517 |
pts = ogg_gptopts(s, idx, os->granule, dts); |
|
518 |
else |
|
519 |
os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts); |
|
520 |
os->granule = -1LL; |
|
521 |
} else |
|
522 |
av_log(s, AV_LOG_WARNING, "Packet is missing granule\n"); |
|
523 |
} |
|
524 |
return pts; |
|
525 |
} |
|
496 | 526 |
|
497 | 527 |
static int |
498 | 528 |
ogg_read_packet (AVFormatContext * s, AVPacket * pkt) |
... | ... | |
518 | 548 |
pkt->stream_index = idx; |
519 | 549 |
memcpy (pkt->data, os->buf + pstart, psize); |
520 | 550 |
|
521 |
if (os->lastpts != AV_NOPTS_VALUE) { |
|
522 |
pkt->pts = os->lastpts; |
|
523 |
os->lastpts = AV_NOPTS_VALUE; |
|
524 |
} |
|
525 |
if (os->lastdts != AV_NOPTS_VALUE) { |
|
526 |
pkt->dts = os->lastdts; |
|
527 |
os->lastdts = AV_NOPTS_VALUE; |
|
528 |
} |
|
529 |
if (os->page_end) { |
|
530 |
if (os->granule != -1LL) { |
|
531 |
if (os->codec && os->codec->granule_is_start) |
|
532 |
pkt->pts = ogg_gptopts(s, idx, os->granule, &pkt->dts); |
|
533 |
else |
|
534 |
os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts); |
|
535 |
os->granule = -1LL; |
|
536 |
} else |
|
537 |
av_log(s, AV_LOG_WARNING, "Packet is missing granule\n"); |
|
538 |
} |
|
539 |
|
|
551 |
pkt->pts = ogg_calc_pts(s, idx, &pkt->dts); |
|
540 | 552 |
pkt->flags = os->pflags; |
541 | 553 |
pkt->duration = os->pduration; |
542 | 554 |
pkt->pos = fpos; |
Also available in: Unified diff