diff --git a/src/main/java/cz/it4i/qcmp/cache/IQvcFile.java b/src/main/java/cz/it4i/qcmp/cache/IQvcFile.java index 908361a25832bbbc38b04c3cfc311938f3215823..b4d678abfd6d33d2144768a766fc950d2eca935e 100644 --- a/src/main/java/cz/it4i/qcmp/cache/IQvcFile.java +++ b/src/main/java/cz/it4i/qcmp/cache/IQvcFile.java @@ -15,4 +15,6 @@ public interface IQvcFile { IQvcHeader getHeader(); void report(StringBuilder builder); + + void convertToNewerVersion(final boolean inPlace, final String inputPath, final String outputPath) throws IOException; } diff --git a/src/main/java/cz/it4i/qcmp/cache/SqQvcFile.java b/src/main/java/cz/it4i/qcmp/cache/SqQvcFile.java index 4364729243ae1b8e3365641812bca046f3da6908..9a27713f50b58a059b4a9ab07048c9a2abafb762 100644 --- a/src/main/java/cz/it4i/qcmp/cache/SqQvcFile.java +++ b/src/main/java/cz/it4i/qcmp/cache/SqQvcFile.java @@ -40,7 +40,7 @@ public class SqQvcFile implements IQvcFile { ((QvcHeaderV2) header).setHuffmanDataSize(huffmanTreeBinaryRepresentationSize); header.writeToStream(outputStream); - + final int[] quantizationValues = codebook.getCentroids(); for (final int qV : quantizationValues) { outputStream.writeShort(qV); @@ -90,6 +90,24 @@ public class SqQvcFile implements IQvcFile { codebook = new SQCodebook(centroids, huffmanRoot); } + private void convertQvcFromV1ToV2(final String outputFilePath) { + + } + + @Override + public void convertToNewerVersion(final boolean inPlace, final String inputPath, final String outputPath) { + final int headerVersion = header.getHeaderVersion(); + if (!inPlace && (outputPath == null || outputPath.isEmpty())) { + System.err.println("InPlace conversion wasn't specified nor the output file path."); + return; + } + if (headerVersion == 1) { + convertQvcFromV1ToV2(inPlace ? inputPath : outputPath); + } else { + System.err.printf("Version %d is already the newest version of QVC file.\n", headerVersion); + } + } + @Override public IQvcHeader getHeader() { return header; diff --git a/src/main/java/cz/it4i/qcmp/cache/VqQvcFile.java b/src/main/java/cz/it4i/qcmp/cache/VqQvcFile.java index 5fcd635afd1e2b9fdcd5bf019ddf9f82e5624017..ab76c5cef728f884e85b0d7ed26afacb80b51be0 100644 --- a/src/main/java/cz/it4i/qcmp/cache/VqQvcFile.java +++ b/src/main/java/cz/it4i/qcmp/cache/VqQvcFile.java @@ -98,6 +98,11 @@ public class VqQvcFile implements IQvcFile { return codebook; } + @Override + public void convertToNewerVersion(final boolean inPlace, final String inputPath, final String outputPath) { + assert false : "NOT IMPLEMENTED YET"; + } + @Override public void report(final StringBuilder builder) { final int[][] vectors = codebook.getVectors(); @@ -108,5 +113,7 @@ public class VqQvcFile implements IQvcFile { } builder.append("\n- - - - - - - - - - - - - - - - - - - - - - - - -\n"); } + + } }