[Bug 787085] tsdemux: Sudden jump in PTS when there is a backward jump in PCR
GStreamer (GNOME Bugzilla)
bugzilla at gnome.org
Tue Sep 5 15:30:33 UTC 2017
https://bugzilla.gnome.org/show_bug.cgi?id=787085
--- Comment #12 from parithi <parithi at gmail.com> ---
Thanks Edward for your suggestions.
One more observation on this issue:
UDP input buffer has 7 TS packers and two of them are having PCRs.
one PCR is going backward and the next one is having proper value.
Consider PTS=12:00:00, base_pcr = 12:00:00 and offset=00:00:00
current_pcr=10:00:00.
For explanation purpose consider skew=0 and base_time=0.
When the backward jump happens (by 02:00:00)
In calculate_skew() function following changes will happen
offset = 02:00:00
base_pcr = 12:00:00
last_pcr = 12:00:00 -> current_pcr + offset
In function mpegts_packetizer_pts_to_ts()
out_PTS = in_PTS + offset = 12:00:00 + 02:00:00 = 14:00:00
if (G_UNLIKELY (pcr_pid != 0x1fff &&
ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND))
res = GST_CLOCK_TIME_NONE;
else {
GstClockTime tmp = pcrtable->base_time + pcrtable->skew;
if (tmp + res > pcrtable->base_pcrtime)
res += tmp - pcrtable->base_pcrtime;
else
res = GST_CLOCK_TIME_NONE;
According to above code first if condition will be satisfied and
GST_CLOCK_TIME_NONE will be returned. Here there is *no issue*.
Now we have a proper PCR (current_pcr=12:00:00). As per calculate_skew
function, first add offset with current_pcr
current_pcr = 12:00:00 + 02:00:00 = 14:00:00
Then this value is assigned to last_pcr.
last_pcr = 14:00:00
offset = 02:00:00
Since both PCR buffers are present in same UDP buffer, both are having same
time stamps. So the following condition will be satisfied and base_pcr time
will not be updated in calculate_skew(). So now we have base_pcr=12:00:00
/* Ignore packets received at 100% the same time (i.e. from the same input
buffer) */
if (G_UNLIKELY (time == pcr->prev_in_time
&& GST_CLOCK_TIME_IS_VALID (pcr->prev_in_time)))
goto no_skew;
Now in function mpegts_packetizer_pts_to_ts()
out_PTS = in_PTS + offset = 12:00:00 + 02:00:00 = 14:00:00
As per above code snippet of mpegts_packetizer_pts_to_ts(), the if condition
will fail because out_PTS == last_pcr and in else part following code will be
executed.
if (tmp + res > pcrtable->base_pcrtime)
res += tmp - pcrtable->base_pcrtime;
So the out_PTS = out_PTS - base_pcr = 14:00:00 - 12:00:00 = 02:00:00.
This is the *issue*.
If we are completely ignoring the second PCR buffer in calculate_skew() as
mentioned in comments there won't be any issue. But we updating last_pcr, that
leads to this issue.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list