Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is my attempt to implement that unpacker. Not tested as there is no example data to test it with... (not even compiled, actually)</p> <pre><code>std::vector&lt;int&gt; regions(std::vector&lt;unsigned char&gt;&amp; data6) { int rp = 0, sz = data6.size(); std::vector&lt;int&gt; result; int current_id = 0; while (rp &lt; sz) { int c = data6[rp++]; if (c &lt;= 0x3E) { // 0x00..0x3E : skip forward by this many region IDs current_id += c; } else if (c == 0x3F) { // 0x3F WORD skip forward by the amount given in the following 16-bit WORD if (rp + 2 &gt; sz) throw std::runtime_error("Invalid data"); int count = data[rp] + (data[rp + 1] &lt;&lt; 8); // (NOTE: May be H/L ?) rp += 2; current_id += count; } else if (c &lt;= 0x7F) { // 0x40..0x7F skip forward based on bits 3..5, // then include the number of IDs based on bits 0..2 int keep = (c &amp; 7); int skip = (c &gt;&gt; 3) &amp; 7; current_id += skip; for (int i=0; i&lt;keep; i++) result.push_back(current_id++); } else if (c &lt;= 0xBF) { // 0x80..0xBF include the number of IDs based on bits 3..5, // then skip the number of IDs based on bits 0..2 int skip = (c &amp; 7); int keep = (c &gt;&gt; 3) &amp; 7; for (int i=0; i&lt;keep; i++) result.push_back(current_id++); current_id += skip; } else if (c &lt;= 0xFE) { // 0xC0..0xFE subtracting 0xC0, this many region IDs are nearby int keep = c - 0xC0; for (int i=0; i&lt;keep; i++) result.push_back(current_id++); } else { // 0xFF WORD the number of region IDs given by the following WORD are nearby if (rp + 2 &gt; sz) throw std::runtime_error("Invalid data"); int count = data[rp] + (data[rp + 1] &lt;&lt; 8); // (NOTE: May be H/L ?) rp += 2; for (int i=0; i&lt;count; i++) result.push_back(current_id++); } } return result; } </code></pre> <p>I assumed that <code>WORD</code>s are encoded as low/high, but may be it's the opposite...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload