mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
imlib: Fix possible signed/unsigned comparisons issues.
This commit is contained in:
parent
20b12228dd
commit
a1f6e04d23
@ -18,8 +18,8 @@
|
||||
#include "fb_alloc.h"
|
||||
#include "gc.h"
|
||||
|
||||
#define MAX_ROW (480)
|
||||
#define MAX_CORNERS (2000)
|
||||
#define MAX_ROW (480u)
|
||||
#define MAX_CORNERS (2000u)
|
||||
#define Compare(X, Y) ((X)>=(Y))
|
||||
|
||||
typedef struct {
|
||||
|
||||
@ -56,7 +56,7 @@ static void bin_up(uint16_t *hist, uint16_t size, unsigned int max_size, uint16_
|
||||
end = i;
|
||||
}
|
||||
|
||||
int bin_count = end - start + 1; // >= 1
|
||||
uint16_t bin_count = end - start + 1; // >= 1
|
||||
*new_size = IM_MIN(max_size, bin_count);
|
||||
*new_hist = xalloc0((*new_size) * sizeof(uint16_t));
|
||||
float div_value = (*new_size) / ((float) bin_count); // Reversed so we can multiply below.
|
||||
@ -74,7 +74,7 @@ static void merge_bins(int b_dst_start, int b_dst_end, uint16_t **b_dst_hist, ui
|
||||
int start = IM_MIN(b_dst_start, b_src_start);
|
||||
int end = IM_MAX(b_dst_end, b_src_end);
|
||||
|
||||
int bin_count = end - start + 1; // >= 1
|
||||
uint16_t bin_count = end - start + 1; // >= 1
|
||||
uint16_t new_size = IM_MIN(max_size, bin_count);
|
||||
uint16_t *new_hist = xalloc0(new_size * sizeof(uint16_t));
|
||||
float div_value = new_size / ((float) bin_count); // Reversed so we can multiply below.
|
||||
|
||||
@ -316,8 +316,8 @@ void Interpolate (kz_pixel_t * pImage, int uiXRes, unsigned long * pulMapLU,
|
||||
|
||||
void imlib_clahe_histeq(image_t *img, float clip_limit, image_t *mask)
|
||||
{
|
||||
int xTileSize = IM_MAX(uiMAX_REG_X >> (10 - IM_MIN(IM_LOG2_32(img->w), 10)), 2);
|
||||
int yTileSize = IM_MAX(uiMAX_REG_Y >> (10 - IM_MIN(IM_LOG2_32(img->h), 10)), 2);
|
||||
int xTileSize = IM_MAX(uiMAX_REG_X >> (10 - IM_MIN(IM_LOG2_32(img->w), 10)), 2u);
|
||||
int yTileSize = IM_MAX(uiMAX_REG_Y >> (10 - IM_MIN(IM_LOG2_32(img->h), 10)), 2u);
|
||||
int pImageW = img->w + ((img->w % xTileSize) ? (xTileSize - (img->w % xTileSize)) : 0);
|
||||
int pImageH = img->h + ((img->h % yTileSize) ? (yTileSize - (img->h % yTileSize)) : 0);
|
||||
int xOffset = (pImageW - img->w) / 2;
|
||||
|
||||
@ -37,8 +37,8 @@
|
||||
|
||||
#ifdef IMLIB_ENABLE_FAST
|
||||
|
||||
#define MAX_ROW (480)
|
||||
#define MAX_CORNERS (2000)
|
||||
#define MAX_ROW (480U)
|
||||
#define MAX_CORNERS (2000U)
|
||||
#define Compare(X, Y) ((X)>=(Y))
|
||||
|
||||
typedef struct {
|
||||
|
||||
@ -628,7 +628,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
// case we shrink the window size to how many lines we're buffering.
|
||||
temp.pixels = alloc;
|
||||
// Set the max buffer height to image height.
|
||||
temp.h = IM_MIN(img->h, (size / (temp.w * temp.bpp)));
|
||||
temp.h = IM_MIN((uint32_t) img->h, (size / (temp.w * temp.bpp)));
|
||||
// This should never happen unless someone forgot to free.
|
||||
if ((!temp.pixels) || (!temp.h)) {
|
||||
mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Not enough memory available!"));
|
||||
|
||||
@ -499,8 +499,8 @@ struct { \
|
||||
#endif
|
||||
|
||||
typedef struct image {
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
PIXFORMAT_STRUCT;
|
||||
union {
|
||||
uint8_t *pixels;
|
||||
|
||||
@ -274,8 +274,8 @@ static void spi_lcd_callback(SPI_HandleTypeDef *hspi)
|
||||
}
|
||||
case SPI_TX_CB_MEMORY_WRITE: {
|
||||
uint16_t *addr = spi_tx_cb_state_memory_write_addr;
|
||||
size_t count = IM_MIN(spi_tx_cb_state_memory_write_count, (65536-8));
|
||||
spi_tx_cb_state = (spi_tx_cb_state_memory_write_count > (65536-8)) ? SPI_TX_CB_MEMORY_WRITE : SPI_TX_CB_DISPLAY_ON;
|
||||
size_t count = IM_MIN(spi_tx_cb_state_memory_write_count, (65536-8u));
|
||||
spi_tx_cb_state = (spi_tx_cb_state_memory_write_count > (65536-8u)) ? SPI_TX_CB_MEMORY_WRITE : SPI_TX_CB_DISPLAY_ON;
|
||||
spi_tx_cb_state_memory_write_addr += count;
|
||||
spi_tx_cb_state_memory_write_count -= count;
|
||||
if (spi_tx_cb_state_memory_write_first) {
|
||||
|
||||
@ -580,7 +580,7 @@ static void spi_tv_callback(SPI_HandleTypeDef *hspi)
|
||||
}
|
||||
case SPI_TX_CB_MEMORY_WRITE: {
|
||||
uint8_t *addr = spi_tx_cb_state_memory_write_addr;
|
||||
size_t count = IM_MIN(spi_tx_cb_state_memory_write_count, (65536-16));
|
||||
size_t count = IM_MIN(spi_tx_cb_state_memory_write_count, (65536-16u));
|
||||
spi_tx_cb_state = (spi_tx_cb_state_memory_write_count > (65536-16))
|
||||
? SPI_TX_CB_MEMORY_WRITE
|
||||
: SPI_TX_CB_MEMORY_WRITE_CMD;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user