-
Notifications
You must be signed in to change notification settings - Fork 317
Description
Describe the bug
When doing streamed output and chunked input, trying to create a file with one image frame followed by Exif/XMP results in a corrupt file. This is most likely due to JxlEncoderAddChunkedFrame not behaving as expected with regards to is_last_frame.
If JxlEncoderAddChunkedFrame is called with is_last_frame set to true, JxlEncoderCloseInput will be called internally, which makes it impossible to add any subsequent boxes. So in order to add more boxes after the frame, is_last_frame needs to be set to false. But this ends up creating a non-terminated partial codestream box.
JxlEncoderAddChunkedFrame should instead be calling JxlEncoderCloseFrames.
To Reproduce
- Set up streamed output
- Set up chunked input
- Call
JxlEncoderAddChunkedFrameto add frame.is_last_frameneeds to be set to false, otherwiseJxlEncoderAddBoxwill return an error. - Call
JxlEncoderCloseBoxes(not technically needed) - Call
JxlEncoderAddBox - Call
JxlEncoderCloseInputandJxlEncoderFlushInput
The resulting file contains a single partial codestream box with index 0. When decoding the decoder complains that more data is needed to decode.
Expected behavior
The results differ from my expectations in two ways:
- Setting
is_last_frameto true when callingJxlEncoderAddChunkedFrameshould not close box input JxlEncoderAddChunkedFramewithis_last_frameset to false followed byJxlEncoderCloseFramesshould close out the partial codestream boxes with an emptyjxlpbox.
Environment
- libxjl v0.10.2