MCPcopy Create free account
hub / github.com/RenderKit/embree / CompressPiz

Function CompressPiz

tutorials/common/image/tinyexr.h:3162–3279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3160#endif
3161
3162static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize,
3163 const unsigned char *inPtr, size_t inSize,
3164 const std::vector<ChannelInfo> &channelInfo,
3165 int data_width, int num_lines) {
3166 std::vector<unsigned char> bitmap(BITMAP_SIZE);
3167 unsigned short minNonZero;
3168 unsigned short maxNonZero;
3169
3170#if !TINYEXR_LITTLE_ENDIAN
3171 // @todo { PIZ compression on BigEndian architecture. }
3172 return false;
3173#endif
3174
3175 // Assume `inSize` is multiple of 2 or 4.
3176 std::vector<unsigned short> tmpBuffer(inSize / sizeof(unsigned short));
3177
3178 std::vector<PIZChannelData> channelData(channelInfo.size());
3179 unsigned short *tmpBufferEnd = &tmpBuffer.at(0);
3180
3181 for (size_t c = 0; c < channelData.size(); c++) {
3182 PIZChannelData &cd = channelData[c];
3183
3184 cd.start = tmpBufferEnd;
3185 cd.end = cd.start;
3186
3187 cd.nx = data_width;
3188 cd.ny = num_lines;
3189 // cd.ys = c.channel().ySampling;
3190
3191 size_t pixelSize = sizeof(int); // UINT and FLOAT
3192 if (channelInfo[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) {
3193 pixelSize = sizeof(short);
3194 }
3195
3196 cd.size = static_cast<int>(pixelSize / sizeof(short));
3197
3198 tmpBufferEnd += cd.nx * cd.ny * cd.size;
3199 }
3200
3201 const unsigned char *ptr = inPtr;
3202 for (int y = 0; y < num_lines; ++y) {
3203 for (size_t i = 0; i < channelData.size(); ++i) {
3204 PIZChannelData &cd = channelData[i];
3205
3206 // if (modp (y, cd.ys) != 0)
3207 // continue;
3208
3209 size_t n = static_cast<size_t>(cd.nx * cd.size);
3210 memcpy(cd.end, ptr, n * sizeof(unsigned short));
3211 ptr += n * sizeof(unsigned short);
3212 cd.end += n;
3213 }
3214 }
3215
3216 bitmapFromData(&tmpBuffer.at(0), static_cast<int>(tmpBuffer.size()),
3217 bitmap.data(), minNonZero, maxNonZero);
3218
3219 std::vector<unsigned short> lut(USHORT_RANGE);

Callers 1

EncodePixelDataFunction · 0.85

Calls 8

bitmapFromDataFunction · 0.85
forwardLutFromBitmapFunction · 0.85
applyLutFunction · 0.85
wav2EncodeFunction · 0.85
hufCompressFunction · 0.85
sizeMethod · 0.45
atMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected