MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / CompressZip

Function CompressZip

third-party/tinyexr/tinyexr.h:1309–1415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1307}
1308
1309static bool CompressZip(unsigned char *dst,
1310 tinyexr::tinyexr_uint64 &compressedSize,
1311 const unsigned char *src, unsigned long src_size) {
1312 std::vector<unsigned char> tmpBuf(src_size);
1313
1314 //
1315 // Apply EXR-specific? postprocess. Grabbed from OpenEXR's
1316 // ImfZipCompressor.cpp
1317 //
1318
1319 //
1320 // Reorder the pixel data.
1321 //
1322
1323 const char *srcPtr = reinterpret_cast<const char *>(src);
1324
1325 {
1326 char *t1 = reinterpret_cast<char *>(&tmpBuf.at(0));
1327 char *t2 = reinterpret_cast<char *>(&tmpBuf.at(0)) + (src_size + 1) / 2;
1328 const char *stop = srcPtr + src_size;
1329
1330 for (;;) {
1331 if (srcPtr < stop)
1332 *(t1++) = *(srcPtr++);
1333 else
1334 break;
1335
1336 if (srcPtr < stop)
1337 *(t2++) = *(srcPtr++);
1338 else
1339 break;
1340 }
1341 }
1342
1343 //
1344 // Predictor.
1345 //
1346
1347 {
1348 unsigned char *t = &tmpBuf.at(0) + 1;
1349 unsigned char *stop = &tmpBuf.at(0) + src_size;
1350 int p = t[-1];
1351
1352 while (t < stop) {
1353 int d = int(t[0]) - p + (128 + 256);
1354 p = t[0];
1355 t[0] = static_cast<unsigned char>(d);
1356 ++t;
1357 }
1358 }
1359
1360#if defined(TINYEXR_USE_MINIZ) && (TINYEXR_USE_MINIZ==1)
1361 //
1362 // Compress the data using miniz
1363 //
1364
1365 mz_ulong outSize = mz_compressBound(src_size);
1366 int ret = mz_compress(

Callers 1

EncodePixelDataFunction · 0.85

Calls 2

nanoz_compressBoundFunction · 0.85
nanoz_compressFunction · 0.85

Tested by

no test coverage detected