⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezw.cpp

📁 介绍小波的函数
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                                        if (*C1 != 0) {
                                                setbits(1);
                                                setcoeffs(*C1);
                                        } else
                                                setbits(0);

                                        if (*(C1 + 1) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C1 + 1));
                                        } else
                                                setbits(0);
                                } else
                                        setbits(0);

                                if (*(B0 + 1) != 0) {
                                        setbits(1);
                                        setcoeffs(*(B0 + 1));

                                        if (*(C0 + 2) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C0 + 2));
                                        } else
                                                setbits(0);

                                        if (*(C0 + 3) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C0 + 3));
                                        } else
                                                setbits(0);

                                        if (*(C1 + 2) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C1 + 2));
                                        } else
                                                setbits(0);

                                        if (*(C1 + 3) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C1 + 3));
                                        } else
                                                setbits(0);
                                } else
                                        setbits(0);

                                if (*B1 != 0) {
                                        setbits(1);
                                        setcoeffs(*B1);

                                        if (*C2 != 0) {
                                                setbits(1);
                                                setcoeffs(*C2);
                                        } else
                                                setbits(0);

                                        if (*(C2 + 1) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C2 + 1));
                                        } else
                                                setbits(0);

                                        if (*C3 != 0) {
                                                setbits(1);
                                                setcoeffs(*C3);
                                        } else
                                                setbits(0);

                                        if (*(C3 + 1) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C3 + 1));
                                        } else
                                                setbits(0);
                                } else
                                        setbits(0);

                                if (*(B1 + 1) != 0) {
                                        setbits(1);
                                        setcoeffs(*(B1 + 1));

                                        if (*(C2 + 2) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C2 + 2));
                                        } else
                                                setbits(0);

                                        if (*(C2 + 3) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C2 + 3));
                                        } else
                                                setbits(0);

                                        if (*(C3 + 2) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C3 + 2));
                                        } else
                                                setbits(0);

                                        if (*(C3 + 3) != 0) {
                                                setbits(1);
                                                setcoeffs(*(C3 + 3));
                                        } else
                                                setbits(0);
                                } else
                                        setbits(0);

                        } else
                                setbits(0);

                        A0++;
                        B0 += 2;
                        B1 += 2;
                        C0 += 4;
                        C1 += 4;
                        C2 += 4;
                        C3 += 4;
                }//for( unsigned int j = 0; j < width; j++ ) {

                a += width8;
                b += 2 * width8;
                c += 4 * width8;
        }//for( unsigned int i = 0; i < height; i++ )
}
//////////////////////////////////store LL,HH bands//////////////////////////////////////////////////////



//////////////////////////////////read LL,HH bands///////////////////////////////////////////////////////
void EZW::readLband(unsigned char* dest)
{
        for (unsigned int j = 0; j < height; j++) {

                __m64* mdest = (__m64 *)dest;
                __m64* msour = (__m64 *)psour;

                for (unsigned int i = 0; i < width / 8; i++)
                        *mdest++ = *msour++;

                psour += 8 * (width / 8);

                if (width % 8) {
                        for (unsigned int i = width - width % 8; i < width; i++)
                                dest[i] = *psour++;
                }

                dest += width8;
        }
        _mm_empty();
}
void EZW::readHband(unsigned char* a, unsigned char* b, unsigned char* c)
{
        unsigned char* A0;
        unsigned char* B0, *B1;
        unsigned char* C0, *C1, *C2, *C3;

        for (unsigned int i = 0; i < height; i++) {

                A0 = a;
                B0 = b;
                B1 = B0 + width8;
                C0 = c;
                C1 = C0 + width8;
                C2 = C1 + width8;
                C3 = C2 + width8;

                for (unsigned int j = 0; j < width; j++) {

                        if (getbits() != 0) {
                                *A0 = getcoeffs();

                                if (getbits() != 0) {
                                        *B0 = getcoeffs();

                                        if (getbits() != 0)
                                                *C0 = getcoeffs();
                                        if (getbits() != 0)
                                                *(C0 + 1) = getcoeffs();
                                        if (getbits() != 0)
                                                *C1 = getcoeffs();
                                        if (getbits())
                                                *(C1 + 1) = getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *(B0 + 1) = getcoeffs();

                                        if (getbits() != 0)
                                                *(C0 + 2) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C0 + 3) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C1 + 2) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C1 + 3) = getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *B1 = getcoeffs();

                                        if (getbits() != 0)
                                                *C2 = getcoeffs();
                                        if (getbits() != 0)
                                                *(C2 + 1) = getcoeffs();
                                        if (getbits() != 0)
                                                *C3 = getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 1) = getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *(B1 + 1) = getcoeffs();

                                        if (getbits() != 0)
                                                *(C2 + 2) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C2 + 3) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 2) = getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 3) = getcoeffs();
                                }

                        }

                        A0++;
                        B0 += 2;
                        B1 += 2;
                        C0 += 4;
                        C1 += 4;
                        C2 += 4;
                        C3 += 4;
                }//for( unsigned int j = 0; j < width; j++ ) {

                a += width8;
                b += 2 * width8;
                c += 4 * width8;
        }//for( unsigned int i = 0; i < height; i++ ) {
}

