hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 3f66c83a209a4f5ea5e6122d883101cdc249e1a4 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 23 Oct 2020 11:11:11 +0800
Subject: [PATCH 20/40] mpegtsdemux: Create new PCR group for big gap
 
Currently it would try to reuse the current group and handle the gap by
just adding 500ms to pcroffset.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 gst/mpegtsdemux/mpegtspacketizer.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
 
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index 21d10e7..1313172 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -1993,6 +1993,7 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable,
      *    Initialize current to that group
      */
     GST_DEBUG ("No current window estimator, Checking for group to use");
+create_new_group:
     for (tmp = pcrtable->groups; tmp; tmp = tmp->next) {
       PCROffsetGroup *group = (PCROffsetGroup *) tmp->data;
 
@@ -2065,6 +2066,15 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable,
   if (G_UNLIKELY (corpcr - current->pending[current->last].pcr >
           500 * PCR_MSECOND)) {
     GST_DEBUG ("New PCR more than 500ms away, handling discont");
+
+#if 1
+    /**
+     * Create new discont group instead of reusing the current, otherwise
+     * it will try to handle the gap by just adding 500ms to pcroffset.
+     */
+    _close_current_group (pcrtable);
+    goto create_new_group;
+#else
     /* Take values from current and put them in the current group (closing it) */
     /* Create new group with pcr/offset just after the current group
      * and mark it as a discont */
@@ -2072,6 +2082,7 @@ record_pcr (MpegTSPacketizer2 * packetizer, MpegTSPCR * pcrtable,
     _append_group_values (current->group, current->pending[current->last]);
     _set_current_group (pcrtable, current->group, pcr, offset, TRUE);
     return;
+#endif
   }
 
   if (G_UNLIKELY (corpcr == current->last_value.pcr)) {
-- 
2.17.1