TER.TERcoder.SegmentCoder
Class CodeBlockAC

java.lang.Object
  extended by TER.TERcoder.SegmentCoder.CodeBlockAC

public class CodeBlockAC
extends java.lang.Object

This class codes as many bitplanes of a block of AC components as the user requires. Usage example:
  construct
  setParameters
  run
  get functions

Version:
1.1
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
(package private)  int bitDepthAC_Block
          Determines, for each block, the number of bits needed to represent the magnitude of AC components
(package private)  int blockNumber
          Indicates the position of the gaggle inside the channel
(package private)  byte[][][][] blockStatus
          This array contains the status of each of the components in the block.
(package private)  int[] BP
          For each family and generation indicates the number of bitplanes that are necessary zero due the weighting stage
(package private)  int channel
          Indicates the channel where the block belongs
(package private)  int[] codeLength
          Stores for each of the entropy coder options the number of bits required to encode the gaggle.
(package private)  boolean computeDistortion
          Indicates whether the decrease of the distortion must be computed in order to stop coding process at a given point.
(package private)  byte[] D
          Indicate whether the descendants (all the components except the parents) are or have been significant for each of the families.
(package private)  DistortionCompute distortion
          Definition in SegmentCode2D.distortion
(package private)  byte Ds
          Indicate whether the descendants (all the components except the parents) are or have been significant.
(package private)  int entropyCode
          Indicates how the obtained code stream is going to be entropy encoded.
(package private)  float[][][] imageSamples
          Definition in Coder.imageSamplesFloat
(package private)  boolean parametersSet
          To know if parameters are set.
(package private)  BitStream[] refinementAC
          This array contains the refinement bits of the block in a bit plane.
(package private)  int resolutionLevels
          Definition in SegmentCode2D.resolutionLevels
(package private)  byte[][] significantPiramid
          Represents the significance of each subband of the block (significantPiramid[level of resolution][family])
(package private)  ByteStream[][][] sortingAC
          This array contains the significance (and its contexts if needed) of a block in a bitplane.
(package private)  int threshold
           
(package private)  int[] WTLevels
          Definition in ForwardWaveletTransform.WTLevels
(package private)  int[][] xInit
          Indicates the initial row of each of the subbands of the block inside the whole image.
(package private)  int[][] yInit
          Indicates the initial column of each of the subbands of the block inside the whole image.
 
Constructor Summary
CodeBlockAC(float[][][] imageSamples, int[] resolutionLevels)
          Constructor that receives the values of the block to be further encoded.
 
Method Summary
private  boolean bitPlaneOfZeros(int rLevel, int subband, int bitPlane)
          This function indicates if the bits of the coefficients are necessarily zero due to the subband scaling operation
private  void codeSquare(int bitPlane, int rLevel, int subband)
          This function create the words needed to encode each of the squares (subbands) contained in a block.
private  int[][] codeWords(int[][] initialWords, int bitPlane, int rLevel, int subband, int pass)
          Given a set of words or transition words it encodes it for a given pass.
 byte[][][][] getBlockStatus()
           
 int[] getCodeLength()
           
 byte[] getD()
           
 byte getDs()
           
 byte getRecommededContext(int stage, int length, boolean impossiblePattern)
          This function indicates which context correspond to each coded word given its stage, lentgh, ...
 BitStream[] getRefinementAC()
           
private  void initBlockStatus()
          Initialize the array with contains the status of each AC component of the block
private  void initStreams(int bitPlane)
          Initialize the bit streams and the byte streams used to store the significance block and to store the the contexts of the encoded words to be further entropy encoded.
 void refinementCoding(int bitPlane)
          Perform the refinement of the components of the block for the given bitPlane
 ByteStream[][][] run(int bitPlane)
          Runs the block coder algorithm
 void setParameters(int[] WTLevels, int resolutionLevels, int channel, int blockNumber, byte[][][][] blockStatus, int bitDepthAC_Block, int entropyAC, int[] BP, DistortionCompute distortion, byte Ds, byte[] D, int[] codeLength)
          Set the parameters used to code a block
 void significanceCoding(int bitPlane)
          The significance of the block is encoded for the given bitPlane.
 void updateLeastSignificantBP(int bitPlane)
          This function update the blockStatus for the values that should not be further encoded due to the weighting step for a given bitplane
