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

Set parsed RAW dims and improve logging.

We weren't setting the parsed dimensions of the RAW file. Also when
input file doesn't exist, report the path of the file.

Added isConsoleApplication() helper, which returns true, when the app is
run from console.
parent 65a2620d
No related branches found
No related tags found
No related merge requests found
......@@ -189,7 +189,7 @@ public class ParsedCliOptions extends CompressionOptions implements Cloneable {
// Check if input file exists.
if (!new File(fileInputData.getFilePath()).exists()) {
parseErrorOccurred = true;
errorBuilder.append("Input file doesn't exist.\n");
errorBuilder.append("Input file doesn't exist. Provided path: '").append(fileInputData.getFilePath()).append("'\n");
return;
}
......@@ -273,13 +273,16 @@ public class ParsedCliOptions extends CompressionOptions implements Cloneable {
getInputDataInfo().setDataLoaderType(InputData.DataLoaderType.RawDataLoader);
final Optional<V3i> parsedImageDims = ParseUtils.tryParseV3i(inputFileArguments[1], 'x');
if (!parsedImageDims.isPresent()) {
if (parsedImageDims.isPresent()) {
getInputDataInfo().setDimension(parsedImageDims.get());
} else {
parseErrorOccurred = true;
errorBuilder.append("Failed to parse image dimensions of format DxDxD. Got: ")
.append(inputFileArguments[1])
.append('\n');
return;
}
// User specified plane index or plane range.
if (inputFileArguments.length > 2) {
parseInputFilePlaneOptions(errorBuilder, inputFileArguments, 2);
......@@ -531,4 +534,9 @@ public class ParsedCliOptions extends CompressionOptions implements Cloneable {
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public boolean isConsoleApplication() {
return true;
}
}
......@@ -139,4 +139,6 @@ public class CompressionOptions {
public void setCodebookType(CodebookType codebookType) {
this.codebookType = codebookType;
}
public boolean isConsoleApplication() {return false;}
}
......@@ -272,10 +272,15 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
final int[] indices = quantizer.quantizeIntoIndices(voxelData, options.getWorkerCount());
voxelLayersSizes[voxelLayerIndex] = writeHuffmanEncodedIndices(compressStream, huffman, indices);
stopwatch.stop();
if (options.isConsoleApplication()) {
reportStatusToListeners("%d/%d Finished voxel layer %s compression pass in %s",
voxelLayerIndex, voxelLayerCount, voxelLayerRange.toString(), stopwatch.getElapsedTimeString());
} else {
reportProgressToListeners(voxelLayerIndex, voxelLayerCount,
"%d/%d Finished voxel layer %s compression pass in %s",
voxelLayerIndex, voxelLayerCount, voxelLayerRange.toString(), stopwatch.getElapsedTimeString());
}
}
return voxelLayersSizes;
}
......
......@@ -231,7 +231,9 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
buffer[planeIndex] = TypeConverter.intArrayToShortArray(decompressedPlane.getData());
} catch (Exception ex) {
throw new ImageDecompressionException("VQImageDecompressor::decompressToBuffer() - Unable to read indices from InBitStream.", ex);
throw new ImageDecompressionException("VQImageDecompressor::decompressToBuffer() - Unable to read indices from " +
"InBitStream.",
ex);
}
reportProgressToListeners(planeIndex, planeCountForDecompression,
"Decompressed plane %d.", planeIndex);
......@@ -289,7 +291,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
final Voxel currentVoxel = new Voxel(currentVoxelLayerDims);
currentVoxelLayer = currentVoxel.reconstructFromVoxelsToDataset(voxelDims, decompressedVoxels);
} catch (Exception e) {
throw new ImageDecompressionException("VQImageDecompressor::decompressVoxels() - Unable to read indices from InBitStream.", e);
throw new ImageDecompressionException("VQImageDecompressor::decompressVoxels() - Unable to read indices from InBitStream.",
e);
}
for (int layer = 0; layer < currentVoxelLayerDims.getZ(); layer++) {
......@@ -301,11 +304,16 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
}
stopwatch.stop();
if (options.isConsoleApplication()) {
reportStatusToListeners("Decompressed voxel layer %d/%d in %s",
voxelLayerIndex, voxelLayerCount, stopwatch.getElapsedTimeString());
} else {
reportProgressToListeners(voxelLayerIndex, voxelLayerCount,
"Decompressed voxel layer %d/%d in %s",
voxelLayerIndex, voxelLayerCount, stopwatch.getElapsedTimeString());
}
}
}
private int decodeHuffmanSymbol(Huffman huffman, InBitStream inBitStream) throws IOException {
HuffmanNode currentHuffmanNode = huffman.getRoot();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment