mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-03 21:55:17 +00:00
Offsets with gamma.
This commit is contained in:
parent
1d421aacf2
commit
77b55bbd14
@ -45,6 +45,10 @@ public class Lx47Algorithm
|
||||
return 1 + (offset > 128 ? 12 : 8) + elias_gamma_bits(len-1);
|
||||
}
|
||||
|
||||
int count_bits2(int offset, int len) {
|
||||
return 1 + (offset > 128 ? (8+elias_gamma_bits((offset-1)>>7)) : 8) + elias_gamma_bits(len-1);
|
||||
}
|
||||
|
||||
Optimal[] optimize(byte[] input_data) {
|
||||
int[] min = new int[MAX_OFFSET+1];
|
||||
int[] max = new int[MAX_OFFSET+1];
|
||||
@ -178,6 +182,16 @@ public class Lx47Algorithm
|
||||
}
|
||||
}
|
||||
|
||||
void write2Gbyte(int offset) {
|
||||
assert offset >= 0 && offset <= 65535;
|
||||
if (offset < 128)
|
||||
writeByte(offset);
|
||||
else {
|
||||
writeByte((offset & 127) | 128);
|
||||
writeEliasGamma(offset >> 7);
|
||||
}
|
||||
}
|
||||
|
||||
void writeOffset(int offset) {
|
||||
write2byte(offset);
|
||||
}
|
||||
@ -317,6 +331,15 @@ public class Lx47Algorithm
|
||||
return val;
|
||||
}
|
||||
|
||||
int read2Gbyte() {
|
||||
int val = readByte();
|
||||
if ((val & 128) == 0)
|
||||
return val;
|
||||
val &= 127;
|
||||
val |= (readEliasGamma() << 7);
|
||||
return val;
|
||||
}
|
||||
|
||||
int readOffset() {
|
||||
return read2byte();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user