[vlc-commits] demux: ts: workaround HLS dumps
Francois Cartegnie
git at videolan.org
Tue Jul 24 22:28:38 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 24 22:26:21 2018 +0200| [3a794b149b9bf2bd2225f94c1cf05c4d5f31724c] | 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a794b149b9bf2bd2225f94c1cf05c4d5f31724c
---
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 cb906be89f..18c4246268 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -2517,9 +2517,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;
@@ -2535,6 +2542,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 6d4b88cbd5..80d1a77ce0 100644
--- a/modules/demux/mpeg/ts_pid.c
+++ b/modules/demux/mpeg/ts_pid.c
@@ -175,6 +175,7 @@ static void PIDReset( ts_pid_t *pid )
pid->i_dup = 0;
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 3a0e6bcffd..cf2c2a9c9d 100644
--- a/modules/demux/mpeg/ts_pid.h
+++ b/modules/demux/mpeg/ts_pid.h
@@ -49,6 +49,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
{
@@ -58,6 +59,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