# CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator" class="text-break">EBCOTRateAllocator Class
</h1>
  <div class="markdown level0 summary"><p>This implements the EBCOT post compression rate allocation algorithm. This
algorithm finds the most suitable truncation points for the set of
code-blocks, for each layer target bitrate. It works by first collecting
the rate distortion info from all code-blocks, in all tiles and all
components, and then running the rate-allocation on the whole image at
once, for each layer.</p>
<pre><code>       &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;
</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.PostCompRateAllocator.html">PostCompRateAllocator</a></div>
    <div class="level3"><span class="xref">EBCOTRateAllocator</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <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_EBCOTRateAllocator_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class EBCOTRateAllocator : PostCompRateAllocator, ImgData</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class EBCOTRateAllocator
    Inherits PostCompRateAllocator
    Implements 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_EBCOTRateAllocator__ctor_CSJ2K_j2k_entropy_encoder_CodedCBlkDataSrcEnc_CSJ2K_j2k_entropy_encoder_LayersInfo_CSJ2K_j2k_codestream_writer_CodestreamWriter_CSJ2K_j2k_encoder_EncoderSpecs_CSJ2K_j2k_util_ParameterList_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.#ctor(CSJ2K.j2k.entropy.encoder.CodedCBlkDataSrcEnc,CSJ2K.j2k.entropy.encoder.LayersInfo,CSJ2K.j2k.codestream.writer.CodestreamWriter,CSJ2K.j2k.encoder.EncoderSpecs,CSJ2K.j2k.util.ParameterList)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.-ctor.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator__ctor_CSJ2K_j2k_entropy_encoder_CodedCBlkDataSrcEnc_CSJ2K_j2k_entropy_encoder_LayersInfo_CSJ2K_j2k_codestream_writer_CodestreamWriter_CSJ2K_j2k_encoder_EncoderSpecs_CSJ2K_j2k_util_ParameterList_">EBCOTRateAllocator(CodedCBlkDataSrcEnc, LayersInfo, CodestreamWriter, EncoderSpecs, ParameterList)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes the EBCOT rate allocator of entropy coded data. The layout
of layers, and their bitrate constraints, is specified by the 'lyrs'
parameter.</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_EBCOTRateAllocator_initialize" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.initialize">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.initialize.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_initialize">initialize()</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes the layers array. This must be called after the main header
has been entirely written or simulated, so as to take its overhead into
account. This method will get all the code-blocks and then initialize
the target bitrates for each layer, according to the specifications.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_runAndWrite" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.runAndWrite">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.runAndWrite.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_runAndWrite">runAndWrite()</a>
        </td>
        <td class="markdown level1 summary"><p>Runs the rate allocation algorithm and writes the data to the bit
stream writer object provided to the constructor.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeCompPosResLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeCompPosResLy(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[][],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeCompPosResLy.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeCompPosResLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_">writeCompPosResLy(int, int, int, int, int, int[][], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Write a piece of bit stream according to the
COMP_POS_RES_LY_PROG progression mode and between given bounds</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeLyResCompPos_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeLyResCompPos(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[][],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeLyResCompPos.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeLyResCompPos_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_">writeLyResCompPos(int, int, int, int, int, int[][], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Write a piece of bit stream according to the
LY_RES_COMP_POS_PROG progression mode and between given bounds</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writePosCompResLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writePosCompResLy(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[][],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writePosCompResLy.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writePosCompResLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_">writePosCompResLy(int, int, int, int, int, int[][], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Write a piece of bit stream according to the
COMP_POS_RES_LY_PROG progression mode and between given bounds</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeResLyCompPos_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeResLyCompPos(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[][],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeResLyCompPos.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeResLyCompPos_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_">writeResLyCompPos(int, int, int, int, int, int[][], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Write a piece of bit stream according to the
RES_LY_COMP_POS_PROG progression mode and between given bounds</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeResPosCompLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_" data-uid="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeResPosCompLy(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[][],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.entropy.encoder.EBCOTRateAllocator.writeResPosCompLy.html#CSJ2K_j2k_entropy_encoder_EBCOTRateAllocator_writeResPosCompLy_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_System_Int32_____System_Int32_">writeResPosCompLy(int, int, int, int, int, int[][], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Write a piece of bit stream according to the
RES_POS_COMP_LY_PROG progression mode and between given bounds</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="seealso">See Also</h3>
  <div class="seealso">
      <div><a class="xref" href="CSJ2K.j2k.entropy.encoder.PostCompRateAllocator.html">PostCompRateAllocator</a></div>
      <div><a class="xref" href="CSJ2K.j2k.entropy.encoder.CodedCBlkDataSrcEnc.html">CodedCBlkDataSrcEnc</a></div>
  </div>

</div>
