Skip to content

Problem encoding short sequences #2

@lucastheis

Description

@lucastheis

We noticed a problem with the range coder for very short sequences. For example, encoding the data below yields a file with 2 bytes instead of the expected 1 byte.

unsigned int data[6] = {0, 2, 2, 2, 1, 2};
SearchType::freq_type cumFreq[3] = {0, 2, 4, 8};

This line seems to cause the extra bit:

*iter++ = buffer;

And this should fix it:

if (!start) {
  *iter++ = buffer;
  for (; carryN != 0; carryN--) {
    *iter++ = 0xFF;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions