# CSJ2K.j2k.entropy.encoder.StdEntropyCoder

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder" class="text-break">StdEntropyCoder Class
</h1>
  <div class="markdown level0 summary"><p>This class implements the JPEG 2000 entropy coder, which codes stripes in
code-blocks. This entropy coding engine can function in a single-threaded
mode where one code-block is encoded at a time, or in a multi-threaded mode
where multiple code-blocks are entropy coded in parallel. The interface
presented by this class is the same in both modes.</p>
<pre><code>       &lt;p&gt;The number of threads used by this entropy coder is specified by the
       &quot;jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads&quot; Java system
       property. If set to &quot;0&quot; the single threaded implementation is used. If set
       to 'n' ('n' larger than 0) then 'n' extra threads are started by this class
       which are used to encode the code-blocks in parallel (i.e. ideally 'n'
       code-blocks will be encoded in parallel at a time). On multiprocessor
       machines under a &quot;native threads&quot; Java Virtual Machine implementation each
       one of these threads can run on a separate processor speeding up the
       encoding time. By default the single-threaded implementation is used. The
       multi-threaded implementation currently assumes that the vast majority of
       consecutive calls to 'getNextCodeBlock()' will be done on the same
       component. If this is not the case, the speed-up that can be expected on
       multiprocessor machines might be significantly decreased.&lt;/p&gt;

       &lt;p&gt;The code-blocks are rectangular, with dimensions which must be powers of
       2. Each dimension has to be no smaller than 4 and no larger than 256. The
       product of the two dimensions (i.e. area of the code-block) may not exceed
       4096.&lt;/p&gt;

       &lt;p&gt;Context 0 of the MQ-coder is used as the uniform one (uniform,
       non-adaptive probability distribution). Context 1 is used for RLC
       coding. Contexts 2-10 are used for zero-coding (ZC), contexts 11-15 are
       used for sign-coding (SC) and contexts 16-18 are used for
       magnitude-refinement (MR).&lt;/p&gt;

       &lt;p&gt;This implementation buffers the symbols and calls the MQ coder only once
       per stripe and per coding pass, to reduce the method call overhead.&lt;/p&gt;

       &lt;p&gt;This implementation also provides some timing features. They can be
       enabled by setting the 'DO_TIMING' constant of this class to true and
       recompiling. The timing uses the 'System.currentTimeMillis()' Java API
       call, which returns wall clock time, not the actual CPU time used. The
       timing results will be printed on the message output. Since the times
       reported are wall clock times and not CPU usage times they can not be added
       to find the total used time (i.e. some time might be counted in several
       places). When timing is disabled ('DO_TIMING' is false) there is no penalty
       if the compiler performs some basic optimizations. Even if not the penalty
       should be negligeable.&lt;/p&gt;

       &lt;p&gt;The source module must implement the CBlkQuantDataSrcEnc interface and
       code-block's data is received in a CBlkWTData instance. This modules sends
       code-block's information in a CBlkRateDistStats instance.&lt;/p&gt;
</code></pre>
</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"><a class="xref" href="CSJ2K.j2k.image.ImgDataAdapter.html">ImgDataAdapter</a></div>
    <div class="level2"><a class="xref" href="CSJ2K.j2k.entropy.encoder.EntropyCoder.html">EntropyCoder</a></div>
    <div class="level3"><span class="xref">StdEntropyCoder</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="CSJ2K.j2k.entropy.encoder.CodedCBlkDataSrcEnc.html">CodedCBlkDataSrcEnc</a></div>
    <div><a class="xref" href="CSJ2K.j2k.wavelet.analysis.ForwWTDataProps.html">ForwWTDataProps</a></div>
    <div><a class="xref" href="CSJ2K.j2k.image.ImgData.html">ImgData</a></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.C1Pdf.4.8.dll</h6>
  <h5 id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class StdEntropyCoder : EntropyCoder, CodedCBlkDataSrcEnc, ForwWTDataProps, ImgData</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class StdEntropyCoder
    Inherits EntropyCoder
    Implements CodedCBlkDataSrcEnc, ForwWTDataProps, ImgData</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_StdEntropyCoder__ctor_CSJ2K_j2k_quantization_quantizer_CBlkQuantDataSrcEnc_CSJ2K_j2k_entropy_CBlkSizeSpec_CSJ2K_j2k_entropy_PrecinctSizeSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.#ctor(CSJ2K.j2k.quantization.quantizer.CBlkQuantDataSrcEnc,CSJ2K.j2k.entropy.CBlkSizeSpec,CSJ2K.j2k.entropy.PrecinctSizeSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec,CSJ2K.j2k.StringSpec)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.-ctor.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder__ctor_CSJ2K_j2k_quantization_quantizer_CBlkQuantDataSrcEnc_CSJ2K_j2k_entropy_CBlkSizeSpec_CSJ2K_j2k_entropy_PrecinctSizeSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_CSJ2K_j2k_StringSpec_">StdEntropyCoder(CBlkQuantDataSrcEnc, CBlkSizeSpec, PrecinctSizeSpec, StringSpec, StringSpec, StringSpec, StringSpec, StringSpec, StringSpec, StringSpec)</a>
        </td>
        <td class="markdown level1 summary"><p>Instantiates a new entropy coder engine, with the specified source of
data, nominal block width and height.</p>
<pre><code>       &lt;p&gt;If the 'OPT_PRED_TERM' option is given then the MQ termination must
       be 'TERM_PRED_ER' or an exception is thrown.&lt;/p&gt;
