mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Adds hint system to fb_alloc
With this commit fb_alloc now takes hints to better decide which ram to give (internal or sdram). Only fb_alloc_all calls are given any hints right now as some of the calls need as much ram as possible and will cause failures to happen if a small amount of fast internal sram is returned. Anyway, hints can be used to tune where things are placed by fb_alloc.
This commit is contained in:
parent
30c4cf4a8c
commit
7ad61b725e
@ -91,7 +91,7 @@ void fb_alloc_free_till_mark()
|
||||
}
|
||||
|
||||
// returns null pointer without error if size==0
|
||||
void *fb_alloc(uint32_t size)
|
||||
void *fb_alloc(uint32_t size, int hints)
|
||||
{
|
||||
if (!size) {
|
||||
return NULL;
|
||||
@ -117,7 +117,8 @@ void *fb_alloc(uint32_t size)
|
||||
printf("fb_alloc %lu bytes\n", size);
|
||||
#endif
|
||||
#if defined(OMV_FB_OVERLAY_MEMORY)
|
||||
if (((uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN)) >= size) {
|
||||
if ((!(hints & FB_ALLOC_PREFER_SIZE))
|
||||
&& (((uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN)) >= size)) {
|
||||
// Return overlay memory instead.
|
||||
pointer_overlay -= size;
|
||||
result = pointer_overlay;
|
||||
@ -128,14 +129,14 @@ void *fb_alloc(uint32_t size)
|
||||
}
|
||||
|
||||
// returns null pointer without error if passed size==0
|
||||
void *fb_alloc0(uint32_t size)
|
||||
void *fb_alloc0(uint32_t size, int hints)
|
||||
{
|
||||
void *mem = fb_alloc(size);
|
||||
void *mem = fb_alloc(size, hints);
|
||||
memset(mem, 0, size); // does nothing if size is zero.
|
||||
return mem;
|
||||
}
|
||||
|
||||
void *fb_alloc_all(uint32_t *size)
|
||||
void *fb_alloc_all(uint32_t *size, int hints)
|
||||
{
|
||||
uint32_t temp = pointer - ((char *) MAIN_FB_PIXELS()) - sizeof(uint32_t);
|
||||
|
||||
@ -145,8 +146,10 @@ void *fb_alloc_all(uint32_t *size)
|
||||
}
|
||||
|
||||
#if defined(OMV_FB_OVERLAY_MEMORY)
|
||||
*size = (uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN);
|
||||
temp = IM_MIN(temp, *size);
|
||||
if (!(hints & FB_ALLOC_PREFER_SIZE)) {
|
||||
*size = (uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN);
|
||||
temp = IM_MIN(temp, *size);
|
||||
}
|
||||
#endif
|
||||
*size = (temp / sizeof(uint32_t)) * sizeof(uint32_t); // Round Down
|
||||
char *result = pointer - *size;
|
||||
@ -163,18 +166,20 @@ void *fb_alloc_all(uint32_t *size)
|
||||
printf("fb_alloc_all %lu bytes\n", *size);
|
||||
#endif
|
||||
#if defined(OMV_FB_OVERLAY_MEMORY)
|
||||
// Return overlay memory instead.
|
||||
pointer_overlay -= *size;
|
||||
result = pointer_overlay;
|
||||
if (!(hints & FB_ALLOC_PREFER_SIZE)) {
|
||||
// Return overlay memory instead.
|
||||
pointer_overlay -= *size;
|
||||
result = pointer_overlay;
|
||||
}
|
||||
*new_pointer |= FB_OVERLAY_MEMORY_FLAG; // Add flag.
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns null pointer without error if returned size==0
|
||||
void *fb_alloc0_all(uint32_t *size)
|
||||
void *fb_alloc0_all(uint32_t *size, int hints)
|
||||
{
|
||||
void *mem = fb_alloc_all(size);
|
||||
void *mem = fb_alloc_all(size, hints);
|
||||
memset(mem, 0, *size); // does nothing if size is zero.
|
||||
return mem;
|
||||
}
|
||||
|
||||
@ -9,15 +9,18 @@
|
||||
#ifndef __FB_ALLOC_H__
|
||||
#define __FB_ALLOC_H__
|
||||
#include <stdint.h>
|
||||
#define FB_ALLOC_NO_HINT 0
|
||||
#define FB_ALLOC_PREFER_SPEED 1
|
||||
#define FB_ALLOC_PREFER_SIZE 2
|
||||
void fb_alloc_fail();
|
||||
void fb_alloc_init0();
|
||||
uint32_t fb_avail();
|
||||
void fb_alloc_mark();
|
||||
void fb_alloc_free_till_mark();
|
||||
void *fb_alloc(uint32_t size);
|
||||
void *fb_alloc0(uint32_t size);
|
||||
void *fb_alloc_all(uint32_t *size); // returns pointer and sets size
|
||||
void *fb_alloc0_all(uint32_t *size); // returns pointer and sets size
|
||||
void *fb_alloc(uint32_t size, int hints);
|
||||
void *fb_alloc0(uint32_t size, int hints);
|
||||
void *fb_alloc_all(uint32_t *size, int hints); // returns pointer and sets size
|
||||
void *fb_alloc0_all(uint32_t *size, int hints); // returns pointer and sets size
|
||||
void fb_free();
|
||||
void fb_free_all();
|
||||
#endif /* __FF_ALLOC_H__ */
|
||||
|
||||
@ -237,7 +237,7 @@ uint32_t file_size_w_buf(FIL *fp)
|
||||
void file_buffer_on(FIL *fp)
|
||||
{
|
||||
file_buffer_offset = f_tell(fp) % 4;
|
||||
file_buffer_pointer = fb_alloc_all(&file_buffer_size) + file_buffer_offset;
|
||||
file_buffer_pointer = fb_alloc_all(&file_buffer_size, FB_ALLOC_PREFER_SIZE) + file_buffer_offset;
|
||||
if (!file_buffer_size) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_MemoryError, "No memory!"));
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ void fb_update_jpeg_buffer()
|
||||
image_t out = { .w=MAIN_FB()->w, .h=MAIN_FB()->h, .bpp=MAIN_FB()->bpp, .data=MAIN_FB()->pixels };
|
||||
int new_size = encode_for_ide_new_size(&out);
|
||||
fb_alloc_mark();
|
||||
uint8_t *temp = fb_alloc(new_size);
|
||||
uint8_t *temp = fb_alloc(new_size, FB_ALLOC_NO_HINT);
|
||||
encode_for_ide(temp, &out);
|
||||
(MP_PYTHON_PRINTER)->print_strn((MP_PYTHON_PRINTER)->data, (const char *) temp, new_size);
|
||||
fb_alloc_free_till_mark();
|
||||
|
||||
@ -198,7 +198,7 @@ static corner_t *agast58_detect(image_t *img, int b, int* num_corners, rectangle
|
||||
|
||||
// Try to alloc MAX_CORNERS or the actual max corners we can alloc.
|
||||
int max_corners = IM_MIN(MAX_CORNERS, (fb_avail() / sizeof(corner_t)));
|
||||
corner_t *corners = (corner_t*) fb_alloc(max_corners * sizeof(corner_t));
|
||||
corner_t *corners = (corner_t*) fb_alloc(max_corners * sizeof(corner_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for(y=roi->y+1; y < ysizeB; y++)
|
||||
{
|
||||
|
||||
@ -9142,8 +9142,8 @@ struct ufrec
|
||||
|
||||
static inline unionfind_t *unionfind_create(uint32_t maxid)
|
||||
{
|
||||
unionfind_t *uf = (unionfind_t*) fb_alloc(sizeof(unionfind_t));
|
||||
uf->data = (struct ufrec*) fb_alloc((maxid+1) * sizeof(struct ufrec));
|
||||
unionfind_t *uf = (unionfind_t*) fb_alloc(sizeof(unionfind_t), FB_ALLOC_NO_HINT);
|
||||
uf->data = (struct ufrec*) fb_alloc((maxid+1) * sizeof(struct ufrec), FB_ALLOC_NO_HINT);
|
||||
for (int i = 0; i <= maxid; i++) {
|
||||
uf->data[i].parent = i;
|
||||
}
|
||||
@ -9326,7 +9326,7 @@ static inline void ptsort(struct pt *pts, int sz)
|
||||
|
||||
// a merge sort with temp storage.
|
||||
|
||||
struct pt *tmp = fb_alloc(sizeof(struct pt) * sz);
|
||||
struct pt *tmp = fb_alloc(sizeof(struct pt) * sz, FB_ALLOC_NO_HINT);
|
||||
|
||||
memcpy(tmp, pts, sizeof(struct pt) * sz);
|
||||
|
||||
@ -9551,7 +9551,7 @@ int quad_segment_maxima(apriltag_detector_t *td, zarray_t *cluster, struct line_
|
||||
|
||||
// printf("sz %5d, ksz %3d\n", sz, ksz);
|
||||
|
||||
float *errs = fb_alloc(sz * sizeof(float));
|
||||
float *errs = fb_alloc(sz * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
fit_line(lfps, sz, (i + sz - ksz) % sz, (i + ksz) % sz, NULL, &errs[i], NULL);
|
||||
@ -9559,7 +9559,7 @@ int quad_segment_maxima(apriltag_detector_t *td, zarray_t *cluster, struct line_
|
||||
|
||||
// apply a low-pass filter to errs
|
||||
if (1) {
|
||||
float *y = fb_alloc(sz * sizeof(float));
|
||||
float *y = fb_alloc(sz * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
// how much filter to apply?
|
||||
|
||||
@ -9581,7 +9581,7 @@ int quad_segment_maxima(apriltag_detector_t *td, zarray_t *cluster, struct line_
|
||||
|
||||
// For default values of cutoff = 0.05, sigma = 3,
|
||||
// we have fsz = 17.
|
||||
float *f = fb_alloc(fsz * sizeof(float));
|
||||
float *f = fb_alloc(fsz * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < fsz; i++) {
|
||||
int j = i - fsz / 2;
|
||||
@ -9602,8 +9602,8 @@ int quad_segment_maxima(apriltag_detector_t *td, zarray_t *cluster, struct line_
|
||||
fb_free(); // y
|
||||
}
|
||||
|
||||
int *maxima = fb_alloc(sz * sizeof(int));
|
||||
float *maxima_errs = fb_alloc(sz * sizeof(float));
|
||||
int *maxima = fb_alloc(sz * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
float *maxima_errs = fb_alloc(sz * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
int nmaxima = 0;
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
@ -9622,7 +9622,7 @@ int quad_segment_maxima(apriltag_detector_t *td, zarray_t *cluster, struct line_
|
||||
int max_nmaxima = td->qtp.max_nmaxima;
|
||||
|
||||
if (nmaxima > max_nmaxima) {
|
||||
float *maxima_errs_copy = fb_alloc(nmaxima * sizeof(float));
|
||||
float *maxima_errs_copy = fb_alloc(nmaxima * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
memcpy(maxima_errs_copy, maxima_errs, nmaxima * sizeof(float));
|
||||
|
||||
// throw out all but the best handful of maxima. Sorts descending.
|
||||
@ -9859,7 +9859,7 @@ int fit_quad(apriltag_detector_t *td, image_u8_t *im, zarray_t *cluster, struct
|
||||
// Step 2. Precompute statistics that allow line fit queries to be
|
||||
// efficiently computed for any contiguous range of indices.
|
||||
|
||||
struct line_fit_pt *lfps = fb_alloc0(sz * sizeof(struct line_fit_pt));
|
||||
struct line_fit_pt *lfps = fb_alloc0(sz * sizeof(struct line_fit_pt), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
struct pt *p;
|
||||
@ -10157,11 +10157,11 @@ image_u8_t *threshold(apriltag_detector_t *td, image_u8_t *im)
|
||||
assert(w < 32768);
|
||||
assert(h < 32768);
|
||||
|
||||
image_u8_t *threshim = fb_alloc(sizeof(image_u8_t));
|
||||
image_u8_t *threshim = fb_alloc(sizeof(image_u8_t), FB_ALLOC_NO_HINT);
|
||||
threshim->width = w;
|
||||
threshim->height = h;
|
||||
threshim->stride = s;
|
||||
threshim->buf = fb_alloc(w * h);
|
||||
threshim->buf = fb_alloc(w * h, FB_ALLOC_NO_HINT);
|
||||
assert(threshim->stride == s);
|
||||
|
||||
// The idea is to find the maximum and minimum values in a
|
||||
@ -10194,8 +10194,8 @@ image_u8_t *threshold(apriltag_detector_t *td, image_u8_t *im)
|
||||
int tw = w / tilesz;
|
||||
int th = h / tilesz;
|
||||
|
||||
uint8_t *im_max = fb_alloc(tw*th*sizeof(uint8_t));
|
||||
uint8_t *im_min = fb_alloc(tw*th*sizeof(uint8_t));
|
||||
uint8_t *im_max = fb_alloc(tw*th*sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
uint8_t *im_min = fb_alloc(tw*th*sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
// first, collect min/max statistics for each tile
|
||||
for (int ty = 0; ty < th; ty++) {
|
||||
@ -10223,8 +10223,8 @@ image_u8_t *threshold(apriltag_detector_t *td, image_u8_t *im)
|
||||
// over larger areas. This reduces artifacts due to abrupt changes
|
||||
// in the threshold value.
|
||||
if (1) {
|
||||
uint8_t *im_max_tmp = fb_alloc(tw*th*sizeof(uint8_t));
|
||||
uint8_t *im_min_tmp = fb_alloc(tw*th*sizeof(uint8_t));
|
||||
uint8_t *im_max_tmp = fb_alloc(tw*th*sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
uint8_t *im_min_tmp = fb_alloc(tw*th*sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int ty = 0; ty < th; ty++) {
|
||||
for (int tx = 0; tx < tw; tx++) {
|
||||
@ -10341,11 +10341,11 @@ image_u8_t *threshold(apriltag_detector_t *td, image_u8_t *im)
|
||||
// this is a dilate/erode deglitching scheme that does not improve
|
||||
// anything as far as I can tell.
|
||||
if (0 || td->qtp.deglitch) {
|
||||
image_u8_t *tmp = fb_alloc(sizeof(image_u8_t));
|
||||
image_u8_t *tmp = fb_alloc(sizeof(image_u8_t), FB_ALLOC_NO_HINT);
|
||||
tmp->width = w;
|
||||
tmp->height = h;
|
||||
tmp->stride = s;
|
||||
tmp->buf = fb_alloc(w * h);
|
||||
tmp->buf = fb_alloc(w * h, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 1; y + 1 < h; y++) {
|
||||
for (int x = 1; x + 1 < w; x++) {
|
||||
@ -10402,7 +10402,7 @@ zarray_t *apriltag_quad_thresh(apriltag_detector_t *td, image_u8_t *im, bool ove
|
||||
}
|
||||
|
||||
uint32_t nclustermap;
|
||||
struct uint32_zarray_entry **clustermap = fb_alloc0_all(&nclustermap);
|
||||
struct uint32_zarray_entry **clustermap = fb_alloc0_all(&nclustermap, FB_ALLOC_PREFER_SPEED);
|
||||
nclustermap /= sizeof(struct uint32_zarray_entry*);
|
||||
if (!nclustermap) fb_alloc_fail();
|
||||
|
||||
@ -11781,7 +11781,7 @@ void imlib_find_apriltags(list_t *out, image_t *ptr, rectangle_t *roi, apriltag_
|
||||
apriltag_detector_add_family(td, (apriltag_family_t *) &artoolkit);
|
||||
}
|
||||
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h);
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
|
||||
image_u8_t im;
|
||||
im.width = roi->w;
|
||||
@ -11914,7 +11914,7 @@ void imlib_find_rects(list_t *out, image_t *ptr, rectangle_t *roi, uint32_t thre
|
||||
umm_init_x(((fb_avail() - fb_alloc_need) / resolution) * resolution);
|
||||
apriltag_detector_t *td = apriltag_detector_create();
|
||||
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h);
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
|
||||
image_u8_t im;
|
||||
im.width = roi->w;
|
||||
@ -12056,9 +12056,9 @@ void imlib_find_rects(list_t *out, image_t *ptr, rectangle_t *roi, uint32_t thre
|
||||
list_init(out, sizeof(find_rects_list_lnk_data_t));
|
||||
|
||||
const int r_diag_len = fast_roundf(fast_sqrtf((roi->w * roi->w) + (roi->h * roi->h))) * 2;
|
||||
int *theta_buffer = fb_alloc(sizeof(int) * r_diag_len);
|
||||
uint32_t *mag_buffer = fb_alloc(sizeof(uint32_t) * r_diag_len);
|
||||
point_t *point_buffer = fb_alloc(sizeof(point_t) * r_diag_len);
|
||||
int *theta_buffer = fb_alloc(sizeof(int) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
uint32_t *mag_buffer = fb_alloc(sizeof(uint32_t) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
point_t *point_buffer = fb_alloc(sizeof(point_t) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0, j = zarray_size(detections); i < j; i++) {
|
||||
struct quad *det;
|
||||
@ -12186,7 +12186,7 @@ void imlib_rotation_corr(image_t *img, float x_rotation, float y_rotation, float
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint32_t *tmp = fb_alloc(((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
uint32_t *tmp = fb_alloc(((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h, FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, ((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
memset(img->data, 0, ((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
|
||||
@ -12210,7 +12210,7 @@ void imlib_rotation_corr(image_t *img, float x_rotation, float y_rotation, float
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint8_t *tmp = fb_alloc(img->w * img->h * sizeof(uint8_t));
|
||||
uint8_t *tmp = fb_alloc(img->w * img->h * sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, img->w * img->h * sizeof(uint8_t));
|
||||
memset(img->data, 0, img->w * img->h * sizeof(uint8_t));
|
||||
|
||||
@ -12234,7 +12234,7 @@ void imlib_rotation_corr(image_t *img, float x_rotation, float y_rotation, float
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint16_t *tmp = fb_alloc(img->w * img->h * sizeof(uint16_t));
|
||||
uint16_t *tmp = fb_alloc(img->w * img->h * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, img->w * img->h * sizeof(uint16_t));
|
||||
memset(img->data, 0, img->w * img->h * sizeof(uint16_t));
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ void imlib_binary(image_t *out, image_t *img, list_t *thresholds, bool invert, b
|
||||
bmp.w = img->w;
|
||||
bmp.h = img->h;
|
||||
bmp.bpp = IMAGE_BPP_BINARY;
|
||||
bmp.data = fb_alloc0(image_size(&bmp));
|
||||
bmp.data = fb_alloc0(image_size(&bmp), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (list_lnk_t *it = iterator_start_from_head(thresholds); it; it = iterator_next(it)) {
|
||||
color_thresholds_list_lnk_data_t lnk_data;
|
||||
@ -677,7 +677,7 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -731,7 +731,7 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -787,7 +787,7 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -886,7 +886,7 @@ void imlib_top_hat(image_t *img, int ksize, int threshold, image_t *mask)
|
||||
temp.w = img->w;
|
||||
temp.h = img->h;
|
||||
temp.bpp = img->bpp;
|
||||
temp.data = fb_alloc(image_size(img));
|
||||
temp.data = fb_alloc(image_size(img), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, img->data, image_size(img));
|
||||
imlib_open(&temp, ksize, threshold, mask);
|
||||
imlib_difference(img, NULL, &temp, 0, mask);
|
||||
@ -899,7 +899,7 @@ void imlib_black_hat(image_t *img, int ksize, int threshold, image_t *mask)
|
||||
temp.w = img->w;
|
||||
temp.h = img->h;
|
||||
temp.bpp = img->bpp;
|
||||
temp.data = fb_alloc(image_size(img));
|
||||
temp.data = fb_alloc(image_size(img), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, img->data, image_size(img));
|
||||
imlib_close(&temp, ksize, threshold, mask);
|
||||
imlib_difference(img, NULL, &temp, 0, mask);
|
||||
|
||||
@ -141,13 +141,13 @@ void imlib_find_blobs(list_t *out, image_t *ptr, rectangle_t *roi, unsigned int
|
||||
bmp.w = ptr->w;
|
||||
bmp.h = ptr->h;
|
||||
bmp.bpp = IMAGE_BPP_BINARY;
|
||||
bmp.data = fb_alloc0(image_size(&bmp));
|
||||
bmp.data = fb_alloc0(image_size(&bmp), FB_ALLOC_NO_HINT);
|
||||
|
||||
uint16_t *x_hist_bins = NULL;
|
||||
if (x_hist_bins_max) x_hist_bins = fb_alloc(ptr->w * sizeof(uint16_t));
|
||||
if (x_hist_bins_max) x_hist_bins = fb_alloc(ptr->w * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
uint16_t *y_hist_bins = NULL;
|
||||
if (y_hist_bins_max) y_hist_bins = fb_alloc(ptr->h * sizeof(uint16_t));
|
||||
if (y_hist_bins_max) y_hist_bins = fb_alloc(ptr->h * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
lifo_t lifo;
|
||||
size_t lifo_len;
|
||||
|
||||
@ -102,7 +102,7 @@ int CLAHE (kz_pixel_t* pImage, unsigned int uiXRes, unsigned int uiYRes,
|
||||
if (fCliplimit == 1.0) return 0; /* is OK, immediately returns original image. */
|
||||
if (uiNrBins == 0) uiNrBins = 128; /* default value when not specified */
|
||||
|
||||
pulMapArray=(unsigned long *)fb_alloc(sizeof(unsigned long)*uiNrX*uiNrY*uiNrBins);
|
||||
pulMapArray=(unsigned long *)fb_alloc(sizeof(unsigned long)*uiNrX*uiNrY*uiNrBins, FB_ALLOC_NO_HINT);
|
||||
if (pulMapArray == 0) return -8; /* Not enough memory! (try reducing uiNrBins) */
|
||||
|
||||
uiXSize = uiXRes/uiNrX; uiYSize = uiYRes/uiNrY; /* Actual size of contextual regions */
|
||||
@ -327,7 +327,7 @@ void imlib_clahe_histeq(image_t *img, float clip_limit, image_t *mask)
|
||||
temp.w = img->w;
|
||||
temp.h = img->h;
|
||||
temp.bpp = img->bpp;
|
||||
temp.data = fb_alloc0(pImageW * pImageH * sizeof(kz_pixel_t));
|
||||
temp.data = fb_alloc0(pImageW * pImageH * sizeof(kz_pixel_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
void bitmap_alloc(bitmap_t *ptr, size_t size)
|
||||
{
|
||||
ptr->size = size;
|
||||
ptr->data = (char *) fb_alloc0(((size + CHAR_MASK) >> CHAR_SHIFT) * sizeof(char));
|
||||
ptr->data = (char *) fb_alloc0(((size + CHAR_MASK) >> CHAR_SHIFT) * sizeof(char), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void bitmap_free(bitmap_t *ptr)
|
||||
@ -54,13 +54,13 @@ void lifo_alloc(lifo_t *ptr, size_t size, size_t data_len)
|
||||
ptr->len = 0;
|
||||
ptr->size = size;
|
||||
ptr->data_len = data_len;
|
||||
ptr->data = (char *) fb_alloc(size * data_len);
|
||||
ptr->data = (char *) fb_alloc(size * data_len, FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void lifo_alloc_all(lifo_t *ptr, size_t *size, size_t data_len)
|
||||
{
|
||||
uint32_t tmp_size;
|
||||
ptr->data = (char *) fb_alloc_all(&tmp_size);
|
||||
ptr->data = (char *) fb_alloc_all(&tmp_size, FB_ALLOC_NO_HINT);
|
||||
ptr->data_len = data_len;
|
||||
ptr->size = tmp_size / data_len;
|
||||
ptr->len = 0;
|
||||
@ -131,13 +131,13 @@ void fifo_alloc(fifo_t *ptr, size_t size, size_t data_len)
|
||||
ptr->len = 0;
|
||||
ptr->size = size;
|
||||
ptr->data_len = data_len;
|
||||
ptr->data = (char *) fb_alloc(size * data_len);
|
||||
ptr->data = (char *) fb_alloc(size * data_len, FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void fifo_alloc_all(fifo_t *ptr, size_t *size, size_t data_len)
|
||||
{
|
||||
uint32_t tmp_size;
|
||||
ptr->data = (char *) fb_alloc_all(&tmp_size);
|
||||
ptr->data = (char *) fb_alloc_all(&tmp_size, FB_ALLOC_NO_HINT);
|
||||
ptr->data_len = data_len;
|
||||
ptr->size = tmp_size / data_len;
|
||||
ptr->len = 0;
|
||||
|
||||
@ -6266,7 +6266,7 @@ dmtxMatrix3Print(DmtxMatrix3 m)
|
||||
|
||||
void imlib_find_datamatrices(list_t *out, image_t *ptr, rectangle_t *roi, int effort)
|
||||
{
|
||||
uint8_t *grayscale_image = (ptr->bpp == IMAGE_BPP_GRAYSCALE) ? ptr->data : fb_alloc(roi->w * roi->h);
|
||||
uint8_t *grayscale_image = (ptr->bpp == IMAGE_BPP_GRAYSCALE) ? ptr->data : fb_alloc(roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
umm_init_x(fb_avail());
|
||||
|
||||
DmtxImage *image = dmtxImageCreate(grayscale_image,
|
||||
|
||||
@ -503,7 +503,7 @@ void imlib_flood_fill(image_t *img, int x, int y,
|
||||
out.w = img->w;
|
||||
out.h = img->h;
|
||||
out.bpp = IMAGE_BPP_BINARY;
|
||||
out.data = fb_alloc0(image_size(&out));
|
||||
out.data = fb_alloc0(image_size(&out), FB_ALLOC_NO_HINT);
|
||||
|
||||
if (mask) {
|
||||
for (int y = 0, yy = out.h; y < yy; y++) {
|
||||
|
||||
@ -38,7 +38,7 @@ void imlib_edge_canny(image_t *src, rectangle_t *roi, int low_thresh, int high_t
|
||||
{
|
||||
int w = src->w;
|
||||
|
||||
gvec_t *gm = fb_alloc0(roi->w*roi->h*sizeof*gm);
|
||||
gvec_t *gm = fb_alloc0(roi->w*roi->h*sizeof*gm, FB_ALLOC_NO_HINT);
|
||||
|
||||
//1. Noise Reduction with a Gaussian filter
|
||||
imlib_sepconv3(src, kernel_gauss_3, 1.0f/16.0f, 0.0f);
|
||||
|
||||
@ -3114,7 +3114,7 @@ static corner_t *fast9_detect(image_t *image, rectangle_t *roi, int *n_corners,
|
||||
int num_corners = 0;
|
||||
// Try to alloc MAX_CORNERS or the actual max corners we can alloc.
|
||||
int max_corners = IM_MIN(MAX_CORNERS, (fb_avail() / sizeof(corner_t)));
|
||||
corner_t *corners = (corner_t*) fb_alloc(max_corners * sizeof(corner_t));
|
||||
corner_t *corners = (corner_t*) fb_alloc(max_corners * sizeof(corner_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for(int y=roi->y+3; y<roi->y+roi->h-3; y++) {
|
||||
for(int x=roi->x+3; x<roi->x+roi->w-3; x++) {
|
||||
|
||||
@ -442,7 +442,7 @@ void fft1d_alloc(fft1d_controller_t *controller, uint8_t *buf, int len)
|
||||
controller->d_pointer = buf;
|
||||
controller->d_len = len;
|
||||
controller->pow2 = int_clog2(len);
|
||||
controller->data = fb_alloc((2 << controller->pow2) * sizeof(float));
|
||||
controller->data = fb_alloc((2 << controller->pow2) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void fft1d_dealloc()
|
||||
@ -455,7 +455,7 @@ void fft1d_run(fft1d_controller_t *controller)
|
||||
// We can speed up the FFT by packing data into both the real and imaginary
|
||||
// values. This results in having to do an FFT of half the size normally.
|
||||
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float));
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
prepare_real_input(controller->d_pointer, controller->d_len,
|
||||
h_buffer, controller->pow2 - 1);
|
||||
do_fft(h_buffer, controller->pow2 - 1, 1);
|
||||
@ -468,7 +468,7 @@ void ifft1d_run(fft1d_controller_t *controller)
|
||||
// We can speed up the FFT by packing data into both the real and imaginary
|
||||
// values. This results in having to do an FFT of half the size normally.
|
||||
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float));
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
pack_fft(controller->data, h_buffer, controller->pow2 - 1);
|
||||
prepare_complex_input(h_buffer, h_buffer,
|
||||
controller->pow2 - 1, 1);
|
||||
@ -535,7 +535,7 @@ void fft1d_run_again(fft1d_controller_t *controller)
|
||||
// We can speed up the FFT by packing data into both the real and imaginary
|
||||
// values. This results in having to do an FFT of half the size normally.
|
||||
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float));
|
||||
float *h_buffer = fb_alloc((1 << controller->pow2) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
prepare_real_input_again(controller->data, 1 << controller->pow2,
|
||||
h_buffer, controller->pow2 - 1);
|
||||
do_fft(h_buffer, controller->pow2 - 1, 1);
|
||||
@ -554,7 +554,7 @@ void fft2d_alloc(fft2d_controller_t *controller, image_t *img, rectangle_t *r)
|
||||
controller->h_pow2 = int_clog2(controller->r.h);
|
||||
|
||||
controller->data =
|
||||
fb_alloc0(2 * (1 << controller->w_pow2) * (1 << controller->h_pow2) * sizeof(float));
|
||||
fb_alloc0(2 * (1 << controller->w_pow2) * (1 << controller->h_pow2) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void fft2d_dealloc()
|
||||
@ -569,7 +569,7 @@ void fft2d_run(fft2d_controller_t *controller)
|
||||
// also handles dealing with a rect less than the image size.
|
||||
for (int i = 0; i < controller->r.h; i++) {
|
||||
// Get image data into buffer.
|
||||
uint8_t *tmp = fb_alloc(controller->r.w * sizeof(uint8_t));
|
||||
uint8_t *tmp = fb_alloc(controller->r.w * sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
for (int j = 0; j < controller->r.w; j++) {
|
||||
if (IM_IS_GS(controller->img)) {
|
||||
tmp[j] = IM_GET_GS_PIXEL(controller->img,
|
||||
@ -688,7 +688,7 @@ void fft2d_linpolar(fft2d_controller_t *controller)
|
||||
int w = 1 << controller->w_pow2;
|
||||
int h = 1 << controller->h_pow2;
|
||||
int s = h * w * 2 * sizeof(float);
|
||||
float *tmp = fb_alloc(s);
|
||||
float *tmp = fb_alloc(s, FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, controller->data, s);
|
||||
memset(controller->data, 0, s);
|
||||
|
||||
@ -722,7 +722,7 @@ void fft2d_logpolar(fft2d_controller_t *controller)
|
||||
int w = 1 << controller->w_pow2;
|
||||
int h = 1 << controller->h_pow2;
|
||||
int s = h * w * 2 * sizeof(float);
|
||||
float *tmp = fb_alloc(s);
|
||||
float *tmp = fb_alloc(s, FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, controller->data, s);
|
||||
memset(controller->data, 0, s);
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ void imlib_histeq(image_t *img, image_t *mask)
|
||||
case IMAGE_BPP_BINARY: {
|
||||
int a = img->w * img->h;
|
||||
float s = (COLOR_BINARY_MAX - COLOR_BINARY_MIN) / ((float) a);
|
||||
uint32_t *hist = fb_alloc0((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(uint32_t));
|
||||
uint32_t *hist = fb_alloc0((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(uint32_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -47,7 +47,7 @@ void imlib_histeq(image_t *img, image_t *mask)
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
int a = img->w * img->h;
|
||||
float s = (COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN) / ((float) a);
|
||||
uint32_t *hist = fb_alloc0((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(uint32_t));
|
||||
uint32_t *hist = fb_alloc0((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(uint32_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -77,7 +77,7 @@ void imlib_histeq(image_t *img, image_t *mask)
|
||||
case IMAGE_BPP_RGB565: {
|
||||
int a = img->w * img->h;
|
||||
float s = (COLOR_Y_MAX - COLOR_Y_MIN) / ((float) a);
|
||||
uint32_t *hist = fb_alloc0((COLOR_Y_MAX - COLOR_Y_MIN + 1) * sizeof(uint32_t));
|
||||
uint32_t *hist = fb_alloc0((COLOR_Y_MAX - COLOR_Y_MIN + 1) * sizeof(uint32_t), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -130,7 +130,7 @@ void imlib_mean_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -185,7 +185,7 @@ void imlib_mean_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -240,7 +240,7 @@ void imlib_mean_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -319,8 +319,8 @@ void imlib_median_filter(image_t *img, const int ksize, float percentile, bool t
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
int *data = fb_alloc(n*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *data = fb_alloc(n*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -378,8 +378,8 @@ void imlib_median_filter(image_t *img, const int ksize, float percentile, bool t
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
int *data = fb_alloc(n*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *data = fb_alloc(n*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -437,10 +437,10 @@ void imlib_median_filter(image_t *img, const int ksize, float percentile, bool t
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
int *r_data = fb_alloc(n*sizeof(int));
|
||||
int *g_data = fb_alloc(n*sizeof(int));
|
||||
int *b_data = fb_alloc(n*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *r_data = fb_alloc(n*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *g_data = fb_alloc(n*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *b_data = fb_alloc(n*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -524,8 +524,8 @@ void imlib_mode_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
int *bins = fb_alloc((COLOR_BINARY_MAX-COLOR_BINARY_MIN+1)*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *bins = fb_alloc((COLOR_BINARY_MAX-COLOR_BINARY_MIN+1)*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -589,8 +589,8 @@ void imlib_mode_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
int *bins = fb_alloc((COLOR_GRAYSCALE_MAX-COLOR_GRAYSCALE_MIN+1)*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *bins = fb_alloc((COLOR_GRAYSCALE_MAX-COLOR_GRAYSCALE_MIN+1)*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -654,10 +654,10 @@ void imlib_mode_filter(image_t *img, const int ksize, bool threshold, int offset
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
int *r_bins = fb_alloc((COLOR_R5_MAX-COLOR_R5_MIN+1)*sizeof(int));
|
||||
int *g_bins = fb_alloc((COLOR_G6_MAX-COLOR_G6_MIN+1)*sizeof(int));
|
||||
int *b_bins = fb_alloc((COLOR_B5_MAX-COLOR_B5_MIN+1)*sizeof(int));
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
int *r_bins = fb_alloc((COLOR_R5_MAX-COLOR_R5_MIN+1)*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *g_bins = fb_alloc((COLOR_G6_MAX-COLOR_G6_MIN+1)*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *b_bins = fb_alloc((COLOR_B5_MAX-COLOR_B5_MIN+1)*sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -761,7 +761,7 @@ void imlib_midpoint_filter(image_t *img, const int ksize, float bias, bool thres
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -818,7 +818,7 @@ void imlib_midpoint_filter(image_t *img, const int ksize, float bias, bool thres
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -875,7 +875,7 @@ void imlib_midpoint_filter(image_t *img, const int ksize, float bias, bool thres
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -961,7 +961,7 @@ void imlib_morph(image_t *img, const int ksize, const int *krn, const float m, c
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint32_t *row_ptr = IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(img, y);
|
||||
@ -1016,7 +1016,7 @@ void imlib_morph(image_t *img, const int ksize, const int *krn, const float m, c
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, y);
|
||||
@ -1071,7 +1071,7 @@ void imlib_morph(image_t *img, const int ksize, const int *krn, const float m, c
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = img->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img, y);
|
||||
@ -1157,8 +1157,8 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows);
|
||||
float *gi_lut = fb_alloc((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(float));
|
||||
buf.data = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
float *gi_lut = fb_alloc((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float max_color = IM_DIV(1.0f, COLOR_BINARY_MAX - COLOR_BINARY_MIN);
|
||||
for (int i = COLOR_BINARY_MIN; i <= COLOR_BINARY_MAX; i++) {
|
||||
@ -1166,7 +1166,7 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
}
|
||||
|
||||
int n = (ksize * 2) + 1;
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float));
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float max_space = IM_DIV(1.0f, distance(ksize, ksize));
|
||||
for (int y = -ksize; y <= ksize; y++) {
|
||||
@ -1234,8 +1234,8 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows);
|
||||
float *gi_lut = fb_alloc((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(float));
|
||||
buf.data = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
float *gi_lut = fb_alloc((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float max_color = IM_DIV(1.0f, COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN);
|
||||
for (int i = COLOR_GRAYSCALE_MIN; i <= COLOR_GRAYSCALE_MAX; i++) {
|
||||
@ -1243,7 +1243,7 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
}
|
||||
|
||||
int n = (ksize * 2) + 1;
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float));
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float max_space = IM_DIV(1.0f, distance(ksize, ksize));
|
||||
for (int y = -ksize; y <= ksize; y++) {
|
||||
@ -1311,10 +1311,10 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows);
|
||||
float *r_gi_lut = fb_alloc((COLOR_R5_MAX - COLOR_R5_MIN + 1) * sizeof(float));
|
||||
float *g_gi_lut = fb_alloc((COLOR_G6_MAX - COLOR_G6_MIN + 1) * sizeof(float));
|
||||
float *b_gi_lut = fb_alloc((COLOR_B5_MAX - COLOR_B5_MIN + 1) * sizeof(float));
|
||||
buf.data = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img) * brows, FB_ALLOC_NO_HINT);
|
||||
float *r_gi_lut = fb_alloc((COLOR_R5_MAX - COLOR_R5_MIN + 1) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
float *g_gi_lut = fb_alloc((COLOR_G6_MAX - COLOR_G6_MIN + 1) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
float *b_gi_lut = fb_alloc((COLOR_B5_MAX - COLOR_B5_MIN + 1) * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float r_max_color = IM_DIV(1.0f, COLOR_R5_MAX - COLOR_R5_MIN);
|
||||
for (int i = COLOR_R5_MIN; i <= COLOR_R5_MAX; i++) {
|
||||
@ -1332,7 +1332,7 @@ void imlib_bilateral_filter(image_t *img, const int ksize, float color_sigma, fl
|
||||
}
|
||||
|
||||
int n = (ksize * 2) + 1;
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float));
|
||||
float *gs_lut = fb_alloc(n * n * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
float max_space = IM_DIV(1.0f, distance(ksize, ksize));
|
||||
for (int y = -ksize; y <= ksize; y++) {
|
||||
@ -1511,12 +1511,12 @@ void imlib_cartoon_filter(image_t *img, float seed_threshold, float floating_thr
|
||||
mean_image.w = img->w;
|
||||
mean_image.h = img->h;
|
||||
mean_image.bpp = IMAGE_BPP_BINARY;
|
||||
mean_image.data = fb_alloc0(image_size(&mean_image));
|
||||
mean_image.data = fb_alloc0(image_size(&mean_image), FB_ALLOC_NO_HINT);
|
||||
|
||||
fill_image.w = img->w;
|
||||
fill_image.h = img->h;
|
||||
fill_image.bpp = IMAGE_BPP_BINARY;
|
||||
fill_image.data = fb_alloc0(image_size(&fill_image));
|
||||
fill_image.data = fb_alloc0(image_size(&fill_image), FB_ALLOC_NO_HINT);
|
||||
|
||||
if (mask) {
|
||||
for (int y = 0, yy = fill_image.h; y < yy; y++) {
|
||||
|
||||
@ -46,7 +46,7 @@ void imlib_find_hog(image_t *src, rectangle_t *roi, int cell_size)
|
||||
int y_cells = (roi->h/cell_size);
|
||||
|
||||
// TODO: Assert row->w/h >= cell_size *2;
|
||||
float *hog = fb_alloc0(x_cells * y_cells * N_BINS * sizeof*hog);
|
||||
float *hog = fb_alloc0(x_cells * y_cells * N_BINS * sizeof*hog, FB_ALLOC_NO_HINT);
|
||||
|
||||
//2. Finding Image Gradients
|
||||
for (int y=roi->y, hog_index=0; y<h; y+=block_size) {
|
||||
|
||||
@ -26,7 +26,7 @@ void imlib_find_lines(list_t *out, image_t *ptr, rectangle_t *roi, unsigned int
|
||||
if (hough_divide > 4) fb_alloc_fail(); // support 1, 2, 4
|
||||
}
|
||||
|
||||
uint32_t *acc = fb_alloc0(sizeof(uint32_t) * theta_size * r_size);
|
||||
uint32_t *acc = fb_alloc0(sizeof(uint32_t) * theta_size * r_size, FB_ALLOC_NO_HINT);
|
||||
|
||||
switch (ptr->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
@ -370,9 +370,9 @@ void imlib_find_line_segments(list_t *out, image_t *ptr, rectangle_t *roi, unsig
|
||||
list_init(out, sizeof(find_lines_list_lnk_data_t));
|
||||
|
||||
const int r_diag_len = fast_roundf(fast_sqrtf((roi->w * roi->w) + (roi->h * roi->h))) * 2;
|
||||
int *theta_buffer = fb_alloc(sizeof(int) * r_diag_len);
|
||||
uint32_t *mag_buffer = fb_alloc(sizeof(uint32_t) * r_diag_len);
|
||||
point_t *point_buffer = fb_alloc(sizeof(point_t) * r_diag_len);
|
||||
int *theta_buffer = fb_alloc(sizeof(int) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
uint32_t *mag_buffer = fb_alloc(sizeof(uint32_t) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
point_t *point_buffer = fb_alloc(sizeof(point_t) * r_diag_len, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (size_t i = 0; list_size(&temp_out); i++) {
|
||||
find_lines_list_lnk_data_t lnk_data;
|
||||
@ -461,8 +461,8 @@ void imlib_find_circles(list_t *out, image_t *ptr, rectangle_t *roi, unsigned in
|
||||
uint32_t threshold, unsigned int x_margin, unsigned int y_margin, unsigned int r_margin,
|
||||
unsigned int r_min, unsigned int r_max, unsigned int r_step)
|
||||
{
|
||||
uint16_t *theta_acc = fb_alloc0(sizeof(uint16_t) * roi->w * roi->h);
|
||||
uint16_t *magnitude_acc = fb_alloc0(sizeof(uint16_t) * roi->w * roi->h);
|
||||
uint16_t *theta_acc = fb_alloc0(sizeof(uint16_t) * roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
uint16_t *magnitude_acc = fb_alloc0(sizeof(uint16_t) * roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
|
||||
switch (ptr->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
@ -694,7 +694,7 @@ void imlib_find_circles(list_t *out, image_t *ptr, rectangle_t *roi, unsigned in
|
||||
if (hough_divide > 4) fb_alloc_fail(); // support 1, 2, 4
|
||||
}
|
||||
|
||||
uint32_t *acc = fb_alloc0(sizeof(uint32_t) * a_size * b_size);
|
||||
uint32_t *acc = fb_alloc0(sizeof(uint32_t) * a_size * b_size, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y = 0, yy = roi->h; y < yy; y++) {
|
||||
for (int x = 0, xx = roi->w; x < xx; x++) {
|
||||
|
||||
@ -577,7 +577,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
{
|
||||
if (path) {
|
||||
uint32_t size = fb_avail() / 2;
|
||||
void *alloc = fb_alloc(size); // We have to do this before the read.
|
||||
void *alloc = fb_alloc(size, FB_ALLOC_NO_HINT); // We have to do this before the read.
|
||||
// This code reads a window of an image in at a time and then executes
|
||||
// the line operation on each line in that window before moving to the
|
||||
// next window. The vflipped part is here because BMP files can be saved
|
||||
@ -645,7 +645,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
} else {
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
uint32_t *row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img));
|
||||
uint32_t *row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(img), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i=0, ii=img->w; i<ii; i++) {
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(row_ptr, i, scalar);
|
||||
@ -659,7 +659,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
uint8_t *row_ptr = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img));
|
||||
uint8_t *row_ptr = fb_alloc(IMAGE_GRAYSCALE_LINE_LEN_BYTES(img), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i=0, ii=img->w; i<ii; i++) {
|
||||
IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_ptr, i, scalar);
|
||||
@ -673,7 +673,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
break;
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
uint16_t *row_ptr = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img));
|
||||
uint16_t *row_ptr = fb_alloc(IMAGE_RGB565_LINE_LEN_BYTES(img), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i=0, ii=img->w; i<ii; i++) {
|
||||
IMAGE_PUT_RGB565_PIXEL_FAST(row_ptr, i, scalar);
|
||||
@ -737,18 +737,18 @@ void imlib_save_image(image_t *img, const char *path, rectangle_t *roi, int qual
|
||||
case FORMAT_DONT_CARE:
|
||||
// Path doesn't have an extension.
|
||||
if (IM_IS_JPEG(img)) {
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5), path), ".jpg");
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5, FB_ALLOC_NO_HINT), path), ".jpg");
|
||||
jpeg_write(img, new_path, quality);
|
||||
fb_free();
|
||||
} else if (IM_IS_BAYER(img)) {
|
||||
FIL fp;
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5), path), ".raw");
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5, FB_ALLOC_NO_HINT), path), ".raw");
|
||||
file_write_open(&fp, new_path);
|
||||
write_data(&fp, img->pixels, img->w * img->h);
|
||||
file_close(&fp);
|
||||
fb_free();
|
||||
} else { // RGB or GS, save as BMP.
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5), path), ".bmp");
|
||||
char *new_path = strcat(strcpy(fb_alloc(strlen(path)+5, FB_ALLOC_NO_HINT), path), ".bmp");
|
||||
bmp_write_subimg(img, new_path, roi);
|
||||
fb_free();
|
||||
}
|
||||
@ -812,7 +812,7 @@ void imlib_lens_corr(image_t *img, float strength, float zoom)
|
||||
switch(img->bpp) {
|
||||
case IMAGE_BPP_BINARY: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint32_t *tmp = fb_alloc(((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
uint32_t *tmp = fb_alloc(((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h, FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, ((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
memset(img->data, 0, ((img->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * img->h);
|
||||
|
||||
@ -845,7 +845,7 @@ void imlib_lens_corr(image_t *img, float strength, float zoom)
|
||||
}
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint8_t *tmp = fb_alloc(img->w * img->h * sizeof(uint8_t));
|
||||
uint8_t *tmp = fb_alloc(img->w * img->h * sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, img->w * img->h * sizeof(uint8_t));
|
||||
memset(img->data, 0, img->w * img->h * sizeof(uint8_t));
|
||||
|
||||
@ -878,7 +878,7 @@ void imlib_lens_corr(image_t *img, float strength, float zoom)
|
||||
}
|
||||
case IMAGE_BPP_RGB565: {
|
||||
// Create a temp copy of the image to pull pixels from.
|
||||
uint16_t *tmp = fb_alloc(img->w * img->h * sizeof(uint16_t));
|
||||
uint16_t *tmp = fb_alloc(img->w * img->h * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
memcpy(tmp, img->data, img->w * img->h * sizeof(uint16_t));
|
||||
memset(img->data, 0, img->w * img->h * sizeof(uint16_t));
|
||||
|
||||
@ -992,7 +992,7 @@ void imlib_sepconv3(image_t *img, const int8_t *krn, const float m, const int b)
|
||||
{
|
||||
int ksize = 3;
|
||||
// TODO: Support RGB
|
||||
int *buffer = fb_alloc(img->w * 2 * sizeof(*buffer));
|
||||
int *buffer = fb_alloc(img->w * 2 * sizeof(*buffer), FB_ALLOC_NO_HINT);
|
||||
|
||||
// NOTE: This doesn't deal with borders right now. Adding if
|
||||
// statements in the inner loop will slow it down significantly.
|
||||
|
||||
@ -18,7 +18,7 @@ void imlib_integral_image_alloc(i_image_t *sum, int w, int h)
|
||||
{
|
||||
sum->w = w;
|
||||
sum->h = h;
|
||||
sum->data = fb_alloc(w * h * sizeof(*sum->data));
|
||||
sum->data = fb_alloc(w * h * sizeof(*sum->data), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
void imlib_integral_image_free(i_image_t *sum)
|
||||
|
||||
@ -67,13 +67,13 @@ void imlib_integral_mw_alloc(mw_image_t *sum, int w, int h)
|
||||
sum->y_offs = 0;
|
||||
sum->x_ratio = (1<<16)+1;
|
||||
sum->y_ratio = (1<<16)+1;
|
||||
sum->data = fb_alloc(h * sizeof(*sum->data));
|
||||
sum->data = fb_alloc(h * sizeof(*sum->data), FB_ALLOC_NO_HINT);
|
||||
// swap is used when shifting the image pointers
|
||||
// to avoid overwriting the image rows in sum->data
|
||||
sum->swap = fb_alloc(h * sizeof(*sum->data));
|
||||
sum->swap = fb_alloc(h * sizeof(*sum->data), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i=0; i<h; i++) {
|
||||
sum->data[i] = fb_alloc(w * sizeof(**sum->data));
|
||||
sum->data[i] = fb_alloc(w * sizeof(**sum->data), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1268,7 +1268,7 @@ void jpeg_write(image_t *img, const char *path, int quality)
|
||||
write_data(&fp, img->pixels, img->bpp);
|
||||
} else {
|
||||
uint32_t size;
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=img->w, .h=img->h, .bpp=size, .pixels=buffer };
|
||||
// When jpeg_compress needs more memory than in currently allocated it
|
||||
// will try to realloc. MP will detect that the pointer is outside of
|
||||
|
||||
@ -2626,7 +2626,7 @@ float * lsd(int * n_out, unsigned char * img, int X, int Y)
|
||||
|
||||
void imlib_lsd_find_line_segments(list_t *out, image_t *ptr, rectangle_t *roi, unsigned int merge_distance, unsigned int max_theta_diff)
|
||||
{
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h);
|
||||
uint8_t *grayscale_image = fb_alloc(roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
uint8_t *grayscale_image_tmp = grayscale_image;
|
||||
umm_init_x(fb_avail());
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ void imlib_gamma_corr(image_t *img, float gamma, float contrast, float brightnes
|
||||
case IMAGE_BPP_BINARY: {
|
||||
float pScale = COLOR_BINARY_MAX - COLOR_BINARY_MIN;
|
||||
float pDiv = 1 / pScale;
|
||||
int *p_lut = fb_alloc((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(int));
|
||||
int *p_lut = fb_alloc((COLOR_BINARY_MAX - COLOR_BINARY_MIN + 1) * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = COLOR_BINARY_MIN; i <= COLOR_BINARY_MAX; i++) {
|
||||
int p = ((fast_powf(i * pDiv, gamma) * contrast) + brightness) * pScale;
|
||||
@ -40,7 +40,7 @@ void imlib_gamma_corr(image_t *img, float gamma, float contrast, float brightnes
|
||||
case IMAGE_BPP_GRAYSCALE: {
|
||||
float pScale = COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN;
|
||||
float pDiv = 1 / pScale;
|
||||
int *p_lut = fb_alloc((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(int));
|
||||
int *p_lut = fb_alloc((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN + 1) * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = COLOR_GRAYSCALE_MIN; i <= COLOR_GRAYSCALE_MAX; i++) {
|
||||
int p = ((fast_powf(i * pDiv, gamma) * contrast) + brightness) * pScale;
|
||||
@ -66,9 +66,9 @@ void imlib_gamma_corr(image_t *img, float gamma, float contrast, float brightnes
|
||||
float rDiv = 1 / rScale;
|
||||
float gDiv = 1 / gScale;
|
||||
float bDiv = 1 / bScale;
|
||||
int *r_lut = fb_alloc((COLOR_R5_MAX - COLOR_R5_MIN + 1) * sizeof(int));
|
||||
int *g_lut = fb_alloc((COLOR_G6_MAX - COLOR_G6_MIN + 1) * sizeof(int));
|
||||
int *b_lut = fb_alloc((COLOR_B5_MAX - COLOR_B5_MIN + 1) * sizeof(int));
|
||||
int *r_lut = fb_alloc((COLOR_R5_MAX - COLOR_R5_MIN + 1) * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *g_lut = fb_alloc((COLOR_G6_MAX - COLOR_G6_MIN + 1) * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *b_lut = fb_alloc((COLOR_B5_MAX - COLOR_B5_MIN + 1) * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = COLOR_R5_MIN; i <= COLOR_R5_MAX; i++) {
|
||||
int r = ((fast_powf(i * rDiv, gamma) * contrast) + brightness) * rScale;
|
||||
@ -223,7 +223,7 @@ void imlib_replace(image_t *img, const char *path, image_t *other, int scalar, b
|
||||
|
||||
if (in_place) {
|
||||
memcpy(&temp, other, sizeof(image_t));
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, other->data, image_size(&temp));
|
||||
other = &temp;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ void mjpeg_add_frame(FIL *fp, uint32_t *frames, uint32_t *bytes, image_t *img, i
|
||||
*bytes += img->bpp + pad;
|
||||
} else {
|
||||
uint32_t size;
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=img->w, .h=img->h, .bpp=size, .pixels=buffer };
|
||||
// When jpeg_compress needs more memory than in currently allocated it
|
||||
// will try to realloc. MP will detect that the pointer is outside of
|
||||
|
||||
@ -379,7 +379,7 @@ array_t *orb_find_keypoints(image_t *img, bool normalized, int threshold,
|
||||
break;
|
||||
}
|
||||
|
||||
img_scaled.pixels = fb_alloc(img_scaled.w * img_scaled.h);
|
||||
img_scaled.pixels = fb_alloc(img_scaled.w * img_scaled.h, FB_ALLOC_NO_HINT);
|
||||
// Down scale image
|
||||
image_scale(img, &img_scaled);
|
||||
|
||||
@ -600,7 +600,7 @@ int orb_filter_keypoints(array_t *kpts, rectangle_t *r, point_t *c)
|
||||
r->w = r->h = 0;
|
||||
r->x = r->y = 20000;
|
||||
|
||||
float *kpts_dist = fb_alloc(kpts_size * sizeof(float));
|
||||
float *kpts_dist = fb_alloc(kpts_size * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
// Find centroid
|
||||
for (int i=0; i<kpts_size; i++) {
|
||||
|
||||
@ -129,7 +129,7 @@ void imlib_logpolar(image_t *img, bool linear, bool reverse)
|
||||
img_2.w = img->w;
|
||||
img_2.h = img->h;
|
||||
img_2.bpp = img->bpp;
|
||||
img_2.data = fb_alloc(image_size(img));
|
||||
img_2.data = fb_alloc(image_size(img), FB_ALLOC_NO_HINT);
|
||||
|
||||
rectangle_t rect;
|
||||
rect.x = 0;
|
||||
@ -291,7 +291,7 @@ void imlib_phasecorrelate(image_t *img0, image_t *img1, rectangle_t *roi0, recta
|
||||
img0_fixed.w = roi0->w;
|
||||
img0_fixed.h = roi0->h;
|
||||
img0_fixed.bpp = img0->bpp;
|
||||
img0_fixed.data = fb_alloc(image_size(&img0_fixed));
|
||||
img0_fixed.data = fb_alloc(image_size(&img0_fixed), FB_ALLOC_NO_HINT);
|
||||
|
||||
roi0_fixed.x = 0;
|
||||
roi0_fixed.y = 0;
|
||||
@ -347,7 +347,7 @@ void imlib_phasecorrelate(image_t *img0, image_t *img1, rectangle_t *roi0, recta
|
||||
img0alt.w = roi0_fixed.w;
|
||||
img0alt.h = roi0_fixed.h;
|
||||
img0alt.bpp = img0_fixed.bpp;
|
||||
img0alt.data = fb_alloc0(image_size(&img0alt));
|
||||
img0alt.data = fb_alloc0(image_size(&img0alt), FB_ALLOC_NO_HINT);
|
||||
imlib_logpolar_int(&img0alt, &img0_fixed, &roi0_fixed, false, false);
|
||||
roi0alt.x = 0;
|
||||
roi0alt.y = 0;
|
||||
@ -357,7 +357,7 @@ void imlib_phasecorrelate(image_t *img0, image_t *img1, rectangle_t *roi0, recta
|
||||
img1alt.w = roi1->w;
|
||||
img1alt.h = roi1->h;
|
||||
img1alt.bpp = img1->bpp;
|
||||
img1alt.data = fb_alloc0(image_size(&img1alt));
|
||||
img1alt.data = fb_alloc0(image_size(&img1alt), FB_ALLOC_NO_HINT);
|
||||
imlib_logpolar_int(&img1alt, img1, roi1, false, false);
|
||||
roi1alt.x = 0;
|
||||
roi1alt.y = 0;
|
||||
|
||||
@ -2795,7 +2795,7 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
|
||||
struct quirc_data *data)
|
||||
{
|
||||
quirc_decode_error_t err;
|
||||
struct datastream *ds = fb_alloc(sizeof(struct datastream));
|
||||
struct datastream *ds = fb_alloc(sizeof(struct datastream), FB_ALLOC_NO_HINT);
|
||||
|
||||
if ((code->size - 17) % 4)
|
||||
{ fb_free(); return QUIRC_ERROR_INVALID_GRID_SIZE; }
|
||||
@ -2855,7 +2855,7 @@ const char *quirc_version(void)
|
||||
|
||||
struct quirc *quirc_new(void)
|
||||
{
|
||||
struct quirc *q = fb_alloc(sizeof(*q));
|
||||
struct quirc *q = fb_alloc(sizeof(*q), FB_ALLOC_NO_HINT);
|
||||
|
||||
if (!q)
|
||||
return NULL;
|
||||
@ -2877,7 +2877,7 @@ void quirc_destroy(struct quirc *q)
|
||||
int quirc_resize(struct quirc *q, int w, int h)
|
||||
{
|
||||
if (q->image) fb_free();
|
||||
uint8_t *new_image = fb_alloc(w * h);
|
||||
uint8_t *new_image = fb_alloc(w * h, FB_ALLOC_NO_HINT);
|
||||
|
||||
if (!new_image)
|
||||
return -1;
|
||||
@ -2885,7 +2885,7 @@ int quirc_resize(struct quirc *q, int w, int h)
|
||||
if (sizeof(*q->image) != sizeof(*q->pixels)) {
|
||||
size_t new_size = w * h * sizeof(quirc_pixel_t);
|
||||
if (q->pixels) fb_free();
|
||||
quirc_pixel_t *new_pixels = fb_alloc(new_size);
|
||||
quirc_pixel_t *new_pixels = fb_alloc(new_size, FB_ALLOC_NO_HINT);
|
||||
if (!new_pixels) {
|
||||
fb_free();
|
||||
return -1;
|
||||
@ -2972,8 +2972,8 @@ void imlib_find_qrcodes(list_t *out, image_t *ptr, rectangle_t *roi)
|
||||
list_init(out, sizeof(find_qrcodes_list_lnk_data_t));
|
||||
|
||||
for (int i = 0, j = quirc_count(controller); i < j; i++) {
|
||||
struct quirc_code *code = fb_alloc(sizeof(struct quirc_code));
|
||||
struct quirc_data *data = fb_alloc(sizeof(struct quirc_data));
|
||||
struct quirc_code *code = fb_alloc(sizeof(struct quirc_code), FB_ALLOC_NO_HINT);
|
||||
struct quirc_data *data = fb_alloc(sizeof(struct quirc_data), FB_ALLOC_NO_HINT);
|
||||
quirc_extract(controller, i, code);
|
||||
|
||||
if(quirc_decode(code, data) == QUIRC_SUCCESS) {
|
||||
|
||||
@ -50,8 +50,8 @@ extern uint32_t rng_randint(uint32_t min, uint32_t max);
|
||||
|
||||
static universe *universe_create(int elements)
|
||||
{
|
||||
universe * uni = (universe*) fb_alloc(sizeof(universe));
|
||||
uni->elts = (uni_elt*) fb_alloc(sizeof(uni_elt)*elements);
|
||||
universe * uni = (universe*) fb_alloc(sizeof(universe), FB_ALLOC_NO_HINT);
|
||||
uni->elts = (uni_elt*) fb_alloc(sizeof(uni_elt)*elements, FB_ALLOC_NO_HINT);
|
||||
uni->num = elements;
|
||||
for (int i=0; i<elements; ++i) {
|
||||
uni->elts[i].p = i;
|
||||
@ -159,7 +159,7 @@ static void segment_graph(universe *u, int num_vertices, int num_edges, edge *ed
|
||||
{
|
||||
qsort (edges, num_edges, sizeof(edge), comp);
|
||||
|
||||
float *threshold = fb_alloc(num_vertices * sizeof(float));
|
||||
float *threshold = fb_alloc(num_vertices * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
for (int i=0; i<num_vertices; i++) {
|
||||
threshold[i] = THRESHOLD(1, c);
|
||||
}
|
||||
@ -212,10 +212,10 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
// Down scale image
|
||||
width = src->w / 4;
|
||||
height = src->h / 4;
|
||||
img = fb_alloc(sizeof(image_t));
|
||||
img = fb_alloc(sizeof(image_t), FB_ALLOC_NO_HINT);
|
||||
img->w = width;
|
||||
img->h = height;
|
||||
img->pixels = fb_alloc(width * height * 2);
|
||||
img->pixels = fb_alloc(width * height * 2, FB_ALLOC_NO_HINT);
|
||||
image_scale(src, img);
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
array_alloc(&proposals, xfree);
|
||||
|
||||
universe *u = universe_create (width * height);
|
||||
edge *edges = (edge*) fb_alloc(width * height * sizeof(edge) * 4);
|
||||
edge *edges = (edge*) fb_alloc(width * height * sizeof(edge) * 4, FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int y=0; y<height; y++) {
|
||||
for (int x=0; x<width; x++) {
|
||||
@ -271,7 +271,7 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
fb_free();
|
||||
|
||||
int num_ccs = universe_num_sets(u);
|
||||
region * regions = (region*) fb_alloc(num_ccs * sizeof(region));
|
||||
region * regions = (region*) fb_alloc(num_ccs * sizeof(region), FB_ALLOC_NO_HINT);
|
||||
for (i=0; i<num_ccs; i++) {
|
||||
regions[i].x = width;
|
||||
regions[i].w = 0;
|
||||
@ -280,9 +280,9 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
}
|
||||
|
||||
int next_component = 0;
|
||||
int *counts = (int*) fb_alloc0(num_ccs * sizeof(int));
|
||||
int *components= (int*) fb_alloc(num_ccs * sizeof(int));
|
||||
float *histogram = (float*) fb_alloc0(num_ccs * sizeof(float) * 75);
|
||||
int *counts = (int*) fb_alloc0(num_ccs * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int *components= (int*) fb_alloc(num_ccs * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
float *histogram = (float*) fb_alloc0(num_ccs * sizeof(float) * 75, FB_ALLOC_NO_HINT);
|
||||
|
||||
// Calc histograms
|
||||
for (int y=0; y<height; y++) {
|
||||
@ -330,7 +330,7 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t * adjacency = (uint8_t*) fb_alloc0(num_ccs * num_ccs * sizeof(uint8_t));
|
||||
uint8_t * adjacency = (uint8_t*) fb_alloc0(num_ccs * num_ccs * sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
for (int y=0; y<height-1; ++y) {
|
||||
for (int x=0; x<width-1; ++x) {
|
||||
int component1 = universe_get_id(u, y * width + x);
|
||||
@ -350,7 +350,7 @@ array_t *imlib_selective_search(image_t *src, float t, int min_size, float a1, f
|
||||
}
|
||||
|
||||
int size = height * width;
|
||||
float * similarity_table = (float*) fb_alloc(num_ccs * num_ccs * sizeof(float));
|
||||
float * similarity_table = (float*) fb_alloc(num_ccs * num_ccs * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
for (i = 0; i < num_ccs; ++i) {
|
||||
for (j = i + 1; j < num_ccs; ++j) {
|
||||
float color_sim = a1 * color_similarity (histogram + 75 * i, histogram + 75 * j);
|
||||
|
||||
@ -163,9 +163,9 @@ void imlib_remove_shadows(image_t *img, const char *path, image_t *other, int sc
|
||||
imlib_remove_shadows_line_op_state_t state;
|
||||
|
||||
for (int i = 0; i < imlib_remove_shadows_kernel_size; i++) {
|
||||
state.img_lines[i] = fb_alloc(img->w * sizeof(uint16_t));
|
||||
state.other_lines[i] = fb_alloc(img->w * sizeof(uint16_t));
|
||||
state.out_lines[i] = fb_alloc(img->w * sizeof(uint16_t));
|
||||
state.img_lines[i] = fb_alloc(img->w * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
state.other_lines[i] = fb_alloc(img->w * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
state.out_lines[i] = fb_alloc(img->w * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
}
|
||||
|
||||
state.lines_processed = 0;
|
||||
@ -185,7 +185,7 @@ void imlib_remove_shadows(image_t *img, const char *path, image_t *other, int sc
|
||||
temp_image.w = img->w;
|
||||
temp_image.h = img->h;
|
||||
temp_image.bpp = img->bpp;
|
||||
temp_image.data = fb_alloc(image_size(img));
|
||||
temp_image.data = fb_alloc(image_size(img), FB_ALLOC_NO_HINT);
|
||||
|
||||
memcpy(temp_image.data, img->data, image_size(img));
|
||||
|
||||
@ -199,9 +199,9 @@ void imlib_remove_shadows(image_t *img, const char *path, image_t *other, int sc
|
||||
h.LBinCount = COLOR_L_MAX - COLOR_L_MIN + 1;
|
||||
h.ABinCount = COLOR_A_MAX - COLOR_A_MIN + 1;
|
||||
h.BBinCount = COLOR_B_MAX - COLOR_B_MIN + 1;
|
||||
h.LBins = fb_alloc(h.LBinCount * sizeof(float));
|
||||
h.ABins = fb_alloc(h.ABinCount * sizeof(float));
|
||||
h.BBins = fb_alloc(h.BBinCount * sizeof(float));
|
||||
h.LBins = fb_alloc(h.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
h.ABins = fb_alloc(h.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
h.BBins = fb_alloc(h.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
imlib_get_histogram(&h, &temp_image, &r, NULL, false);
|
||||
|
||||
statistics_t s;
|
||||
@ -245,7 +245,7 @@ void imlib_remove_shadows(image_t *img, const char *path, image_t *other, int sc
|
||||
temp_image_2.w = temp_image.w;
|
||||
temp_image_2.h = temp_image.h;
|
||||
temp_image_2.bpp = temp_image.bpp;
|
||||
temp_image_2.data = fb_alloc(image_size(&temp_image));
|
||||
temp_image_2.data = fb_alloc(image_size(&temp_image), FB_ALLOC_NO_HINT);
|
||||
|
||||
memcpy(temp_image_2.data, temp_image.data, image_size(&temp_image));
|
||||
imlib_erode(&temp_image_2, 3, 48, NULL);
|
||||
|
||||
@ -121,11 +121,11 @@ void imlib_get_similarity(image_t *img, const char *path, image_t *other, int sc
|
||||
|
||||
int int_h_blocks = h_blocks * sizeof(int);
|
||||
imlib_similatiry_line_op_state_t state;
|
||||
state.sumBucketsOfX = fb_alloc0(int_h_blocks);
|
||||
state.sumBucketsOfY = fb_alloc0(int_h_blocks);
|
||||
state.sum2BucketsOfX = fb_alloc0(int_h_blocks);
|
||||
state.sum2BucketsOfY = fb_alloc0(int_h_blocks);
|
||||
state.sum2Buckets = fb_alloc0(int_h_blocks);
|
||||
state.sumBucketsOfX = fb_alloc0(int_h_blocks, FB_ALLOC_NO_HINT);
|
||||
state.sumBucketsOfY = fb_alloc0(int_h_blocks, FB_ALLOC_NO_HINT);
|
||||
state.sum2BucketsOfX = fb_alloc0(int_h_blocks, FB_ALLOC_NO_HINT);
|
||||
state.sum2BucketsOfY = fb_alloc0(int_h_blocks, FB_ALLOC_NO_HINT);
|
||||
state.sum2Buckets = fb_alloc0(int_h_blocks, FB_ALLOC_NO_HINT);
|
||||
state.similarity_sum = 0.0f;
|
||||
state.similarity_sum_2 = 0.0f;
|
||||
state.similarity_min = FLT_MAX;
|
||||
@ -862,14 +862,14 @@ bool imlib_get_regression(find_lines_list_lnk_data_t *out, image_t *ptr, rectang
|
||||
}
|
||||
}
|
||||
} else { // Theil-Sen Estimator
|
||||
int *x_histogram = fb_alloc0(ptr->w * sizeof(int)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
int *y_histogram = fb_alloc0(ptr->h * sizeof(int)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
int *x_histogram = fb_alloc0(ptr->w * sizeof(int), FB_ALLOC_NO_HINT); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
int *y_histogram = fb_alloc0(ptr->h * sizeof(int), FB_ALLOC_NO_HINT); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
|
||||
long long *x_delta_histogram = fb_alloc0((2 * ptr->w) * sizeof(long long)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
long long *y_delta_histogram = fb_alloc0((2 * ptr->h) * sizeof(long long)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
long long *x_delta_histogram = fb_alloc0((2 * ptr->w) * sizeof(long long), FB_ALLOC_NO_HINT); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
long long *y_delta_histogram = fb_alloc0((2 * ptr->h) * sizeof(long long), FB_ALLOC_NO_HINT); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
|
||||
uint32_t size;
|
||||
point_t *points = (point_t *) fb_alloc_all(&size);
|
||||
point_t *points = (point_t *) fb_alloc_all(&size, FB_ALLOC_NO_HINT);
|
||||
size_t points_max = size / sizeof(point_t);
|
||||
size_t points_count = 0;
|
||||
|
||||
|
||||
@ -8713,7 +8713,7 @@ void zbar_scanner_get_state (const zbar_scanner_t *scn,
|
||||
|
||||
void imlib_find_barcodes(list_t *out, image_t *ptr, rectangle_t *roi)
|
||||
{
|
||||
uint8_t *grayscale_image = (ptr->bpp == IMAGE_BPP_GRAYSCALE) ? ptr->data : fb_alloc(roi->w * roi->h);
|
||||
uint8_t *grayscale_image = (ptr->bpp == IMAGE_BPP_GRAYSCALE) ? ptr->data : fb_alloc(roi->w * roi->h, FB_ALLOC_NO_HINT);
|
||||
umm_init_x(fb_avail());
|
||||
zbar_image_scanner_t *scanner = zbar_image_scanner_create();
|
||||
zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1);
|
||||
|
||||
@ -364,9 +364,9 @@ int nn_run_network(nn_t *net, image_t *img, rectangle_t *roi, bool softmax)
|
||||
|
||||
fb_alloc_mark();
|
||||
|
||||
q7_t *buffer1 = fb_alloc(net->max_scrbuf_size);
|
||||
q7_t *buffer1 = fb_alloc(net->max_scrbuf_size, FB_ALLOC_NO_HINT);
|
||||
q7_t *buffer2 = buffer1 + net->max_layer_size;
|
||||
q7_t *col_buffer = fb_alloc(net->max_colbuf_size);
|
||||
q7_t *col_buffer = fb_alloc(net->max_colbuf_size, FB_ALLOC_NO_HINT);
|
||||
|
||||
while (layer != NULL) {
|
||||
layer_t *prev_layer = layer->prev;
|
||||
@ -374,7 +374,7 @@ int nn_run_network(nn_t *net, image_t *img, rectangle_t *roi, bool softmax)
|
||||
switch (layer->type) {
|
||||
case LAYER_TYPE_DATA: {
|
||||
data_layer_t *data_layer = (data_layer_t *) layer;
|
||||
input_data = fb_alloc(data_layer->c * data_layer->h * data_layer->w);
|
||||
input_data = fb_alloc(data_layer->c * data_layer->h * data_layer->w, FB_ALLOC_NO_HINT);
|
||||
nn_transform_input(data_layer, img, input_data, roi);
|
||||
// Set image data as input buffer for the next layer.
|
||||
input_buffer = input_data;
|
||||
@ -528,7 +528,7 @@ int nn_dry_run_network(nn_t *net, image_t *img, bool softmax)
|
||||
|
||||
fb_alloc_mark();
|
||||
|
||||
q7_t *buffer1 = fb_alloc(net->max_scrbuf_size);
|
||||
q7_t *buffer1 = fb_alloc(net->max_scrbuf_size, FB_ALLOC_NO_HINT);
|
||||
q7_t *buffer2 = buffer1 + net->max_layer_size;
|
||||
|
||||
while (layer != NULL) {
|
||||
@ -537,7 +537,7 @@ int nn_dry_run_network(nn_t *net, image_t *img, bool softmax)
|
||||
case LAYER_TYPE_DATA: {
|
||||
data_layer_t *data_layer = (data_layer_t *) layer;
|
||||
// Set image data as input buffer for the next layer.
|
||||
input_buffer = input_data = fb_alloc(data_layer->c * data_layer->h * data_layer->w);
|
||||
input_buffer = input_data = fb_alloc(data_layer->c * data_layer->h * data_layer->w, FB_ALLOC_NO_HINT);
|
||||
output_buffer = buffer1;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ static float calculate_Ta() // ambient temp
|
||||
static void calculate_To(float Ta, float *To)
|
||||
{
|
||||
fb_alloc_mark();
|
||||
int16_t *v_ir = fb_alloc(64 * sizeof(int16_t));
|
||||
int16_t *v_ir = fb_alloc(64 * sizeof(int16_t), FB_ALLOC_NO_HINT);
|
||||
// Read IR sensor result
|
||||
test_ack(soft_i2c_write_bytes(FIR_MODULE_ADDR,
|
||||
(uint8_t [4]){FIR_READ_CMD, 0x00, 0x01, 0x40}, 4, false));
|
||||
@ -264,7 +264,7 @@ mp_obj_t py_fir_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
alpha_ij = xalloc(64 * sizeof(*alpha_ij));
|
||||
|
||||
fb_alloc_mark();
|
||||
uint8_t *eeprom = fb_alloc(256 * sizeof(uint8_t));
|
||||
uint8_t *eeprom = fb_alloc(256 * sizeof(uint8_t), FB_ALLOC_NO_HINT);
|
||||
// Read the whole eeprom.
|
||||
test_ack(soft_i2c_write_bytes(FIR_EEPROM_ADDR,
|
||||
(uint8_t [1]){0x00}, 1, false));
|
||||
@ -368,7 +368,7 @@ mp_obj_t py_fir_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
error |= MLX90640_SetRefreshRate(MLX90640_ADDR, IR_refresh_rate);
|
||||
|
||||
fb_alloc_mark();
|
||||
uint16_t *eeprom = fb_alloc(832 * sizeof(uint16_t));
|
||||
uint16_t *eeprom = fb_alloc(832 * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
error |= MLX90640_DumpEE(MLX90640_ADDR, eeprom);
|
||||
error |= MLX90640_ExtractParameters(eeprom, (paramsMLX90640 *) alpha_ij);
|
||||
|
||||
@ -447,7 +447,7 @@ mp_obj_t py_fir_read_ta()
|
||||
case FIR_MLX90640:
|
||||
{
|
||||
fb_alloc_mark();
|
||||
uint16_t *data = fb_alloc(834 * sizeof(uint16_t));
|
||||
uint16_t *data = fb_alloc(834 * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
PY_ASSERT_TRUE_MSG(MLX90640_GetFrameData(MLX90640_ADDR, data) >= 0,
|
||||
"Failed to read the MLX90640 sensor data!");
|
||||
mp_obj_t result = mp_obj_new_float(MLX90640_GetTa(data, (paramsMLX90640 *) alpha_ij));
|
||||
@ -475,7 +475,7 @@ mp_obj_t py_fir_read_ir()
|
||||
case FIR_SHIELD:
|
||||
{
|
||||
fb_alloc_mark();
|
||||
float *To = fb_alloc(64 * sizeof(float)), *To_rot = fb_alloc(64 * sizeof(float));
|
||||
float *To = fb_alloc(64 * sizeof(float), FB_ALLOC_NO_HINT), *To_rot = fb_alloc(64 * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
float Ta = calculate_Ta();
|
||||
float min = FLT_MAX, max = FLT_MIN;
|
||||
|
||||
@ -507,12 +507,12 @@ mp_obj_t py_fir_read_ir()
|
||||
case FIR_MLX90640:
|
||||
{
|
||||
fb_alloc_mark();
|
||||
uint16_t *data = fb_alloc(834 * sizeof(uint16_t));
|
||||
uint16_t *data = fb_alloc(834 * sizeof(uint16_t), FB_ALLOC_NO_HINT);
|
||||
// Calculate 1st sub-frame...
|
||||
PY_ASSERT_TRUE_MSG(MLX90640_GetFrameData(MLX90640_ADDR, data) >= 0,
|
||||
"Failed to read the MLX90640 sensor data!");
|
||||
float Ta = MLX90640_GetTa(data, (paramsMLX90640 *) alpha_ij);
|
||||
float *To = fb_alloc0(768 * sizeof(float));
|
||||
float *To = fb_alloc0(768 * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
MLX90640_CalculateTo(data, (paramsMLX90640 *) alpha_ij, 0.95, Ta - 8, To);
|
||||
// Calculate 2nd sub-frame...
|
||||
PY_ASSERT_TRUE_MSG(MLX90640_GetFrameData(MLX90640_ADDR, data) >= 0,
|
||||
@ -552,7 +552,7 @@ mp_obj_t py_fir_read_ir()
|
||||
|
||||
test_ack(soft_i2c_write_bytes(AMG8833_ADDR, (uint8_t [1]){0x80}, 1, true));
|
||||
fb_alloc_mark();
|
||||
int16_t *data = fb_alloc(64 * sizeof(int16_t));
|
||||
int16_t *data = fb_alloc(64 * sizeof(int16_t), FB_ALLOC_NO_HINT);
|
||||
test_ack(soft_i2c_read_bytes(AMG8833_ADDR, (uint8_t *) data, 128, true));
|
||||
float To[64], min = FLT_MAX, max = FLT_MIN;
|
||||
for (int i = 0; i < 64; i++) {
|
||||
@ -655,7 +655,7 @@ mp_obj_t py_fir_draw_ir(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_get_array_fixed_n(args[1], width*height, &arg_To);
|
||||
|
||||
fb_alloc_mark();
|
||||
float *To = fb_alloc(width*height * sizeof(float)), min = FLT_MAX, max = FLT_MIN;
|
||||
float *To = fb_alloc(width*height * sizeof(float), FB_ALLOC_NO_HINT), min = FLT_MAX, max = FLT_MIN;
|
||||
for (int i=0; i<width*height; i++) {
|
||||
float temp = To[i] = mp_obj_get_float(arg_To[i]);
|
||||
min = IM_MIN(min, temp);
|
||||
|
||||
@ -787,7 +787,7 @@ static mp_obj_t py_image_to_bitmap(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
PY_ASSERT_TRUE_MSG((out.w >= (sizeof(uint32_t)/sizeof(uint8_t))) || copy,
|
||||
"Can't convert to bitmap in place!");
|
||||
fb_alloc_mark();
|
||||
uint32_t *out_row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(&out));
|
||||
uint32_t *out_row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(&out), FB_ALLOC_NO_HINT);
|
||||
for (int y = 0, yy = out.h; y < yy; y++) {
|
||||
uint8_t *row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(arg_img, y);
|
||||
for (int x = 0, xx = out.w; x < xx; x++) {
|
||||
@ -804,7 +804,7 @@ static mp_obj_t py_image_to_bitmap(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
PY_ASSERT_TRUE_MSG((out.w >= (sizeof(uint32_t)/sizeof(uint16_t))) || copy,
|
||||
"Can't convert to bitmap in place!");
|
||||
fb_alloc_mark();
|
||||
uint32_t *out_row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(&out));
|
||||
uint32_t *out_row_ptr = fb_alloc(IMAGE_BINARY_LINE_LEN_BYTES(&out), FB_ALLOC_NO_HINT);
|
||||
for (int y = 0, yy = out.h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(arg_img, y);
|
||||
for (int x = 0, xx = out.w; x < xx; x++) {
|
||||
@ -881,7 +881,7 @@ static mp_obj_t py_image_to_grayscale(uint n_args, const mp_obj_t *args, mp_map_
|
||||
image_t temp;
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
|
||||
MAIN_FB()->w = 0;
|
||||
@ -984,7 +984,7 @@ static mp_obj_t py_image_to_rgb565(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
image_t temp;
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
|
||||
MAIN_FB()->w = 0;
|
||||
@ -1024,7 +1024,7 @@ static mp_obj_t py_image_to_rgb565(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
image_t temp;
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
|
||||
MAIN_FB()->w = 0;
|
||||
@ -1132,7 +1132,7 @@ static mp_obj_t py_image_to_rainbow(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
image_t temp;
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
|
||||
MAIN_FB()->w = 0;
|
||||
@ -1172,7 +1172,7 @@ static mp_obj_t py_image_to_rainbow(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
image_t temp;
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
|
||||
MAIN_FB()->w = 0;
|
||||
@ -1250,7 +1250,7 @@ static mp_obj_t py_image_compress(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
|
||||
uint32_t size;
|
||||
fb_alloc_mark();
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=arg_img->w, .h=arg_img->h, .bpp=size, .data=buffer };
|
||||
PY_ASSERT_FALSE_MSG(jpeg_compress(arg_img, &out, arg_q, false), "Out of Memory!");
|
||||
PY_ASSERT_TRUE_MSG(out.bpp <= image_size(arg_img), "Can't compress in place!");
|
||||
@ -1274,7 +1274,7 @@ static mp_obj_t py_image_compress_for_ide(uint n_args, const mp_obj_t *args, mp_
|
||||
|
||||
uint32_t size;
|
||||
fb_alloc_mark();
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=arg_img->w, .h=arg_img->h, .bpp=size, .data=buffer };
|
||||
PY_ASSERT_FALSE_MSG(jpeg_compress(arg_img, &out, arg_q, false), "Out of Memory!");
|
||||
int new_size = encode_for_ide_new_size(&out);
|
||||
@ -1301,7 +1301,7 @@ static mp_obj_t py_image_compressed(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
|
||||
uint32_t size;
|
||||
fb_alloc_mark();
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=arg_img->w, .h=arg_img->h, .bpp=size, .data=buffer };
|
||||
PY_ASSERT_FALSE_MSG(jpeg_compress(arg_img, &out, arg_q, false), "Out of Memory!");
|
||||
uint8_t *temp = xalloc(out.bpp);
|
||||
@ -1321,7 +1321,7 @@ static mp_obj_t py_image_compressed_for_ide(uint n_args, const mp_obj_t *args, m
|
||||
|
||||
uint32_t size;
|
||||
fb_alloc_mark();
|
||||
uint8_t *buffer = fb_alloc_all(&size);
|
||||
uint8_t *buffer = fb_alloc_all(&size, FB_ALLOC_PREFER_SIZE);
|
||||
image_t out = { .w=arg_img->w, .h=arg_img->h, .bpp=size, .data=buffer };
|
||||
PY_ASSERT_FALSE_MSG(jpeg_compress(arg_img, &out, arg_q, false), "Out of Memory!");
|
||||
int new_size = encode_for_ide_new_size(&out);
|
||||
@ -1344,7 +1344,7 @@ static mp_obj_t py_image_jpeg_encode_for_ide(mp_obj_t img_obj)
|
||||
|
||||
int new_size = encode_for_ide_new_size(arg_img);
|
||||
fb_alloc_mark();
|
||||
uint8_t *temp = fb_alloc(new_size);
|
||||
uint8_t *temp = fb_alloc(new_size, FB_ALLOC_NO_HINT);
|
||||
encode_for_ide(temp, arg_img);
|
||||
|
||||
MAIN_FB()->bpp = 0;
|
||||
@ -1439,7 +1439,7 @@ static mp_obj_t py_image_copy_int(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
if (in_place) {
|
||||
memcpy(&temp, arg_img, sizeof(image_t));
|
||||
fb_alloc_mark();
|
||||
temp.data = fb_alloc(image_size(&temp));
|
||||
temp.data = fb_alloc(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
memcpy(temp.data, arg_img->data, image_size(&temp));
|
||||
arg_img = &temp;
|
||||
if (copy_to_fb) {
|
||||
@ -1919,7 +1919,7 @@ STATIC mp_obj_t py_image_mask_rectangle(uint n_args, const mp_obj_t *args, mp_ma
|
||||
temp.w = arg_img->w;
|
||||
temp.h = arg_img->h;
|
||||
temp.bpp = IMAGE_BPP_BINARY;
|
||||
temp.data = fb_alloc0(image_size(&temp));
|
||||
temp.data = fb_alloc0(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
|
||||
imlib_draw_rectangle(&temp, arg_rx, arg_ry, arg_rw, arg_rh, -1, 0, true);
|
||||
imlib_zero(arg_img, &temp, true);
|
||||
@ -1953,7 +1953,7 @@ STATIC mp_obj_t py_image_mask_circle(uint n_args, const mp_obj_t *args, mp_map_t
|
||||
temp.w = arg_img->w;
|
||||
temp.h = arg_img->h;
|
||||
temp.bpp = IMAGE_BPP_BINARY;
|
||||
temp.data = fb_alloc0(image_size(&temp));
|
||||
temp.data = fb_alloc0(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
|
||||
imlib_draw_circle(&temp, arg_cx, arg_cy, arg_cr, -1, 0, true);
|
||||
imlib_zero(arg_img, &temp, true);
|
||||
@ -1993,7 +1993,7 @@ STATIC mp_obj_t py_image_mask_ellipse(uint n_args, const mp_obj_t *args, mp_map_
|
||||
temp.w = arg_img->w;
|
||||
temp.h = arg_img->h;
|
||||
temp.bpp = IMAGE_BPP_BINARY;
|
||||
temp.data = fb_alloc0(image_size(&temp));
|
||||
temp.data = fb_alloc0(image_size(&temp), FB_ALLOC_NO_HINT);
|
||||
|
||||
imlib_draw_ellipse(&temp, arg_cx, arg_cy, arg_rx, arg_ry, arg_r, -1, 0, true);
|
||||
imlib_zero(arg_img, &temp, true);
|
||||
@ -2798,7 +2798,7 @@ STATIC mp_obj_t py_image_morph(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
||||
|
||||
fb_alloc_mark();
|
||||
|
||||
int *arg_krn = fb_alloc(n * sizeof(int));
|
||||
int *arg_krn = fb_alloc(n * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int arg_m = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
@ -2843,14 +2843,14 @@ STATIC mp_obj_t py_image_gaussian(uint n_args, const mp_obj_t *args, mp_map_t *k
|
||||
|
||||
fb_alloc_mark();
|
||||
|
||||
int *pascal = fb_alloc(n * sizeof(int));
|
||||
int *pascal = fb_alloc(n * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
pascal[0] = 1;
|
||||
|
||||
for (int i = 0; i < k_2; i++) { // Compute a row of pascal's triangle.
|
||||
pascal[i + 1] = (pascal[i] * (k_2 - i)) / (i + 1);
|
||||
}
|
||||
|
||||
int *arg_krn = fb_alloc(n * n * sizeof(int));
|
||||
int *arg_krn = fb_alloc(n * n * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int arg_m = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
@ -2899,14 +2899,14 @@ STATIC mp_obj_t py_image_laplacian(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
|
||||
fb_alloc_mark();
|
||||
|
||||
int *pascal = fb_alloc(n * sizeof(int));
|
||||
int *pascal = fb_alloc(n * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
pascal[0] = 1;
|
||||
|
||||
for (int i = 0; i < k_2; i++) { // Compute a row of pascal's triangle.
|
||||
pascal[i + 1] = (pascal[i] * (k_2 - i)) / (i + 1);
|
||||
}
|
||||
|
||||
int *arg_krn = fb_alloc(n * n * sizeof(int));
|
||||
int *arg_krn = fb_alloc(n * n * sizeof(int), FB_ALLOC_NO_HINT);
|
||||
int arg_m = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
@ -3710,9 +3710,9 @@ mp_obj_t py_histogram_get_percentile(mp_obj_t self_in, mp_obj_t percentile)
|
||||
hist.ABinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->ABins)->len;
|
||||
hist.BBinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->BBins)->len;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float));
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < hist.LBinCount; i++) {
|
||||
hist.LBins[i] = mp_obj_get_float(((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->LBins)->items[i]);
|
||||
@ -3748,9 +3748,9 @@ mp_obj_t py_histogram_get_threshold(mp_obj_t self_in)
|
||||
hist.ABinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->ABins)->len;
|
||||
hist.BBinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->BBins)->len;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float));
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < hist.LBinCount; i++) {
|
||||
hist.LBins[i] = mp_obj_get_float(((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->LBins)->items[i]);
|
||||
@ -3786,9 +3786,9 @@ mp_obj_t py_histogram_get_statistics(mp_obj_t self_in)
|
||||
hist.ABinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->ABins)->len;
|
||||
hist.BBinCount = ((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->BBins)->len;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float));
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
|
||||
for (int i = 0; i < hist.LBinCount; i++) {
|
||||
hist.LBins[i] = mp_obj_get_float(((mp_obj_list_t *) ((py_histogram_obj_t *) self_in)->LBins)->items[i]);
|
||||
@ -3891,7 +3891,7 @@ static mp_obj_t py_image_get_histogram(uint n_args, const mp_obj_t *args, mp_map
|
||||
hist.ABinCount = 0;
|
||||
hist.BBinCount = 0;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = NULL;
|
||||
hist.BBins = NULL;
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
@ -3907,7 +3907,7 @@ static mp_obj_t py_image_get_histogram(uint n_args, const mp_obj_t *args, mp_map
|
||||
hist.ABinCount = 0;
|
||||
hist.BBinCount = 0;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = NULL;
|
||||
hist.BBins = NULL;
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
@ -3931,9 +3931,9 @@ static mp_obj_t py_image_get_histogram(uint n_args, const mp_obj_t *args, mp_map
|
||||
hist.BBinCount = py_helper_keyword_int(n_args, args, n_args, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_b_bins), b_bins);
|
||||
PY_ASSERT_TRUE_MSG(hist.BBinCount >= 2, "b_bins must be >= 2");
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float));
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
list_free(&thresholds);
|
||||
break;
|
||||
@ -3992,7 +3992,7 @@ static mp_obj_t py_image_get_statistics(uint n_args, const mp_obj_t *args, mp_ma
|
||||
hist.ABinCount = 0;
|
||||
hist.BBinCount = 0;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = NULL;
|
||||
hist.BBins = NULL;
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
@ -4008,7 +4008,7 @@ static mp_obj_t py_image_get_statistics(uint n_args, const mp_obj_t *args, mp_ma
|
||||
hist.ABinCount = 0;
|
||||
hist.BBinCount = 0;
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = NULL;
|
||||
hist.BBins = NULL;
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
@ -4032,9 +4032,9 @@ static mp_obj_t py_image_get_statistics(uint n_args, const mp_obj_t *args, mp_ma
|
||||
hist.BBinCount = py_helper_keyword_int(n_args, args, n_args, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_b_bins), b_bins);
|
||||
PY_ASSERT_TRUE_MSG(hist.BBinCount >= 2, "b_bins must be >= 2");
|
||||
fb_alloc_mark();
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float));
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float));
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float));
|
||||
hist.LBins = fb_alloc(hist.LBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.ABins = fb_alloc(hist.ABinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
hist.BBins = fb_alloc(hist.BBinCount * sizeof(float), FB_ALLOC_NO_HINT);
|
||||
imlib_get_histogram(&hist, arg_img, &roi, &thresholds, invert);
|
||||
list_free(&thresholds);
|
||||
break;
|
||||
@ -7354,7 +7354,7 @@ static mp_obj_t py_image_match_descriptor(uint n_args, const mp_obj_t *args, mp_
|
||||
|
||||
if (array_length(kpts1->kpts) && array_length(kpts1->kpts)) {
|
||||
fb_alloc_mark();
|
||||
int *match = fb_alloc(array_length(kpts1->kpts) * sizeof(int) * 2);
|
||||
int *match = fb_alloc(array_length(kpts1->kpts) * sizeof(int) * 2, FB_ALLOC_NO_HINT);
|
||||
|
||||
// Match the two keypoint sets
|
||||
count = orb_match_keypoints(kpts1->kpts, kpts2->kpts, match, threshold, &r, &c, &theta);
|
||||
|
||||
@ -313,8 +313,8 @@ static mp_obj_t py_lcd_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
||||
case LCD_SHIELD:
|
||||
lcd_write_command_byte(0x2C);
|
||||
fb_alloc_mark();
|
||||
uint8_t *zero = fb_alloc0(width*2);
|
||||
uint16_t *line = fb_alloc(width*2);
|
||||
uint8_t *zero = fb_alloc0(width*2, FB_ALLOC_NO_HINT);
|
||||
uint16_t *line = fb_alloc(width*2, FB_ALLOC_NO_HINT);
|
||||
for (int i=0; i<t_pad; i++) {
|
||||
lcd_write_data(width*2, zero);
|
||||
}
|
||||
@ -354,7 +354,7 @@ static mp_obj_t py_lcd_clear()
|
||||
case LCD_SHIELD:
|
||||
lcd_write_command_byte(0x2C);
|
||||
fb_alloc_mark();
|
||||
uint8_t *zero = fb_alloc0(width*2);
|
||||
uint8_t *zero = fb_alloc0(width*2, FB_ALLOC_NO_HINT);
|
||||
for (int i=0; i<height; i++) {
|
||||
lcd_write_data(width*2, zero);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ static mp_obj_t py_sensor_alloc_extra_fb(mp_obj_t w_obj, mp_obj_t h_obj, mp_obj_
|
||||
// Alloc image first (could fail) then alloc RAM so that there's no leak on failure.
|
||||
mp_obj_t r = py_image_from_struct(&img);
|
||||
// Don't mark before on purpose.
|
||||
((image_t *) py_image_cobj(r))->pixels = fb_alloc0(image_size(&img));
|
||||
((image_t *) py_image_cobj(r))->pixels = fb_alloc0(image_size(&img), FB_ALLOC_NO_HINT);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@ -556,7 +556,7 @@ static mp_obj_t py_tv_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
|
||||
uint16_t y = y1;
|
||||
|
||||
fb_alloc_mark();
|
||||
uint8_t *line = fb_alloc(w*2);
|
||||
uint8_t *line = fb_alloc(w*2, FB_ALLOC_NO_HINT);
|
||||
|
||||
while (y < y2) {
|
||||
address = PICLINE_BYTE_ADDRESS(y) + x1;
|
||||
|
||||
@ -243,7 +243,7 @@ void umm_init_x( size_t size ) {
|
||||
uint32_t UMM_MALLOC_CFG_HEAP_SIZE = (size / sizeof(size_t)) * sizeof(size_t);
|
||||
if (UMM_MALLOC_CFG_HEAP_SIZE < (sizeof(umm_block) * 128)) fb_alloc_fail();
|
||||
if (UMM_MALLOC_CFG_HEAP_SIZE > (sizeof(umm_block) * 32768)) UMM_MALLOC_CFG_HEAP_SIZE = sizeof(umm_block) * 32768;
|
||||
void *UMM_MALLOC_CFG_HEAP_ADDR = fb_alloc(UMM_MALLOC_CFG_HEAP_SIZE);
|
||||
void *UMM_MALLOC_CFG_HEAP_ADDR = fb_alloc(UMM_MALLOC_CFG_HEAP_SIZE, FB_ALLOC_NO_HINT);
|
||||
/* init heap pointer and size, and memset it to 0 */
|
||||
umm_heap = (umm_block *)UMM_MALLOC_CFG_HEAP_ADDR;
|
||||
umm_numblocks = (UMM_MALLOC_CFG_HEAP_SIZE / sizeof(umm_block));
|
||||
|
||||
@ -22,7 +22,7 @@ int burn_firmware(const char *path)
|
||||
UINT bytes = 0, bytes_out=0;
|
||||
|
||||
int ret = M2M_ERR_FAIL;
|
||||
uint8_t *buf = fb_alloc(FLASH_SECTOR_SZ);
|
||||
uint8_t *buf = fb_alloc(FLASH_SECTOR_SZ, FB_ALLOC_NO_HINT);
|
||||
|
||||
if (f_open_helper(&fp, path, FA_READ|FA_OPEN_EXISTING) != FR_OK) {
|
||||
goto error;
|
||||
@ -68,8 +68,8 @@ int verify_firmware(const char *path)
|
||||
UINT bytes = 0, bytes_out=0;
|
||||
|
||||
int ret = M2M_ERR_FAIL;
|
||||
uint8_t *file_buf = fb_alloc(FLASH_SECTOR_SZ);
|
||||
uint8_t *flash_buf = fb_alloc(FLASH_SECTOR_SZ);
|
||||
uint8_t *file_buf = fb_alloc(FLASH_SECTOR_SZ, FB_ALLOC_NO_HINT);
|
||||
uint8_t *flash_buf = fb_alloc(FLASH_SECTOR_SZ, FB_ALLOC_NO_HINT);
|
||||
|
||||
if (f_open_helper(&fp, path, FA_READ|FA_OPEN_EXISTING) != FR_OK) {
|
||||
goto error;
|
||||
@ -123,7 +123,7 @@ int dump_firmware(const char *path)
|
||||
UINT bytes = 0, bytes_out=0;
|
||||
|
||||
int ret = M2M_ERR_FAIL;
|
||||
uint8_t *flash_buf = fb_alloc(FLASH_SECTOR_SZ);
|
||||
uint8_t *flash_buf = fb_alloc(FLASH_SECTOR_SZ, FB_ALLOC_NO_HINT);
|
||||
|
||||
if (f_open_helper(&fp, path, FA_WRITE | FA_CREATE_ALWAYS) != FR_OK) {
|
||||
goto error;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user