Coder Social home page Coder Social logo

ulz77's People

Contributors

zooxyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ulz77's Issues

Something goes wrong when Decompressing the data

Something goes wrong when Decompressing the data。 Here is the code:
int main(int argc, const char *argv[])
{
int ret = 0;
int mode = 0;
/int method = ULZ77C_METHOD_STREAM;/
int method = ULZ77C_METHOD_FILE;
char *src_file = NULL;
char dst_file = NULL;
size_t bs = 1024; /
1M /
srand((unsigned int)time(NULL));
printf("TestData:\n ");
for(int i=0;i<1024
2;i++)
{
TestData[i] = rand()%256;
printf("%02X ",TestData[i]);
}
printf("\n");

unsigned int block_size;
unsigned char *src = NULL;
unsigned char *dst = NULL;
size_t dst_len;

int originpos = 0;
for(int i =0 ;i <2;i++)
{
    ret = ulz77_encode_data(&dst, &dst_len, TestData, 1024, ULZ77_TYPE_COMPRESSION);
    printf("RecoverLen:%d\n",dst_len);
#if 0
    unsigned char * testttttt = (unsigned char *)&dst_len;
    EncodedData[originpos] =  testttttt[0];
    originpos++;
    EncodedData[originpos] =  testttttt[1];
    originpos++;
    EncodedData[originpos] =  testttttt[2];
    originpos++;
    EncodedData[originpos] =  testttttt[3];
    originpos++;
#endif
    if (ret == 0)
    {
        for(int index = 0;index < dst_len; index++)
        {
            EncodedData[originpos+index] = dst[index];
        }
        originpos+=dst_len;
    }
    free(dst);
}
printf("RecoverData:%d\n",originpos);

printf("RecoverData:\n");
int recoverpos = 0;
int recoverlen = 0;
while(originpos > 0)
{
    int len = originpos;
    ret = ulz77_encode_data(&dst, &dst_len, &EncodedData[recoverpos], len, ULZ77_TYPE_DECOMPRESSION);
    if (ret == 0)
    {
        for(int i=0;i<dst_len;i++)
        {
            printf("%02X ",dst[i]);
        }
    }
    recoverlen += dst_len;
    originpos -= dst_len;
    recoverpos += len + 4;
    free(dst);
}
printf("\n RecoverData:%d\n ",recoverlen);

}

Decompress Data is not correct.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.