# CSJ2K.j2k.entropy.encoder.MQCoder

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_entropy_encoder_MQCoder" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder" class="text-break">MQCoder Class
</h1>
  <div class="markdown level0 summary"></div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">MQCoder</span></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="CSJ2K.j2k.entropy.encoder.html">CSJ2K.j2k.entropy.encoder</a></h6>
  <h6><strong>Assembly</strong>: C1.WPF.ReportViewer.4.6.2.dll</h6>
  <h5 id="CSJ2K_j2k_entropy_encoder_MQCoder_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class MQCoder</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class MQCoder</code></pre>
  </div>
  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder__ctor_CSJ2K_j2k_entropy_encoder_ByteOutputBuffer_System_Int32_System_Int32___" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.#ctor(CSJ2K.j2k.entropy.encoder.ByteOutputBuffer,System.Int32,System.Int32[])">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.-ctor.html#CSJ2K_j2k_entropy_encoder_MQCoder__ctor_CSJ2K_j2k_entropy_encoder_ByteOutputBuffer_System_Int32_System_Int32___">MQCoder(ByteOutputBuffer, int, int[])</a>
        </td>
        <td class="markdown level1 summary"><p>Instantiates a new MQ-coder, with the specified number of contexts and
initial states. The compressed bytestream is written to the 'oStream'
object.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="fields">Fields
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_LENGTH_LAZY" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_LAZY">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_LAZY.html">LENGTH_LAZY</a>
        </td>
        <td class="markdown level1 summary"><p>Identifier for the lazy length calculation. The lazy length
calculation is not optimal but is extremely simple.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_LENGTH_LAZY_GOOD" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_LAZY_GOOD">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_LAZY_GOOD.html">LENGTH_LAZY_GOOD</a>
        </td>
        <td class="markdown level1 summary"><p>Identifier for a very simple length calculation. This provides better
results than the 'LENGTH_LAZY' computation. This is the old length
calculation that was implemented in this class.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_LENGTH_NEAR_OPT" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_NEAR_OPT">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.LENGTH_NEAR_OPT.html">LENGTH_NEAR_OPT</a>
        </td>
        <td class="markdown level1 summary"><p>Identifier for the near optimal length calculation. This calculation
is more complex than the lazy one but provides an almost optimal length
calculation.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_TERM_EASY" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_EASY">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_EASY.html">TERM_EASY</a>
        </td>
        <td class="markdown level1 summary"><p>The identifier for the easy termination that is simpler than the
'TERM_NEAR_OPT' one but slightly less efficient.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_TERM_FULL" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_FULL">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_FULL.html">TERM_FULL</a>
        </td>
        <td class="markdown level1 summary"><p>The identifier fort the termination that uses a full flush. This is
the less efficient termination.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_TERM_NEAR_OPT" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_NEAR_OPT">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_NEAR_OPT.html">TERM_NEAR_OPT</a>
        </td>
        <td class="markdown level1 summary"><p>The identifier for the termination that uses the near optimal length
calculation to terminate the arithmetic codewrod</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_TERM_PRED_ER" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_PRED_ER">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.TERM_PRED_ER.html">TERM_PRED_ER</a>
        </td>
        <td class="markdown level1 summary"><p>The identifier for the predictable termination policy for error
resilience. This is the same as the 'TERM_EASY' one but an special
sequence of bits is embodied in the spare bits for error resilience
purposes.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_LenCalcType" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.LenCalcType">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.LenCalcType.html#CSJ2K_j2k_entropy_encoder_MQCoder_LenCalcType">LenCalcType</a>
        </td>
        <td class="markdown level1 summary"><p>Set the length calculation type to the specified type.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_NumCodedBytes" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.NumCodedBytes">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.NumCodedBytes.html#CSJ2K_j2k_entropy_encoder_MQCoder_NumCodedBytes">NumCodedBytes</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of bytes that are necessary from the compressed
