[vlc-commits] contribs: dvbpsi: fix duplicate pkt fake positives
Francois Cartegnie
git at videolan.org
Wed Jul 10 19:13:22 CEST 2019
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Aug 7 17:46:58 2018 +0200| [2ed25c9a35d49a17c561c930b1e6c41d080b96d6] | committer: Francois Cartegnie
contribs: dvbpsi: fix duplicate pkt fake positives
(cherry picked from commit 82af958a696e2047ccb3c311e3607b1fea7c9483)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=2ed25c9a35d49a17c561c930b1e6c41d080b96d6
---
.../dvbpsi/0001-really-identify-duplicates.patch | 71 ++++++++++++++++++++++
.../dvbpsi/0002-really-reset-packet-counter.patch | 26 ++++++++
contrib/src/dvbpsi/rules.mak | 2 +
3 files changed, 99 insertions(+)
diff --git a/contrib/src/dvbpsi/0001-really-identify-duplicates.patch b/contrib/src/dvbpsi/0001-really-identify-duplicates.patch
new file mode 100644
index 0000000000..f41204d1d5
--- /dev/null
+++ b/contrib/src/dvbpsi/0001-really-identify-duplicates.patch
@@ -0,0 +1,71 @@
+From 6f7ae04fdcdc52c98003b51318be152c9f51709b Mon Sep 17 00:00:00 2001
+From: Francois Cartegnie <fcvlcdev at free.fr>
+Date: Tue, 7 Aug 2018 17:25:52 +0200
+Subject: [PATCH 1/2] really identify duplicates
+
+---
+ src/dvbpsi.c | 21 ++++++++++++++++-----
+ src/dvbpsi.h | 1 +
+ 2 files changed, 17 insertions(+), 5 deletions(-)
+
+diff --git a/src/dvbpsi.c b/src/dvbpsi.c
+index b74587f..7a844f0 100644
+--- a/src/dvbpsi.c
++++ b/src/dvbpsi.c
+@@ -91,6 +91,7 @@ void *dvbpsi_decoder_new(dvbpsi_callback_gather_t pf_gather,
+ p_decoder->i_section_max_size = i_section_max_size;
+ p_decoder->b_discontinuity = b_discontinuity;
+ p_decoder->i_continuity_counter = DVBPSI_INVALID_CC;
++ p_decoder->prevpacket[0] = 0;
+ p_decoder->p_current_section = NULL;
+ p_decoder->b_current_valid = false;
+
+@@ -285,11 +286,19 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, const uint8_t* p_data)
+ if (i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
+ && !p_decoder->b_discontinuity)
+ {
+- dvbpsi_error(p_dvbpsi, "PSI decoder",
+- "TS duplicate (received %d, expected %d) for PID %d",
+- p_decoder->i_continuity_counter, i_expected_counter,
+- ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
+- return false;
++ if(!memcmp(p_decoder->prevpacket, p_data, 188))
++ {
++ dvbpsi_debug(p_dvbpsi, "PSI decoder",
++ "TS duplicate (received %d, expected %d) for PID %d",
++ p_decoder->i_continuity_counter, i_expected_counter,
++ ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
++ return false;
++ }
++ else /* Fake duplicate */
++ {
++ /* force discontinuity */
++ i_expected_counter = p_decoder->i_continuity_counter + 1;
++ }
+ }
+
+ if (i_expected_counter != p_decoder->i_continuity_counter)
+@@ -307,6 +316,8 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, const uint8_t* p_data)
+ }
+ }
+
++ memcpy(p_decoder->prevpacket, p_data, 188);
++
+ /* Return if no payload in the TS packet */
+ if (!(p_data[3] & 0x10))
+ return false;
+diff --git a/src/dvbpsi.h b/src/dvbpsi.h
+index 061b928..a0446ba 100644
+--- a/src/dvbpsi.h
++++ b/src/dvbpsi.h
+@@ -239,6 +239,7 @@ typedef void (* dvbpsi_callback_gather_t)(dvbpsi_t *p_dvbpsi, /*!< pointer to d
+ bool b_discontinuity; /*!< Discontinuity flag */ \
+ bool b_current_valid; /*!< Current valid indicator */ \
+ uint8_t i_continuity_counter; /*!< Continuity counter */ \
++ uint8_t prevpacket[188]; /*!< Previous packet data */ \
+ uint8_t i_last_section_number;/*!< Last received section number */ \
+ dvbpsi_psi_section_t *p_current_section; /*!< Current section */ \
+ dvbpsi_psi_section_t *p_sections; /*!< List of received PSI sections */ \
+--
+2.14.4
+
diff --git a/contrib/src/dvbpsi/0002-really-reset-packet-counter.patch b/contrib/src/dvbpsi/0002-really-reset-packet-counter.patch
new file mode 100644
index 0000000000..b8b24316d8
--- /dev/null
+++ b/contrib/src/dvbpsi/0002-really-reset-packet-counter.patch
@@ -0,0 +1,26 @@
+From 48a9948b341f2b38cf6c88d275dbb1ad52e18f79 Mon Sep 17 00:00:00 2001
+From: Francois Cartegnie <fcvlcdev at free.fr>
+Date: Tue, 7 Aug 2018 17:26:05 +0200
+Subject: [PATCH 2/2] really reset packet counter
+
+---
+ src/dvbpsi.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/dvbpsi.c b/src/dvbpsi.c
+index 7a844f0..cf63702 100644
+--- a/src/dvbpsi.c
++++ b/src/dvbpsi.c
+@@ -113,6 +113,9 @@ void dvbpsi_decoder_reset(dvbpsi_decoder_t* p_decoder, const bool b_force)
+ if (b_force)
+ p_decoder->b_current_valid = false;
+
++ p_decoder->i_continuity_counter = DVBPSI_INVALID_CC;
++ p_decoder->prevpacket[0] = 0;
++
+ /* Clear the section array */
+ dvbpsi_DeletePSISections(p_decoder->p_sections);
+ p_decoder->p_sections = NULL;
+--
+2.14.4
+
diff --git a/contrib/src/dvbpsi/rules.mak b/contrib/src/dvbpsi/rules.mak
index 86953a2be9..518949e11a 100644
--- a/contrib/src/dvbpsi/rules.mak
+++ b/contrib/src/dvbpsi/rules.mak
@@ -18,6 +18,8 @@ libdvbpsi: libdvbpsi-$(DVBPSI_VERSION).tar.bz2 .sum-dvbpsi
$(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR) && mv config.guess config.sub .auto
$(APPLY) $(SRC)/dvbpsi/dvbpsi-noexamples.patch
$(APPLY) $(SRC)/dvbpsi/dvbpsi-sys-types.patch
+ $(APPLY) $(SRC)/dvbpsi/0001-really-identify-duplicates.patch
+ $(APPLY) $(SRC)/dvbpsi/0002-really-reset-packet-counter.patch
$(MOVE)
.dvbpsi: libdvbpsi
More information about the vlc-commits
mailing list