diff --git a/src/omv/common/omv_common.h b/src/omv/common/omv_common.h index af69e40ad..0ca87da2e 100644 --- a/src/omv/common/omv_common.h +++ b/src/omv/common/omv_common.h @@ -50,12 +50,11 @@ #if OMV_PROFILE_ENABLE #include #include "py/mphal.h" - -#define OMV_PROFILE_START mp_uint_t omv_profile_ticks_start = mp_hal_ticks_us(); -#define OMV_PROFILE_END printf("%s %u us\n", __FUNCTION__, mp_hal_ticks_us() - omv_profile_ticks_start); +#define OMV_PROFILE_START(F) mp_uint_t F##_ticks_start_ = mp_hal_ticks_us() +#define OMV_PROFILE_END(F) printf("%s %u us\n", #F, mp_hal_ticks_us() - F##_ticks_start_) #else -#define OMV_PROFILE_START -#define OMV_PROFILE_END +#define OMV_PROFILE_START(F) +#define OMV_PROFILE_END(F) #endif #endif //__OMV_COMMON_H__ diff --git a/src/omv/imlib/draw.c b/src/omv/imlib/draw.c index 74a60ae33..8c8b10d73 100644 --- a/src/omv/imlib/draw.c +++ b/src/omv/imlib/draw.c @@ -2843,7 +2843,7 @@ void imlib_draw_image(image_t *dst_img, imlib_draw_row_callback_t callback, void *callback_arg, void *dst_row_override) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); int dst_delta_x = 1; // positive direction if (x_scale < 0.f) { // flip X @@ -5518,7 +5518,7 @@ exit_cleanup: if (&new_src_img == src_img) { fb_free(); } - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); } #ifdef IMLIB_ENABLE_FLOOD_FILL diff --git a/src/omv/imlib/jpegd.c b/src/omv/imlib/jpegd.c index 297a1b99f..7e50cce31 100644 --- a/src/omv/imlib/jpegd.c +++ b/src/omv/imlib/jpegd.c @@ -2841,7 +2841,7 @@ static int DecodeJPEG(JPEGIMAGE *pJPEG) { } void jpeg_decompress(image_t *dst, image_t *src) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); JPEGIMAGE jpg; // Supports decoding baseline JPEGs only. @@ -2882,6 +2882,6 @@ void jpeg_decompress(image_t *dst, image_t *src) { mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("JPEG decoder failed.")); } - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); } #endif diff --git a/src/omv/imlib/jpege.c b/src/omv/imlib/jpege.c index 1983603a5..02135a1dd 100644 --- a/src/omv/imlib/jpege.c +++ b/src/omv/imlib/jpege.c @@ -1609,7 +1609,7 @@ static void jpeg_write_headers(jpeg_buf_t *jpeg_buf, int w, int h, int bpp, jpeg } bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_subsampling_t subsampling) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); if (!dst->data) { uint32_t size = 0; @@ -1941,7 +1941,7 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_s dst->size = jpeg_buf.idx; dst->data = jpeg_buf.buf; - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); return false; } diff --git a/src/omv/imlib/png.c b/src/omv/imlib/png.c index 12f8d3079..f71555328 100644 --- a/src/omv/imlib/png.c +++ b/src/omv/imlib/png.c @@ -105,7 +105,7 @@ unsigned lodepng_convert_cb(unsigned char *out, const unsigned char *in, #if defined(IMLIB_ENABLE_PNG_ENCODER) bool png_compress(image_t *src, image_t *dst) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); if (src->is_compressed) { return true; @@ -177,14 +177,14 @@ bool png_compress(image_t *src, image_t *dst) { // free fb_alloc() memory used for umm_init_x(). fb_free(); // umm_init_x(); } - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); return false; } #endif // IMLIB_ENABLE_PNG_ENCODER #if defined(IMLIB_ENABLE_PNG_DECODER) void png_decompress(image_t *dst, image_t *src) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); umm_init_x(fb_avail()); LodePNGState state; @@ -226,7 +226,7 @@ void png_decompress(image_t *dst, image_t *src) { // free fb_alloc() memory used for umm_init_x(). fb_free(); // umm_init_x(); - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); } #endif // IMLIB_ENABLE_PNG_DECODER #endif // IMLIB_ENABLE_PNG_ENCODER || IMLIB_ENABLE_PNG_DECODER diff --git a/src/omv/ports/stm32/jpeg.c b/src/omv/ports/stm32/jpeg.c index 5caec8b62..a1bf294f4 100644 --- a/src/omv/ports/stm32/jpeg.c +++ b/src/omv/ports/stm32/jpeg.c @@ -106,7 +106,7 @@ static void jpeg_compress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOu } bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc, jpeg_subsampling_t subsampling) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); HAL_JPEG_RegisterGetDataCallback(&JPEG_state.jpeg_descr, jpeg_compress_get_data); HAL_JPEG_RegisterDataReadyCallback(&JPEG_state.jpeg_descr, jpeg_compress_data_ready); @@ -365,7 +365,7 @@ exit_cleanup: fb_free(); // mcu_row_buffer (after DMA is aborted) - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); return jpeg_overflow; } @@ -397,7 +397,7 @@ static void jpeg_decompress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pData } void jpeg_decompress(image_t *dst, image_t *src) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); // Verify the jpeg image is not a non-baseline jpeg image and check that is has // valid headers up to the start-of-scan header (which cannot be trivially walked). @@ -752,7 +752,7 @@ exit_cleanup: fb_free(); // JPEG_state.jpeg_descr.pJpegInBuffPtr (after DMA is aborted) } - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); } void imlib_hardware_jpeg_init() { diff --git a/src/omv/ports/stm32/omv_gpu.c b/src/omv/ports/stm32/omv_gpu.c index 27818db1e..2729d19c8 100644 --- a/src/omv/ports/stm32/omv_gpu.c +++ b/src/omv/ports/stm32/omv_gpu.c @@ -32,7 +32,7 @@ int omv_gpu_draw_image(image_t *src_img, const uint16_t *color_palette, const uint8_t *alpha_palette, image_hint_t hint) { - OMV_PROFILE_START + OMV_PROFILE_START(__FUNCTION__); // DMA2D can only draw on RGB565 buffers and the destination/source buffers must be accessible by DMA. if ((dst_img->pixfmt != PIXFORMAT_RGB565) || (!DMA_BUFFER(dst_img->data)) || (!DMA_BUFFER(src_img->data))) { @@ -211,7 +211,7 @@ int omv_gpu_draw_image(image_t *src_img, fb_free(); // clut } - OMV_PROFILE_END + OMV_PROFILE_END(__FUNCTION__); return 0; } #endif // (OMV_GPU_ENABLE == 1)