From d77e823c42ba9f64b9d50c4c15f0be9c573032e8 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Wed, 20 Nov 2024 11:17:21 +0100 Subject: [PATCH] add typesize --- .../n5/blosc/BloscCompression.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/janelia/saalfeldlab/n5/blosc/BloscCompression.java b/src/main/java/org/janelia/saalfeldlab/n5/blosc/BloscCompression.java index c21cfd7..9648ed0 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/blosc/BloscCompression.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/blosc/BloscCompression.java @@ -64,6 +64,9 @@ public class BloscCompression implements DefaultBlockReader, DefaultBlockWriter, @CompressionParameter private final int blocksize; + @CompressionParameter + private final int typesize; + @CompressionParameter private int nthreads; @@ -93,6 +96,12 @@ public int getBlocksize() { return blocksize; } + public int getTypesize() { + + return typesize; + } + + public int getNthreads() { @@ -112,6 +121,7 @@ public BloscCompression() { this.clevel = 6; this.shuffle = NOSHUFFLE; this.blocksize = 0; // auto + this.typesize = 1; this.nthreads = 1; } @@ -120,21 +130,34 @@ public BloscCompression( final int clevel, final int shuffle, final int blocksize, + final int typesize, final int nthreads) { this.cname = cname; this.clevel = clevel; this.shuffle = shuffle; this.blocksize = blocksize; + this.typesize = typesize; this.nthreads = nthreads; } + public BloscCompression( + final String cname, + final int clevel, + final int shuffle, + final int blocksize, + final int nthreads) { + + this(cname, clevel, shuffle, blocksize, 1, nthreads); + } + public BloscCompression(final BloscCompression template) { this.cname = template.cname; this.clevel = template.clevel; this.shuffle = template.shuffle; this.blocksize = template.blocksize; + this.typesize = template.typesize; this.nthreads = template.nthreads; } @@ -164,7 +187,7 @@ public void write( final ByteBuffer src = dataBlock.toByteBuffer(); final ByteBuffer dst = ByteBuffer.allocate(src.limit() + JBlosc.OVERHEAD); - JBlosc.compressCtx(clevel, shuffle, 1, src, src.limit(), dst, dst.limit(), cname, blocksize, nthreads); + JBlosc.compressCtx(clevel, shuffle, typesize, src, src.limit(), dst, dst.limit(), cname, blocksize, nthreads); final BufferSizes sizes = blosc.cbufferSizes(dst); final int dstSize = (int)sizes.getCbytes(); out.write(dst.array(), 0, dstSize);