Hi guys, it's me again.<div>I found a bug in libdvbpsi TOT table decoding.</div><div>Every time a TOT occurres in my transport stream the library throws a CRC error even if the CRC is correct.</div><div>That's because "dvbpsi_ValidPSISection" always return false since TOT tables have "section_syntax_indicator" set to 0</div>
<div>but it has a CRC field. </div><div>TOT has section_syntax_indicator==0 and CRC field (ETSI EN 300 468 clause 5.2.6) but the dvbpsi_ValidPSISection function assumes that any table</div><div>which have "section_syntax_indicator" set to 0 has no CRC field, thus it returns false, which comes to TOT crc error.</div>
<div><br></div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#808000">bool</span><span style="color:#c0c0c0"> </span>dvbpsi_ValidPSISection(<span style="color:#800080">dvbpsi_psi_section_t</span>*<span style="color:#c0c0c0"> </span>p_section)</pre>
<pre style="margin-top:0px;margin-bottom:0px">{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(p_section->b_syntax_indicator)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#008000">/*</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Check</span><span style="color:#c0c0c0"> </span><span style="color:#008000">the</span><span style="color:#c0c0c0"> </span><span style="color:#008000">CRC_32</span><span style="color:#c0c0c0"> </span><span style="color:#008000">if</span><span style="color:#c0c0c0"> </span><span style="color:#008000">b_syntax_indicator</span><span style="color:#c0c0c0"> </span><span style="color:#008000">is</span><span style="color:#c0c0c0"> </span><span style="color:#008000">false</span><span style="color:#c0c0c0"> </span><span style="color:#008000">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>uint32_t<span style="color:#c0c0c0"> </span>i_crc<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">0xffffffff</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>uint8_t*<span style="color:#c0c0c0"> </span>p_byte<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>p_section->p_data;</pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">while</span>(p_byte<span style="color:#c0c0c0"> </span><<span style="color:#c0c0c0"> </span>p_section->p_payload_end<span style="color:#c0c0c0"> </span>+<span style="color:#c0c0c0"> </span><span style="color:#000080">4</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>i_crc<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>(i_crc<span style="color:#c0c0c0"> </span><<<span style="color:#c0c0c0"> </span><span style="color:#000080">8</span>)<span style="color:#c0c0c0"> </span>^<span style="color:#c0c0c0"> </span>dvbpsi_crc32_table[(i_crc<span style="color:#c0c0c0"> </span>>><span style="color:#c0c0c0"> </span><span style="color:#000080">24</span>)<span style="color:#c0c0c0"> </span>^<span style="color:#c0c0c0"> </span>(*p_byte)];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>p_byte++;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(i_crc<span style="color:#c0c0c0"> </span>==<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#808000">true</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">else</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#808000">false</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">else</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#008000">/*</span><span style="color:#c0c0c0"> </span><span style="color:#008000">No</span><span style="color:#c0c0c0"> </span><span style="color:#008000">check</span><span style="color:#c0c0c0"> </span><span style="color:#008000">to</span><span style="color:#c0c0c0"> </span><span style="color:#008000">do</span><span style="color:#c0c0c0"> </span><span style="color:#008000">if</span><span style="color:#c0c0c0"> </span><span style="color:#008000">b_syntax_indicator</span><span style="color:#c0c0c0"> </span><span style="color:#008000">is</span><span style="color:#c0c0c0"> </span><span style="color:#008000">false</span><span style="color:#c0c0c0"> </span><span style="color:#008000">*/</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#808000">false</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px">}</pre></div>
<div><br></div>