</code></pre>
</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_StdEntropyCoder_DEF_THREADS_NUM" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.DEF_THREADS_NUM">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.DEF_THREADS_NUM.html">DEF_THREADS_NUM</a>
        </td>
        <td class="markdown level1 summary"><p>The default value for the property in THREADS_PROP_NAME: 0</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_THREADS_PRIORITY_INC" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.THREADS_PRIORITY_INC">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.THREADS_PRIORITY_INC.html">THREADS_PRIORITY_INC</a>
        </td>
        <td class="markdown level1 summary"><p>The increase in priority for the compressor threads, currently 3. The
compressor threads will have a priority of THREADS_PRIORITY_INC more
than the priority of the thread calling this class constructor. Used
only in the multi-threaded implementation.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_THREADS_PROP_NAME" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.THREADS_PROP_NAME">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.THREADS_PROP_NAME.html">THREADS_PROP_NAME</a>
        </td>
        <td class="markdown level1 summary"><p>The Java system property name for the number of threads to use:
jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_bms" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.bms">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.bms.html">bms</a>
        </td>
        <td class="markdown level1 summary"><p>By-pass mode specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_css" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.css">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.css.html">css</a>
        </td>
        <td class="markdown level1 summary"><p>Causal stripes specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_lcs" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.lcs">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.lcs.html">lcs</a>
        </td>
        <td class="markdown level1 summary"><p>The length calculation specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_mqrs" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.mqrs">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.mqrs.html">mqrs</a>
        </td>
        <td class="markdown level1 summary"><p>MQ reset specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_rts" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.rts">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.rts.html">rts</a>
        </td>
        <td class="markdown level1 summary"><p>Regular termination specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_sss" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.sss">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.sss.html">sss</a>
        </td>
        <td class="markdown level1 summary"><p>Error resilience segment symbol use specifications</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_tts" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.tts">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.tts.html">tts</a>
        </td>
        <td class="markdown level1 summary"><p>The termination type specifications</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_StdEntropyCoder_getCBlkHeight_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getCBlkHeight(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getCBlkHeight.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getCBlkHeight_System_Int32_System_Int32_">getCBlkHeight(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the code-block height for the specified tile and component.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getCBlkWidth_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getCBlkWidth(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getCBlkWidth.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getCBlkWidth_System_Int32_System_Int32_">getCBlkWidth(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the code-block width for the specified tile and component.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getNextCodeBlock_System_Int32_CSJ2K_j2k_entropy_encoder_CBlkRateDistStats_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getNextCodeBlock(System.Int32,CSJ2K.j2k.entropy.encoder.CBlkRateDistStats)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getNextCodeBlock.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getNextCodeBlock_System_Int32_CSJ2K_j2k_entropy_encoder_CBlkRateDistStats_">getNextCodeBlock(int, CBlkRateDistStats)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the next coded code-block in the current tile for the specified
component, as a copy (see below). The order in which code-blocks are
returned is not specified. However each code-block is returned only
once and all code-blocks will be returned if the method is called 'N'
times, where 'N' is the number of code-blocks in the tile. After all
the code-blocks have been returned for the current tile calls to this
method will return 'null'.</p>
<pre><code>       &lt;p&gt;When changing the current tile (through 'setTile()' or 'nextTile()')
       this method will always return the first code-block, as if this method
       was never called before for the new current tile.&lt;/p&gt;

       &lt;p&gt;The data returned by this method is always a copy of the internal
       data of this object, if any, and it can be modified &quot;in place&quot; without
       any problems after being returned.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getPPX_System_Int32_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getPPX(System.Int32,System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getPPX.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getPPX_System_Int32_System_Int32_System_Int32_">getPPX(int, int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the precinct partition width for the specified component, tile
and resolution level.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getPPY_System_Int32_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getPPY(System.Int32,System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.getPPY.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_getPPY_System_Int32_System_Int32_System_Int32_">getPPY(int, int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the precinct partition height for the specified component, tile
and resolution level.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_initTileComp_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.initTileComp(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.initTileComp.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_initTileComp_System_Int32_System_Int32_">initTileComp(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Load options, length calculation type and termination type for each
tile-component.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_nextTile" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.nextTile">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.nextTile.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_nextTile">nextTile()</a>
        </td>
        <td class="markdown level1 summary"><p>Advances to the next tile, in standard scan-line order (by rows then
columns). An NoNextElementException is thrown if the current tile is
the last one (i.e. there is no next tile).</p>
<pre><code>       &lt;p&gt;This default implementation just advances to the next tile in the
       source.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_precinctPartitionUsed_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.precinctPartitionUsed(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.precinctPartitionUsed.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_precinctPartitionUsed_System_Int32_System_Int32_">precinctPartitionUsed(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns true if precinct partition is used for the specified component
and tile, returns false otherwise.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_StdEntropyCoder_setTile_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.setTile(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.StdEntropyCoder.setTile.html#CSJ2K_j2k_entropy_encoder_StdEntropyCoder_setTile_System_Int32_System_Int32_">setTile(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Changes the current tile, given the new indexes. An
IllegalArgumentException is thrown if the indexes do not correspond to
a valid tile.</p>
<pre><code>       &lt;p&gt;This default implementation just changes the tile in the source.&lt;/p&gt;
</code></pre>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="seealso">See Also</h3>
  <div class="seealso">
      <div><a class="xref" href="CSJ2K.j2k.quantization.quantizer.CBlkQuantDataSrcEnc.html">CBlkQuantDataSrcEnc</a></div>
      <div><a class="xref" href="CSJ2K.j2k.wavelet.analysis.CBlkWTData.html">CBlkWTData</a></div>
      <div><a class="xref" href="CSJ2K.j2k.entropy.encoder.CBlkRateDistStats.html">CBlkRateDistStats</a></div>
  </div>

</div>