private  void updateLengthEntropyEncoder(int word, byte context)
          This function computes the lenght that would use any of the entropy encoding options.
private  void updateStreams(int rLevel, int subband, int pass, int word, int length, int stage, boolean impossiblePattern)
          Here are stored words and additional information which is needed to entropy encode each block
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sortingAC

ByteStream[][][] sortingAC
This array contains the significance (and its contexts if needed) of a block in a bitplane. It is structured as follows: stream[resolution level][family][coding pass]


blockStatus

byte[][][][] blockStatus
This array contains the status of each of the components in the block. They are structured as follows: blockStatus[resolution level][family][y][x]


bitDepthAC_Block

int bitDepthAC_Block
Determines, for each block, the number of bits needed to represent the magnitude of AC components


resolutionLevels

int resolutionLevels
Definition in SegmentCode2D.resolutionLevels


entropyCode

int entropyCode
Indicates how the obtained code stream is going to be entropy encoded.


refinementAC

BitStream[] refinementAC
This array contains the refinement bits of the block in a bit plane. It is structured as follows: refinementAC[level of resolution]


distortion

DistortionCompute distortion
Definition in SegmentCode2D.distortion


Ds

byte Ds
Indicate whether the descendants (all the components except the parents) are or have been significant. Valid values are:


D

byte[] D
Indicate whether the descendants (all the components except the parents) are or have been significant for each of the families. That means, D[i] indicate the significance of the descendant in the family 'i'. Valid values are:


BP

int[] BP
For each family and generation indicates the number of bitplanes that are necessary zero due the weighting stage

Negative values are not allowed.


parametersSet

boolean parametersSet
To know if parameters are set.

True indicates that they are set otherwise false.


codeLength

int[] codeLength
Stores for each of the entropy coder options the number of bits required to encode the gaggle.

Negative values are not allowed.


imageSamples

float[][][] imageSamples
Definition in Coder.imageSamplesFloat


WTLevels

int[] WTLevels
Definition in ForwardWaveletTransform.WTLevels


channel

int channel
Indicates the channel where the block belongs


blockNumber

int blockNumber
Indicates the position of the gaggle inside the channel


xInit

int[][] xInit
Indicates the initial row of each of the subbands of the block inside the whole image.


yInit

int[][] yInit
Indicates the initial column of each of the subbands of the block inside the whole image.


significantPiramid

byte[][] significantPiramid
Represents the significance of each subband of the block (significantPiramid[level of resolution][family])


computeDistortion

boolean computeDistortion
Indicates whether the decrease of the distortion must be computed in order to stop coding process at a given point.


threshold

int threshold
Constructor Detail

CodeBlockAC

public CodeBlockAC(float[][][] imageSamples,
                   int[] resolutionLevels)
Constructor that receives the values of the block to be further encoded.

Parameters:
imageSamples - Coder.imageSamplesFloat
resolutionLevels - SegmentCode2D.resolutionLevels
Method Detail

setParameters

public void setParameters(int[] WTLevels,
                          int resolutionLevels,
                          int channel,
                          int blockNumber,
                          byte[][][][] blockStatus,
                          int bitDepthAC_Block,
                          int entropyAC,
                          int[] BP,
                          DistortionCompute distortion,
                          byte Ds,
                          byte[] D,
                          int[] codeLength)
Set the parameters used to code a block

Parameters:
WTLevels - definition in ForwardWaveletTransform.WTLevels
resolutionLevels - definition in SegmentCode2D.resolutionLevels
channel - definition in channel
blockNumber - definition in blockNumber
blockStatus - definition in blockStatus
bitDepthAC_Block - definition in bitDepthAC_Block
entropyAC - definition in EncodeGaggleAC.entropyAC
BP - definition in BP
distortion - distortion
Ds - Ds
D - D
codeLength - codeLength

run

public ByteStream[][][] run(int bitPlane)
                     throws java.lang.Exception
Runs the block coder algorithm

Parameters:
bitPlane - indicates the bitplane that must be coded
Returns:
an array the stream of the coded block for the given bitplane structured as follows: [level of resolution (parents, children,...)][subband or family][coding pass]
Throws:
java.lang.Exception - when something goes wrong and block coding must be stopped

significanceCoding

