You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
oggdec: Move PTS/DTS calculation to a function
Originally committed as revision 22461 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -493,6 +493,36 @@ ogg_read_header (AVFormatContext * s, AVFormatParameters * ap)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts)
|
||||||
|
{
|
||||||
|
struct ogg *ogg = s->priv_data;
|
||||||
|
struct ogg_stream *os = ogg->streams + idx;
|
||||||
|
int64_t pts = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
|
if (dts)
|
||||||
|
*dts = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
|
if (os->lastpts != AV_NOPTS_VALUE) {
|
||||||
|
pts = os->lastpts;
|
||||||
|
os->lastpts = AV_NOPTS_VALUE;
|
||||||
|
}
|
||||||
|
if (os->lastdts != AV_NOPTS_VALUE) {
|
||||||
|
if (dts)
|
||||||
|
*dts = os->lastdts;
|
||||||
|
os->lastdts = AV_NOPTS_VALUE;
|
||||||
|
}
|
||||||
|
if (os->page_end) {
|
||||||
|
if (os->granule != -1LL) {
|
||||||
|
if (os->codec && os->codec->granule_is_start)
|
||||||
|
pts = ogg_gptopts(s, idx, os->granule, dts);
|
||||||
|
else
|
||||||
|
os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts);
|
||||||
|
os->granule = -1LL;
|
||||||
|
} else
|
||||||
|
av_log(s, AV_LOG_WARNING, "Packet is missing granule\n");
|
||||||
|
}
|
||||||
|
return pts;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
|
ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
|
||||||
@@ -518,25 +548,7 @@ ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
|
|||||||
pkt->stream_index = idx;
|
pkt->stream_index = idx;
|
||||||
memcpy (pkt->data, os->buf + pstart, psize);
|
memcpy (pkt->data, os->buf + pstart, psize);
|
||||||
|
|
||||||
if (os->lastpts != AV_NOPTS_VALUE) {
|
pkt->pts = ogg_calc_pts(s, idx, &pkt->dts);
|
||||||
pkt->pts = os->lastpts;
|
|
||||||
os->lastpts = AV_NOPTS_VALUE;
|
|
||||||
}
|
|
||||||
if (os->lastdts != AV_NOPTS_VALUE) {
|
|
||||||
pkt->dts = os->lastdts;
|
|
||||||
os->lastdts = 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, &pkt->dts);
|
|
||||||
else
|
|
||||||
os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts);
|
|
||||||
os->granule = -1LL;
|
|
||||||
} else
|
|
||||||
av_log(s, AV_LOG_WARNING, "Packet is missing granule\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt->flags = os->pflags;
|
pkt->flags = os->pflags;
|
||||||
pkt->duration = os->pduration;
|
pkt->duration = os->pduration;
|
||||||
pkt->pos = fpos;
|
pkt->pos = fpos;
|
||||||
|
Reference in New Issue
Block a user