Skip to content

encoder output mode using out-of-order jxlp#4745

Open
jonsneyers wants to merge 4 commits into
libjxl:mainfrom
jonsneyers:enc_ooo_jxlp
Open

encoder output mode using out-of-order jxlp#4745
jonsneyers wants to merge 4 commits into
libjxl:mainfrom
jonsneyers:enc_ooo_jxlp

Conversation

@jonsneyers

Copy link
Copy Markdown
Member

(builds on #4741)

This adds a new encoder option JXL_ENC_FRAME_SETTING_OUTPUT_MODE to set the output mode:

  • mode 0 (default): buffer the entire output codestream, progressive-decodable
  • mode 1 (streaming output using seek): this does what used to be buffering=3: use a permuted TOC to write sections in an order convenient for chunked encode but not progressively decodable; use seeking to update the TOC and jxlp box size after encode
  • mode 2 (ooo jxlp, new): uses ftyp version 1 which allows jxlp boxes to be in arbitrary order. Writes sections in the same order as in mode 1, but wraps each of them in its own jxlp box. The final jxlp box contains the TOC. No seeking is required during encode, and the 'logical' codestream does not use a permuted TOC, but it is shuffled at the file format level since it is split in jxlp boxes that are out of order.

It is not recommended to start using output mode 2 since current decoders do not support this yet. This is mostly just to create test bitstreams; it could be useful in some very specific use cases but generally sticking to mode 0 is recommended (to produce progressive-decodable output).

@veluca93 veluca93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add roundtrip tests for this, with and without TOC permutation?

@veluca93 veluca93 mentioned this pull request Apr 30, 2026
9 tasks
@jonsneyers

Copy link
Copy Markdown
Member Author

Can we add roundtrip tests for this, with and without TOC permutation?

Initially TOC permutation was being ignored in output mode 2 (just like in output mode 1). Changed it to actually do the requested TOC permutation in mode 2, since even if modes 1 and 2 are inherently non-progressive, mode 2 can be easily converted to mode 0 by sorting and merging the jxlp boxes, so it may be useful to be able to do a center-first permutation even if it will only be usable after doing a conversion from ftyp 1 to ftyp 0.

Added a test that checks that all output modes and TOC permutations produce different files but identical decoded images.

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

Successfully merging this pull request may close these issues.

2 participants