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

Function ParseEXRVersionFromMemory

third-party/tinyexr/tinyexr.h:8763–8818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8761}
8762
8763int ParseEXRVersionFromMemory(EXRVersion *version, const unsigned char *memory,
8764 size_t size) {
8765 if (version == NULL || memory == NULL) {
8766 return TINYEXR_ERROR_INVALID_ARGUMENT;
8767 }
8768
8769 if (size < tinyexr::kEXRVersionSize) {
8770 return TINYEXR_ERROR_INVALID_DATA;
8771 }
8772
8773 const unsigned char *marker = memory;
8774
8775 // Header check.
8776 {
8777 const char header[] = {0x76, 0x2f, 0x31, 0x01};
8778
8779 if (memcmp(marker, header, 4) != 0) {
8780 return TINYEXR_ERROR_INVALID_MAGIC_NUMBER;
8781 }
8782 marker += 4;
8783 }
8784
8785 version->tiled = false;
8786 version->long_name = false;
8787 version->non_image = false;
8788 version->multipart = false;
8789
8790 // Parse version header.
8791 {
8792 // must be 2
8793 if (marker[0] != 2) {
8794 return TINYEXR_ERROR_INVALID_EXR_VERSION;
8795 }
8796
8797 if (version == NULL) {
8798 return TINYEXR_SUCCESS; // May OK
8799 }
8800
8801 version->version = 2;
8802
8803 if (marker[1] & 0x2) { // 9th bit
8804 version->tiled = true;
8805 }
8806 if (marker[1] & 0x4) { // 10th bit
8807 version->long_name = true;
8808 }
8809 if (marker[1] & 0x8) { // 11th bit
8810 version->non_image = true; // (deep image)
8811 }
8812 if (marker[1] & 0x10) { // 12th bit
8813 version->multipart = true;
8814 }
8815 }
8816
8817 return TINYEXR_SUCCESS;
8818}
8819
8820int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) {

Callers 3

IsEXRFromMemoryFunction · 0.85
LoadEXRFromMemoryFunction · 0.85
ParseEXRVersionFromFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected