dlbeer / quirc

QR decoder library
Other
865 stars 285 forks source link

Add an option to use single-precision floating point in calculations #134

Closed igrr closed 1 year ago

igrr commented 1 year ago

On some platforms, such as microcontrollers with a single-precision FPU, operations on double type can be significantly slower compared to the float type. For example, on an ESP32-S3 microcontroller, decoding a QR code of a certain size may take 1700ms when 'double' is used and just 250ms when 'float' is used, ~6 times faster.

This commit adds two options to allow for such optimizations:

The change is backwards compatible with existing applications. If these macros are not defined, the behavior is the same as before.


If desired, I can combine these two new options into a simpler one, such as QUIRC_USE_FLOAT — then the float type will be used and tgmath.h will be included.

dlbeer commented 1 year ago

Yep, agree with @kaworu -- it's a great idea, but just needs a note in the README and then I'd be happy to merge.

igrr commented 1 year ago

@dlbeer @kaworu Thank you for the quick review. I have added a new section about compile time options to README.md, please take a look again.

dlbeer commented 1 year ago

I think that's looking good. Will leave the final approval with @kaworu

igrr commented 1 year ago

@dlbeer @kaworu May I ask you to consider tagging a new release version?

There hasn't been a release tag in a while, and in the project where I'm using quirc I would prefer to point to a specific tag, not just to a random commit on the master branch.

Edit: One more note, I see there are some ESP32-specific issues in the issue tracker. Since I am working on that platform, I can help triage these issues, if you are okay with it. Probably I will publish a "reference" quirc example for Espressif chips, which should handle most of the open issues.

dlbeer commented 1 year ago

@igrr Done. Pushed and tagged version 1.2.

Anything you can do to help would be much appreciated.

igrr commented 1 year ago

@dlbeer Thanks! Looks like the git tag didn't get pushed yet, though? https://github.com/dlbeer/quirc/tags only shows 1.0 and 1.1 now.

dlbeer commented 1 year ago

Ah, sorry -- forgot --tags. Pushed now.