这是indexloc提供的服务,不要输入任何密码
Skip to content

Chunked encoding that tries to add boxes after single image frame results in corrupt file #4466

@leo-barnes

Description

@leo-barnes

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

  1. Set up streamed output
  2. Set up chunked input
  3. Call JxlEncoderAddChunkedFrame to add frame. is_last_frame needs to be set to false, otherwise JxlEncoderAddBox will return an error.
  4. Call JxlEncoderCloseBoxes (not technically needed)
  5. Call JxlEncoderAddBox
  6. Call JxlEncoderCloseInput and JxlEncoderFlushInput

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:

  1. Setting is_last_frame to true when calling JxlEncoderAddChunkedFrame should not close box input
  2. JxlEncoderAddChunkedFrame with is_last_frame set to false followed by JxlEncoderCloseFrames should close out the partial codestream boxes with an empty jxlp box.

Environment

  • libxjl v0.10.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions