Skip to content

Improvements and larger refactor

As mentioned in !805, here is a larger refactor with some additional improvements. This contains all changes in !805 plus the following major changes:

  • The redundant code between families 2, 3, and 4 was unified into a common base class.
  • The scan data decoders were given a common base class, simplifying the code where they are called.
  • Performance improvement: Now we only read from USB when we don't have enough cached data to fill the output buffer. Before this change it took ~8 seconds to decode a JPEG image, now it takes ~0.2 seconds on my arm-based device.
  • An additional family4 improvement was implemented.
  • I modified the debug macro so it now automatically inserts the calling method. While this does introduce a small runtime overhead (a compile-time solution requires at least C++17, maybe even C++2x), I think the massive reduction of boilerplate is definitely worth it. This also automatically fixes numerous typos in those debug calls.

One caveat:

  • The changes to families 2 and 3 have not been tested. While nothing major was changed intentionally, some of the family4 fixes (e.g. buffered data loss fix, workaround for scanner not delivering requested resolution) are now part of these families as well.

Any feedback is welcome. Happy to undo some changes if you don't like them. @skelband , looking forward to a review whenever you find the time.

Merge request reports