public getNextCodeBlock ( int c, CSJ2K.j2k.wavelet.analysis.CBlkWTData cblk ) : CSJ2K.j2k.wavelet.analysis.CBlkWTData | ||
c | int | The component for which to return the next code-block. /// /// |
cblk | CSJ2K.j2k.wavelet.analysis.CBlkWTData | If non-null this object will be used to return the new /// code-block. If null a new one will be allocated and returned. If the /// "data" array of the object is non-null it will be reused, if possible, /// to return the data. /// /// |
return | CSJ2K.j2k.wavelet.analysis.CBlkWTData |
public override CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk)
{
// We can not directly use getNextInternCodeBlock() since that returns
// a reference to the internal buffer, we have to copy that data
int j, k;
int w;
System.Object dst_data; // a int[] or float[] object
int[] dst_data_int;
float[] dst_data_float;
System.Object src_data; // a int[] or float[] object
intData = (filters.getWTDataType(tIdx, c) == DataBlk.TYPE_INT);
dst_data = null;
// Cache the data array, if any
if (cblk != null)
{
dst_data = cblk.Data;
}
// Get the next code-block
cblk = getNextInternCodeBlock(c, cblk);
if (cblk == null)
{
return null; // No more code-blocks in current tile for component
// c
}
// Ensure size of output buffer
if (intData)
{
// int data
dst_data_int = (int[]) dst_data;
if (dst_data_int == null || dst_data_int.Length < cblk.w * cblk.h)
{
dst_data = new int[cblk.w * cblk.h];
}
}
else
{
// float data
dst_data_float = (float[]) dst_data;
if (dst_data_float == null || dst_data_float.Length < cblk.w * cblk.h)
{
dst_data = new float[cblk.w * cblk.h];
}
}
// Copy data line by line
src_data = cblk.Data;
w = cblk.w;
for (j = w * (cblk.h - 1), k = cblk.offset + (cblk.h - 1) * cblk.scanw; j >= 0; j -= w, k -= cblk.scanw)
{
// CONVERSION PROBLEM?
Array.Copy((System.Array)src_data, k, (System.Array)dst_data, j, w);
}
cblk.Data = dst_data;
cblk.offset = 0;
cblk.scanw = w;
return cblk;
}