C# 클래스 CSJ2K.j2k.entropy.encoder.StdEntropyCoder

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.

The number of threads used by this entropy coder is specified by the "jj2000.j2k.entropy.encoder.StdEntropyCoder.nthreads" Java system property. If set to "0" 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 "native threads" 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.

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.

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).

This implementation buffers the symbols and calls the MQ coder only once per stripe and per coding pass, to reduce the method call overhead.

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.

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.

상속: CSJ2K.j2k.entropy.encoder.EntropyCoder
파일 보기 프로젝트 열기: cureos/csj2k 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
bms CSJ2K.j2k.StringSpec
css CSJ2K.j2k.StringSpec
lcs CSJ2K.j2k.StringSpec
mqrs CSJ2K.j2k.StringSpec
rts CSJ2K.j2k.StringSpec
sss CSJ2K.j2k.StringSpec
tts CSJ2K.j2k.StringSpec

공개 메소드들

메소드 설명
StdEntropyCoder ( CBlkQuantDataSrcEnc src, CBlkSizeSpec cblks, PrecinctSizeSpec pss, CSJ2K.j2k.StringSpec bms, CSJ2K.j2k.StringSpec mqrs, CSJ2K.j2k.StringSpec rts, CSJ2K.j2k.StringSpec css, CSJ2K.j2k.StringSpec sss, CSJ2K.j2k.StringSpec lcs, CSJ2K.j2k.StringSpec tts ) : CSJ2K.j2k.quantization.quantizer

Instantiates a new entropy coder engine, with the specified source of data, nominal block width and height.

If the 'OPT_PRED_TERM' option is given then the MQ termination must be 'TERM_PRED_ER' or an exception is thrown.

getCBlkHeight ( int t, int c ) : int

Returns the code-block height for the specified tile and component.

getCBlkWidth ( int t, int c ) : int

Returns the code-block width for the specified tile and component.

getNextCodeBlock ( int c, CSJ2K.j2k.entropy.encoder.CBlkRateDistStats ccb ) : CSJ2K.j2k.entropy.encoder.CBlkRateDistStats

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'.

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.

The data returned by this method is always a copy of the internal data of this object, if any, and it can be modified "in place" without any problems after being returned.

getPPX ( int t, int c, int rl ) : int

Returns the precinct partition width for the specified component, tile and resolution level.

getPPY ( int t, int c, int rl ) : int

Returns the precinct partition height for the specified component, tile and resolution level.

initTileComp ( int nt, int nc ) : void

Load options, length calculation type and termination type for each tile-component.

nextTile ( ) : void

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).

This default implementation just advances to the next tile in the source.

precinctPartitionUsed ( int c, int t ) : bool

Returns true if precinct partition is used for the specified component and tile, returns false otherwise.

setTile ( int x, int y ) : void

Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.

This default implementation just changes the tile in the source.

비공개 메소드들

메소드 설명
StdEntropyCoder ( ) : CSJ2K.j2k.quantization.quantizer

Static initializer: initializes all the lookup tables.

calcSkipMSBP ( CSJ2K.j2k.wavelet.analysis.CBlkWTData cblk, int lmb ) : int

Calculates the number of magnitude bit-planes that are to be skipped, because they are non-significant. The algorithm looks for the largest magnitude and calculates the most significant bit-plane of it.

checkEndOfPassFF ( byte data, int rates, bool isterm, int n ) : void

Ensures that at the end of a non-terminated coding pass there is not a 0xFF byte, modifying the stored rates if necessary.

Due to error resiliance reasons, a coding pass should never have its last byte be a 0xFF, since that can lead to the emulation of a resync marker. This method checks if that is the case, and reduces the rate for a given pass if necessary. The ommitted 0xFF will be synthetized by the decoder if necessary, as required by JPEG 2000. This method should only be called once that the entire code-block is coded.

Passes that are terminated are not checked for the 0xFF byte, since it is assumed that the termination procedure does not output any trailing 0xFF. Checking the terminated segments would involve much more than just modifying the stored rates.

NOTE: It is assumed by this method that the coded data does not contain consecutive 0xFF bytes, as is the case with the MQ and 'arithemetic coding bypass' bit stuffing policy. However, the termination policies used should also respect this requirement.

