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

Function SaveEXRNPartImageToMemory

Source/ThirdParty/tinyexr.h:9206–9584  ·  view source on GitHub ↗

can save a single or multi-part image (no deep* formats)

Source from the content-addressed store, hash-verified

9204
9205// can save a single or multi-part image (no deep* formats)
9206static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
9207 const EXRHeader** exr_headers,
9208 unsigned int num_parts,
9209 unsigned char** memory_out, const char** err) {
9210 if (exr_images == NULL || exr_headers == NULL || num_parts == 0 ||
9211 memory_out == NULL) {
9212 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
9213 err);
9214 return 0;
9215 }
9216 {
9217 for (unsigned int i = 0; i < num_parts; ++i) {
9218 if (exr_headers[i]->compression_type < 0) {
9219 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
9220 err);
9221 return 0;
9222 }
9223#if !TINYEXR_USE_PIZ
9224 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {
9225 SetErrorMessage("PIZ compression is not supported in this build",
9226 err);
9227 return 0;
9228 }
9229#endif
9230 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {
9231#if !TINYEXR_USE_ZFP
9232 SetErrorMessage("ZFP compression is not supported in this build",
9233 err);
9234 return 0;
9235#else
9236 // All channels must be fp32.
9237 // No fp16 support in ZFP atm(as of 2023 June)
9238 // https://github.com/LLNL/fpzip/issues/2
9239 for (int c = 0; c < exr_headers[i]->num_channels; ++c) {
9240 if (exr_headers[i]->requested_pixel_types[c] != TINYEXR_PIXELTYPE_FLOAT) {
9241 SetErrorMessage("Pixel type must be FLOAT for ZFP compression",
9242 err);
9243 return 0;
9244 }
9245 }
9246#endif
9247 }
9248 }
9249 }
9250
9251 std::vector<unsigned char> memory;
9252
9253 // Header
9254 {
9255 const char header[] = { 0x76, 0x2f, 0x31, 0x01 };
9256 memory.insert(memory.end(), header, header + 4);
9257 }
9258
9259 // Version
9260 // using value from the first header
9261 int long_name = exr_headers[0]->long_name;
9262 {
9263 char marker[] = { 2, 0, 0, 0 };

Callers 2

SaveEXRImageToMemoryFunction · 0.85

Calls 9

SetErrorMessageFunction · 0.85
NumScanlinesFunction · 0.85
PrecalculateTileInfoFunction · 0.85
InitTileOffsetsFunction · 0.85
WriteChannelInfoFunction · 0.85
WriteAttributeToMemoryFunction · 0.85
swap4Function · 0.85
EncodeChunkFunction · 0.85

Tested by

no test coverage detected