[vlc-commits] demux: ts: workaround HLS dumps

Francois Cartegnie git at videolan.org
Wed Jul 10 19:09:15 CEST 2019


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 24 22:26:21 2018 +0200| [9368f7783284697272563bba24b866cf1864814c] | committer: Francois Cartegnie

demux: ts: workaround HLS dumps

Triggers duplicate packets on some boundaries
and artifacts. There's no way to tell if that's
a real discontinuity or duplicate packet.
At least we can discard false positives for duplicates.

(cherry picked from commit 3a794b149b9bf2bd2225f94c1cf05c4d5f31724c)
Backported because it seems also needed for non HLS dumps

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=9368f7783284697272563bba24b866cf1864814c
---

 modules/demux/mpeg/ts.c     | 10 +++++++++-
 modules/demux/mpeg/ts_pid.c |  1 +
 modules/demux/mpeg/ts_pid.h |  2 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index eae6a54947..3dbe527756 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -2510,9 +2510,16 @@ static block_t * ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pk
                          pid->i_pid, i_cc );
                 pid->i_cc = i_cc;
             }
-            else if( i_diff == 0 && pid->i_dup == 0 )
+            else if( i_diff == 0 && pid->i_dup == 0 &&
+                     !memcmp(pid->prevpktbytes, /* see comment below */
+                             &p_pkt->p_buffer[1], PREVPKTKEEPBYTES)  )
             {
                 /* Discard duplicated payload 2.4.3.3 */
+                /* Added previous pkt bytes comparison for
+                 * stupid HLS dumps/joined segments which are
+                 * triggering erroneous duplicates instead of discontinuity.
+                 * That should not need CRC or full payload as it should be
+                 * restarting with PSI packets */
                 pid->i_dup++;
                 block_Release( p_pkt );
                 return NULL;
@@ -2528,6 +2535,7 @@ static block_t * ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pk
             }
             else pid->i_cc = i_cc;
         }
+        memcpy(pid->prevpktbytes, &p_pkt->p_buffer[1], PREVPKTKEEPBYTES);
     }
     else /* Ignore all 00 or 10 as in 2.4.3.3 CC counter must not be
             incremented in those cases, but there is humax inserting
diff --git a/modules/demux/mpeg/ts_pid.c b/modules/demux/mpeg/ts_pid.c
index 2971e942b1..7a7084fd50 100644
--- a/modules/demux/mpeg/ts_pid.c
+++ b/modules/demux/mpeg/ts_pid.c
@@ -171,6 +171,7 @@ static void PIDReset( ts_pid_t *pid )
     pid->i_cc       = 0xff;
     pid->i_flags    &= ~FLAG_SCRAMBLED;
     pid->type = TYPE_FREE;
+    memset(pid->prevpktbytes, 0, PREVPKTKEEPBYTES);
 }
 
 bool PIDSetup( demux_t *p_demux, ts_pid_type_t i_type, ts_pid_t *pid, ts_pid_t *p_parent )
diff --git a/modules/demux/mpeg/ts_pid.h b/modules/demux/mpeg/ts_pid.h
index 6103768fa3..70e1102cf0 100644
--- a/modules/demux/mpeg/ts_pid.h
+++ b/modules/demux/mpeg/ts_pid.h
@@ -47,6 +47,7 @@ enum
 
 #define SEEN(x) ((x)->i_flags & FLAG_SEEN)
 #define SCRAMBLED(x) ((x).i_flags & FLAG_SCRAMBLED)
+#define PREVPKTKEEPBYTES 16
 
 struct ts_pid_t
 {
@@ -56,6 +57,7 @@ struct ts_pid_t
     uint8_t     i_cc;   /* countinuity counter */
     uint8_t     i_dup;  /* duplicate counter */
     uint8_t     type;
+    uint8_t     prevpktbytes[PREVPKTKEEPBYTES];
 
     uint16_t    i_refcount;
 



More information about the vlc-commits mailing list