Hi Jean-Paul,<div>thanks for your attention,</div><div>Here is my actual solution which does not break those sections which have section_indicator set to 0 and do not have a CRC32 field</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">// TOT has table_id 0x73</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>(<span style="color:#c0c0c0"> </span>(p_section->p_data[<span style="color:#000080">0</span>]==<span style="color:#000080">0x73</span>)<span style="color:#c0c0c0"> </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><br></div><div>Anyway, i'm gonna patch everything on git.</div><div>Currently I found problem in decoding NIT CAT BAT TOT.</div><div>thanks</div><div><br></div>
<br><div class="gmail_quote">2013/1/23 Jean-Paul Saman <span dir="ltr"><<a href="mailto:jpsaman@videolan.org" target="_blank">jpsaman@videolan.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">HI Angelo,<br><div><div class="gmail_extra"><br></div><div class="gmail_extra">Thank you for bringing this to my attention.<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div class="im">On Tue, Jan 22, 2013 at 12:20 PM, Angelo Schiavone <span dir="ltr"><<a href="mailto:angelo.schiavone@gmail.com" target="_blank">angelo.schiavone@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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></blockquote><div><br></div></div><div>Removing this check will break RST, ST and DIT tables, both have section_indicator set to 0 and do not have a CRC32 field.<br>The change should be a little more intelligent, then that and properly reviewed and tested.<br>
<br></div><div>Kind regards,<br><br></div><div>Jean-Paul Saman.<br></div><div>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><div></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>
<br></div>_______________________________________________<br>
libdvbpsi-devel mailing list<br>
<a href="mailto:libdvbpsi-devel@videolan.org" target="_blank">libdvbpsi-devel@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/libdvbpsi-devel" target="_blank">http://mailman.videolan.org/listinfo/libdvbpsi-devel</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div>