CADI.Server.LogicalTarget.JPEG2000.RateDistortion
Class CoRDBasedDelivery

java.lang.Object
  extended by CADI.Server.LogicalTarget.JPEG2000.RateDistortion.CoRDBasedDelivery

public class CoRDBasedDelivery
extends java.lang.Object

This class implements a Characterization of Rate Distortion (CoRD) -based algorithm to deliver the precincts belonging to the client requested Window of Interest.

The CoRD algorithm achieves a rate-distortion performance which is very close to the PCPRD. However, sometimes the scanning order followed by CoRD forces a change in the natural scanning order of subbands from a precinct. Therefore, the only way to keep the CoRD's scanning order is to build one packet for each subband of the precinct and setting the other subbands of this packet to null. Moreover, this scanning order has to be kept the packets are delivered to clients, so that a JPIP message has to be built for each packet. This issue generates an overhead, and it makes that CoRD may not be as competitive as it is when images are decompressed and not transmitted.

This degradation of the CoRD algorith when it is used for image transmission can be improved with a minor modification of the algorithm. This modification consists in each packet always include one block of each subband. The rate-distortion performance of this CoRD-based algorithm is a bit worse than CoRD's one, but it reduces the packet and JPIP headers considerably. Therefore, its rate-distortion performance taken into account the packet header, packet body, and JPIP message headers achieves competitive results. Usage example:
  constructor
  runResponseParameters
  getResponseViewWindow
  getQuality
  runResponseData
  getJPIPMessageData
  getEORReasonCode

Version:
1.1.2 2009/05/18
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  CODParameters codParameters
          Definition in CODParameters
private  int[][] comps
           
private  int EORReasonCode
          Definition in ServerLogicalTargetManager.EORReasonCode.
private  int[] fsiz
          Some internal attributes for passing values between diferents methods.
private  HTTPResponseSender httpResponseSender
          Definition in Worker.httpResponseSender
private  long[][][] inClassIdentifierCorrespondence
          Is a multiple-dimensional array which will be a mapping between the component-resolutionlevel-precinct and the unique in-class identifier.
private  JPCParameters jpcParameters
          Definition in JPCParameters
private  JPIPMessageEncoder jpipMessageEncoder
          Definition in JP2LogicalTargetManager.
private  java.util.ArrayList<JPIPMessageHeader> jpipMessageHeaders
          Definition in ServerLogicalTargetManager.jpipMessageHeaders.
private  int layers
           
private  JP2LogicalTarget logicalTarget
          Definition in ServerLogicalTargetManager.EORReasonCode.
private  byte[] mainHeader
          Contains the encoded main header.
private  long maximumResponseLength
          Definition in DataLimitField.len
private  int maxNumLayers
          Definition in CODParameters.numLayers
private  int MSBPlane
          Definition in CADI.Server.LogicalTarget.JPEG2000.JP2LogicalTarget#MSBPlanes.
private  PacketHeadersEncoder packetHeading
          This object is used to build the packet headers.
private  int[][][] precinctsPerRLevel
          Is a mutiple-dimensional array which will contain the precincts belonging to the WOI.
private  int quality
          Definition in ServerLogicalTargetManager.quality.
private  long responseLength
          It is a temporal attribute to accumulate the response length which is sending to the client.
private  ViewWindowField responseViewWindow
          Definition in ServerLogicalTargetManager.responseViewWindow.
private  int[] roff
           
private  int[] rsiz
           
private  JPCServerCache serverCache
          This attribute contains the cache data for the client.
private  SIZParameters sizParameters
          Definition in SIZParameters
 
Constructor Summary
CoRDBasedDelivery(JP2LogicalTarget logicalTarget, JPCServerCache serverCache, long maximumResponseLength)
          Constructor.
 
Method Summary
private  java.util.ArrayList<CodingPassID> adjustScanningOrder(java.util.ArrayList<BlockOrder> blockOrders)
           
 void calculateMaxMinBitPlanes(int[][][] precinctsPerRLevel, int[][][] maxsBP, int[][][] minsBP, long[][][] inClassIdentifierCorrespondence, int[] components)
          Construction of two structures which contain the max and min number of bit-planes of the code-blocks, by subbands Indexes mean: [component][rLevel][subbandBP]
private  void calculateSlopeStimations(float[][][][][] slopes, int[][][] minsBP)
          SLOPE ESTIMATIONS
private  void deliverPrecincts(java.util.ArrayList<CodingPassID> scanningOrder)
          This method is used to deliver the requested window of interest when the maximum response length parameter has been set.
private  void encodeMainHeader()
          Gets the main header as a byte array.
private  java.util.ArrayList<BlockOrder> findSubbandScanningOrder(float[][][][][] slopes, int[][][][] currSLs, int[][][] minsBP, int[] components)
           
