Daniel Beer
516d91a94d
Fix stack corruption on oversized QR codes.
...
Issue reported by dswetz on Github:
https://github.com/dlbeer/quirc/issues/119
2021-10-08 19:40:36 +13:00
Jaap Haitsma
7bd87c32dd
Use abs instead of fabs to please compiler
2021-08-25 14:50:45 -04:00
Jaap Haitsma
064ebd5b87
Estimate gridsize better. Fixes #112
2021-08-25 14:40:31 -04:00
Jaap Haitsma
2ff513b0b4
merge upstream
2021-06-16 23:52:51 -04:00
Jaap Haitsma
00f187d94a
Remove unused functions
2021-06-16 22:18:15 -04:00
YAMAMOTO Takashi
6b3575cd59
flood_fill_seed: Add comments on exit conditions
2021-05-11 15:03:09 +09:00
YAMAMOTO Takashi
22269c9a43
flood_fill_seed: initialize left_up and left_down together
...
Just for readability.
2021-05-11 14:59:22 +09:00
YAMAMOTO Takashi
87ca2b6c2d
flood_fill_seed: Switch from goto to while
2021-05-11 14:57:53 +09:00
YAMAMOTO Takashi
a436fde8a0
flood_fill_seed: Reduce code duplicatino
...
This is also a preparation to eliminate the uses of goto.
2021-05-11 14:54:19 +09:00
YAMAMOTO Takashi
eadbc2caca
flood_fill_seed: Move flood_fill_line to the "caller"
...
This restructure allows us to unify "call" and "return_from_call".
2021-05-11 14:09:24 +09:00
YAMAMOTO Takashi
0b69940876
flood_fill_line: call user callback as well
2021-05-11 14:05:02 +09:00
YAMAMOTO Takashi
38f882b3d6
flood_fill_seed: Simplify the flow by having a single "return point".
2021-05-11 13:46:31 +09:00
YAMAMOTO Takashi
1fa9b0c109
flood_fill_seed: Add assertions
2021-05-11 13:26:59 +09:00
YAMAMOTO Takashi
dd6c64cafe
Add QUIRC_ASSERT
2021-05-11 13:26:47 +09:00
YAMAMOTO Takashi
40def012e7
flood_fill_seed: Unify "left" and "x" vars
...
This reduces the memory usage a bit.
2021-05-11 13:04:02 +09:00
YAMAMOTO Takashi
aad3fc63b6
flood_fill_seed: separate a logic to fill a line
2021-05-11 12:55:44 +09:00
YAMAMOTO Takashi
f1dd37fbdb
quirc_resize: Make this a bit more careful about integer overflows
...
Also, avoid malloc(0), which is not too portable.
2021-05-11 11:05:58 +09:00
YAMAMOTO Takashi
772cd3e73f
Improve stack usage for flood filling
...
* Make flood filling logic iterative (vs recursive)
I basically tried one-to-one conversions here to avoid mistakes.
probably it has a room for later optimizations.
* Use explicit malloc (vs variables on stack) to allocate the work area.
* Estimate the amount of memory for the work area dynamically
from the image size, instead of using a constant FLOOD_FILL_MAX_DEPTH,
which is too big in the most cases.
2021-05-11 11:05:58 +09:00
Daniel Beer
c6fc67088a
Merge pull request #103 from yamt/otsu
...
Fix possible overflows in otsu()
2021-05-11 13:24:56 +12:00
Daniel Beer
db49540f36
Merge pull request #107 from yamt/shrink-datastream
...
Shrink struct datastream by borrowing the user buffer
2021-05-11 10:30:58 +12:00
YAMAMOTO Takashi
21b7581b04
Shrink struct datastream by borrowing the user buffer
2021-04-23 13:40:37 +09:00
YAMAMOTO Takashi
65379a7c39
finder_scan: Improve capstone detection on small images
...
When using small captured images, I somehow frequently see failures
to recognize a capstone due to rounding errors.
eg. when pb[] = {2 3 8 3 2}.
This commit tries to improve it by using fixed-point arithmetics.
The scaling factor was chosen somehow arbitrary. A moderate scaling
should be enough.
2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
734258c775
finder_scan: constify the "check" array
2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
02ed1066ba
test_grouping: use unsigned variables where it makes more sense
2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
ea9b6ee5ef
otsu: Use unsigned for the pixel numbers
...
Because singed numbers don't make sense here.
2021-04-08 13:38:30 +09:00
YAMAMOTO Takashi
de68db7b69
otsu: Use double for weighted sums
...
My phone camera produces 12M-pixel images.
They can easily overflow an int.
2021-04-08 13:38:30 +09:00
Claudio Felber
4bc17cf8c6
Optimize quirc_flip()
2020-09-22 12:14:09 +02:00
Claudio Felber
5beb59e3b4
Support horizontally flipped QR-codes according to ISO 18004:2015
2020-09-21 16:54:55 +02:00
Claudio Felber
963d6ed126
Fix stack corruption and bus errors while scanning oversized QR codes
2020-09-15 00:51:41 +02:00
Jaap Haitsma
bff065d88b
Try all possible groups and new algo for grid_size
2020-05-27 21:33:51 -04:00
Alexandre Perrin
a0b41121e4
Refactored some c99 features
...
Fixes #68
2020-02-27 20:40:23 +01:00
Alexandre Perrin
026485bdc6
missing <limits.h> header
2019-09-25 11:10:43 +02:00
Alexandre Perrin
bf397f0794
Merge pull request #57 from kAworu/cosmetic
...
define a QUIRC_PIXEL_ALIAS_IMAGE constant to explicit conditional path
2019-09-25 10:59:08 +02:00
Alexandre Perrin
74459b9f59
Don't assume that sizeof(int) == sizeof(int32_t)
...
See https://github.com/dlbeer/quirc/pull/59#discussion_r320307589
2019-09-25 10:57:38 +02:00
Sushrut Shringarputale
26d2402655
Fixes issue #60
2019-09-09 23:09:20 -04:00
Sushrut Shringarputale
ed833132d5
Fix some compile-time issues for better production usability
...
Fixed up some type coercion and uninitialized variable instances for
better production code usability.
2019-08-20 09:50:39 -07:00
Alexandre Perrin
f700e456b4
define a QUIRC_PIXEL_ALIAS_IMAGE constant to explicit conditional path
...
Before this patch, the "sizeof dance" was confusing, fix #54 .
2019-07-02 09:22:25 +02:00
Daniel Beer
5d71b1853e
identify: make otsu() static.
2019-05-02 15:56:35 +12:00
Claudio Felber
766f79ce7c
Use const struct quirc parameter in otsu() function and fix tabs
2019-04-30 18:44:59 +02:00
Claudio Felber
96a5a380fb
Remove quirc.row_average and associated code
...
quirc.row_average was used by the former threshold function and has
become obsolete with the introduction of the Otsu threshold function.
2019-04-30 18:43:57 +02:00
Claudio Felber
97ffaabfb5
Replace existing threshold function with Otsu threshold algorithm
2019-04-30 13:02:11 +02:00
Alexandre Perrin
d3780f3e6f
Warning comment improvement.
2017-06-11 10:19:31 +02:00
Alexandre Perrin
90371f36a0
threshold() uses now the row_average member of struct quirc.
2017-06-11 10:08:58 +02:00
Alexandre Perrin
21f6863577
Added a row_average member to struct quirc.
...
Prep to remove the VLA from threshold()
2017-06-11 10:08:58 +02:00
Daniel Beer
7b26f6e193
Merge pull request #39 from kAworu/quirc_resize.fix
...
Fix a potential use-after-free on quirc_resize failure.
2017-06-10 14:02:40 +12:00
Alexandre Perrin
971c9d4e8c
refactor quirc_resize
...
So that the given quirc struct is never invalid once we return to the
caller.
2017-06-09 22:12:06 +02:00
Alexandre Perrin
1f9edb0b84
Fix a potential use-after-free on quirc_resize failure.
...
Before this patch, in the event of `q->image` reallocation success but
`q->pixels` failure, `q->image` would point to a freed memory.
After this patch, once quirc_resize() returns, `q->image` consistently
point to a memory address that can be freed.
There is still an inconsistency left in the example codepath: `q->{h,w}`
would hold the "old" values, while `q->image` allocated size would be
based in the requested width/height; hence the comment update about the
state of the QR-code recognizer (it should only be passed to
quirc_destroy()).
2017-06-07 19:37:14 +02:00
Alexandre Perrin
a858ec4896
Fixes warnings emitted by gcc -Wold-style-declaration
2017-06-07 10:24:43 +02:00
Alexandre Perrin
2528ea3955
Comment fix
...
Bad copy-pasta from
http://www.thonky.com/qr-code-tutorial/kanji-mode-encoding
2017-05-30 19:23:42 +02:00
Alexandre Perrin
e16c02e226
Fix Kanji decoding.
...
Before this patch, Kanji decoding was broken.
2017-05-30 18:52:31 +02:00