MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / LoadDeepEXR

Function LoadDeepEXR

SampleFramework11/v1.02/TinyEXR.cpp:7753–8087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7751}
7752
7753int LoadDeepEXR(DeepImage *deepImage, const char *filename, const char **err) {
7754 if (deepImage == NULL) {
7755 if (err) {
7756 (*err) = "Invalid argument.";
7757 }
7758 return -1;
7759 }
7760
7761 FILE *fp = fopen(filename, "rb");
7762 if (!fp) {
7763 if (err) {
7764 (*err) = "Cannot read file.";
7765 }
7766 return -1;
7767 }
7768
7769 size_t filesize;
7770 // Compute size
7771 fseek(fp, 0, SEEK_END);
7772 filesize = ftell(fp);
7773 fseek(fp, 0, SEEK_SET);
7774
7775 std::vector<char> buf(filesize); // @todo { use mmap }
7776 {
7777 size_t ret;
7778 ret = fread(&buf[0], 1, filesize, fp);
7779 assert(ret == filesize);
7780 fclose(fp);
7781 }
7782
7783 const char *head = &buf[0];
7784 const char *marker = &buf[0];
7785
7786 // Header check.
7787 {
7788 const char header[] = {0x76, 0x2f, 0x31, 0x01};
7789
7790 if (memcmp(marker, header, 4) != 0) {
7791 if (err) {
7792 (*err) = "Header mismatch.";
7793 }
7794 return -3;
7795 }
7796 marker += 4;
7797 }
7798
7799 // Version, scanline.
7800 {
7801 // ver 2.0, scanline, deep bit on(0x800)
7802 // must be [2, 0, 0, 0]
7803 if (marker[0] != 2 || marker[1] != 8 || marker[2] != 0 || marker[3] != 0) {
7804 if (err) {
7805 (*err) = "Unsupported version or scanline.";
7806 }
7807 return -4;
7808 }
7809
7810 marker += 4;

Callers

nothing calls this directly

Calls 9

ReadAttributeFunction · 0.85
ReadChannelInfoFunction · 0.85
IsBigEndianFunction · 0.85
swap4Function · 0.85
swap8Function · 0.85
DecompressZipFunction · 0.85
half_to_floatFunction · 0.85
atMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected