| 6927 | } |
| 6928 | |
| 6929 | void DecompressZip(unsigned char *dst, unsigned long &uncompressedSize, |
| 6930 | const unsigned char *src, unsigned long srcSize) { |
| 6931 | std::vector<unsigned char> tmpBuf(uncompressedSize); |
| 6932 | |
| 6933 | int ret = |
| 6934 | miniz::mz_uncompress(&tmpBuf.at(0), &uncompressedSize, src, srcSize); |
| 6935 | assert(ret == miniz::MZ_OK); |
| 6936 | |
| 6937 | // |
| 6938 | // Apply EXR-specific? postprocess. Grabbed from OpenEXR's |
| 6939 | // ImfZipCompressor.cpp |
| 6940 | // |
| 6941 | |
| 6942 | // Predictor. |
| 6943 | { |
| 6944 | unsigned char *t = &tmpBuf.at(0) + 1; |
| 6945 | unsigned char *stop = &tmpBuf.at(0) + uncompressedSize; |
| 6946 | |
| 6947 | while (t < stop) { |
| 6948 | int d = int(t[-1]) + int(t[0]) - 128; |
| 6949 | t[0] = d; |
| 6950 | ++t; |
| 6951 | } |
| 6952 | } |
| 6953 | |
| 6954 | // Reorder the pixel data. |
| 6955 | { |
| 6956 | const char *t1 = reinterpret_cast<const char *>(&tmpBuf.at(0)); |
| 6957 | const char *t2 = reinterpret_cast<const char *>(&tmpBuf.at(0)) + |
| 6958 | (uncompressedSize + 1) / 2; |
| 6959 | char *s = reinterpret_cast<char *>(dst); |
| 6960 | char *stop = s + uncompressedSize; |
| 6961 | |
| 6962 | while (true) { |
| 6963 | if (s < stop) |
| 6964 | *(s++) = *(t1++); |
| 6965 | else |
| 6966 | break; |
| 6967 | |
| 6968 | if (s < stop) |
| 6969 | *(s++) = *(t2++); |
| 6970 | else |
| 6971 | break; |
| 6972 | } |
| 6973 | } |
| 6974 | } |
| 6975 | |
| 6976 | } // namespace |
| 6977 |
no test coverage detected