Skip to content
Snippets Groups Projects
Commit 7a06c09a authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Modify QCMPFileHeaderV1 header variables.

Make variables protected and rename planeDataSizes array to
chunkDataSizes, with this the getters and setters are renamed also.
parent 434ddb96
Branches
Tags
No related merge requests found
...@@ -109,7 +109,7 @@ public class ImageDecompressor extends CompressorDecompressorBase { ...@@ -109,7 +109,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
if (validFile && options.isVerbose()) { if (validFile && options.isVerbose()) {
final String prefix = header.getQuantizationType() != QuantizationType.Vector3D ? "Plane" : "Voxel layer"; final String prefix = header.getQuantizationType() != QuantizationType.Vector3D ? "Plane" : "Voxel layer";
final long[] planeDataSizes = header.getPlaneDataSizes(); final long[] planeDataSizes = header.getChunkDataSizes();
long planeIndex = 0; long planeIndex = 0;
for (final long planeDataSize : planeDataSizes) { for (final long planeDataSize : planeDataSizes) {
logBuilder.append(String.format("%s %d: %d Bytes\n", prefix, planeIndex++, planeDataSize)); logBuilder.append(String.format("%s %d: %d Bytes\n", prefix, planeIndex++, planeDataSize));
...@@ -244,7 +244,7 @@ public class ImageDecompressor extends CompressorDecompressorBase { ...@@ -244,7 +244,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
dis.reset(); dis.reset();
header.setPlaneDataSizes(chunkSizes); header.setChunkDataSizes(chunkSizes);
return cachedDecompressor.decompressStreamMode(dis, header); return cachedDecompressor.decompressStreamMode(dis, header);
......
...@@ -73,7 +73,7 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -73,7 +73,7 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I
reportStatusToListeners(String.format("Decompressing plane %d...", planeIndex)); reportStatusToListeners(String.format("Decompressing plane %d...", planeIndex));
byte[] decompressedPlaneData = null; byte[] decompressedPlaneData = null;
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex]; final int planeDataSize = (int) header.getChunkDataSizes()[planeIndex];
try (final InBitStream inBitStream = new InBitStream(compressedStream, try (final InBitStream inBitStream = new InBitStream(compressedStream,
header.getBitsPerCodebookIndex(), header.getBitsPerCodebookIndex(),
planeDataSize)) { planeDataSize)) {
...@@ -140,7 +140,7 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -140,7 +140,7 @@ public class SQImageDecompressor extends CompressorDecompressorBase implements I
} }
assert (codebook != null && huffmanDecoder != null); assert (codebook != null && huffmanDecoder != null);
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex]; final int planeDataSize = (int) header.getChunkDataSizes()[planeIndex];
try (final InBitStream inBitStream = new InBitStream(compressedStream, header.getBitsPerCodebookIndex(), planeDataSize)) { try (final InBitStream inBitStream = new InBitStream(compressedStream, header.getBitsPerCodebookIndex(), planeDataSize)) {
inBitStream.fillEntireBuffer(); inBitStream.fillEntireBuffer();
inBitStream.setAllowReadFromUnderlyingStream(false); inBitStream.setAllowReadFromUnderlyingStream(false);
......
...@@ -139,7 +139,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -139,7 +139,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
assert (codebook != null && huffmanDecoder != null); assert (codebook != null && huffmanDecoder != null);
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex]; final int planeDataSize = (int) header.getChunkDataSizes()[planeIndex];
try (final InBitStream inBitStream = new InBitStream(compressedStream, try (final InBitStream inBitStream = new InBitStream(compressedStream,
header.getBitsPerCodebookIndex(), header.getBitsPerCodebookIndex(),
planeDataSize)) { planeDataSize)) {
...@@ -183,7 +183,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -183,7 +183,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
for (int planeIndex = 0; planeIndex < planeCountForDecompression; planeIndex++) { for (int planeIndex = 0; planeIndex < planeCountForDecompression; planeIndex++) {
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex]; final int planeDataSize = (int) header.getChunkDataSizes()[planeIndex];
try (final InBitStream inBitStream = new InBitStream(compressedStream, try (final InBitStream inBitStream = new InBitStream(compressedStream,
header.getBitsPerCodebookIndex(), header.getBitsPerCodebookIndex(),
planeDataSize)) { planeDataSize)) {
...@@ -253,7 +253,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -253,7 +253,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
? header.getImageSizeZ() ? header.getImageSizeZ()
: (voxelLayerDepth + (voxelLayerIndex * voxelLayerDepth)); : (voxelLayerDepth + (voxelLayerIndex * voxelLayerDepth));
final V3i currentVoxelLayerDims = new V3i(header.getImageSizeX(), header.getImageSizeY(), toZ - fromZ); final V3i currentVoxelLayerDims = new V3i(header.getImageSizeX(), header.getImageSizeY(), toZ - fromZ);
final int voxelLayerDataSize = (int) header.getPlaneDataSizes()[voxelLayerIndex]; final int voxelLayerDataSize = (int) header.getChunkDataSizes()[voxelLayerIndex];
final int voxelLayerVoxelCount = Voxel.calculateRequiredVoxelCount(currentVoxelLayerDims, voxelDims); final int voxelLayerVoxelCount = Voxel.calculateRequiredVoxelCount(currentVoxelLayerDims, voxelDims);
final int[][] decompressedVoxels = new int[voxelLayerVoxelCount][vectorSize]; final int[][] decompressedVoxels = new int[voxelLayerVoxelCount][vectorSize];
...@@ -311,7 +311,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -311,7 +311,7 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
? header.getImageSizeZ() ? header.getImageSizeZ()
: (voxelLayerDepth + (voxelLayerIndex * voxelLayerDepth)); : (voxelLayerDepth + (voxelLayerIndex * voxelLayerDepth));
final V3i currentVoxelLayerDims = new V3i(header.getImageSizeX(), header.getImageSizeY(), toZ - fromZ); final V3i currentVoxelLayerDims = new V3i(header.getImageSizeX(), header.getImageSizeY(), toZ - fromZ);
final int voxelLayerDataSize = (int) header.getPlaneDataSizes()[voxelLayerIndex]; final int voxelLayerDataSize = (int) header.getChunkDataSizes()[voxelLayerIndex];
final int voxelLayerVoxelCount = Voxel.calculateRequiredVoxelCount(currentVoxelLayerDims, voxelDims); final int voxelLayerVoxelCount = Voxel.calculateRequiredVoxelCount(currentVoxelLayerDims, voxelDims);
final int[][] decompressedVoxels = new int[voxelLayerVoxelCount][vectorSize]; final int[][] decompressedVoxels = new int[voxelLayerVoxelCount][vectorSize];
......
...@@ -19,20 +19,20 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable { ...@@ -19,20 +19,20 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable {
//endregion //endregion
//region Header fields //region Header fields
private String magicValue = MAGIC_VALUE; protected String magicValue = MAGIC_VALUE;
private QuantizationType quantizationType; protected QuantizationType quantizationType;
private byte bitsPerCodebookIndex; protected byte bitsPerCodebookIndex;
private boolean codebookPerPlane; protected boolean codebookPerPlane;
private int imageSizeX; protected int imageSizeX;
private int imageSizeY; protected int imageSizeY;
private int imageSizeZ; protected int imageSizeZ;
private int vectorSizeX; protected int vectorSizeX;
private int vectorSizeY; protected int vectorSizeY;
private int vectorSizeZ; protected int vectorSizeZ;
private long[] planeDataSizes; protected long[] chunkDataSizes;
//endregion //endregion
//region IFileHeader implementation //region IFileHeader implementation
...@@ -121,10 +121,10 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable { ...@@ -121,10 +121,10 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable {
? imageSizeZ ? imageSizeZ
: VQImageCompressor.calculateVoxelLayerCount(imageSizeZ, vectorSizeZ); : VQImageCompressor.calculateVoxelLayerCount(imageSizeZ, vectorSizeZ);
planeDataSizes = new long[chunkCount]; chunkDataSizes = new long[chunkCount];
for (int i = 0; i < chunkCount; i++) { for (int i = 0; i < chunkCount; i++) {
final long readValue = inputStream.readInt(); final long readValue = inputStream.readInt();
planeDataSizes[i] = (readValue & 0x00000000FFFFFFFFL); chunkDataSizes[i] = (readValue & 0x00000000FFFFFFFFL);
} }
} }
...@@ -211,7 +211,7 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable { ...@@ -211,7 +211,7 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable {
// Indices are encoded using huffman. Plane data size is written in the header. // Indices are encoded using huffman. Plane data size is written in the header.
long totalPlaneDataSize = 0; long totalPlaneDataSize = 0;
for (final long planeDataSize : planeDataSizes) { for (final long planeDataSize : chunkDataSizes) {
totalPlaneDataSize += planeDataSize; totalPlaneDataSize += planeDataSize;
} }
...@@ -231,7 +231,7 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable { ...@@ -231,7 +231,7 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable {
// Indices are encoded using huffman. Plane data size is written in the header. // Indices are encoded using huffman. Plane data size is written in the header.
long totalPlaneDataSize = 0; long totalPlaneDataSize = 0;
for (final long planeDataSize : planeDataSizes) { for (final long planeDataSize : chunkDataSizes) {
totalPlaneDataSize += planeDataSize; totalPlaneDataSize += planeDataSize;
} }
return (codebookDataSize + totalPlaneDataSize); return (codebookDataSize + totalPlaneDataSize);
...@@ -361,12 +361,12 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable { ...@@ -361,12 +361,12 @@ public class QCMPFileHeaderV1 implements IFileHeader, Cloneable {
vectorSizeZ = vectorDims.getZ(); vectorSizeZ = vectorDims.getZ();
} }
public long[] getPlaneDataSizes() { public long[] getChunkDataSizes() {
return planeDataSizes; return chunkDataSizes;
} }
public void setPlaneDataSizes(final long[] sizes) { public void setChunkDataSizes(final long[] sizes) {
planeDataSizes = sizes; chunkDataSizes = sizes;
} }
public long getHeaderSize() { public long getHeaderSize() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment