Skip to content

Commit e64ca1a

Browse files
committed
Add ROLZXCodec to tests.
1 parent 6b51427 commit e64ca1a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/function/ROLZCodec.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace kanzi {
3232
class ROLZEncoder {
3333
private:
3434
static const uint64 TOP = 0x00FFFFFFFFFFFFFF;
35-
static const uint64 MASK_0_24 = 0x0000000000FFFFFF;
3635
static const uint64 MASK_0_32 = 0x00000000FFFFFFFF;
3736
static const int MATCH_FLAG = 0;
3837
static const int LITERAL_FLAG = 1;
@@ -253,7 +252,7 @@ namespace kanzi {
253252

254253
inline void ROLZEncoder::encodeBit(int bit)
255254
{
256-
const uint64 split = ((_high - _low) >> 4) * uint64((_probs[_pIdx][_ctx + _c1]) >> 4) >> 8;
255+
const uint64 split = ((_high - _low) >> 4) * uint64(_probs[_pIdx][_ctx + _c1] >> 4) >> 8;
257256

258257
// Update fields with new interval bounds
259258
if (bit == 0) {
@@ -278,7 +277,7 @@ namespace kanzi {
278277

279278
inline int ROLZDecoder::decodeBit()
280279
{
281-
const uint64 mid = _low + (((_high - _low) >> 4) * uint64((_probs[_pIdx][_ctx + _c1]) >> 4) >> 8);
280+
const uint64 mid = _low + (((_high - _low) >> 4) * uint64(_probs[_pIdx][_ctx + _c1] >> 4) >> 8);
282281
int bit;
283282

284283
// Update bounds and predictor

src/test/TestFunctions.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ static Function<byte>* getByteFunction(string name)
4747
if (name.compare("ROLZ") == 0)
4848
return new ROLZCodec();
4949

50+
if (name.compare("ROLZX") == 0) {
51+
Context ctx;
52+
ctx.putString("transform", "ROLZX");
53+
return new ROLZCodec(ctx);
54+
}
55+
5056
cout << "No such byte function: " << name << endl;
5157
return nullptr;
5258
}
@@ -67,7 +73,6 @@ int testFunctionsCorrectness(const string& name)
6773
byte values[80000];
6874

6975
if (ii == 0) {
70-
size = 15;
7176
byte arr[] = {
7277
(byte)0, (byte)1, (byte)2, (byte)2, (byte)2, (byte)2, (byte)7, (byte)9,
7378
(byte)9, (byte)16, (byte)16, (byte)16, (byte)1, (byte)3, (byte)3, (byte)3,
@@ -203,7 +208,7 @@ int testFunctionsCorrectness(const string& name)
203208
}
204209

205210
if (f->forward(iba1, iba2, size) == false) {
206-
if (iba1._index != size) {
211+
if ((iba1._index != size) || (iba2._index >= iba1._index)) {
207212
cout << endl
208213
<< "No compression (ratio > 1.0), skip reverse" << endl;
209214
continue;
@@ -330,7 +335,12 @@ int testFunctionsSpeed(const string& name)
330335
before = clock();
331336

332337
if (f->forward(iba1, iba2, size) == false) {
333-
// ZRLT may fail if the input data has too few 0s
338+
if ((iba1._index != size) || (iba2._index >= iba1._index)) {
339+
cout << endl
340+
<< "No compression (ratio > 1.0), skip reverse" << endl;
341+
continue;
342+
}
343+
334344
cout << "Encoding error" << endl;
335345
delete f;
336346
continue;

0 commit comments

Comments
 (0)