Mercurial > libavformat.hg
comparison oggdec.c @ 5816:c587ece53810 libavformat
oggdec: Move PTS/DTS calculation to a function
author | conrad |
---|---|
date | Thu, 11 Mar 2010 07:17:53 +0000 |
parents | e6cd8ca154f5 |
children | eb9c746c3584 |
comparison
equal
deleted
inserted
replaced
5815:9e5e8c64ab54 | 5816:c587ece53810 |
---|---|
491 | 491 |
492 //fill the extradata in the per codec callbacks | 492 //fill the extradata in the per codec callbacks |
493 return 0; | 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 static int | 527 static int |
498 ogg_read_packet (AVFormatContext * s, AVPacket * pkt) | 528 ogg_read_packet (AVFormatContext * s, AVPacket * pkt) |
499 { | 529 { |
500 struct ogg *ogg; | 530 struct ogg *ogg; |
516 if (av_new_packet (pkt, psize) < 0) | 546 if (av_new_packet (pkt, psize) < 0) |
517 return AVERROR(EIO); | 547 return AVERROR(EIO); |
518 pkt->stream_index = idx; | 548 pkt->stream_index = idx; |
519 memcpy (pkt->data, os->buf + pstart, psize); | 549 memcpy (pkt->data, os->buf + pstart, psize); |
520 | 550 |
521 if (os->lastpts != AV_NOPTS_VALUE) { | 551 pkt->pts = ogg_calc_pts(s, idx, &pkt->dts); |
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 | |
540 pkt->flags = os->pflags; | 552 pkt->flags = os->pflags; |
541 pkt->duration = os->pduration; | 553 pkt->duration = os->pduration; |
542 pkt->pos = fpos; | 554 pkt->pos = fpos; |
543 | 555 |
544 return psize; | 556 return psize; |