31 #define c1 1    // best value 1    32 #define c2 2    // best value 2    41 : m_nLevels(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;
   105                 row0 = src; row1 = row0 + width; row2 = row1 + width;
   109                 for (UINT32 k=0; k < width; k++) {
   110                         row1[k] -= ((row0[k] + row2[k] + 
c1) >> 1); 
   111                         row0[k] += ((row1[k] + 
c1) >> 1); 
   114                 row0 = row1; row1 = row2; row2 += width; row3 = row2 + width;
   117                 for (UINT32 i=3; i < height-1; i += 2) {
   120                         for (UINT32 k=0; k < width; k++) {
   121                                 row2[k] -= ((row1[k] + row3[k] + 
c1) >> 1); 
   122                                 row1[k] += ((row0[k] + row2[k] + 
c2) >> 2); 
   125                         row0 = row2; row1 = row3; row2 = row3 + width; row3 = row2 + width;
   130                         for (UINT32 k=0; k < width; k++) {
   131                                 row1[k] += ((row0[k] + 
c1) >> 1); 
   134                         row0 = row1; row1 += width;
   137                         for (UINT32 k=0; k < width; k++) {
   139                                 row1[k] += ((row0[k] + row2[k] + 
c2) >> 2); 
   142                         row0 = row1; row1 = row2; row2 += width;
   146                 row0 = src; row1 = row0 + width;
   148                 for (UINT32 k=0; k < height; k += 2) {
   152                         row0 += width << 1; row1 += width << 1;
   185                 src[1] -= ((src[0] + src[2] + 
c1) >> 1); 
   186                 src[0] += ((src[1] + 
c1) >> 1); 
   189                 for (; i < width-1; i += 2) {
   190                         src[i] -= ((src[i-1] + src[i+1] + 
c1) >> 1); 
   191                         src[i-1] += ((src[i-2] + src[i] + 
c2) >> 2); 
   196                         src[i-1] += ((src[i-2] + 
c1) >> 1); 
   199                         src[i-1] += ((src[i-2] + src[i] + 
c2) >> 2); 
   207         const UINT32 wquot = width >> 1;
   208         const bool wrem = (width & 1);
   213                 for (UINT32 i=0; i < wquot; i++) {
   215                         hl.WriteBuffer(*loRow++);
   217                         hh.WriteBuffer(*hiRow++);
   224                 for (UINT32 i=0; i < wquot; i++) {
   226                         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 *origin = destBand->
GetBuffer(), *row0, *row1, *row2, *row3;
   256 #ifdef __PGFROISUPPORT__   257         PGFRect destROI = destBand->GetAlignedROI();    
   258         const UINT32 destWidth  = destROI.
Width();  
   259         const UINT32 destHeight = destROI.
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].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);
   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;
   424                 dest[0] -= ((dest[1] + 
c1) >> 1); 
   427                 for (; i < width - 1; i += 2) {
   428                         dest[i] -= ((dest[i-1] + dest[i+1] + 
c2) >> 2); 
   429                         dest[i-1] += ((dest[i-2] + dest[i] + 
c1) >> 1); 
   434                         dest[i] -= ((dest[i-1] + 
c1) >> 1); 
   435                         dest[i-1] += ((dest[i-2] + dest[i] + 
c1) >> 1); 
   437                         dest[i-1] += dest[i-2]; 
   445         const UINT32 wquot = width >> 1;
   446         const bool wrem = (width & 1);
   451         #ifdef __PGFROISUPPORT__   452                 const bool storePos = wquot < ll.BufferWidth();
   453                 UINT32 llPos = 0, hlPos = 0, lhPos = 0, hhPos = 0;
   458                         hlPos = hl.GetBuffPos(); 
   460                         hhPos = hh.GetBuffPos(); 
   464                 for (UINT32 i=0; i < wquot; i++) {
   466                         *loRow++ = hl.ReadBuffer();
   468                         *hiRow++ = hh.ReadBuffer();
   476         #ifdef __PGFROISUPPORT__   479                         ll.IncBuffRow(llPos); 
   480                         hl.IncBuffRow(hlPos); 
   481                         lh.IncBuffRow(lhPos); 
   482                         hh.IncBuffRow(hhPos); 
   487         #ifdef __PGFROISUPPORT__   488                 const bool storePos = wquot < ll.BufferWidth();
   489                 UINT32 llPos = 0, hlPos = 0;
   494                         hlPos = hl.GetBuffPos(); 
   498                 for (UINT32 i=0; i < wquot; i++) {
   500                         *loRow++ = hl.ReadBuffer();
   504         #ifdef __PGFROISUPPORT__   507                         ll.IncBuffRow(llPos); 
   508                         hl.IncBuffRow(hlPos); 
   514 #ifdef __PGFROISUPPORT__   515 void CWaveletTransform::SetROI(
PGFRect roi) {
   527         roi.
top  = (roi.
top  > delta) ? roi.
top  - delta : 0;
   533                 PGFRect& indices = m_indices[l];
   534                 UINT32 nTiles = GetNofTiles(l);
   538                 subband.SetNTiles(nTiles); 
   539                 subband.TileIndex(
true, roi.
left, roi.
top, indices.
left, indices.
top, alignedROI.
left, alignedROI.
top);
   541                 subband.SetAlignedROI(alignedROI);
   543                         (m_indices[l-1].left >= 2*m_indices[l].left &&
   544                         m_indices[l-1].top >= 2*m_indices[l].top &&
   545                         m_indices[l-1].right <= 2*m_indices[l].right &&
   546                         m_indices[l-1].bottom <= 2*m_indices[l].bottom));
   553                         sb.SetNTiles(nTiles); 
   554                         sb.TilePosition(indices.
left, indices.
top, aroi.
left, aroi.
top, w, h);
   558                         sb.SetAlignedROI(aroi);
   563                 roi.
top = alignedROI.
top >> 1;
   569 #endif // __PGFROISUPPORT__ 
void Initialize(UINT32 width, UINT32 height, int level, Orientation orient)
UINT32 GetBuffPos() const
#define MaxLevel
maximum number of transform levels
void FreeMemory()
Delete the memory buffer of this subband.
void Quantize(int quantParam)
void WriteBuffer(DataT val)
#define NSubbands
number of subbands per level