private  java.util.ArrayList<BlockOrder> getDeliveryOrder(java.util.ArrayList relevantPrecincts)
          Performs the block building and reads the needed bytestreams using the number of bytes.
 int getEORReasonCode()
          Returns the EORReasonCode attribute.
 java.util.ArrayList<JPIPMessageHeader> getJPIPMessageHeaders()
          Returns the jpipMessageHeaders attribute.
 byte[] getMainHeader()
          Returns the main header.
private  int getMaxSubbandWeight()
          Calculate which is the maximum subband weight for the whole image.
 void getPrecinctsPerRLevel(java.util.ArrayList relevantPrecincts)
          Gets the relevant precincts for each subband.
 int getQuality()
          Returns the quality attribute.
 ViewWindowField getResponseViewWindow()
          Returns the responseViewWindow attribute.
private  int getSubbandWeight(int z, int rLevel, int subband)
          Returns a rate-distortion adjustment for a component, resolution level, and subband.
private  java.util.ArrayList<CodingPassID> includeCP(java.util.ArrayList<CodingPassID> orderOfCodingPasses, long inClassIdentifier, int component, int rLevel, int precinct, int subband, int yBlock, int xBlock, int codingLevelGlobal)
           
 void list(java.io.PrintStream out)
          Prints this CoRD delivery out to the specified output stream.
 void runResponseData(HTTPResponseSender httpResponseSender, JPIPMessageEncoder jpipMessageEncoder, java.util.ArrayList<JPIPMessageHeader> jpipMessageHeaders)
          Gets the data of the response window of interest.
 void runResponseParameters(ViewWindowField viewWindow)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

httpResponseSender

private HTTPResponseSender httpResponseSender
Definition in Worker.httpResponseSender


jpipMessageEncoder

private JPIPMessageEncoder jpipMessageEncoder
Definition in JP2LogicalTargetManager.


jpipMessageHeaders

private java.util.ArrayList<JPIPMessageHeader> jpipMessageHeaders
Definition in ServerLogicalTargetManager.jpipMessageHeaders.


mainHeader

private byte[] mainHeader
Contains the encoded main header.


responseViewWindow

private ViewWindowField responseViewWindow
Definition in ServerLogicalTargetManager.responseViewWindow.


quality

private int quality
Definition in ServerLogicalTargetManager.quality.


EORReasonCode

private int EORReasonCode
Definition in ServerLogicalTargetManager.EORReasonCode.


logicalTarget

private JP2LogicalTarget logicalTarget
Definition in ServerLogicalTargetManager.EORReasonCode.


serverCache

private JPCServerCache serverCache
This attribute contains the cache data for the client.

This reference is passed from the


maximumResponseLength

private long maximumResponseLength
Definition in DataLimitField.len


jpcParameters

private JPCParameters jpcParameters
Definition in JPCParameters


sizParameters

private SIZParameters sizParameters
Definition in SIZParameters


codParameters

private CODParameters codParameters
Definition in CODParameters


MSBPlane

private int MSBPlane
Definition in CADI.Server.LogicalTarget.JPEG2000.JP2LogicalTarget#MSBPlanes.


responseLength

private long responseLength
It is a temporal attribute to accumulate the response length which is sending to the client.


fsiz

private int[] fsiz
Some internal attributes for passing values between diferents methods. They contains the view window attributes, then for a full description see ViewWindowField


roff

private int[] roff

rsiz

private int[] rsiz

comps

private int[][] comps

layers

private int layers

maxNumLayers

private int maxNumLayers
Definition in CODParameters.numLayers


precinctsPerRLevel

private int[][][] precinctsPerRLevel
Is a mutiple-dimensional array which will contain the precincts belonging to the WOI.


inClassIdentifierCorrespondence

private long[][][] inClassIdentifierCorrespondence
Is a multiple-dimensional array which will be a mapping between the component-resolutionlevel-precinct and the unique in-class identifier.


packetHeading

private PacketHeadersEncoder packetHeading
This object is used to build the packet headers.

Constructor Detail

CoRDBasedDelivery

public CoRDBasedDelivery(JP2LogicalTarget logicalTarget,
                         JPCServerCache serverCache,
                         long maximumResponseLength)
Constructor.

Parameters:
logicalTarget - definition in logicalTarget
serverCache - definition in serverCache
maximumResponseLength - definition in maximumResponseLength
Method Detail

runResponseParameters

public void runResponseParameters(ViewWindowField viewWindow)
Parameters:
viewWindow - the requested Window Of Interest

runResponseData

public void runResponseData(HTTPResponseSender httpResponseSender,
                            JPIPMessageEncoder jpipMessageEncoder,
                            java.util.ArrayList<JPIPMessageHeader> jpipMessageHeaders)
                     throws ErrorException,
                            java.io.IOException
Gets the data of the response window of interest. This data is calculate using the CoRD algorithm.

