Fix compression of large repetitions
* src/misc/intvcomp.cc (stream_compression_base::run): Limit repeatitions to 40, not 42. (stream_decompression_base::refill): Refill the end of the stream with 0. (stream_decompression_base::look_n_bits): Add assertion. * src/tgbatest/intvcomp.cc: Add a new test case.
This commit is contained in:
parent
1b447c3676
commit
445a785e10
3 changed files with 29 additions and 5 deletions
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
||||||
|
2011-04-13 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
Fix compression of large repetitions
|
||||||
|
|
||||||
|
* src/misc/intvcomp.cc (stream_compression_base::run): Limit
|
||||||
|
repeatitions to 40, not 42.
|
||||||
|
(stream_decompression_base::refill): Refill the end of the stream
|
||||||
|
with 0.
|
||||||
|
(stream_decompression_base::look_n_bits): Add assertion.
|
||||||
|
* src/tgbatest/intvcomp.cc: Add a new test case.
|
||||||
|
|
||||||
2011-04-12 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2011-04-12 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
More interfaces to the int array compression routines.
|
More interfaces to the int array compression routines.
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ namespace spot
|
||||||
if (val == last_val)
|
if (val == last_val)
|
||||||
{
|
{
|
||||||
unsigned int count = 1;
|
unsigned int count = 1;
|
||||||
while (count <= 41 && self().skip_if(val))
|
while (count < 40 && self().skip_if(val))
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if ((val == 0 && count < 3) || (val == 1 && count == 1))
|
if ((val == 0 && count < 3) || (val == 1 && count == 1))
|
||||||
|
|
@ -376,9 +376,10 @@ namespace spot
|
||||||
buffer_ &= buffer_mask_;
|
buffer_ &= buffer_mask_;
|
||||||
look_bits_ += fill_size;
|
look_bits_ += fill_size;
|
||||||
|
|
||||||
if (buffer_bits_ == 0 && self().have_comp_data())
|
if (buffer_bits_ == 0)
|
||||||
{
|
{
|
||||||
buffer_ = self().next_comp_data();
|
if (self().have_comp_data())
|
||||||
|
buffer_ = self().next_comp_data();
|
||||||
buffer_bits_ = max_bits;
|
buffer_bits_ = max_bits;
|
||||||
buffer_mask_ = -1U;
|
buffer_mask_ = -1U;
|
||||||
if (look_bits_ != max_bits)
|
if (look_bits_ != max_bits)
|
||||||
|
|
@ -399,12 +400,11 @@ namespace spot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 010 00 00 010 00 101:011 010 00 101:010 010
|
|
||||||
// 010 00010000001000010010000100000
|
|
||||||
unsigned int look_n_bits(unsigned int n)
|
unsigned int look_n_bits(unsigned int n)
|
||||||
{
|
{
|
||||||
if (look_bits_ < n)
|
if (look_bits_ < n)
|
||||||
refill();
|
refill();
|
||||||
|
assert(n <= look_bits_);
|
||||||
return look_ >> (look_bits_ - n);
|
return look_ >> (look_bits_ - n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,5 +205,18 @@ int main()
|
||||||
int comp9[] = { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
int comp9[] = { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
errors += check(comp9, sizeof(comp9) / sizeof(*comp9));
|
errors += check(comp9, sizeof(comp9) / sizeof(*comp9));
|
||||||
|
|
||||||
|
int comp10[] = { 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0,
|
||||||
|
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
|
||||||
|
9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 10,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 9 };
|
||||||
|
errors += check(comp10, sizeof(comp10) / sizeof(*comp10));
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue