From 4609f0295eaa3b8c2dd9f9179812479c1ee91001 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 1 Feb 2014 20:44:53 +0200 Subject: [PATCH] Use main RAM block exclusively for frame buffers * Remove malloc's on the main RAM block. --- src/imlib.c | 6 +++--- src/sensor.c | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index 75cd33958..148ec9289 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -472,7 +472,6 @@ struct array *imlib_merge_detections(struct array *rectangles) return objects; } - struct array *imlib_detect_objects(struct cascade *cascade, struct frame_buffer *fb) { /* scaling factor */ @@ -492,7 +491,8 @@ struct array *imlib_detect_objects(struct cascade *cascade, struct frame_buffer /* allocate buffer for integral image */ sum.width = fb->width; sum.height = fb->height; - sum.data = malloc(fb->width *fb->height*sizeof(*sum.data)); + //sum.data = malloc(fb->width *fb->height*sizeof(*sum.data)); + sum.data = (uint32_t*) fb->pixels+(fb->width * fb->height * 2); /* allocate the detections array */ array_alloc(&objects, free); @@ -534,7 +534,7 @@ struct array *imlib_detect_objects(struct cascade *cascade, struct frame_buffer ScaleImageInvoker(cascade, factor, sum.height, sum.width, objects); } - free(sum.data); + //free(sum.data); objects = imlib_merge_detections(objects); return objects; diff --git a/src/sensor.c b/src/sensor.c index ebd218176..1e9ebcf01 100644 --- a/src/sensor.c +++ b/src/sensor.c @@ -496,11 +496,16 @@ int sensor_set_framesize(struct sensor_dev *sensor, enum sensor_framesize frames return -1; } +#if 0 /* realloc frame buffer */ if ((fb->pixels = realloc(/* always allocate 2 bpp */ fb->pixels, fb->width * fb->height * 2)) == NULL) { return -1; } +#else + extern char _heap_start; + fb->pixels = &_heap_start; +#endif /* Reconfigure the DMA stream */ dma_config(fb->pixels, fb->width * fb->height * 2);