mpegts: Take into account adaptation field discont

If the flag is set, there is an *expected* discontinuity:
* For CC, we ignore the fact it's not contiguous
* For PCR, we acknowledge the values aren't contiguous

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8420>
This commit is contained in:
Edward Hervey 2025-02-06 09:11:14 +01:00 committed by GStreamer Marge Bot
parent 0a562a92d7
commit 63a03b167a
2 changed files with 29 additions and 0 deletions

View File

@ -414,8 +414,24 @@ mpegts_packetizer_parse_adaptation_field_control (MpegTSPacketizer2 *
if (packetizer->calculate_skew
&& GST_CLOCK_TIME_IS_VALID (packetizer->last_in_time)) {
pcrtable = get_pcr_table (packetizer, packet->pid);
/* There is a signalled discontinuity. Reset observations */
if (afcflags & MPEGTS_AFC_DISCONTINUITY_FLAG) {
GST_DEBUG ("pcr 0x%04x Discontinuity signalled, resetting observations",
packet->pid);
pcrtable->base_time = GST_CLOCK_TIME_NONE;
pcrtable->base_pcrtime = GST_CLOCK_TIME_NONE;
}
calculate_skew (packetizer, pcrtable, packet->pcr,
packetizer->last_in_time);
if (afcflags & MPEGTS_AFC_DISCONTINUITY_FLAG) {
MpegTSPCR *ignore_pcr =
packetizer->observations[packetizer->pcrtablelut[0x1fff]];
if (ignore_pcr) {
GST_DEBUG ("Resetting fallback PCR table due to discontinuity");
/* If there is a discontinuity, we need to reset the fallback PCR in case of */
ignore_pcr->base_time = GST_CLOCK_TIME_NONE;
}
}
}
if (packetizer->calculate_offset) {
if (!pcrtable)
@ -990,6 +1006,12 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer,
packetizer->streams[packet->pid] = stream;
}
if (G_UNLIKELY (packet->afc_flags & MPEGTS_AFC_DISCONTINUITY_FLAG)) {
GST_DEBUG ("PID 0x%04x discontinuity flag, resetting stream counter",
packet->pid);
stream->continuity_counter = CONTINUITY_UNSET;
}
GST_MEMDUMP ("Full packet data", packet->data,
packet->data_end - packet->data);

View File

@ -2852,6 +2852,13 @@ gst_ts_demux_queue_data (GstTSDemux * demux, TSDemuxStream * stream,
GST_LOG_OBJECT (demux, "pid: 0x%04x state:%d", stream->stream.pid,
stream->state);
/* Handle expected discontinuity */
if (G_UNLIKELY (packet->afc_flags & MPEGTS_AFC_DISCONTINUITY_FLAG)) {
GST_LOG_OBJECT (demux, "pid: 0x%04x discontinuity flag, resetting counter",
stream->stream.pid);
stream->continuity_counter = CONTINUITY_UNSET;
}
size = packet->data_end - packet->payload;
data = packet->payload;