Parameters:
httpResponseSender - definition in httpResponseSender
jpipMessageEncoder - definition in jpipMessageEncoder
jpipMessageHeaders - definition in jpipMessageHeaders
Throws:
ErrorException
java.io.IOException

getMainHeader

public byte[] getMainHeader()
Returns the main header.

Returns:
the mainHeader.

getEORReasonCode

public int getEORReasonCode()
Returns the EORReasonCode attribute.

Returns:
the EORReasonCode attribute.

getResponseViewWindow

public ViewWindowField getResponseViewWindow()
Returns the responseViewWindow attribute.

Returns:
the responseViewWindow attribute.

getJPIPMessageHeaders

public java.util.ArrayList<JPIPMessageHeader> getJPIPMessageHeaders()
Returns the jpipMessageHeaders attribute.

Returns:
the jpipMessageHeaders attribute.

getQuality

public int getQuality()
Returns the quality attribute.

Returns:
the quality attribute.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

list

public void list(java.io.PrintStream out)
Prints this CoRD delivery out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

encodeMainHeader

private void encodeMainHeader()
Gets the main header as a byte array. This method can be called if the transcoding is done.


getSubbandWeight

private int getSubbandWeight(int z,
                             int rLevel,
                             int subband)
Returns a rate-distortion adjustment for a component, resolution level, and subband.

Parameters:
z - image component
rLevel - 0 is the LL subband, and 1, 2, ... represents next starting with the little one
subband - 0 - HL, 1 - LH, 2 - HH (if resolutionLevel == 0 --> 0 - LL)
Returns:
the rate-distortion adjustment for a component, resolution level, and subband.

getMaxSubbandWeight

private int getMaxSubbandWeight()
Calculate which is the maximum subband weight for the whole image.

Returns:
the maximum subband weight.
See Also:
method.

getDeliveryOrder

private java.util.ArrayList<BlockOrder> getDeliveryOrder(java.util.ArrayList relevantPrecincts)
                                                  throws ErrorException
Performs the block building and reads the needed bytestreams using the number of bytes.

Returns:
a bi-dimensional array with the order of precincts. The first index is the ordering number. And the second index is: if 1, indicates the current subband bit plane if 2, then number of bit planes if 3, the coding level if 4, if the coding pass must be concatenated
Throws:
ErrorException - when some problem reading file occurs

calculateSlopeStimations

private void calculateSlopeStimations(float[][][][][] slopes,
                                      int[][][] minsBP)
SLOPE ESTIMATIONS

Parameters:
slopes -
minsBP -

findSubbandScanningOrder

private java.util.ArrayList<BlockOrder> findSubbandScanningOrder(float[][][][][] slopes,
                                                                 int[][][][] currSLs,
                                                                 int[][][] minsBP,
                                                                 int[] components)
Parameters:
slopes -
currSLs -
minsBP -
Returns:

adjustScanningOrder

private java.util.ArrayList<CodingPassID> adjustScanningOrder(java.util.ArrayList<BlockOrder> blockOrders)
Parameters:
order -

includeCP

private java.util.ArrayList<CodingPassID> includeCP(java.util.ArrayList<CodingPassID> orderOfCodingPasses,
                                                    long inClassIdentifier,
                                                    int component,
                                                    int rLevel,
                                                    int precinct,
                                                    int subband,
                                                    int yBlock,
                                                    int xBlock,
                                                    int codingLevelGlobal)
Parameters:
blockOrder -
inClassIdentifier -
component -
rLevel -
precinct -
yBlock -
xBlock -
codingLevel -
Returns:

deliverPrecincts

private void deliverPrecincts(java.util.ArrayList<CodingPassID> scanningOrder)
                       throws ErrorException,
                              java.io.IOException
This method is used to deliver the requested window of interest when the maximum response length parameter has been set. This method, in order to keep the right scanning order given by the CoRD algorithm, sends only one coding-pass per packet.

Parameters:
scanningOrder - is an ArrayList with the order of precincts including the subband, yBlock, xBlock and coding passes to be sent.
Throws:
ErrorException
java.io.IOException

getPrecinctsPerRLevel

public void getPrecinctsPerRLevel(java.util.ArrayList relevantPrecincts)
Gets the relevant precincts for each subband.

Parameters:
relevantPrecincts - an array list with the unique precinct identifier of the relevant precincts.

calculateMaxMinBitPlanes

public void calculateMaxMinBitPlanes(int[][][] precinctsPerRLevel,
                                     int[][][] maxsBP,
                                     int[][][] minsBP,
                                     long[][][] inClassIdentifierCorrespondence,
                                     int[] components)
Construction of two structures which contain the max and min number of bit-planes of the code-blocks, by subbands Indexes mean: [component][rLevel][subbandBP]

Parameters:
precinctsPerRLevel -
maxsBP -
minsBP -


CADI - Copyright (C) 2007
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) (contact)