@@ -122,6 +122,7 @@ private void getBestBFromData(int[] in, int pos) {
122
122
int thiscost = cexcept * OVERHEAD_OF_EACH_EXCEPT
123
123
+ cexcept * (bestbbestcexceptmaxb [2 ] - b ) + b
124
124
* BLOCK_SIZE + 8 ;
125
+ if (bestbbestcexceptmaxb [2 ] - b == 1 ) thiscost -= cexcept ;
125
126
if (thiscost < bestcost ) {
126
127
bestcost = thiscost ;
127
128
bestbbestcexceptmaxb [0 ] = b ;
@@ -142,7 +143,6 @@ private void encodePage(int[] in, IntWrapper inpos, int thissize,
142
143
143
144
int tmpinpos = inpos .get ();
144
145
for (final int finalinpos = tmpinpos + thissize - BLOCK_SIZE ; tmpinpos <= finalinpos ; tmpinpos += BLOCK_SIZE ) {
145
-
146
146
getBestBFromData (in , tmpinpos );
147
147
final int tmpbestb = bestbbestcexceptmaxb [0 ];
148
148
byteContainer .put ((byte )bestbbestcexceptmaxb [0 ]);
@@ -187,17 +187,16 @@ private void encodePage(int[] in, IntWrapper inpos, int thissize,
187
187
byteContainer .asIntBuffer ().get (out , tmpoutpos , howmanyints );
188
188
tmpoutpos += howmanyints ;
189
189
int bitmap = 0 ;
190
- for (int k = 1 ; k <= 32 ; ++k ) {
190
+ for (int k = 2 ; k <= 32 ; ++k ) {
191
191
if (dataPointers [k ] != 0 )
192
192
bitmap |= (1 << (k - 1 ));
193
193
}
194
194
out [tmpoutpos ++] = bitmap ;
195
195
196
- for (int k = 1 ; k <= 32 ; ++k ) {
196
+ for (int k = 2 ; k <= 32 ; ++k ) {
197
197
if (dataPointers [k ] != 0 ) {
198
198
out [tmpoutpos ++] = dataPointers [k ];// size
199
199
int j = 0 ;
200
-
201
200
for (; j + 31 < dataPointers [k ]; j += 32 ) {
202
201
BitPacking .fastpack (dataTobePacked [k ],
203
202
j , out , tmpoutpos , k );
@@ -250,7 +249,7 @@ private void decodePage(int[] in, IntWrapper inpos, int[] out,
250
249
inexcept += (bytesize + 3 )/ 4 ;
251
250
252
251
final int bitmap = in [inexcept ++];
253
- for (int k = 1 ; k <= 32 ; ++k ) {
252
+ for (int k = 2 ; k <= 32 ; ++k ) {
254
253
if ((bitmap & (1 << (k - 1 ))) != 0 ) {
255
254
int size = in [inexcept ++];
256
255
if (dataTobePacked [k ].length < size )
@@ -282,14 +281,20 @@ private void decodePage(int[] in, IntWrapper inpos, int[] out,
282
281
tmpinpos += b ;
283
282
}
284
283
if (cexcept > 0 ) {
285
- final int maxbits = byteContainer .get ();
286
- final int index = maxbits - b ;
284
+ final int maxbits = byteContainer .get ();
285
+ final int index = maxbits - b ;
286
+ if (index == 1 ) {
287
287
for (int k = 0 ; k < cexcept ; ++k ) {
288
- final int pos = byteContainer .get () &0xFF ;
289
- final int exceptvalue = dataTobePacked [index ][dataPointers [index ]++];
290
- out [pos + tmpoutpos ] |= exceptvalue << b ;
288
+ final int pos = byteContainer .get () &0xFF ;
289
+ out [pos + tmpoutpos ] |= 1 << b ;
290
+ }
291
+ } else {
292
+ for (int k = 0 ; k < cexcept ; ++k ) {
293
+ final int pos = byteContainer .get () &0xFF ;
294
+ final int exceptvalue = dataTobePacked [index ][dataPointers [index ]++];
295
+ out [pos + tmpoutpos ] |= exceptvalue << b ;
291
296
}
292
-
297
+ }
293
298
}
294
299
}
295
300
outpos .set (tmpoutpos );
0 commit comments