Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load RLE encoded file #34

Closed
zeroeffects opened this issue Oct 28, 2016 · 6 comments
Closed

Failed to load RLE encoded file #34

zeroeffects opened this issue Oct 28, 2016 · 6 comments

Comments

@zeroeffects
Copy link

zeroeffects commented Oct 28, 2016

The newer versions of TinyEXR seem to include RLE support. However, it seems that there is some issue with the determination of the block offsets as I am having an issue with loading some of our data. It basically triggers the assert in tinyexr.h:10383 (assert(num_lines > 0)). You can find a sample at the following address: http://3dgraphics.guru/sites/default/files/sample-tinyexr-bug.exr.

@syoyo
Copy link
Owner

syoyo commented Oct 28, 2016

I have investigated your EXR file and offset tables looks corrupted.

http://www.openexr.com/openexrfilelayout.pdf (See page 10 for Offset tables)

First element of offset tables contains the byte offset to 1023th scanline correctly, but other elements are filled with zeros, so tinyexr reads pixel data from invalid location, resulting an assertion.

Also, exrheader program from OpenEXR displays your EXR is incomplete.

$ exrheader sample-tinyexr-bug.exr 

file sample-tinyexr-bug.exr (incomplete):

file format version: 2, flags 0x0
channels (type chlist):
    B, 16-bit floating-point, sampling 1 1
    G, 16-bit floating-point, sampling 1 1
    R, 16-bit floating-point, sampling 1 1
compression (type compression): run-length encoding
dataWindow (type box2i): (0 0) - (1023 1023)
displayWindow (type box2i): (0 0) - (1023 1023)
lineOrder (type lineOrder): increasing y
pixelAspectRatio (type float): 1
screenWindowCenter (type v2f): (0 0)
screenWindowWidth (type float): 1
type (type string): "scanlineimage"

How do you create your EXR file?

(For some reason, it looks OpenEXR can handle such an incomplete data, whereas tinyexr is not)

@syoyo
Copy link
Owner

syoyo commented Oct 28, 2016

BTW I have found another issue related RLE, filed as #35

(FYI, offset tables in comp_rle.exr are correct, thus issue #35 looks purely the problem of RLE decoding)

@zeroeffects
Copy link
Author

The file was produced by a legacy toolchain, so I don't exactly have control over it. Anyway, I will see whether I can hack around the issue.

@syoyo syoyo closed this as completed in cd73a48 Oct 29, 2016
@syoyo
Copy link
Owner

syoyo commented Oct 29, 2016

I found OpenEXR try to reconstruct offset information for incomplete EXR file.
(i.e. offset is zero)

https://github.com/openexr/openexr/blob/develop/OpenEXR/IlmImf/ImfScanLineInputFile.cpp#L338

And adding similar code to tinyexr, now your file can be read correctly.

BTW, Is it ok to add your EXR file to unit tests? @zeroeffects

@zeroeffects
Copy link
Author

It seems that the latest version is crashing with null pointer dereference in rleDecompress.

Also, you can use the image. It is a rectified image of alcantara material measured in camera dome under specific lighting and viewing conditions.

@syoyo
Copy link
Owner

syoyo commented Oct 29, 2016

Ah, I found memory bug and fixed it. Now recent master should work.

Also, you can use the image.

Thank you. But I found the image has 5.8MB which is too large to add into tinyexr repo. Do you have much more smaller one? (e.g. 0.5 MB or less)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants