/*
* Imagesqueeze - Image codec optimized for photos.
* Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
for (int i = 0; i < 256; i++) {
- if (range[currentCheckPointer] == i) {
+ if (range[currentCheckPointer] == i)
currentCheckPointer++;
- }
- if (currentCheckPointer > 0) {
+ if (currentCheckPointer > 0)
bitCountForRange[i] = bitcount[currentCheckPointer - 1];
- } else {
+ else
bitCountForRange[i] = 0;
- }
}
int seek;
seekLoop: {
- for (seek = 0; seek < usedEntries; seek++) {
-
+ for (seek = 0; seek < usedEntries; seek++)
if (switchTreshold[seek] >= i)
break seekLoop;
-
- }
}
proposedRangeForActualRange[i] = range[seek];
- if (seek == 0) {
+ if (seek == 0)
proposedRangeForActualRangeLow[i] = 0;
- } else {
+ else
proposedRangeForActualRangeLow[i] = switchTreshold[seek - 1] + 1;
- }
proposedRangeForActualRangeHigh[i] = switchTreshold[seek];
}
if (range[currentCheckPointer] == i)
currentCheckPointer--;
- if (currentCheckPointer < 0) {
+ if (currentCheckPointer < 0)
proposedDecreasedRange[i] = 0;
- } else {
+ else
proposedDecreasedRange[i] = (byte) (range[currentCheckPointer]);
- }
}
}
public void load(final BitInputStream inputStream) throws IOException {
reset();
- final int availableEntries = inputStream.readIntegerCompressed8();
+ final int availableEntries = ImageDecoder
+ .readIntegerCompressed8(inputStream);
- for (int i = 0; i < availableEntries; i++) {
+ for (int i = 0; i < availableEntries; i++)
addEntry(inputStream.readBits(8), inputStream.readBits(8),
inputStream.readBits(4));
- }
}
public int proposeBitcountForRange(int range) {
if (inheritedRange < 0)
inheritedRange = 0;
- if (proposedRangeForActualRangeLow[inheritedRange] <= actualRange) {
+ if (proposedRangeForActualRangeLow[inheritedRange] <= actualRange)
return inheritedRange;
- }
return proposeDecreasedRange(inheritedRange);
}
}
public void save(final BitOutputStream outputStream) throws IOException {
- outputStream.storeIntegerCompressed8(usedEntries);
+ ImageEncoder.storeIntegerCompressed8(outputStream, usedEntries);
for (int i = 0; i < usedEntries; i++) {
outputStream.storeBits(range[i], 8);