Skip to content

Commit

Permalink
fix renderVarblocks with lossless input
Browse files Browse the repository at this point in the history
  • Loading branch information
Traneptora committed Oct 29, 2024
1 parent 52b08d2 commit de1fb07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion java/com/traneptora/jxlatte/JXLCodestreamDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

public class JXLCodestreamDecoder {

private static void copyToCanvas(ImageBuffer canvas, Point start, Point off, Dimension size, ImageBuffer frameBuffer) {
private static void copyToCanvas(ImageBuffer canvas, Point start, Point off,
Dimension size, ImageBuffer frameBuffer) {
Object[] canvasB = canvas.isInt() ? canvas.getIntBuffer() : canvas.getFloatBuffer();
Object[] frameB = frameBuffer.isInt() ? frameBuffer.getIntBuffer() : frameBuffer.getFloatBuffer();
for (int y = 0; y < size.height; y++) {
Expand Down
4 changes: 4 additions & 0 deletions java/com/traneptora/jxlatte/bundle/BitDepthHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public BitDepthHeader(Bitreader reader) throws IOException {
}
}

public int getMaxValue() {
return ~(~0 << bitsPerSample);
}

@Override
public int hashCode() {
return Objects.hash(usesFloatSamples, bitsPerSample, expBits);
Expand Down
5 changes: 4 additions & 1 deletion java/com/traneptora/jxlatte/frame/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,14 @@ public void decodeFrame(ImageBuffer[] lfBuffer) throws IOException {

// do this in RGB
public void drawVarblocks() {
float[][][] buff = Stream.of(buffer[0], buffer[1], buffer[2]).map(b -> {
b.castToFloatIfInt(globalMetadata.getBitDepthHeader().getMaxValue());
return b.getFloatBuffer();
}).toArray(float[][][]::new);
for (LFGroup lfg : lfGroups) {
Point pixelPos = getLFGroupLocation(lfg.lfGroupID);
pixelPos.y <<= 11;
pixelPos.x <<= 11;
float[][][] buff = Stream.of(buffer).map(ImageBuffer::getFloatBuffer).toArray(float[][][]::new);
for (int i = 0; i < lfg.hfMetadata.blockList.length; i++) {
Point block = lfg.hfMetadata.blockList[i];
TransformType tt = lfg.hfMetadata.dctSelect[block.y][block.x];
Expand Down

0 comments on commit de1fb07

Please sign in to comment.