41: m_nLevels(levels + 1)
46#ifdef __PGFROISUPPORT__
47 m_ROIindices.SetLevels(levels + 1);
60 UINT32 loWidth = width;
61 UINT32 hiWidth = width;
62 UINT32 loHeight = height;
63 UINT32 hiHeight = height;
65 for (
int level = 0; level <
m_nLevels; level++) {
70 hiWidth = loWidth >> 1; hiHeight = loHeight >> 1;
71 loWidth = (loWidth + 1) >> 1; loHeight = (loHeight + 1) >> 1;
89 ASSERT(level >= 0 && level <
m_nLevels - 1);
90 const int destLevel = level + 1;
93 const UINT32 width = srcBand->
GetWidth();
94 const UINT32 height = srcBand->
GetHeight();
96 DataT *row0, *row1, *row2, *row3;
100 if (!
m_subband[destLevel][i].AllocMemory())
return InsufficientMemory;
106 row0 = src; row1 = row0 + width; row2 = row1 + width;
110 for (UINT32 k=0; k < width; k++) {
111 row1[k] -= ((row0[k] + row2[k] +
c1) >> 1);
112 row0[k] += ((row1[k] +
c1) >> 1);
115 row0 = row1; row1 = row2; row2 += width; row3 = row2 + width;
118 for (UINT32 i=3; i < height-1; i += 2) {
121 for (UINT32 k=0; k < width; k++) {
122 row2[k] -= ((row1[k] + row3[k] +
c1) >> 1);
123 row1[k] += ((row0[k] + row2[k] +
c2) >> 2);
126 row0 = row2; row1 = row3; row2 = row3 + width; row3 = row2 + width;
131 for (UINT32 k=0; k < width; k++) {
132 row1[k] += ((row0[k] +
c1) >> 1);
135 row0 = row1; row1 += width;
138 for (UINT32 k=0; k < width; k++) {
140 row1[k] += ((row0[k] + row2[k] +
c2) >> 2);
143 row0 = row1; row1 = row2; row2 += width;
147 row0 = src; row1 = row0 + width;
149 for (UINT32 k=0; k < height; k += 2) {
153 row0 += width << 1; row1 += width << 1;
186 src[1] -= ((src[0] + src[2] +
c1) >> 1);
187 src[0] += ((src[1] +
c1) >> 1);
190 for (; i < width-1; i += 2) {
191 src[i] -= ((src[i-1] + src[i+1] +
c1) >> 1);
192 src[i-1] += ((src[i-2] + src[i] +
c2) >> 2);
197 src[i-1] += ((src[i-2] +
c1) >> 1);
200 src[i-1] += ((src[i-2] + src[i] +
c2) >> 2);
208 const UINT32 wquot = width >> 1;
209 const bool wrem = width & 1;
214 for (UINT32 i=0; i < wquot; i++) {
216 hl.WriteBuffer(*loRow++);
218 hh.WriteBuffer(*hiRow++);
225 for (UINT32 i=0; i < wquot; i++) {
227 hl.WriteBuffer(*loRow++);
246 ASSERT(srcLevel > 0 && srcLevel <
m_nLevels);
247 const int destLevel = srcLevel - 1;
250 UINT32 width, height;
253 if (!destBand->
AllocMemory())
return InsufficientMemory;
254 DataT *dest = destBand->
GetBuffer(), *origin = dest, *row0, *row1, *row2, *row3;
256#ifdef __PGFROISUPPORT__
257 PGFRect destROI = destBand->GetROI();
258 width = destROI.
Width();
259 height = destROI.
Height();
260 const UINT32 destWidth = width;
261 const UINT32 destHeight = height;
264 if (destROI.
top & 1) {
269 if (destROI.
left & 1) {
276 const UINT32 leftD = destROI.
left >> 1;
277 const UINT32 left0 =
m_subband[srcLevel][
LL].GetROI().left;
278 const UINT32 left1 =
m_subband[srcLevel][
HL].GetROI().left;
279 const UINT32 topD = destROI.
top >> 1;
280 const UINT32 top0 =
m_subband[srcLevel][
LL].GetROI().top;
281 const UINT32 top1 =
m_subband[srcLevel][
LH].GetROI().top;
282 ASSERT(
m_subband[srcLevel][
LH].GetROI().left == left0);
283 ASSERT(
m_subband[srcLevel][
HH].GetROI().left == left1);
284 ASSERT(
m_subband[srcLevel][
HL].GetROI().top == top0);
285 ASSERT(
m_subband[srcLevel][
HH].GetROI().top == top1);
287 UINT32 srcOffsetX[2] = { 0, 0 };
288 UINT32 srcOffsetY[2] = { 0, 0 };
290 if (leftD >=
__max(left0, left1)) {
291 srcOffsetX[0] = leftD - left0;
292 srcOffsetX[1] = leftD - left1;
294 if (left0 <= left1) {
295 const UINT32 dx = (left1 - leftD) << 1;
299 srcOffsetX[0] = left1 - left0;
301 const UINT32 dx = (left0 - leftD) << 1;
305 srcOffsetX[1] = left0 - left1;
308 if (topD >=
__max(top0, top1)) {
309 srcOffsetY[0] = topD - top0;
310 srcOffsetY[1] = topD - top1;
313 const UINT32 dy = (top1 - topD) << 1;
315 origin += dy*destWidth;
317 srcOffsetY[0] = top1 - top0;
319 const UINT32 dy = (top0 - topD) << 1;
321 origin += dy*destWidth;
323 srcOffsetY[1] = top0 - top1;
335 PGFRect destROI(0, 0, width, height);
336 const UINT32 destWidth = width;
337 const UINT32 destHeight = height;
347 row0 = origin; row1 = row0 + destWidth;
349 for (UINT32 k=0; k < width; k++) {
350 row0[k] -= ((row1[k] +
c1) >> 1);
354 row2 = row1 + destWidth; row3 = row2 + destWidth;
355 for (UINT32 i=destROI.
top + 2; i < destROI.
bottom - 1; i += 2) {
357 for (UINT32 k=0; k < width; k++) {
358 row2[k] -= ((row1[k] + row3[k] +
c2) >> 2);
359 row1[k] += ((row0[k] + row2[k] +
c1) >> 1);
363 row0 = row2; row1 = row3; row2 = row1 + destWidth; row3 = row2 + destWidth;
369 for (UINT32 k=0; k < width; k++) {
370 row2[k] -= ((row1[k] +
c1) >> 1);
371 row1[k] += ((row0[k] + row2[k] +
c1) >> 1);
376 row0 = row1; row1 = row2; row2 += destWidth;
378 for (UINT32 k=0; k < width; k++) {
383 row0 = row1; row1 += destWidth;
387 row0 = origin; row1 = row0 + destWidth;
389 for (UINT32 k=0; k < height; k += 2) {
393 row0 += destWidth << 1; row1 += destWidth << 1;
423 dest[0] -= ((dest[1] +
c1) >> 1);
426 for (; i < width - 1; i += 2) {
427 dest[i] -= ((dest[i-1] + dest[i+1] +
c2) >> 2);
428 dest[i-1] += ((dest[i-2] + dest[i] +
c1) >> 1);
433 dest[i] -= ((dest[i-1] +
c1) >> 1);
434 dest[i-1] += ((dest[i-2] + dest[i] +
c1) >> 1);
436 dest[i-1] += dest[i-2];
444 const UINT32 wquot = width >> 1;
445 const bool wrem = width & 1;
450 #ifdef __PGFROISUPPORT__
451 const bool storePos = wquot < ll.BufferWidth();
452 UINT32 llPos = 0, hlPos = 0, lhPos = 0, hhPos = 0;
457 hlPos = hl.GetBuffPos();
459 hhPos = hh.GetBuffPos();
463 for (UINT32 i=0; i < wquot; i++) {
465 *loRow++ = hl.ReadBuffer();
467 *hiRow++ = hh.ReadBuffer();
475 #ifdef __PGFROISUPPORT__
478 ll.IncBuffRow(llPos);
479 hl.IncBuffRow(hlPos);
480 lh.IncBuffRow(lhPos);
481 hh.IncBuffRow(hhPos);
486 #ifdef __PGFROISUPPORT__
487 const bool storePos = wquot < ll.BufferWidth();
488 UINT32 llPos = 0, hlPos = 0;
493 hlPos = hl.GetBuffPos();
497 for (UINT32 i=0; i < wquot; i++) {
499 *loRow++ = hl.ReadBuffer();
503 #ifdef __PGFROISUPPORT__
506 ll.IncBuffRow(llPos);
507 hl.IncBuffRow(hlPos);
513#ifdef __PGFROISUPPORT__
517void CWaveletTransform::SetROI(
const PGFRect& rect) {
519 m_ROIindices.CreateIndices();
529 const PGFRect& indices = m_ROIindices.GetIndices(i);
534 subband.SetNTiles(m_ROIindices.GetNofTiles(i));
535 subband.TilePosition(indices.
left, indices.
top, r.
left, r.
top, w, h);
547void CRoiIndices::CreateIndices() {
550 m_indices =
new PGFRect[m_nLevels];
561void CRoiIndices::ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos,
bool horizontal,
bool isMin) {
565 UINT32 tileIndex = 0;
566 UINT32 tileMin = 0, tileMax = (horizontal) ? width : height;
567 ASSERT(pos <= tileMax);
570 for (
int i=m_nLevels - 1; i >= 0; i--) {
574 m_indices[i].left = tileIndex;
576 m_indices[i].right = tileIndex + 1;
580 m_indices[i].top = tileIndex;
582 m_indices[i].bottom = tileIndex + 1;
588 m = tileMin + (tileMax - tileMin)/2;
603void CRoiIndices::ComputeIndices(UINT32 width, UINT32 height,
const PGFRect& rect) {
604 ComputeTileIndex(width, height, rect.
left,
true,
true);
605 ComputeTileIndex(width, height, rect.
top,
false,
true);
606 ComputeTileIndex(width, height, rect.
right,
true,
false);
607 ComputeTileIndex(width, height, rect.
bottom,
false,
false);
#define NSubbands
number of subbands per level
#define MaxLevel
maximum number of transform levels
void WriteBuffer(DataT val)
void Initialize(UINT32 width, UINT32 height, int level, Orientation orient)
void Quantize(int quantParam)
void FreeMemory()
Delete the memory buffer of this subband.
UINT32 GetBuffPos() const