public void significanceCoding(int bitPlane)
The significance of the block is encoded for the given bitPlane.

Parameters:
bitPlane - indicates the bitplane that must be coded

bitPlaneOfZeros

private boolean bitPlaneOfZeros(int rLevel,
                                int subband,
                                int bitPlane)
This function indicates if the bits of the coefficients are necessarily zero due to the subband scaling operation

Parameters:
rLevel - indicates the resolution level of the subband to be encoded
subband - determines the subband once is known the resolution level
bitPlane - indicates the bitplane that is being encoded
Returns:
a boolean that indicates if the coefficients of this subband should be taken into account for significance encoding purposes

codeSquare

private void codeSquare(int bitPlane,
                        int rLevel,
                        int subband)
This function create the words needed to encode each of the squares (subbands) contained in a block.

Parameters:
bitPlane - indicates the bitplane that is being encoded
rLevel - indicates the resolution level of the subband to be encoded
subband - determines the subband once is known the resolution level

codeWords

private int[][] codeWords(int[][] initialWords,
                          int bitPlane,
                          int rLevel,
                          int subband,
                          int pass)
Given a set of words or transition words it encodes it for a given pass. It also computes the words required for the previous pass

Parameters:
initialWords - contains the set of words to be encoded
bitPlane - indicates the bitplane that is being encoded
rLevel - indicates the resolution level of the subband to be encoded
subband - determines the subband once is known the resolution level
pass - indicates the coding pass that is being encoded
Returns:
the set of words required for encoding next pass

updateStreams

private void updateStreams(int rLevel,
                           int subband,
                           int pass,
                           int word,
                           int length,
                           int stage,
                           boolean impossiblePattern)
Here are stored words and additional information which is needed to entropy encode each block

Parameters:
rLevel - indicates the resolution level of the subband to be encoded
subband - determines the subband once is known the resolution level
pass - indicates the coding pass that is being encoded
word - contains a word that has been encoded
length - indicates the lenght of the word to be encoded. Valid values are between 1 and 4.
stage - indicates if the word corresponds to the significance encoding, the sign encoding or the refinement.
  • -2- Ds coding
  • -1- significance of components
  • 0 - significance of a set of components
  • 1 - sign
  • 2 - refinement
impossiblePattern - indicates if all zeros value if possible

refinementCoding

public void refinementCoding(int bitPlane)
Perform the refinement of the components of the block for the given bitPlane

Parameters:
bitPlane - indicates the bitplane that is being encoded

updateLengthEntropyEncoder

private void updateLengthEntropyEncoder(int word,
                                        byte context)
This function computes the lenght that would use any of the entropy encoding options.

Parameters:
word - contains a word that has been encoded
context - indicates the kind of word to be encoded, i.e. the lenght and the encoding pass

initBlockStatus

private void initBlockStatus()
Initialize the array with contains the status of each AC component of the block


initStreams

private void initStreams(int bitPlane)
Initialize the bit streams and the byte streams used to store the significance block and to store the the contexts of the encoded words to be further entropy encoded.

Parameters:
bitPlane - indicates the bitplane that is going to be encoded

updateLeastSignificantBP

public void updateLeastSignificantBP(int bitPlane)
This function update the blockStatus for the values that should not be further encoded due to the weighting step for a given bitplane

Parameters:
bitPlane - indicates the bitplane for which the blockStatus is updated

getRecommededContext

public byte getRecommededContext(int stage,
                                 int length,
                                 boolean impossiblePattern)
This function indicates which context correspond to each coded word given its stage, lentgh, ...

Parameters:
stage - indicates if the word corresponds to the significance encoding, the sign encoding or the refinement.
  • -2- Ds coding
  • -1- significance of components
  • 0 - significance of a set of components
  • 1 - sign
  • 2 - refinement
length - indicates the lenght of the word to be encoded. Valid values are between 1 and 4.
impossiblePattern - indicates if all zeros value if possible.
Returns:
a byte that contains the context for entropy encoding the word.

getBlockStatus

public byte[][][][] getBlockStatus()

getD

public byte[] getD()

getDs

public byte getDs()

getRefinementAC

public BitStream[] getRefinementAC()

getCodeLength

public int[] getCodeLength()


TER - Copyright (C) 2006
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) - UAB (Spain)