Compute fast inverse wavelet transform of all 4 subbands of given level and stores result in LL subband of level - 1.
245 {
246 ASSERT(srcLevel > 0 && srcLevel <
m_nLevels);
247 const int destLevel = srcLevel - 1;
250 UINT32 width, height;
251
252
253 if (!destBand->
AllocMemory())
return InsufficientMemory;
254 DataT *origin = destBand->
GetBuffer(), *row0, *row1, *row2, *row3;
255
256#ifdef __PGFROISUPPORT__
257 PGFRect destROI = destBand->GetAlignedROI();
258 const UINT32 destWidth = destROI.
Width();
259 const UINT32 destHeight = destROI.
Height();
260 width = destWidth;
261 height = destHeight;
262
263
264 if (destROI.
top & 1) {
266 origin += destWidth;
267 height--;
268 }
269 if (destROI.
left & 1) {
271 origin++;
272 width--;
273 }
274
275
276 const UINT32 leftD = destROI.
left >> 1;
277 const UINT32 left0 =
m_subband[srcLevel][
LL].GetAlignedROI().left;
278 const UINT32 left1 =
m_subband[srcLevel][
HL].GetAlignedROI().left;
279 const UINT32 topD = destROI.
top >> 1;
280 const UINT32 top0 =
m_subband[srcLevel][
LL].GetAlignedROI().top;
281 const UINT32 top1 =
m_subband[srcLevel][
LH].GetAlignedROI().top;
282 ASSERT(
m_subband[srcLevel][
LH].GetAlignedROI().left == left0);
283 ASSERT(
m_subband[srcLevel][
HH].GetAlignedROI().left == left1);
284 ASSERT(
m_subband[srcLevel][
HL].GetAlignedROI().top == top0);
285 ASSERT(
m_subband[srcLevel][
HH].GetAlignedROI().top == top1);
286
287 UINT32 srcOffsetX[2] = { 0, 0 };
288 UINT32 srcOffsetY[2] = { 0, 0 };
289
290 if (leftD >=
__max(left0, left1)) {
291 srcOffsetX[0] = leftD - left0;
292 srcOffsetX[1] = leftD - left1;
293 } else {
294 if (left0 <= left1) {
295 const UINT32 dx = (left1 - leftD) << 1;
297 origin += dx;
298 width -= dx;
299 srcOffsetX[0] = left1 - left0;
300 } else {
301 const UINT32 dx = (left0 - leftD) << 1;
303 origin += dx;
304 width -= dx;
305 srcOffsetX[1] = left0 - left1;
306 }
307 }
308 if (topD >=
__max(top0, top1)) {
309 srcOffsetY[0] = topD - top0;
310 srcOffsetY[1] = topD - top1;
311 } else {
312 if (top0 <= top1) {
313 const UINT32 dy = (top1 - topD) << 1;
315 origin += dy*destWidth;
316 height -= dy;
317 srcOffsetY[0] = top1 - top0;
318 } else {
319 const UINT32 dy = (top0 - topD) << 1;
321 origin += dy*destWidth;
322 height -= dy;
323 srcOffsetY[1] = top0 - top1;
324 }
325 }
326
331
332#else
335 PGFRect destROI(0, 0, width, height);
336 const UINT32 destWidth = width;
337 const UINT32 destHeight = height;
338
339
342 }
343#endif
344
346
347 row0 = origin; row1 = row0 + destWidth;
349 for (UINT32 k = 0; k < width; k++) {
350 row0[k] -= ((row1[k] +
c1) >> 1);
351 }
352
353
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);
360 }
363 row0 = row2; row1 = row3; row2 = row1 + destWidth; row3 = row2 + destWidth;
364 }
365
366
367 if (height & 1) {
369 for (UINT32 k = 0; k < width; k++) {
370 row2[k] -= ((row1[k] +
c1) >> 1);
371 row1[k] += ((row0[k] + row2[k] +
c1) >> 1);
372 }
376 row0 = row1; row1 = row2; row2 += destWidth;
377 } else {
378 for (UINT32 k = 0; k < width; k++) {
379 row1[k] += row0[k];
380 }
383 row0 = row1; row1 += destWidth;
384 }
385 } else {
386
387 row0 = origin; row1 = row0 + destWidth;
388
389 for (UINT32 k = 0; k < height; k += 2) {
393 row0 += destWidth << 1; row1 += destWidth << 1;
394 }
395
396 if (height & 1) {
399 }
400 }
401
402
405 }
406
407
408 *w = destWidth;
409 *h = destHeight;
411 return NoError;
412}