mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
tsdemux: Handle PTS->TS at wraparound
This has been a FIXME for ages. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1179>
This commit is contained in:
parent
66a24023c0
commit
6efa9dc00e
1 changed files with 8 additions and 7 deletions
|
@ -2280,21 +2280,22 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
|
||||||
res = pts + pcrtable->pcroffset;
|
res = pts + pcrtable->pcroffset;
|
||||||
|
|
||||||
/* Don't return anything if we differ too much against last seen PCR */
|
/* Don't return anything if we differ too much against last seen PCR */
|
||||||
/* FIXME : Ideally we want to figure out whether we have a wraparound or
|
|
||||||
* a reset so we can provide actual values.
|
|
||||||
* That being said, this will only happen for the small interval of time
|
|
||||||
* where PTS/DTS are wrapping just before we see the first reset/wrap PCR
|
|
||||||
*/
|
|
||||||
if (G_UNLIKELY (pcr_pid != 0x1fff &&
|
if (G_UNLIKELY (pcr_pid != 0x1fff &&
|
||||||
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
|
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
|
||||||
res = GST_CLOCK_TIME_NONE;
|
res = GST_CLOCK_TIME_NONE;
|
||||||
else {
|
else {
|
||||||
GstClockTime tmp = pcrtable->base_time + pcrtable->skew;
|
GstClockTime tmp = pcrtable->base_time + pcrtable->skew;
|
||||||
if (tmp + res >= pcrtable->base_pcrtime)
|
if (tmp + res >= pcrtable->base_pcrtime) {
|
||||||
res += tmp - pcrtable->base_pcrtime;
|
res += tmp - pcrtable->base_pcrtime;
|
||||||
else
|
} else if (ABSDIFF (tmp + res + PCR_GST_MAX_VALUE,
|
||||||
|
pcrtable->base_pcrtime) < PCR_GST_MAX_VALUE / 2) {
|
||||||
|
/* Handle wrapover */
|
||||||
|
res += tmp + PCR_GST_MAX_VALUE - pcrtable->base_pcrtime;
|
||||||
|
} else {
|
||||||
|
/* Fallback for values that differ way too much */
|
||||||
res = GST_CLOCK_TIME_NONE;
|
res = GST_CLOCK_TIME_NONE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (packetizer->calculate_offset && pcrtable->groups) {
|
} else if (packetizer->calculate_offset && pcrtable->groups) {
|
||||||
gint64 refpcr = G_MAXINT64, refpcroffset;
|
gint64 refpcr = G_MAXINT64, refpcroffset;
|
||||||
PCROffsetGroup *group = pcrtable->current->group;
|
PCROffsetGroup *group = pcrtable->current->group;
|
||||||
|
|
Loading…
Reference in a new issue