cleanuppass ( CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int state, int fs, int zc_lut, int symbuf, int ctxtbuf, int ratebuf, int pidx, int ltpidx, int options ) : int

Performs the cleanup pass on the specified data and bit-plane. It codes all insignificant samples which have its "visited" state bit off, using the ZC, SC, and RLC primitives. It toggles the "visited" state bit to 0 (off) for all samples in the code-block.

compressCodeBlock ( int c, CSJ2K.j2k.entropy.encoder.CBlkRateDistStats ccb, CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, MQCoder mq, CSJ2K.j2k.entropy.encoder.BitToByteOutput bout, CSJ2K.j2k.entropy.encoder.ByteOutputBuffer out_Renamed, int state, double distbuf, int ratebuf, bool istermbuf, int symbuf, int ctxtbuf, int options, bool rev, int lcType, int tType ) : void

Compresses the code-block in 'srcblk' and puts the results in 'ccb', using the specified options and temporary storage.

magRefPass ( CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int state, int fm, int symbuf, int ctxtbuf, int ratebuf, int pidx, int ltpidx, int options ) : int

Performs the magnitude refinement pass on the specified data and bit-plane. It codes the samples which are significant and which do not have the "visited" state bit turned on, using the MR primitive. The "visited" state bit is not mofified for any samples.

rawMagRefPass ( CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, CSJ2K.j2k.entropy.encoder.BitToByteOutput bout, bool doterm, int bp, int state, int fm, int ratebuf, int pidx, int ltpidx, int options ) : int

Performs the magnitude refinement pass on the specified data and bit-plane, without using the arithmetic coder. It codes the samples which are significant and which do not have the "visited" state bit turned on, using the MR primitive. The "visited" state bit is not mofified for any samples.

In this method, the arithmetic coder is bypassed, and raw bits are directly written in the bit stream (useful when distribution are close to uniform, for intance, at high bit-rates and at lossless compression). The 'STATE_PREV_MR_R1' and 'STATE_PREV_MR_R2' bits are not set because they are used only when the arithmetic coder is not bypassed.

rawSigProgPass ( CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, CSJ2K.j2k.entropy.encoder.BitToByteOutput bout, bool doterm, int bp, int state, int fs, int ratebuf, int pidx, int ltpidx, int options ) : int

Performs the significance propagation pass on the specified data and bit-plane, without using the arithmetic coder. It codes all insignificant samples which have, at least, one of its immediate eight neighbors already significant, using the ZC and SC primitives as needed. It toggles the "visited" state bit to 1 for all those samples.

In this method, the arithmetic coder is bypassed, and raw bits are directly written in the bit stream (useful when distribution are close to uniform, for intance, at high bit-rates and at lossless compression).

sigProgPass ( CSJ2K.j2k.wavelet.analysis.CBlkWTData srcblk, MQCoder mq, bool doterm, int bp, int state, int fs, int zc_lut, int symbuf, int ctxtbuf, int ratebuf, int pidx, int ltpidx, int options ) : int

Performs the significance propagation pass on the specified data and bit-plane. It codes all insignificant samples which have, at least, one of its immediate eight neighbors already significant, using the ZC and SC primitives as needed. It toggles the "visited" state bit to 1 for all those samples.

메소드 상세

StdEntropyCoder() 공개 메소드

Instantiates a new entropy coder engine, with the specified source of data, nominal block width and height.

If the 'OPT_PRED_TERM' option is given then the MQ termination must be 'TERM_PRED_ER' or an exception is thrown.

public StdEntropyCoder ( CBlkQuantDataSrcEnc src, CBlkSizeSpec cblks, PrecinctSizeSpec pss, CSJ2K.j2k.StringSpec bms, CSJ2K.j2k.StringSpec mqrs, CSJ2K.j2k.StringSpec rts, CSJ2K.j2k.StringSpec css, CSJ2K.j2k.StringSpec sss, CSJ2K.j2k.StringSpec lcs, CSJ2K.j2k.StringSpec tts ) : CSJ2K.j2k.quantization.quantizer
src CBlkQuantDataSrcEnc The source of data /// ///
cblks CSJ2K.j2k.entropy.CBlkSizeSpec
pss CSJ2K.j2k.entropy.PrecinctSizeSpec Precinct partition specifications /// ///
bms CSJ2K.j2k.StringSpec By-pass mode specifications /// ///
mqrs CSJ2K.j2k.StringSpec MQ-reset specifications /// ///
rts CSJ2K.j2k.StringSpec Regular termination specifications /// ///
css CSJ2K.j2k.StringSpec Causal stripes specifications /// ///
sss CSJ2K.j2k.StringSpec Error resolution segment symbol use specifications /// ///
lcs CSJ2K.j2k.StringSpec Length computation specifications /// ///
tts CSJ2K.j2k.StringSpec Termination type specifications /// ///
리턴 CSJ2K.j2k.quantization.quantizer

