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

Use new InputFileInfo object.

parent 780ef867
No related branches found
No related tags found
No related merge requests found
Showing
with 134 additions and 138 deletions
......@@ -30,7 +30,7 @@ public class DataCompressor {
}
ParsedCliOptions parsedCliOptions = new ParsedCliOptions(cmd);
if (parsedCliOptions.hasErrorOccured()) {
if (parsedCliOptions.didErrorOccure()) {
System.err.println(parsedCliOptions.getError());
return;
}
......
package azgracompress.benchmark;
import azgracompress.cli.InputFileInfo;
import azgracompress.cli.ParsedCliOptions;
import azgracompress.data.ImageU16;
import azgracompress.data.V3i;
......@@ -53,18 +54,19 @@ abstract class BenchmarkBase {
}
protected BenchmarkBase(final ParsedCliOptions options) {
this.inputFile = options.getInputFile();
final InputFileInfo ifi = options.getInputFileInfo();
this.inputFile = ifi.getFilePath();
this.outputDirectory = options.getOutputFile();
this.rawImageDims = options.getImageDimension();
this.rawImageDims = ifi.getDimensions();
this.hasReferencePlane = options.hasReferencePlaneIndex();
this.referencePlaneIndex = options.getReferencePlaneIndex();
this.codebookSize = (int) Math.pow(2, options.getBitsPerPixel());
if (options.hasPlaneIndexSet()) {
this.planes = new int[]{options.getPlaneIndex()};
} else if (options.hasPlaneRangeSet()) {
final int from = options.getFromPlaneIndex();
final int to = options.getToPlaneIndex();
if (ifi.isPlaneIndexSet()) {
this.planes = new int[]{ifi.getPlaneIndex()};
} else if (ifi.isPlaneRangeSet()) {
final int from = ifi.getPlaneRange().getX();
final int to = ifi.getPlaneRange().getY();
final int count = to - from;
this.planes = new int[count + 1];
......@@ -72,7 +74,7 @@ abstract class BenchmarkBase {
this.planes[i] = from + i;
}
} else {
final int planeCount = options.getImageDimension().getZ();
final int planeCount = ifi.getDimensions().getZ();
this.planes = new int[planeCount];
for (int i = 0; i < planeCount; i++) {
this.planes[i] = i;
......
......@@ -30,23 +30,32 @@ public class InputFileInfo {
this.filePath = filePath;
}
public void setDimension(V3i dimension) {
this.dimension = dimension;
/**
* Get number of selected planes to be compressed.
*
* @return Number of planes for compression.
*/
public int getNumberOfPlanes() {
if (planeIndexSet) {
return 1;
} else if (planeRangeSet) {
return ((planeRange.getY() + 1) - planeRange.getX());
} else {
return dimension.getZ();
}
}
public void setPlaneIndexSet(boolean planeIndexSet) {
this.planeIndexSet = planeIndexSet;
public void setDimension(final V3i dimension) {
this.dimension = dimension;
}
public void setPlaneIndex(int planeIndex) {
public void setPlaneIndex(final int planeIndex) {
this.planeIndexSet = true;
this.planeIndex = planeIndex;
}
public void setPlaneRangeSet(boolean planeRangeSet) {
this.planeRangeSet = planeRangeSet;
}
public void setPlaneRange(V2i planeRange) {
public void setPlaneRange(final V2i planeRange) {
this.planeRangeSet = true;
this.planeRange = planeRange;
}
......@@ -58,7 +67,7 @@ public class InputFileInfo {
return filePath;
}
public V3i getDimension() {
public V3i getDimensions() {
return dimension;
}
......
......@@ -4,6 +4,7 @@ import azgracompress.compression.CompressorDecompressorBase;
import azgracompress.data.V2i;
import azgracompress.data.V3i;
import azgracompress.fileformat.FileExtensions;
import azgracompress.fileformat.FileType;
import azgracompress.fileformat.QuantizationType;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.io.FilenameUtils;
......@@ -18,16 +19,14 @@ public class ParsedCliOptions {
private ProgramMethod method;
private QuantizationType quantizationType;
private String inputFile;
private InputFileInfo inputFileInfo;
private String outputFile;
private String codebookCacheFolder = null;
private int bitsPerPixel;
private V2i vectorDimension = new V2i(0);
private V3i imageDimension = new V3i(0);
private boolean planeIndexSet = false;
private int planeIndex;
private boolean refPlaneIndexSet = false;
private int referencePlaneIndex = -1;
......@@ -37,10 +36,6 @@ public class ParsedCliOptions {
private boolean errorOccurred;
private String error;
private boolean planeRangeSet = false;
private int fromPlaneIndex;
private int toPlaneIndex;
private int workerCount = 1;
public ParsedCliOptions(CommandLine cmdInput) {
......@@ -116,12 +111,37 @@ public class ParsedCliOptions {
codebookCacheFolder = cmd.getOptionValue(CliConstants.CODEBOOK_CACHE_FOLDER_LONG, null);
if (!errorOccurred) {
outputFile = cmd.getOptionValue(CliConstants.OUTPUT_LONG, getDefaultOutputFilePath(inputFile));
outputFile = cmd.getOptionValue(CliConstants.OUTPUT_LONG,
getDefaultOutputFilePath(inputFileInfo.getFilePath()));
}
error = errorBuilder.toString();
}
/**
* Get file type from file extension.
*
* @param path File path.
* @return File type.
*/
private FileType getFileType(final String path) {
final String extension = FilenameUtils.getExtension(path).toLowerCase();
switch (extension) {
case FileExtensions.RAW: {
return FileType.RAW;
}
case FileExtensions.TIFF: {
return FileType.TIFF;
}
case FileExtensions.QCMP: {
return FileType.QCMP;
}
default: {
return FileType.Unsupported;
}
}
}
private void parseInputFilePart(StringBuilder errorBuilder, final String[] inputFileArguments) {
if (inputFileArguments.length < 1) {
......@@ -130,32 +150,27 @@ public class ParsedCliOptions {
return;
}
inputFile = inputFileArguments[0];
inputFileInfo = new InputFileInfo(getFileType(inputFileArguments[0]), inputFileArguments[0]);
// Decompress and Inspect methods doesn't require additional file information.
if ((method == ProgramMethod.Decompress) || (method == ProgramMethod.InspectFile)) {
return;
}
File inputFileInfo = new File(inputFile);
// Check if input file exists.
if (!inputFileInfo.exists()) {
if (!new File(inputFileInfo.getFilePath()).exists()) {
errorOccurred = true;
errorBuilder.append("Input file doesn't exist.\n");
return;
}
final String extension = FilenameUtils.getExtension(inputFile).toLowerCase();
switch (extension) {
case FileExtensions.RAW: {
switch (inputFileInfo.getFileType()) {
case RAW:
parseRawFileArguments(errorBuilder, inputFileArguments);
}
break;
case FileExtensions.TIFF: {
break;
case TIFF:
parseTiffFileArguments(errorBuilder, inputFileArguments);
}
break;
break;
default: {
errorOccurred = true;
errorBuilder.append("Unsupported input file type. Currently supporting RAW and TIFF files.\n");
......@@ -208,9 +223,7 @@ public class ParsedCliOptions {
final ParseResult<Integer> indexToResult = tryParseInt(toIndexString);
if (indexFromResult.isSuccess() && indexToResult.isSuccess()) {
fromPlaneIndex = indexFromResult.getValue();
toPlaneIndex = indexToResult.getValue();
planeRangeSet = true;
inputFileInfo.setPlaneRange(new V2i(indexFromResult.getValue(), indexToResult.getValue()));
} else {
errorOccurred = true;
errorBuilder.append("Plane range index is wrong. Expected format D-D, got: ").append(
......@@ -220,8 +233,7 @@ public class ParsedCliOptions {
// Here we parse single plane index option.
final ParseResult<Integer> parseResult = tryParseInt(inputFileArguments[inputFileArgumentsOffset]);
if (parseResult.isSuccess()) {
planeIndexSet = true;
planeIndex = parseResult.getValue();
inputFileInfo.setPlaneIndex(parseResult.getValue());
} else {
errorOccurred = true;
errorBuilder.append("Failed to parse plane index option, expected integer, got: ")
......@@ -254,7 +266,7 @@ public class ParsedCliOptions {
final ParseResult<Integer> n1Result = tryParseInt(num1String);
final ParseResult<Integer> n2Result = tryParseInt(secondPart);
if (n1Result.isSuccess() && n2Result.isSuccess()) {
imageDimension = new V3i(n1Result.getValue(), n2Result.getValue(), 1);
inputFileInfo.setDimension(new V3i(n1Result.getValue(), n2Result.getValue(), 1));
} else {
errorOccurred = true;
errorBuilder.append("Failed to parse image dimensions of format DxD, got: ");
......@@ -269,7 +281,7 @@ public class ParsedCliOptions {
final ParseResult<Integer> n3Result = tryParseInt(num3String);
if (n1Result.isSuccess() && n2Result.isSuccess() && n3Result.isSuccess()) {
imageDimension = new V3i(n1Result.getValue(), n2Result.getValue(), n3Result.getValue());
inputFileInfo.setDimension(new V3i(n1Result.getValue(), n2Result.getValue(), n3Result.getValue()));
} else {
errorOccurred = true;
errorBuilder.append("Failed to parse image dimensions of format DxDxD, got: ");
......@@ -410,8 +422,8 @@ public class ParsedCliOptions {
return quantizationType;
}
public String getInputFile() {
return inputFile;
public InputFileInfo getInputFileInfo() {
return inputFileInfo;
}
public String getOutputFile() {
......@@ -426,14 +438,6 @@ public class ParsedCliOptions {
return vectorDimension;
}
public V3i getImageDimension() {
return imageDimension;
}
public int getPlaneIndex() {
return planeIndex;
}
public int getReferencePlaneIndex() {
return referencePlaneIndex;
}
......@@ -446,11 +450,7 @@ public class ParsedCliOptions {
return refPlaneIndexSet;
}
public boolean hasPlaneIndexSet() {
return planeIndexSet;
}
public boolean hasErrorOccured() {
public boolean didErrorOccure() {
return errorOccurred;
}
......@@ -458,18 +458,6 @@ public class ParsedCliOptions {
return error;
}
public boolean hasPlaneRangeSet() {
return planeRangeSet;
}
public int getFromPlaneIndex() {
return fromPlaneIndex;
}
public int getToPlaneIndex() {
return toPlaneIndex;
}
public int getWorkerCount() {
return workerCount;
}
......@@ -520,24 +508,24 @@ public class ParsedCliOptions {
sb.append("BitsPerPixel: ").append(bitsPerPixel).append('\n');
sb.append("Output: ").append(outputFile).append('\n');
sb.append("InputFile: ").append(inputFile).append('\n');
sb.append("InputFile: ").append(inputFileInfo.getFilePath()).append('\n');
if (hasCodebookCacheFolder()) {
sb.append("CodebookCacheFolder: ").append(codebookCacheFolder).append('\n');
}
if (hasQuantizationType(method)) {
sb.append("Input image dims: ").append(imageDimension.toString()).append('\n');
sb.append("Input image dims: ").append(inputFileInfo.getDimensions().toString()).append('\n');
}
if (planeIndexSet) {
sb.append("PlaneIndex: ").append(planeIndex).append('\n');
if (inputFileInfo.isPlaneIndexSet()) {
sb.append("PlaneIndex: ").append(inputFileInfo.getPlaneIndex()).append('\n');
}
if (refPlaneIndexSet) {
sb.append("ReferencePlaneIndex: ").append(referencePlaneIndex).append('\n');
}
if (planeRangeSet) {
sb.append("FromPlaneIndex: ").append(fromPlaneIndex).append('\n');
sb.append("ToPlaneIndex: ").append(toPlaneIndex).append('\n');
if (inputFileInfo.isPlaneRangeSet()) {
sb.append("FromPlaneIndex: ").append(inputFileInfo.getPlaneRange().getX()).append('\n');
sb.append("ToPlaneIndex: ").append(inputFileInfo.getPlaneRange().getY()).append('\n');
}
sb.append("Verbose: ").append(verbose).append('\n');
......@@ -546,18 +534,5 @@ public class ParsedCliOptions {
return sb.toString();
}
/**
* Get number of planes to be compressed.
*
* @return Number of planes for compression.
*/
public int getNumberOfPlanes() {
if (hasPlaneIndexSet()) {
return 1;
} else if (hasPlaneRangeSet()) {
return ((toPlaneIndex + 1) - fromPlaneIndex);
} else {
return imageDimension.getZ();
}
}
}
package azgracompress.compression;
import azgracompress.cli.InputFileInfo;
import azgracompress.cli.ParsedCliOptions;
public abstract class CompressorDecompressorBase {
......@@ -14,11 +15,12 @@ public abstract class CompressorDecompressorBase {
}
protected int[] getPlaneIndicesForCompression() {
if (options.hasPlaneIndexSet()) {
return new int[]{options.getPlaneIndex()};
} else if (options.hasPlaneRangeSet()) {
final int from = options.getFromPlaneIndex();
final int to = options.getToPlaneIndex();
final InputFileInfo ifi = options.getInputFileInfo();
if (ifi.isPlaneIndexSet()) {
return new int[]{ifi.getPlaneIndex()};
} else if (ifi.isPlaneRangeSet()) {
final int from = ifi.getPlaneRange().getX();
final int to = ifi.getPlaneRange().getY();
final int count = to - from;
int[] indices = new int[count + 1];
......@@ -27,7 +29,7 @@ public abstract class CompressorDecompressorBase {
}
return indices;
} else {
return generateAllPlaneIndices(options.getImageDimension().getZ());
return generateAllPlaneIndices(ifi.getDimensions().getZ());
}
}
......
......@@ -106,9 +106,9 @@ public class ImageCompressor extends CompressorDecompressorBase {
final boolean oneCodebook = options.hasReferencePlaneIndex() || options.hasCodebookCacheFolder();
header.setCodebookPerPlane(!oneCodebook);
header.setImageSizeX(options.getImageDimension().getX());
header.setImageSizeY(options.getImageDimension().getY());
header.setImageSizeZ(options.getNumberOfPlanes());
header.setImageSizeX(options.getInputFileInfo().getDimensions().getX());
header.setImageSizeY(options.getInputFileInfo().getDimensions().getY());
header.setImageSizeZ(options.getInputFileInfo().getNumberOfPlanes());
header.setVectorDimension(options.getVectorDimension());
......
......@@ -60,7 +60,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
boolean validFile = true;
QCMPFileHeader header = null;
try (FileInputStream fileInputStream = new FileInputStream(options.getInputFile());
try (FileInputStream fileInputStream = new FileInputStream(options.getInputFileInfo().getFilePath());
DataInputStream dataInputStream = new DataInputStream(fileInputStream)) {
header = readQCMPFileHeader(dataInputStream);
} catch (IOException ioEx) {
......@@ -108,7 +108,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
logBuilder.append("Vector size Y:\t\t").append(header.getVectorSizeY()).append('\n');
logBuilder.append("Vector size Z:\t\t").append(header.getVectorSizeZ()).append('\n');
final long fileSize = new File(options.getInputFile()).length();
final long fileSize = new File(options.getInputFileInfo().getFilePath()).length();
final long dataSize = fileSize - QCMPFileHeader.QCMP_HEADER_SIZE;
final IImageDecompressor decompressor = getImageDecompressor(header);
if (decompressor != null) {
......@@ -128,7 +128,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
public boolean decompress() {
try (FileInputStream fileInputStream = new FileInputStream(options.getInputFile());
try (FileInputStream fileInputStream = new FileInputStream(options.getInputFileInfo().getFilePath());
DataInputStream dataInputStream = new DataInputStream(fileInputStream)) {
final QCMPFileHeader header = readQCMPFileHeader(dataInputStream);
......@@ -148,7 +148,7 @@ public class ImageDecompressor extends CompressorDecompressorBase {
return false;
}
final long fileSize = new File(options.getInputFile()).length();
final long fileSize = new File(options.getInputFileInfo().getFilePath()).length();
final long dataSize = fileSize - QCMPFileHeader.QCMP_HEADER_SIZE;
final long expectedDataSize = imageDecompressor.getExpectedDataSize(header);
if (dataSize != expectedDataSize) {
......
package azgracompress.compression;
import azgracompress.U16;
import azgracompress.cli.InputFileInfo;
import azgracompress.cli.ParsedCliOptions;
import azgracompress.compression.exception.ImageCompressionException;
import azgracompress.data.ImageU16;
......@@ -65,7 +66,8 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
private ScalarQuantizer loadQuantizerFromCache() throws ImageCompressionException {
QuantizationValueCache cache = new QuantizationValueCache(options.getCodebookCacheFolder());
try {
final int[] quantizationValues = cache.readCachedValues(options.getInputFile(), codebookSize);
final int[] quantizationValues = cache.readCachedValues(options.getInputFileInfo().getFilePath(),
codebookSize);
return new ScalarQuantizer(U16.Min, U16.Max, quantizationValues);
} catch (IOException e) {
throw new ImageCompressionException("Failed to read quantization values from cache file.", e);
......@@ -79,6 +81,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
* @throws ImageCompressionException When compress process fails.
*/
public void compress(DataOutputStream compressStream) throws ImageCompressionException {
final InputFileInfo inputFileInfo = options.getInputFileInfo();
Stopwatch stopwatch = new Stopwatch();
final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.hasReferencePlaneIndex();
......@@ -93,8 +96,8 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
stopwatch.restart();
ImageU16 referencePlane = null;
try {
referencePlane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
referencePlane = RawDataIO.loadImageU16(inputFileInfo.getFilePath(),
inputFileInfo.getDimensions(),
options.getReferencePlaneIndex());
} catch (Exception ex) {
throw new ImageCompressionException("Unable to load reference plane data.", ex);
......@@ -118,8 +121,8 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
ImageU16 plane = null;
try {
plane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
plane = RawDataIO.loadImageU16(inputFileInfo.getFilePath(),
inputFileInfo.getDimensions(),
planeIndex);
} catch (Exception ex) {
throw new ImageCompressionException("Unable to load plane data.", ex);
......@@ -148,21 +151,22 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
}
private int[] loadConfiguredPlanesData() throws ImageCompressionException {
final InputFileInfo inputFileInfo = options.getInputFileInfo();
int[] trainData = null;
if (options.hasPlaneIndexSet()) {
if (inputFileInfo.isPlaneIndexSet()) {
try {
Log("Loading single plane data.");
trainData = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
options.getPlaneIndex()).getData();
trainData = RawDataIO.loadImageU16(inputFileInfo.getFilePath(),
inputFileInfo.getDimensions(),
inputFileInfo.getPlaneIndex()).getData();
} catch (IOException e) {
throw new ImageCompressionException("Failed to load reference image data.", e);
}
} else if (options.hasPlaneRangeSet()) {
} else if (inputFileInfo.isPlaneRangeSet()) {
Log("Loading plane range data.");
final int[] planes = getPlaneIndicesForCompression();
try {
trainData = RawDataIO.loadPlanesData(options.getInputFile(), options.getImageDimension(), planes);
trainData = RawDataIO.loadPlanesData(inputFileInfo.getFilePath(), inputFileInfo.getDimensions(), planes);
} catch (IOException e) {
e.printStackTrace();
throw new ImageCompressionException("Failed to load plane range data.", e);
......@@ -170,7 +174,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
} else {
Log("Loading all planes data.");
try {
trainData = RawDataIO.loadAllPlanesData(options.getInputFile(), options.getImageDimension());
trainData = RawDataIO.loadAllPlanesData(inputFileInfo.getFilePath(), inputFileInfo.getDimensions());
} catch (IOException e) {
throw new ImageCompressionException("Failed to load all planes data.", e);
}
......@@ -196,7 +200,7 @@ public class SQImageCompressor extends CompressorDecompressorBase implements IIm
Log(String.format("Saving cache file to %s", options.getOutputFile()));
QuantizationValueCache cache = new QuantizationValueCache(options.getOutputFile());
try {
cache.saveQuantizationValues(options.getInputFile(), qValues);
cache.saveQuantizationValues(options.getInputFileInfo().getFilePath(), qValues);
} catch (IOException e) {
throw new ImageCompressionException("Unable to write cache.", e);
}
......
package azgracompress.compression;
import azgracompress.cli.InputFileInfo;
import azgracompress.cli.ParsedCliOptions;
import azgracompress.compression.exception.ImageCompressionException;
import azgracompress.data.Chunk2D;
......@@ -68,7 +69,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
private VectorQuantizer loadQuantizerFromCache() throws ImageCompressionException {
QuantizationValueCache cache = new QuantizationValueCache(options.getCodebookCacheFolder());
try {
final CodebookEntry[] codebook = cache.readCachedValues(options.getInputFile(),
final CodebookEntry[] codebook = cache.readCachedValues(options.getInputFileInfo().getFilePath(),
codebookSize,
options.getVectorDimension().getX(),
options.getVectorDimension().getY());
......@@ -86,6 +87,7 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
* @throws ImageCompressionException When compress process fails.
*/
public void compress(DataOutputStream compressStream) throws ImageCompressionException {
final InputFileInfo inputFileInfo = options.getInputFileInfo();
Stopwatch stopwatch = new Stopwatch();
final boolean hasGeneralQuantizer = options.hasCodebookCacheFolder() || options.hasReferencePlaneIndex();
VectorQuantizer quantizer = null;
......@@ -100,8 +102,8 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
ImageU16 referencePlane = null;
try {
referencePlane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
referencePlane = RawDataIO.loadImageU16(inputFileInfo.getFilePath(),
inputFileInfo.getDimensions(),
options.getReferencePlaneIndex());
} catch (Exception ex) {
throw new ImageCompressionException("Unable to load reference plane data.", ex);
......@@ -123,8 +125,8 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
ImageU16 plane = null;
try {
plane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
plane = RawDataIO.loadImageU16(inputFileInfo.getFilePath(),
inputFileInfo.getDimensions(),
planeIndex);
} catch (Exception ex) {
throw new ImageCompressionException("Unable to load plane data.", ex);
......@@ -164,8 +166,8 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
* @throws IOException When reading fails.
*/
private int[][] loadPlaneQuantizationVectors(final int planeIndex) throws IOException {
ImageU16 refPlane = RawDataIO.loadImageU16(options.getInputFile(),
options.getImageDimension(),
ImageU16 refPlane = RawDataIO.loadImageU16(options.getInputFileInfo().getFilePath(),
options.getInputFileInfo().getDimensions(),
planeIndex);
return refPlane.toQuantizationVectors(options.getVectorDimension());
......@@ -173,22 +175,23 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
private int[][] loadConfiguredPlanesData() throws ImageCompressionException {
final int vectorSize = options.getVectorDimension().getX() * options.getVectorDimension().getY();
final InputFileInfo ifi = options.getInputFileInfo();
int[][] trainData = null;
Stopwatch s = new Stopwatch();
s.start();
if (options.hasPlaneIndexSet()) {
if (ifi.isPlaneIndexSet()) {
Log("VQ: Loading single plane data.");
try {
trainData = loadPlaneQuantizationVectors(options.getPlaneIndex());
trainData = loadPlaneQuantizationVectors(ifi.getPlaneIndex());
} catch (IOException e) {
throw new ImageCompressionException("Failed to load reference image data.", e);
}
} else {
Log(options.hasPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data.");
Log(ifi.isPlaneRangeSet() ? "VQ: Loading plane range data." : "VQ: Loading all planes data.");
final int[] planeIndices = getPlaneIndicesForCompression();
final int chunkCountPerPlane = Chunk2D.calculateRequiredChunkCountPerPlane(
options.getImageDimension().toV2i(),
ifi.getDimensions().toV2i(),
options.getVectorDimension());
final int totalChunkCount = chunkCountPerPlane * planeIndices.length;
......@@ -227,7 +230,9 @@ public class VQImageCompressor extends CompressorDecompressorBase implements IIm
Log("Saving cache file to %s", options.getOutputFile());
QuantizationValueCache cache = new QuantizationValueCache(options.getOutputFile());
try {
cache.saveQuantizationValues(options.getInputFile(), lbgResult.getCodebook(), options.getVectorDimension());
cache.saveQuantizationValues(options.getInputFileInfo().getFilePath(),
lbgResult.getCodebook(),
options.getVectorDimension());
} catch (IOException e) {
throw new ImageCompressionException("Unable to write cache.", e);
}
......
......@@ -13,9 +13,7 @@ public class V2i {
this(universalValue, universalValue);
}
public int getX() {
return x;
}
public int getX() { return x; }
public int getY() {
return y;
......
......@@ -3,5 +3,6 @@ package azgracompress.fileformat;
public enum FileType {
RAW,
TIFF,
QCMP
QCMP,
Unsupported
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment