Skip to content
Snippets Groups Projects
Commit cfbedd67 authored by Vojtěch Moravec's avatar Vojtěch Moravec
Browse files

Remove offset from both 2D and 3D chunk.

Remove V2l and V3l offsets from chunks. These offsets weren't used and
were only taking place in memory.
parent 0b976466
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ public class VQBenchmark extends BenchmarkBase { ...@@ -32,7 +32,7 @@ public class VQBenchmark extends BenchmarkBase {
private ImageU16 reconstructImageFromQuantizedVectors(final ImageU16 plane, private ImageU16 reconstructImageFromQuantizedVectors(final ImageU16 plane,
final int[][] vectors, final int[][] vectors,
final V2i qVector) { final V2i qVector) {
Chunk2D reconstructedChunk = new Chunk2D(new V2i(rawImageDims.getX(), rawImageDims.getY()), new V2l(0, 0)); Chunk2D reconstructedChunk = new Chunk2D(new V2i(rawImageDims.getX(), rawImageDims.getY()));
if (qVector.getY() > 1) { if (qVector.getY() > 1) {
reconstructedChunk.reconstructFrom2DVectors(vectors, qVector); reconstructedChunk.reconstructFrom2DVectors(vectors, qVector);
} else { } else {
......
...@@ -215,7 +215,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -215,7 +215,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
reportStatusToListeners(inputDataInfo.isPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data."); reportStatusToListeners(inputDataInfo.isPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data.");
final int[] planeIndices = getPlaneIndicesForCompression(); final int[] planeIndices = getPlaneIndicesForCompression();
final int chunkCountPerPlane = Chunk2D.calculateRequiredChunkCountPerPlane( final int chunkCountPerPlane = Chunk2D.calculateRequiredChunkCount(
inputDataInfo.getDimensions().toV2i(), inputDataInfo.getDimensions().toV2i(),
options.getVectorDimension()); options.getVectorDimension());
final int totalChunkCount = chunkCountPerPlane * planeIndices.length; final int totalChunkCount = chunkCountPerPlane * planeIndices.length;
......
...@@ -64,7 +64,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -64,7 +64,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
final V2i qVector, final V2i qVector,
final V3i imageDims) { final V3i imageDims) {
Chunk2D reconstructedChunk = new Chunk2D(new V2i(imageDims.getX(), imageDims.getY()), new V2l(0, 0)); Chunk2D reconstructedChunk = new Chunk2D(new V2i(imageDims.getX(), imageDims.getY()));
if (qVector.getY() > 1) { if (qVector.getY() > 1) {
reconstructedChunk.reconstructFrom2DVectors(vectors, qVector); reconstructedChunk.reconstructFrom2DVectors(vectors, qVector);
} else { } else {
...@@ -205,7 +205,6 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -205,7 +205,6 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
assert (codebook != null && huffman != null); assert (codebook != null && huffman != null);
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex]; final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex];
try (InBitStream inBitStream = new InBitStream(compressedStream, try (InBitStream inBitStream = new InBitStream(compressedStream,
header.getBitsPerCodebookIndex(), header.getBitsPerCodebookIndex(),
......
...@@ -5,19 +5,16 @@ public class Chunk2D { ...@@ -5,19 +5,16 @@ public class Chunk2D {
private int[] data; private int[] data;
private final V2i dims; private final V2i dims;
private final V2l offset;
/** /**
* Create the Chunk2D of given dimensions, offset and initialize it with data. * Create the Chunk2D of given dimensions, offset and initialize it with data.
* *
* @param dims Dimensions of the chunk. * @param dims Dimensions of the chunk.
* @param offset Offset of the chunk.
* @param data Chunk data. * @param data Chunk data.
*/ */
public Chunk2D(final V2i dims, final V2l offset, final int[] data) { public Chunk2D(final V2i dims, final int[] data) {
this.dims = dims; this.dims = dims;
this.data = data; this.data = data;
this.offset = offset;
assert (data.length == (dims.getX() * dims.getY())) : "Wrong box data."; assert (data.length == (dims.getX() * dims.getY())) : "Wrong box data.";
} }
...@@ -25,10 +22,9 @@ public class Chunk2D { ...@@ -25,10 +22,9 @@ public class Chunk2D {
* Create Chunk2D of given dimensions and offset. Allocates the data. * Create Chunk2D of given dimensions and offset. Allocates the data.
* *
* @param dims Dimensions of the chunk. * @param dims Dimensions of the chunk.
* @param offset Offset of the chunk.
*/ */
public Chunk2D(final V2i dims, final V2l offset) { public Chunk2D(final V2i dims) {
this(dims, offset, new int[dims.getX() * dims.getY()]); this(dims, new int[dims.getX() * dims.getY()]);
} }
/** /**
...@@ -69,10 +65,6 @@ public class Chunk2D { ...@@ -69,10 +65,6 @@ public class Chunk2D {
return dims; return dims;
} }
public V2l getOffset() {
return offset;
}
@Override @Override
public String toString() { public String toString() {
return String.format("2D shape %s %d values", dims.toString(), data.length); return String.format("2D shape %s %d values", dims.toString(), data.length);
...@@ -273,8 +265,6 @@ public class Chunk2D { ...@@ -273,8 +265,6 @@ public class Chunk2D {
final Chunk2D otherChunk = (Chunk2D) obj; final Chunk2D otherChunk = (Chunk2D) obj;
if (data.length != otherChunk.data.length) { if (data.length != otherChunk.data.length) {
return false; return false;
} else if (!(offset.equals(otherChunk.offset))) {
return false;
} else { } else {
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
if (data[i] != otherChunk.data[i]) { if (data[i] != otherChunk.data[i]) {
......
...@@ -25,7 +25,7 @@ public class ImageU16 { ...@@ -25,7 +25,7 @@ public class ImageU16 {
} }
public Chunk2D as2dChunk() { public Chunk2D as2dChunk() {
return new Chunk2D(new V2i(width, height), new V2l(0, 0), data); return new Chunk2D(new V2i(width, height), data);
} }
public ImageU16 difference(final ImageU16 other) { public ImageU16 difference(final ImageU16 other) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment