[libdvbpsi-devel] src/tables/tot.c: Simplify dvbpsi_ValidTOTSection()

Jean-Paul Saman git at videolan.org
Wed Jun 27 14:29:07 CEST 2012


libdvbpsi | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Jun 27 14:20:33 2012 +0200| [f2b2ab34043fd2a20b7b9754a1c116f071729d85] | committer: Jean-Paul Saman

src/tables/tot.c: Simplify dvbpsi_ValidTOTSection()

The function reimplemented the CRC check function which is available
in src/psi.c

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=f2b2ab34043fd2a20b7b9754a1c116f071729d85
---

 src/tables/tot.c |   22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/tables/tot.c b/src/tables/tot.c
index ccdf96f..4eead37 100644
--- a/src/tables/tot.c
+++ b/src/tables/tot.c
@@ -310,10 +310,11 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
     assert(p_dvbpsi);
     assert(p_dvbpsi->p_private);
 
-    const uint8_t i_table_id = ((p_section->i_table_id == 0x70 ||
-                                 p_section->i_table_id == 0x73)) ?
+    const uint8_t i_table_id = ((p_section->i_table_id == 0x70 ||  /* TDT */
+                                 p_section->i_table_id == 0x73)) ? /* TOT */
                                     p_section->i_table_id : 0x70;
 
+    /* FIXME: setting b_syntax_indicator is a workaround here */
     p_section->b_syntax_indicator = true;
     if (!dvbpsi_CheckPSISection(p_dvbpsi, p_section, i_table_id, "TDT/TOT decoder"))
     {
@@ -412,22 +413,11 @@ static bool dvbpsi_ValidTOTSection(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_s
         return true;
     }
 
-    /* Check the CRC_32 if it's a TOT */
-    uint32_t i_crc = 0xffffffff;
-    uint8_t* p_byte = p_section->p_data;
-
-    while (p_byte < p_section->p_payload_end)
-    {
-        i_crc = (i_crc << 8) ^ dvbpsi_crc32_table[(i_crc >> 24) ^ (*p_byte)];
-        p_byte++;
-    }
-
-    if (i_crc == 0)
-        return true;
-    else
+    if (p_section->b_syntax_indicator &&
+        !dvbpsi_ValidPSISection(p_section))
     {
         dvbpsi_error(p_dvbpsi, "TDT/TOT decoder",
-                               "Bad CRC_32 (0x%08x) !!!", i_crc);
+                               "Bad CRC_32!!!");
         return false;
     }
 



More information about the libdvbpsi-devel mailing list