You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned in #20, I'm working on an ImageIO plugin for JPEG XL using your decoder. For this to work reasonably, I need a way to read the header (ImageHeader) without also decoding the entire image.
I've added a method to JXLCodestreamDecoder, like this:
publicImageHeaderreadHeader() throwsIOException {
if (imageHeader == null) {
if (atEnd()) {
returnnull;
}
bitreader.showBits(16); // force the level to be populatedintlevel = demuxer.getLevel();
imageHeader = ImageHeader.read(newLoggers(options, newPrintWriter(newOutputStreamWriter(System.err, StandardCharsets.UTF_8))), bitreader, level);
}
returnimageHeader;
}
(I also made some minor tweaks to initialize canvas in the decode method to avoid NPE).
This kind of works, but in some cases it seems to create what I believe is alignment issues in the codestream when I later invoke decode(). Causing exceptions like:
For samples/ants.jxl as an example:
com.traneptora.jxlatte.io.InvalidBitstreamException: Invalid Level 1 Prefix codes
at com.traneptora.jxlatte.entropy.PrefixSymbolDistribution.populateComplexPrefix(PrefixSymbolDistribution.java:97)
at com.traneptora.jxlatte.entropy.PrefixSymbolDistribution.<init>(PrefixSymbolDistribution.java:194)
at com.traneptora.jxlatte.entropy.EntropyStream.<init>(EntropyStream.java:147)
at com.traneptora.jxlatte.entropy.EntropyStream.<init>(EntropyStream.java:101)
at com.traneptora.jxlatte.frame.Frame.readTOC(Frame.java:155)
at com.traneptora.jxlatte.JXLCodestreamDecoder.decode(JXLCodestreamDecoder.java:754)
at com.traneptora.jxlatte.JXLCodestreamDecoder.decode(JXLCodestreamDecoder.java:686)
at com.traneptora.jxlatte.JXLDecoder.decode(JXLDecoder.java:41)
I can work around this, by repositioning the stream and creating a new decoder for reading the image after reading the header. But it would be nice to have a method that could read the header without other side effects. My plan was to create a PR with the above code, but it's no good until we can fix the alignment issues.
The text was updated successfully, but these errors were encountered:
haraldk
changed the title
Read header only
New feature: Read header only
Nov 8, 2024
As mentioned in #20, I'm working on an ImageIO plugin for JPEG XL using your decoder. For this to work reasonably, I need a way to read the header (
ImageHeader
) without also decoding the entire image.I've added a method to
JXLCodestreamDecoder
, like this:(I also made some minor tweaks to initialize
canvas
in thedecode
method to avoid NPE).This kind of works, but in some cases it seems to create what I believe is alignment issues in the codestream when I later invoke
decode()
. Causing exceptions like:For
samples/ants.jxl
as an example:I can work around this, by repositioning the stream and creating a new decoder for reading the image after reading the header. But it would be nice to have a method that could read the header without other side effects. My plan was to create a PR with the above code, but it's no good until we can fix the alignment issues.
The text was updated successfully, but these errors were encountered: