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
No related branches found
No related tags found
No related merge requests found
......@@ -138,7 +138,6 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
int planeCounter = 0;
for (final int planeIndex : planeIndices) {
stopwatch.restart();
reportStatusToListeners(String.format("Loading plane %d.", planeIndex));
ImageU16 plane = null;
......@@ -161,14 +160,13 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
assert (quantizer != null) : "Scalar Quantizer wasn't initialized.";
assert (huffman != null) : "Huffman wasn't initialized.";
reportStatusToListeners("Compressing plane...");
final int[] indices = quantizer.quantizeIntoIndices(plane.getData(), 1);
planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices);
stopwatch.stop();
reportStatusToListeners("Plane time: " + stopwatch.getElapsedTimeString());
reportStatusToListeners(String.format("Finished processing of plane %d", planeIndex));
reportProgressListeners(planeIndex, planeIndices.length,
"Compressed plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString());
}
return planeDataSizes;
}
......
......@@ -161,19 +161,17 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
quantizer = trainVectorQuantizerFromPlaneVectors(planeVectors);
huffman = createHuffmanCoder(huffmanSymbols, quantizer.getFrequencies());
writeQuantizerToCompressStream(quantizer, compressStream);
reportStatusToListeners("Wrote plane codebook.");
}
assert (quantizer != null);
reportProgressListeners(planeCounter, planeIndices.length, "Compressing plane %d", planeIndex);
final int[] indices = quantizer.quantizeIntoIndices(planeVectors, options.getWorkerCount());
planeDataSizes[planeCounter++] = writeHuffmanEncodedIndices(compressStream, huffman, indices);
stopwatch.stop();
reportStatusToListeners("Plane time: " + stopwatch.getElapsedTimeString());
reportStatusToListeners(String.format("Finished processing of plane %d.", planeIndex));
reportProgressListeners(planeIndex, planeIndices.length,
"Finished compression of plane %d in %s.", planeIndex, stopwatch.getElapsedTimeString());
}
return planeDataSizes;
}
......
......@@ -132,8 +132,6 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
}
assert (codebook != null && huffman != null);
reportStatusToListeners(String.format("Decompressing plane %d...", planeIndex));
byte[] decompressedPlaneData = null;
final int planeDataSize = (int) header.getPlaneDataSizes()[planeIndex];
......@@ -176,7 +174,8 @@ public class VQImageDecompressor extends CompressorDecompressorBase implements I
}
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
} catch (Exception 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