output stream to decode all the symbols that have been coded this
far. The number of returned bytes does not include anything coded
previous to the last time the 'terminate()' or 'reset()' methods where
called.</p>
<pre><code>       &lt;p&gt;The values returned by this method are then to be used in finishing
       the length calculation with the 'finishLengthCalculation()' method,
       after compensation of the offset in the number of bytes due to previous
       terminated segments.&lt;/p&gt;&lt;p&gt;This method should not be called if the current coding pass is to be
       terminated. The 'terminate()' method should be called instead.&lt;/p&gt;&lt;p&gt;The calculation is done based on the type of length calculation
       specified at the constructor.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_NumCtxts" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.NumCtxts">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.NumCtxts.html#CSJ2K_j2k_entropy_encoder_MQCoder_NumCtxts">NumCtxts</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of contexts in the arithmetic coder.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_TermType" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.TermType">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.TermType.html#CSJ2K_j2k_entropy_encoder_MQCoder_TermType">TermType</a>
        </td>
        <td class="markdown level1 summary"><p>Set termination type to the specified type.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_codeSymbol_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.codeSymbol(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.codeSymbol.html#CSJ2K_j2k_entropy_encoder_MQCoder_codeSymbol_System_Int32_System_Int32_">codeSymbol(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>This function performs the arithmetic encoding of one symbol. The
function receives a bit that is to be encoded and a context with which
to encode it.</p>
<pre><code>       &lt;p&gt;Each context has a current MPS and an index describing what the 
       current probability is for the LPS. Each bit is encoded and if the
       probability of the LPS exceeds .5, the MPS and LPS are switched.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_codeSymbols_System_Int32___System_Int32___System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.codeSymbols(System.Int32[],System.Int32[],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.codeSymbols.html#CSJ2K_j2k_entropy_encoder_MQCoder_codeSymbols_System_Int32___System_Int32___System_Int32_">codeSymbols(int[], int[], int)</a>
        </td>
        <td class="markdown level1 summary"><p>This function performs the arithmetic encoding of several symbols
together. The function receives an array of symbols that are to be
encoded and an array containing the contexts with which to encode them.</p>
<pre><code>       &lt;p&gt;The advantage of using this function is that the cost of the method
       call is amortized by the number of coded symbols per method call.&lt;/p&gt;&lt;p&gt;Each context has a current MPS and an index describing what the 
       current probability is for the LPS. Each bit is encoded and if the
       probability of the LPS exceeds .5, the MPS and LPS are switched.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_fastCodeSymbols_System_Int32_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.fastCodeSymbols(System.Int32,System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.fastCodeSymbols.html#CSJ2K_j2k_entropy_encoder_MQCoder_fastCodeSymbols_System_Int32_System_Int32_System_Int32_">fastCodeSymbols(int, int, int)</a>
        </td>
        <td class="markdown level1 summary"></td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_finishLengthCalculation_System_Int32___System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.finishLengthCalculation(System.Int32[],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.finishLengthCalculation.html#CSJ2K_j2k_entropy_encoder_MQCoder_finishLengthCalculation_System_Int32___System_Int32_">finishLengthCalculation(int[], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Terminates the calculation of the required length for each coding
pass. This method must be called just after the 'terminate()' one has
been called for each terminated MQ segment.</p>
<pre><code>       &lt;p&gt;The values in 'rates' must have been compensated for any offset due
       to previous terminated segments, so that the correct index to the
       stored coded data is used.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_reset" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.reset">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.reset.html#CSJ2K_j2k_entropy_encoder_MQCoder_reset">reset()</a>
        </td>
        <td class="markdown level1 summary"><p>Reinitializes the MQ coder and the underlying 'ByteOutputBuffer' buffer
as if a new object was instantaited. All the data in the
'ByteOutputBuffer' buffer is erased and the state and contexts of the
MQ coder are reinitialized). Additionally any saved MQ states are
discarded.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_resetCtxt_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.resetCtxt(System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.resetCtxt.html#CSJ2K_j2k_entropy_encoder_MQCoder_resetCtxt_System_Int32_">resetCtxt(int)</a>
        </td>
        <td class="markdown level1 summary"><p>Resets a context to the original probability distribution, and sets its
more probable symbol to 0.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_resetCtxts" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.resetCtxts">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.resetCtxts.html#CSJ2K_j2k_entropy_encoder_MQCoder_resetCtxts">resetCtxts()</a>
        </td>
        <td class="markdown level1 summary"><p>Resets all contexts to their original probability distribution and sets
all more probable symbols to 0.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_MQCoder_terminate" data-uid="CSJ2K.j2k.entropy.encoder.MQCoder.terminate">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.MQCoder.terminate.html#CSJ2K_j2k_entropy_encoder_MQCoder_terminate">terminate()</a>
        </td>
        <td class="markdown level1 summary"><p>This function flushes the remaining encoded bits and makes sure that
enough information is written to the bit stream to be able to finish
decoding, and then it reinitializes the internal state of the MQ coder
but without modifying the context states.</p>
<pre><code>       &lt;p&gt;After calling this method the 'finishLengthCalculation()' method
       should be called, after compensating the returned length for the length
       of previous coded segments, so that the length calculation is
       finalized.&lt;/p&gt;&lt;p&gt;The type of termination used depends on the one specified at the
       constructor.&lt;/p&gt;
</code></pre>
</td>
      </tr>
    </tbody>
  </table>

</div>
