Compute fast inverse wavelet transform of all 4 subbands of given level and stores result in LL subband of level - 1.
{
ASSERT(srcLevel > 0 && srcLevel <
m_nLevels);
const int destLevel = srcLevel - 1;
UINT32 width, height;
if (!destBand->
AllocMemory())
return InsufficientMemory;
DataT *dest = destBand->
GetBuffer(), *origin = dest, *row0, *row1, *row2, *row3;
#ifdef __PGFROISUPPORT__
PGFRect destROI = destBand->GetROI();
const UINT32 destWidth = width;
const UINT32 destHeight = height;
origin += destWidth;
height--;
}
origin++;
width--;
}
const UINT32 leftD = destROI.
left >> 1;
const UINT32 left0 =
m_subband[srcLevel][
LL].GetROI().left;
const UINT32 left1 =
m_subband[srcLevel][
HL].GetROI().left;
const UINT32 topD = destROI.
top >> 1;
const UINT32 top0 =
m_subband[srcLevel][
LL].GetROI().top;
const UINT32 top1 =
m_subband[srcLevel][
LH].GetROI().top;
ASSERT(
m_subband[srcLevel][
LH].GetROI().left == left0);
ASSERT(
m_subband[srcLevel][
HH].GetROI().left == left1);
UINT32 srcOffsetX[2] = { 0, 0 };
UINT32 srcOffsetY[2] = { 0, 0 };
if (leftD >=
__max(left0, left1)) {
srcOffsetX[0] = leftD - left0;
srcOffsetX[1] = leftD - left1;
} else {
if (left0 <= left1) {
const UINT32 dx = (left1 - leftD) << 1;
origin += dx;
width -= dx;
srcOffsetX[0] = left1 - left0;
} else {
const UINT32 dx = (left0 - leftD) << 1;
origin += dx;
width -= dx;
srcOffsetX[1] = left0 - left1;
}
}
if (topD >=
__max(top0, top1)) {
srcOffsetY[0] = topD - top0;
srcOffsetY[1] = topD - top1;
} else {
if (top0 <= top1) {
const UINT32 dy = (top1 - topD) << 1;
origin += dy*destWidth;
height -= dy;
srcOffsetY[0] = top1 - top0;
} else {
const UINT32 dy = (top0 - topD) << 1;
origin += dy*destWidth;
height -= dy;
srcOffsetY[1] = top0 - top1;
}
}
#else
PGFRect destROI(0, 0, width, height);
const UINT32 destWidth = width;
const UINT32 destHeight = height;
}
#endif
row0 = origin; row1 = row0 + destWidth;
for (UINT32 k=0; k < width; k++) {
row0[k] -= ((row1[k] +
c1) >> 1);
}
row2 = row1 + destWidth; row3 = row2 + destWidth;
for (UINT32 i=destROI.
top + 2; i < destROI.
bottom - 1; i += 2) {
for (UINT32 k=0; k < width; k++) {
row2[k] -= ((row1[k] + row3[k] +
c2) >> 2);
row1[k] += ((row0[k] + row2[k] +
c1) >> 1);
}
row0 = row2; row1 = row3; row2 = row1 + destWidth; row3 = row2 + destWidth;
}
if (height & 1) {
for (UINT32 k=0; k < width; k++) {
row2[k] -= ((row1[k] +
c1) >> 1);
row1[k] += ((row0[k] + row2[k] +
c1) >> 1);
}
row0 = row1; row1 = row2; row2 += destWidth;
} else {
for (UINT32 k=0; k < width; k++) {
row1[k] += row0[k];
}
row0 = row1; row1 += destWidth;
}
} else {
row0 = origin; row1 = row0 + destWidth;
for (UINT32 k=0; k < height; k += 2) {
row0 += destWidth << 1; row1 += destWidth << 1;
}
if (height & 1) {
}
}
}
*w = destWidth;
*h = height;
*data = dest;
return NoError;
}