getCBlkHeight() 공개 메소드

Returns the code-block height for the specified tile and component.
public getCBlkHeight ( int t, int c ) : int
t int The tile index /// ///
c int The component index /// ///
리턴 int

getCBlkWidth() 공개 메소드

Returns the code-block width for the specified tile and component.
public getCBlkWidth ( int t, int c ) : int
t int The tile index /// ///
c int the component index /// ///
리턴 int

getNextCodeBlock() 공개 메소드

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'.

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.

The data returned by this method is always a copy of the internal data of this object, if any, and it can be modified "in place" without any problems after being returned.

public getNextCodeBlock ( int c, CSJ2K.j2k.entropy.encoder.CBlkRateDistStats ccb ) : CSJ2K.j2k.entropy.encoder.CBlkRateDistStats
c int The component for which to return the next code-block. /// ///
ccb CSJ2K.j2k.entropy.encoder.CBlkRateDistStats If non-null this object might be used in returning the coded /// code-block in this or any subsequent call to this method. If null a new /// one is created and returned. If the 'data' array of 'cbb' is not null /// it may be reused to return the compressed data. /// ///
리턴 CSJ2K.j2k.entropy.encoder.CBlkRateDistStats

getPPX() 공개 메소드

Returns the precinct partition width for the specified component, tile and resolution level.
public getPPX ( int t, int c, int rl ) : int
t int the tile index /// ///
c int the component /// ///
rl int the resolution level /// ///
리턴 int

getPPY() 공개 메소드

Returns the precinct partition height for the specified component, tile and resolution level.
public getPPY ( int t, int c, int rl ) : int
t int the tile index /// ///
c int the component /// ///
rl int the resolution level /// ///
리턴 int

initTileComp() 공개 메소드

Load options, length calculation type and termination type for each tile-component.
public initTileComp ( int nt, int nc ) : void
nt int The number of tiles /// ///
nc int The number of components /// ///
리턴 void

nextTile() 공개 메소드

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).

This default implementation just advances to the next tile in the source.

public nextTile ( ) : void
리턴 void

precinctPartitionUsed() 공개 메소드

Returns true if precinct partition is used for the specified component and tile, returns false otherwise.
public precinctPartitionUsed ( int c, int t ) : bool
c int The component /// ///
t int The tile /// ///
리턴 bool

setTile() 공개 메소드

Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.

This default implementation just changes the tile in the source.

public setTile ( int x, int y ) : void
x int The horizontal index of the tile. /// ///
y int The vertical index of the new tile. /// ///
리턴 void

프로퍼티 상세

bms 공개적으로 프로퍼티

By-pass mode specifications
public StringSpec,CSJ2K.j2k bms
리턴 CSJ2K.j2k.StringSpec

css 공개적으로 프로퍼티

Causal stripes specifications
public StringSpec,CSJ2K.j2k css
리턴 CSJ2K.j2k.StringSpec

lcs 공개적으로 프로퍼티

The length calculation specifications
public StringSpec,CSJ2K.j2k lcs
리턴 CSJ2K.j2k.StringSpec

mqrs 공개적으로 프로퍼티

MQ reset specifications
public StringSpec,CSJ2K.j2k mqrs
리턴 CSJ2K.j2k.StringSpec

rts 공개적으로 프로퍼티

Regular termination specifications
public StringSpec,CSJ2K.j2k rts
리턴 CSJ2K.j2k.StringSpec

sss 공개적으로 프로퍼티

Error resilience segment symbol use specifications
public StringSpec,CSJ2K.j2k sss
리턴 CSJ2K.j2k.StringSpec

tts 공개적으로 프로퍼티

The termination type specifications
public StringSpec,CSJ2K.j2k tts
리턴 CSJ2K.j2k.StringSpec