diff --git a/src/omv/Makefile b/src/omv/Makefile index faaa1fbdc..eb56c821e 100644 --- a/src/omv/Makefile +++ b/src/omv/Makefile @@ -121,4 +121,6 @@ $(BUILD)/%.o : %.s $(ECHO) "AS $<" $(AS) $(AFLAGS) $< -o $@ +$(BUILD)/imlib/fmath.o: override CFLAGS += -fno-strict-aliasing + -include $(OBJS:%.o=%.d) diff --git a/src/omv/imlib/filter.c b/src/omv/imlib/filter.c index 2ef5e6499..999f2b650 100644 --- a/src/omv/imlib/filter.c +++ b/src/omv/imlib/filter.c @@ -1239,7 +1239,7 @@ void imlib_morph(image_t *img, const int ksize, const int *krn, const float m, - const int b, + const float b, bool threshold, int offset, bool invert, @@ -1250,7 +1250,7 @@ void imlib_morph(image_t *img, buf.h = brows; buf.pixfmt = img->pixfmt; const int32_t m_int = fast_roundf(65536 * m); - const int32_t b_int = b << 16; + const int32_t b_int = fast_roundf(65536 * b); invert = invert ? 1 : 0; // ensure binary switch (img->pixfmt) { diff --git a/src/omv/imlib/fmath.c b/src/omv/imlib/fmath.c index d7d197b99..fa1216ed3 100644 --- a/src/omv/imlib/fmath.c +++ b/src/omv/imlib/fmath.c @@ -69,11 +69,8 @@ int OMV_ATTR_ALWAYS_INLINE fast_ceilf(float x) { asm volatile ( "vcvtp.S32.f32 %[r], %[x]\n" #else - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" uint32_t max = 0x3f7fffff; x += *((float *) &max); - #pragma GCC diagnostic pop asm volatile ( "vcvt.S32.f32 %[r], %[x]\n" #endif @@ -100,8 +97,6 @@ float OMV_ATTR_ALWAYS_INLINE fast_fabsf(float x) { } #endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" typedef union { uint32_t l; struct { @@ -120,7 +115,6 @@ float fast_expf(float x) { uint32_t packed = (e.s << 31) | (e.e << 23) | e.m << 3; return *((float *) &packed); } -#pragma GCC diagnostic pop /* * From Hackers Delight: diff --git a/src/omv/imlib/imlib.h b/src/omv/imlib/imlib.h index 1c3dd035a..73973de2c 100644 --- a/src/omv/imlib/imlib.h +++ b/src/omv/imlib/imlib.h @@ -1402,7 +1402,7 @@ void imlib_morph(image_t *img, const int ksize, const int *krn, const float m, - const int b, + const float b, bool threshold, int offset, bool invert, diff --git a/src/omv/imlib/qrcode.c b/src/omv/imlib/qrcode.c index d5894bcd3..02a76c324 100644 --- a/src/omv/imlib/qrcode.c +++ b/src/omv/imlib/qrcode.c @@ -840,26 +840,16 @@ typedef struct xylf } xylf_t; -static void lifo_enqueue_fast(lifo_t *ptr, void *data) +static void lifo_enqueue_fast(lifo_t *ptr, xylf_t *data) { -// we know the structure size is 8 bytes, so don't waste time calling memcpy - uint32_t *d = (uint32_t *)(ptr->data + (ptr->len * ptr->data_len)); - uint32_t *s = (uint32_t *)data; -// memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len); - d[0] = s[0]; d[1] = s[1]; // copy 8 bytes + *((xylf_t *)(ptr->data + (ptr->len * ptr->data_len))) = *data; ptr->len += 1; } -static void lifo_dequeue_fast(lifo_t *ptr, void *data) +static void lifo_dequeue_fast(lifo_t *ptr, xylf_t *data) { - // we know the structure size is 8 bytes, so don't waste time calling memcpy - uint32_t *s = (uint32_t *)(ptr->data + ((ptr->len-1) * ptr->data_len)); - uint32_t *d = (uint32_t *)data; -// if (data) { -// memcpy(data, ptr->data + ((ptr->len - 1) * ptr->data_len), ptr->data_len); -// } - d[0] = s[0]; d[1] = s[1]; // copy 8 bytes ptr->len -= 1; + *data = *((xylf_t *)(ptr->data + (ptr->len * ptr->data_len))); } static void flood_fill_seed(struct quirc *q, int x, int y, int from, int to, diff --git a/src/omv/ports/rp2/omv_portconfig.cmake b/src/omv/ports/rp2/omv_portconfig.cmake index 9cdda95d7..4dd907672 100644 --- a/src/omv/ports/rp2/omv_portconfig.cmake +++ b/src/omv/ports/rp2/omv_portconfig.cmake @@ -178,6 +178,11 @@ target_sources(${MICROPY_TARGET} PRIVATE ${OMV_USER_MODULES} ) +set_source_files_properties( + ${TOP_DIR}/${OMV_DIR}/imlib/fmath.c + PROPERTIES + COMPILE_OPTIONS "-fno-strict-aliasing" +) if(MICROPY_PY_SENSOR) target_compile_definitions(${MICROPY_TARGET} PRIVATE