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

Improve the reporting to listeners.

parent 04a9caf9
Branches
No related tags found
No related merge requests found
...@@ -138,7 +138,6 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -138,7 +138,6 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
int planeCounter = 0; int planeCounter = 0;
for (final int planeIndex : planeIndices) { for (final int planeIndex : planeIndices) {
stopwatch.restart(); stopwatch.restart();
reportStatusToListeners(String.format("Loading plane %d.", planeIndex));
ImageU16 plane = null; ImageU16 plane = null;
...@@ -161,14 +160,13 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -161,14 +160,13 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
assert (quantizer != null) : "Scalar Quantizer wasn't initialized."; assert (quantizer != null) : "Scalar Quantizer wasn't initialized.";
assert (huffman != null) : "Huffman wasn't initialized."; assert (huffman != null) : "Huffman wasn't initialized.";
reportStatusToListeners("Compressing plane...");
final int[] indices = quantizer.quantizeIntoIndices(plane.getData(), 1); final int[] indices = quantizer.quantizeIntoIndices(plane.getData(), 1);
planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices); planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices);
stopwatch.stop(); stopwatch.stop();
reportStatusToListeners("Plane time: " + stopwatch.getElapsedTimeString()); reportProgressListeners(planeIndex, planeIndices.length,
reportStatusToListeners(String.format("Finished processing of plane %d", planeIndex)); "Compressed plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString());
} }
return planeDataSizes; return planeDataSizes;
} }
......
...@@ -161,19 +161,17 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm ...@@ -161,19 +161,17 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
quantizer = trainVectorQuantizerFromPlaneVectors(planeVectors); quantizer = trainVectorQuantizerFromPlaneVectors(planeVectors);
huffman = createHuffmanCoder(huffmanSymbols, quantizer.getFrequencies()); huffman = createHuffmanCoder(huffmanSymbols, quantizer.getFrequencies());
writeQuantizerToCompressStream(quantizer, compressStream); writeQuantizerToCompressStream(quantizer, compressStream);
reportStatusToListeners("Wrote plane codebook.");
} }
assert (quantizer != null); assert (quantizer != null);
reportProgressListeners(planeCounter, planeIndices.length, "Compressing plane %d", planeIndex);
final int[] indices = quantizer.quantizeIntoIndices(planeVectors, options.getWorkerCount()); final int[] indices = quantizer.quantizeIntoIndices(planeVectors, options.getWorkerCount());
planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices); planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices);
stopwatch.stop(); stopwatch.stop();
reportStatusToListeners("Plane time: " + stopwatch.getElapsedTimeString()); reportProgressListeners(planeIndex, planeIndices.length,
reportStatusToListeners(String.format("Finished processing of plane %d.", planeIndex)); "Finished compression of plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString());
} }
return planeDataSizes; return planeDataSizes;
} }
......
...@@ -132,8 +132,6 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -132,8 +132,6 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
} }
assert (codebook != null && huffman != null); assert (codebook != null && huffman != null);
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.getPlaneDataSizes()[planeIndex];
...@@ -176,7 +174,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -176,7 +174,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
} }
stopwatch.stop(); stopwatch.stop();
reportStatusToListeners(String.format("Decompressed plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString())); reportProgressListeners(planeIndex, planeCountForDecompression,
"Decompressed plane %d in %s", planeIndex, stopwatch.getElapsedTimeString());
} }
} }
...@@ -240,6 +239,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I ...@@ -240,6 +239,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
} catch (Exception ex) { } catch (Exception ex) {
throw new ImageDecompressionException("Unable to read indices from InBitStream.", ex); throw new ImageDecompressionException("Unable to read indices from InBitStream.", ex);
} }
reportProgressListeners(planeIndex, planeCountForDecompression,
"Decompressed plane %d.", planeIndex);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment