Skip to content

Commit

Permalink
Pass size as tuple (the vec_xy struct) one more place
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Dec 3, 2024
1 parent d05e0d3 commit c265b58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/bit_file/bitreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class bitreader
return bits;
}

std::tuple<unsigned, unsigned> bytes_and_bits(unsigned how_many_bits, unsigned bitoffset) const
std::tuple<unsigned, unsigned> bytes_and_bits(unsigned how_many_bits) const
{
unsigned remainder_bits = how_many_bits % 8;
unsigned bytes = how_many_bits / 8;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cimbar_js/cimbar_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int next_frame()
enc.set_legacy_mode();

enc.set_encode_id(_encodeId);
_next = enc.encode_next(*_fes, _window->width(), _window->height());
_next = enc.encode_next(*_fes, {(int)_window->width(), (int)_window->height()});
return ++_frameCount;
}

Expand Down
14 changes: 7 additions & 7 deletions src/lib/encoder/SimpleEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class SimpleEncoder
void set_encode_id(uint8_t encode_id); // [0-127] -- the high bit is ignored.

template <typename STREAM>
std::optional<cv::Mat> encode_next(STREAM& stream, int canvas_width=0, int canvas_height=0);
std::optional<cv::Mat> encode_next(STREAM& stream, cimbar::vec_xy canvas_size={});

template <typename STREAM>
fountain_encoder_stream::ptr create_fountain_encoder(STREAM& stream, int compression_level=6);

protected:
template <typename STREAM>
std::optional<cv::Mat> encode_next_coupled(STREAM& stream, int canvas_width=0, int canvas_height=0);
std::optional<cv::Mat> encode_next_coupled(STREAM& stream, cimbar::vec_xy canvas_size={});

protected:
unsigned _eccBytes;
Expand Down Expand Up @@ -64,16 +64,16 @@ inline void SimpleEncoder::set_encode_id(uint8_t encode_id)
}

template <typename STREAM>
inline std::optional<cv::Mat> SimpleEncoder::encode_next(STREAM& stream, int canvas_width, int canvas_height)
inline std::optional<cv::Mat> SimpleEncoder::encode_next(STREAM& stream, cimbar::vec_xy canvas_size)
{
if (_coupled)
return encode_next_coupled(stream, canvas_width, canvas_height);
return encode_next_coupled(stream, canvas_size);

if (!stream.good())
return std::nullopt;

unsigned bits_per_op = _bitsPerColor + _bitsPerSymbol;
CimbWriter writer(_bitsPerSymbol, _bitsPerColor, _dark, _colorMode, {canvas_width, canvas_height});
CimbWriter writer(_bitsPerSymbol, _bitsPerColor, _dark, _colorMode, canvas_size);

unsigned numCells = writer.num_cells();
bitbuffer bb(cimbar::Config::capacity(bits_per_op));
Expand Down Expand Up @@ -127,7 +127,7 @@ inline std::optional<cv::Mat> SimpleEncoder::encode_next(STREAM& stream, int can
}

template <typename STREAM>
inline std::optional<cv::Mat> SimpleEncoder::encode_next_coupled(STREAM& stream, int canvas_width, int canvas_height)
inline std::optional<cv::Mat> SimpleEncoder::encode_next_coupled(STREAM& stream, cimbar::vec_xy canvas_size)
{
// the old way. Symbol and color bits are mixed together, limiting the color correction possibilities
// but potentially allowing a lack of errors in one channel to correct errors in the other.
Expand All @@ -138,7 +138,7 @@ inline std::optional<cv::Mat> SimpleEncoder::encode_next_coupled(STREAM& stream,
return std::nullopt;

unsigned bits_per_op = _bitsPerColor + _bitsPerSymbol;
CimbWriter writer(_bitsPerSymbol, _bitsPerColor, _dark, _colorMode, {canvas_width, canvas_height});
CimbWriter writer(_bitsPerSymbol, _bitsPerColor, _dark, _colorMode, canvas_size);

reed_solomon_stream rss(stream, _eccBytes, _eccBlockSize);
bitreader br;
Expand Down

0 comments on commit c265b58

Please sign in to comment.