Skip to content

Commit

Permalink
First pass at decoder for split symbols/colors
Browse files Browse the repository at this point in the history
Probably some optimizations here...
  • Loading branch information
sz3 committed Sep 23, 2023
1 parent 742b91b commit 113c92d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lib/encoder/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ inline unsigned Decoder::do_decode(CimbReader& reader, STREAM& ostream)
std::vector<PositionData> colorPositions;
colorPositions.resize(reader.num_reads()); // the number of cells == reader.num_reads(). Can we calculate this from config at compile time?

unsigned bitsPerSymbol = cimbar::Config::symbol_bits();
unsigned maxSymbolBit = reader.num_reads() * cimbar::Config::symbol_bits();

// read symbols first
while (!reader.done())
{
Expand All @@ -77,10 +80,13 @@ inline unsigned Decoder::do_decode(CimbReader& reader, STREAM& ostream)
PositionData pos;
unsigned bits = reader.read(pos);

unsigned bitPos = interleaveLookup[pos.i] * _bitsPerOp;
bb.write(bits, bitPos, _bitsPerOp);
unsigned bitPos = interleaveLookup[pos.i] * bitsPerSymbol; // bitspersymbol, *iff* we're in the new mode
bb.write(bits, bitPos, bitsPerSymbol);

// is colorBitPos == interleaveLookup[pos.i] * _colorBits + (maxSymbolBitPos)?
// where maxSymbolBiPos is interleaveLookup[-1] * bitspersymbol ?

colorPositions[pos.i] = {bitPos, pos.x, pos.y};
colorPositions[pos.i] = {maxSymbolBit + (interleaveLookup[pos.i] * _colorBits), pos.x, pos.y}; // if no mode, bitPos is different...
}

// then decode colors.
Expand Down

0 comments on commit 113c92d

Please sign in to comment.