MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / CompressZip

Function CompressZip

Source/ThirdParty/tinyexr.h:1453–1559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1451}
1452
1453static bool CompressZip(unsigned char *dst,
1454 tinyexr::tinyexr_uint64 &compressedSize,
1455 const unsigned char *src, unsigned long src_size) {
1456 std::vector<unsigned char> tmpBuf(src_size);
1457
1458 //
1459 // Apply EXR-specific? postprocess. Grabbed from OpenEXR's
1460 // ImfZipCompressor.cpp
1461 //
1462
1463 //
1464 // Reorder the pixel data.
1465 //
1466
1467 const char *srcPtr = reinterpret_cast<const char *>(src);
1468
1469 {
1470 char *t1 = reinterpret_cast<char *>(&tmpBuf.at(0));
1471 char *t2 = reinterpret_cast<char *>(&tmpBuf.at(0)) + (src_size + 1) / 2;
1472 const char *stop = srcPtr + src_size;
1473
1474 for (;;) {
1475 if (srcPtr < stop)
1476 *(t1++) = *(srcPtr++);
1477 else
1478 break;
1479
1480 if (srcPtr < stop)
1481 *(t2++) = *(srcPtr++);
1482 else
1483 break;
1484 }
1485 }
1486
1487 //
1488 // Predictor.
1489 //
1490
1491 {
1492 unsigned char *t = &tmpBuf.at(0) + 1;
1493 unsigned char *stop = &tmpBuf.at(0) + src_size;
1494 int p = t[-1];
1495
1496 while (t < stop) {
1497 int d = int(t[0]) - p + (128 + 256);
1498 p = t[0];
1499 t[0] = static_cast<unsigned char>(d);
1500 ++t;
1501 }
1502 }
1503
1504#if defined(TINYEXR_USE_MINIZ) && (TINYEXR_USE_MINIZ==1)
1505 //
1506 // Compress the data using miniz
1507 //
1508
1509 mz_ulong outSize = mz_compressBound(src_size);
1510 int ret = mz_compress(

Callers 1

EncodePixelDataFunction · 0.85

Calls 1

stbi_zlib_compressFunction · 0.85

Tested by

no test coverage detected