Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mickaelpic
Beginner
37 Views

Access violation in ippsEncodeLZ77_8u

Hi, I am trying to use the compression IPPs to compress big files (~100MB)

But afterdeflating a few buffers I get an access violation in ippsEncodeLZ77_8u.
I tried to follow the operation description in zlib.h for deflate.

I would really like to understand what is wrong.

I use IPPss 5.3 Update 3 build 85.25, [5.3.471.85]

The following code isdeflating 3 buffers, (but stream.avail_out is always 2 after the first deflate, so I never get to write a single buffer to the output file)and then fails.

#define bufferSize 65536 // 64KB
#define aesBlkSize 32

inBuffer = (unsigned char*)ippMalloc(bufferSize);
if(inBuffer == NULL)
{
printf("Failed to initialize inBuffer ");
return -1;
}
outBuffer = (
unsigned char*)ippMalloc(bufferSize);
if(outBuffer == NULL)
{
printf(
"Failed to initialize outBuffer ");
return -1;
}

stream.next_in = inBuffer;
stream.next_out = outBuffer;
stream.avail_out = bufferSize;
stream.avail_in = 0;
int toWrite = 0;
do
{
len = (
unsigned long)fread((char*)inBuffer, 1, bufferSize, fin);
stream.avail_in = len;
if(len > 0)
{
do
{
err = deflate(&stream, Z_NO_FLUSH);
if(err == Z_OK)
{
if(stream.avail_out < bufferSize)
{
toWrite = bufferSize - stream.avail_out;
// write the buffer
  ;if(fwrite((char*)outBuffer, 1, toWrite, fout) != toWrite)
{
printf(
"Failed to write to file ");
return -1;
}
stream.avail_out = bufferSize;
}
}
else
{
if(Check_Error(err, "deflate") == -1)
{
return -1;
}
}
}
while(stream.avail_in != 0);
}
}
while(len != 0);
do
{
err = deflate(&stream, Z_FINISH);
if(err == Z_OK || err == Z_STREAM_END)
{
// write the buffer
if(fwrite((char*)outBuffer, 1, stream.total_out, fout) != stream.total_out)
{
printf(
"Failed to write to file ");
return -1;
}
stream.avail_out = bufferSize;
}
else
{
// Error
if(Check_Error(err, "Z_FINISH") == -1)
& nbsp;{
return -1;
}
}
}
while(err != Z_STREAM_END);
err = deflateEnd(&stream);
if(Check_Error(err, "deflateEnd") == -1)
{
return -1;
}

0 Kudos
2 Replies
mickaelpic
Beginner
37 Views

Nevermind, I firgured it out.

I thought that next_in and next_outwould always point to the beginning of inBuffer and outBuffer.
So I just have to re-set them everytime I read/write from the buffer to the files.

Vladimir_Dudnik
Employee
37 Views

Thanks for updating us on that issue!

Vladimir