public class CPIDelivery
extends java.lang.Object
Four CPI approaches have been developed:
deliverOnePacketPerPrecinct()
method.
deliverOnePacketPerBitPlane()
method.
deliverOnePacketPerCodingPass()
method.
#getResponseScale()
method.
Usage example:
construct
runResponseParameters
getResponseViewWindow
getQuality
runResponseData
getJPIPMessageData
getEORReasonCode
Modifier and Type | Field and Description |
---|---|
private ViewWindowField |
actualViewWindow |
private static boolean |
APPLY_SUBBAND_WEIGHTS
Indicates if a subband weight must be applied.
|
private ServerJPEG2KCodestream |
codestream |
private ServerJPEG2KComponent |
compObj |
private int |
cpiType
Indicates which type of CPI will be used to deliver images.
|
private int |
discardLevels |
private int |
EORReasonCode
Definition in
CADI.Server.LogicalTarget.ServerLogicalTargetManager#EORReasonCode . |
private int |
layers |
private JP2KServerLogicalTarget |
logicalTarget
Definition in
CADI.Server.LogicalTarget.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#MSBPlane |
private static int |
PACKET_PER_BIT_PLANE
This CPI tye delivery the image's window of interest by bit planes.
|
private static int |
PACKET_PER_CODING_PASS
This CPI type delivery the image's window of interest building a layer
for each coding pass.
|
private static int |
PACKET_PER_PRECINCT
This CPI tye delivery the image's window of interest building only one
packet, i.e., all coding passes of a precinct are grouped in one packet.
|
private int |
quality
Definition in
CADI.Server.LogicalTarget.ServerLogicalTargetManager#quality . |
private java.util.ArrayList<ResponseData> |
responseDataList |
private long |
responseLength
It is a temporal attribute to accumulate the response length which is
sending to the client.
|
private ViewWindowField |
responseViewWindow
Definition in
CADI.Server.LogicalTarget.ServerLogicalTargetManager#responseViewWindow . |
private static int |
SCALE
This CPI type delivery the image's window of interest following the
SCALE method:
l = L - 1 - ((c div 3) * 2)- ((c mod 3) div 2)
where:
L = (K * 2) - 1
K = number of bit-planes
It can be uses when the request belongs to a session or with stateless
request.
|
private ServerCacheModel |
serverCache
This attribute contains the cache data for the client.
|
private ServerJPEG2KTile |
tileObj |
Constructor and Description |
---|
CPIDelivery(JP2KServerLogicalTarget logicalTarget,
ServerCacheModel serverCache) |
CPIDelivery(JP2KServerLogicalTarget logicalTarget,
ServerCacheModel serverCache,
boolean align) |
Modifier and Type | Method and Description |
---|---|
private void |
deliverOnePacketPerBitPlane()
This method is used to deliver the requested window of interes using
only one packet per bit-plane.
|
private void |
deliverOnePacketPerCodingPass()
This method is used to deliver the requested window of interes using
only one packet per coding pass.
|
private void |
deliverOnePacketPerPrecinct()
This method is used to deliver the requested window of interes using
only one packet per precinct.
|
private void |
deliverScale()
This method is used to delivery the requested window of interes using
SCALE method.
|
private void |
encodeMainHeader()
Gets the main header as a byte array.
|
int |
getEORReasonCode()
Returns the
EORReasonCode attribute. |
private int |
getLayer(int codingLevel) |
byte[] |
getMainHeader()
Returns the main header.
|
private int |
getMaxNumLayers(int cpiType)
Gets the maximum number of layers.
|
private int |
getMaxSubbandWeight()
Calculate which is the maximum subband weight for the whole image.
|
private int |
getNextCodingLevel(int codingLevel) |
private byte[] |
getPacketHeaderOnePacketPerBitPlane(PacketHeadersEncoder packetHeading,
long inClassIdentifier,
int tile,
int z,
int rLevel,
int virtualBitPlane,
int totalNumVirtualBitPlanes,
int[][][][] codingPassesLengths)
Builds a packet header using one packet per bit plane
It is an auxiliary method used by
#getResponseOnePacketPerBitPlane()
method to build the packet headers. |
private byte[] |
getPacketHeaderOnePacketPerCodingPass(PacketHeadersEncoder packetHeadersEncoder,
long inClassIdentifier,
int tile,
int z,
int rLevel,
int realCodingLevel,
int[][][][] codingPassesLengths)
Builds a packet header for a specific coding level.
|
private byte[] |
getPacketHeaderScale(PacketHeadersEncoder packetHeading,
long inClassIdentifier,
int tile,
int z,
int rLevel,
int totalNumVirtualCodingLevels,
int virtualCodingLevel,
int[][][][] codingPassesLengths)
Builds a packet header for a specific coding level.
|
int |
getQuality()
Returns the
quality attribute. |
java.util.ArrayList<ResponseData> |
getResponseData()
Returns the
#jpipMessageHeaders attribute. |
ViewWindowField |
getResponseViewWindow()
Returns the
responseViewWindow attribute. |
private int |
getSubbandWeight(int tile,
int z,
int rLevel,
int subband)
Returns the subband weight for a component, resolution level, and subband.
|
private boolean |
isMRP(int codingLevel)
Check whether a coding level is or not a MRP pass.
|
void |
list(java.io.PrintStream out)
Prints this CPI delivery out to the specified output stream.
|
private static void |
printByteArray(byte[] buffer)
Useful method for printing a byte array.
|
private void |
printTypeOfCodingPass(int codingLevel)
Useful to print which is the type of each coding level.
|
void |
runResponseData(java.util.ArrayList<ResponseData> responseDataList,
long maximumResponseLength)
Gets the data of the response window of interes.
|
void |
runResponseParameters(ViewWindowField viewWindow)
Calculates the WOI which will be sent to the client using a layers-based
rate-distortion method (file is delivery in the same order that is is
saved).
|
void |
setCPIType(int cpiType)
Set the subtype of the CPI.
|
private void |
setFirstLayerOnePacketPerBitPlane(PacketHeadersEncoder packetHeading,
long inClassIdentifier,
int tile,
int z,
int rLevel,
int[][][][] codingPassesLengths)
This method adjusts the first layer when requested window of interest is
delivered using one packet per bit plane.
|
private void |
setFirstLayerScale(PacketHeadersEncoder packetHeading,
long inClassIdentifier,
int tile,
int z,
int rLevel,
int[][][][] codingPassesLengths,
int totalNumVirtualCodingLevels)
This method adjusts the first layer when requested window of interest is
delivered using the SCALE method.
|
private boolean |
skipPrecinctScale(long inClassIdentifier,
int tile,
int z,
int rLevel,
int totalNumVirtualCodingLevels,
int virtualCodingLevel,
int[][][][] codingPassesLengths)
Check if a precinct has to be, or not, included in a fixed coding level.
|
java.lang.String |
toString() |
private ServerJPEG2KCodestream codestream
private java.util.ArrayList<ResponseData> responseDataList
private byte[] mainHeader
private ViewWindowField responseViewWindow
CADI.Server.LogicalTarget.ServerLogicalTargetManager#responseViewWindow
.private int quality
CADI.Server.LogicalTarget.ServerLogicalTargetManager#quality
.private int EORReasonCode
CADI.Server.LogicalTarget.ServerLogicalTargetManager#EORReasonCode
.private JP2KServerLogicalTarget logicalTarget
CADI.Server.LogicalTarget.ServerLogicalTargetManager#EORReasonCode
.private ServerCacheModel serverCache
This reference is passed from the
private long maximumResponseLength
DataLimitField.len
private int cpiType
Allowed values:
private long responseLength
private int discardLevels
private ViewWindowField actualViewWindow
private ServerJPEG2KTile tileObj
private ServerJPEG2KComponent compObj
private int MSBPlane
CADI.Server.LogicalTarget.JPEG2000.JP2LogicalTarget#MSBPlane
private int maxNumLayers
CODParameters.numLayers
private int layers
private static final int PACKET_PER_PRECINCT
It can be uses when the request belongs to a session or with stateless request.
private static final int PACKET_PER_BIT_PLANE
Builds a packet for each bit-plane. So coding passes of different bit-planes are not grouped in the same packet.
It can be uses when the request belongs to a session or with stateless request.
private static final int PACKET_PER_CODING_PASS
It is the worst approach because a packet is built for each coding pass, even when two or more coding passes of the same precinct are sent.
It can be uses when the request belongs to a session or with stateless request.
private static final int SCALE
It can be uses when the request belongs to a session or with stateless request.
private static boolean APPLY_SUBBAND_WEIGHTS
Further information, see #getSubbandWeight(int, int, int)
method.
public CPIDelivery(JP2KServerLogicalTarget logicalTarget, ServerCacheModel serverCache)
logicalTarget
- serverCache
- public CPIDelivery(JP2KServerLogicalTarget logicalTarget, ServerCacheModel serverCache, boolean align)
logicalTarget
- serverCache
- align
- public void setCPIType(int cpiType)
cpiType
- definition in cpiType
public void runResponseParameters(ViewWindowField viewWindow) throws ErrorException
viewWindow
- the requested Window Of InterestErrorException
public void runResponseData(java.util.ArrayList<ResponseData> responseDataList, long maximumResponseLength) throws ErrorException
httpResponseSender
- definition in #httpResponseSender
jpipMessageEncoder
- definition in #jpipMessageEncoder
jpipMessageHeaders
- definition in #jpipMessageHeaders
ErrorException
java.io.IOException
public byte[] getMainHeader() throws ErrorException
mainHeader
.ErrorException
public int getEORReasonCode()
EORReasonCode
attribute.EORReasonCode
attribute.public ViewWindowField getResponseViewWindow()
responseViewWindow
attribute.responseViewWindow
attribute.public java.util.ArrayList<ResponseData> getResponseData()
#jpipMessageHeaders
attribute.#jpipMessageHeaders
attribute.public java.lang.String toString()
toString
in class java.lang.Object
public void list(java.io.PrintStream out)
out
- an output stream.private int getMaxNumLayers(int cpiType)
cpiType
- definition in cpiType
.maxNumLayers
.private void encodeMainHeader() throws ErrorException
ErrorException
private int getSubbandWeight(int tile, int z, int rLevel, int subband)
z
- image componentrLevel
- 0 is the LL subband, and 1, 2, ... represents
next starting with the little onesubband
- 0 - HL, 1 - LH, 2 - HH (if resolutionLevel == 0 --> 0 -
LL)private int getMaxSubbandWeight()
method.
private void deliverOnePacketPerPrecinct() throws ErrorException
The algorithm of this rate-distortion method is the most simple. But the coding performance achieved when the image is delivered with this algorithm is not the best one.
The coding performance is improved when delivered data are weigthed
applying a weight to each subband of the tansformed image. Further
information about suband weights, see the
#getRateDistortionAdjustment(int, int, int)
method.
ErrorException
private void deliverOnePacketPerCodingPass() throws ErrorException
This rate-distortion method is useful to delivery the image when the request does not belong to a session, so the server does not have any information about the client's cache status. In this case, a fixed image structure is needed because, sometimes, the client includes in its request (stateless) information about the status of its cache.
The algorithm of this rate-distortion method is very simple. But the coding performance achieved when the image is delivered with this algorithm is not the best one.
ErrorException
private byte[] getPacketHeaderOnePacketPerCodingPass(PacketHeadersEncoder packetHeadersEncoder, long inClassIdentifier, int tile, int z, int rLevel, int realCodingLevel, int[][][][] codingPassesLengths) throws ErrorException
It is an auxiliary method used by deliverOnePacketPerCodingPass()
method to build the packet headers.
z
- the image componentrLevel
- the resolution level in the componentprecinct
- the precinct in the resolution levelcodingLevel
- the coding levelcodingPassesLengths
- a multiple array with the length of all coding
passes that belong to the same precinct.ErrorException
- if the packet header cannot be built because an
error has been found.private void deliverOnePacketPerBitPlane() throws ErrorException
This rate-distortion method is useful to delivery the image when the request does not belong to a session, so the server does not have any information about the client's cache status. In this case, a fixed image structure is needed because, sometimes, the client includes in its request (stateless) information about the status of its cache.
The algorithm of this rate-distortion method is the very simple. But the coding performance achieved when the image is delivered with this algorithm is not the best one.
ErrorException
private void setFirstLayerOnePacketPerBitPlane(PacketHeadersEncoder packetHeading, long inClassIdentifier, int tile, int z, int rLevel, int[][][][] codingPassesLengths) throws ErrorException
packetHeading
- inClassIdentifier
- z
- rLevel
- int[][][][]
- codingPassesLengthsErrorException
private byte[] getPacketHeaderOnePacketPerBitPlane(PacketHeadersEncoder packetHeading, long inClassIdentifier, int tile, int z, int rLevel, int virtualBitPlane, int totalNumVirtualBitPlanes, int[][][][] codingPassesLengths) throws ErrorException
It is an auxiliary method used by #getResponseOnePacketPerBitPlane()
method to build the packet headers.
packetHeading
- the packet heading object used to build the header.inClassIdentifier
- z
- the image component.rLevel
- the resolution level in the component.virtualBitPlane
- totalNumVirtualBitPlanes
- codingPasses
- a multiple array with the length of all coding
passes belonging to the precinct.ErrorException
- if the packet header cannot be built because an
error has been found.private void deliverScale() throws ErrorException
This rate-distortion method is useful to delivery the image when the request does not belong to a session, so the server does not have any information about the client's cache status. In this case, a fixed image structure is needed because, sometimes, the client includes in its request (stateless) information about the status of its cache.
NOTE: Although the subband weight function is the number of coding passes to be upshifted, this value is mapped to bit planes (multipling by 3) in order to keep the coherence and allow the MRP and CP may be joined.
ErrorException
private int getNextCodingLevel(int codingLevel)
codingLevel
- private int getLayer(int codingLevel)
codingLevel
- private boolean isMRP(int codingLevel)
codingLevel
- private void setFirstLayerScale(PacketHeadersEncoder packetHeading, long inClassIdentifier, int tile, int z, int rLevel, int[][][][] codingPassesLengths, int totalNumVirtualCodingLevels) throws ErrorException
packetHeading
- inClassIdentifier
- z
- rLevel
- codingPassesLengths
- ErrorException
private byte[] getPacketHeaderScale(PacketHeadersEncoder packetHeading, long inClassIdentifier, int tile, int z, int rLevel, int totalNumVirtualCodingLevels, int virtualCodingLevel, int[][][][] codingPassesLengths) throws ErrorException
It is an auxiliary method used by #getResponseOnePacketPerCodingPass()
method to build the packet headers.
packetHeading
- the packet heading object used to build the header.z
- the image component.rLevel
- the resolution level in the component.precinct
- the precinct in the resolution levelinitialCodingPass
- the first coding pass of the packet.numOfCodingPasses
- the number of coding passes of the packet.codingPasses
- a multiple array with the length of all coding
passes belonging to the precinct.ErrorException
- if the packet header cannot be built because an
error has been found.private boolean skipPrecinctScale(long inClassIdentifier, int tile, int z, int rLevel, int totalNumVirtualCodingLevels, int virtualCodingLevel, int[][][][] codingPassesLengths)
This method is only used by the deliverScale()
method.
inClassIdentifier
- z
- rLevel
- totalNumVirtualCodingLevels
- virtualCodingLevel
- codingPassesLengths
- private void printTypeOfCodingPass(int codingLevel)
codingLevel
- private static void printByteArray(byte[] buffer)
buffer
- the byte array to be printed.
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)