I want to compress my data, using compress zlib function, so, code, looks like following:
ifs.read(srcBuf,srcLen) // std::ifstream, srcLen = 256kb
compress(dstBuf, &dstLen, srcBuf, srcLen); // casts are omitted
ofs.write(dstBuf, dstLen); // std::ofstream
dstLen = dstBufSize;
Result file is ~4% smaller, than original (380mb vs 360mb), which is, actually, awful. Meanwhile, Winrar compress this file to 70mb file. I've tried bzip2 and zlib, and both provide similar result. I guess the problem is that 256KB buffer is too small, but I'd like to understand how it works, and how I can use zlib, to achieve better compression. Overall, I want to make lowlevel facility to compress several files to 1 big one for internal use, and compress() looks very suited for it, but...
Deep explanations are very welcome. Thanks in advance.
Z_BEST_COMPRESSION
as the compression level.