Closed igrr closed 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.
@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.
I think that's looking good. Will leave the final approval with @kaworu
@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.
@igrr Done. Pushed and tagged version 1.2.
Anything you can do to help would be much appreciated.
@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.
Ah, sorry -- forgot --tags. Pushed now.
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:
QUIRC_FLOAT_TYPE
: if defined, it is the type name to use in floating point calculations. Can be set, for example, using:CFLAGS += -DQUIRC_FLOAT_TYPE=float
QUIRC_USE_TGMATH
: if defined, Quirc will internally use<tgmath.h>
header, instead of<math.h>
. This C99-or-later header allows the program to call type-generic functions, such assqrt
, and the calls will be dispatched to the correct implementation (sqrtf, sqrt, sqrtl) depending on the actual argument type. Without setting this option, the benefit of-DQUIRC_FLOAT_TYPE=float
would be limited as the double-precision versions of math functions would still be used.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.