void EZW::readHband(char* a, char* b, char* c)
{
        char* A0;
        char* B0, *B1;
        char* C0, *C1, *C2, *C3;

        for (unsigned int i = 0; i < height; i++) {

                A0 = a;
                B0 = b;
                B1 = B0 + width8;
                C0 = c;
                C1 = C0 + width8;
                C2 = C1 + width8;
                C3 = C2 + width8;

                for (unsigned int j = 0; j < width; j++) {

                        if (getbits() != 0) {
                                *A0 = (char)getcoeffs();

                                if (getbits() != 0) {
                                        *B0 = (char)getcoeffs();

                                        if (getbits() != 0)
                                                *C0 = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C0 + 1) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *C1 = (char)getcoeffs();
                                        if (getbits())
                                                *(C1 + 1) = (char)getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *(B0 + 1) = (char)getcoeffs();

                                        if (getbits() != 0)
                                                *(C0 + 2) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C0 + 3) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C1 + 2) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C1 + 3) = (char)getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *B1 = (char)getcoeffs();

                                        if (getbits() != 0)
                                                *C2 = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C2 + 1) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *C3 = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 1) = (char)getcoeffs();
                                }

                                if (getbits() != 0) {
                                        *(B1 + 1) = (char)getcoeffs();

                                        if (getbits() != 0)
                                                *(C2 + 2) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C2 + 3) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 2) = (char)getcoeffs();
                                        if (getbits() != 0)
                                                *(C3 + 3) = (char)getcoeffs();
                                }

                        }

                        A0++;
                        B0 += 2;
                        B1 += 2;
                        C0 += 4;
                        C1 += 4;
                        C2 += 4;
                        C3 += 4;
                }//for( unsigned int j = 0; j < width; j++ ) {

                a += width8;
                b += 2 * width8;
                c += 4 * width8;
        }//for( unsigned int i = 0; i < height; i++ ) {
}
//////////////////////////////////read LL,HH bands///////////////////////////////////////////////////////









/////////////////////////////////mmx routines////////////////////////////////////////////////////////////
void EZW::mmxmemset(unsigned char* dest, unsigned int size, unsigned char c) const
{
        __m64 val;
        __m64* mdest = (__m64 *)dest;
        val = _mm_setr_pi8(c, c, c, c, c, c, c, c);

        for (unsigned int i = 0; i < size / 8; i++)
                *mdest++ = val;

        if (size % 8) {
                dest = (unsigned char *)mdest;
                for (unsigned int i = 0; i < size % 8; i++)
                        *dest++ = c;
        }

        _mm_empty();
}
void EZW::mmxmemcpy(unsigned char* dest, const unsigned char* sour, unsigned int size) const
{
        __m64* mdest = (__m64 *)dest;
        __m64* msour = (__m64 *)sour;

        for (unsigned int i = 0; i < size / 8; i++)
                *mdest++ = *msour++;

        if (size % 8) {
                dest = (unsigned char *)mdest;
                sour = (unsigned char *)msour;
                for (unsigned int i = 0; i < size % 8; i++)
                        *dest++ = *sour++;
        }

        _mm_empty();
}
/////////////////////////////////mmx routines////////////////////////////////////////////////////////////









⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -