From 9b2260745590d76ade1176b4de1fcc212bf2883c Mon Sep 17 00:00:00 2001 From: Ilia Sibiryakov Date: Tue, 18 Jul 2017 17:04:13 +0100 Subject: [PATCH] Fixed FAT PURPLE bands that appeared with AMaZE Some core counts/image resolutions meant debayer stripe did not start on an even number, so the pixels were wrong colours, leading to funky purple images. Fixed now with % 2. --- src/debayer/debayer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/debayer/debayer.c b/src/debayer/debayer.c index fd59dea8..7df14de8 100644 --- a/src/debayer/debayer.c +++ b/src/debayer/debayer.c @@ -45,16 +45,22 @@ void debayerAmaze(uint16_t * debayerto, float * bayerdata, int width, int height /* Else do multithreading */ else { - uint16_t startchunk_y[threads]; - uint16_t endchunk_y[threads]; + int startchunk_y[threads]; + int endchunk_y[threads]; + + /* How big each thread's chunk is, multiple of 2 - or debayer + * would start on wrong pixel and magenta stripes appear */ + int chunk_height = height / threads; + chunk_height -= chunk_height % 2; /* Calculate chunks of image for each thread */ for (int thread = 0; thread < threads; ++thread) { - startchunk_y[thread] = ( (height) / threads ) * thread; - endchunk_y[thread] = ( ( (height) / threads ) * (thread + 1) ); + startchunk_y[thread] = chunk_height * thread; + endchunk_y[thread] = chunk_height * (thread + 1); } + /* Last chunk must reach end of frame */ endchunk_y[threads-1] = height; pthread_t thread_id[threads]; @@ -233,4 +239,4 @@ void debayerBasic(uint16_t * debayerto, float * bayerdata, int width, int height memcpy(debayerto, debayerto + (width * 3), width * 6); /* Unsure why width needs to be * 6, but * 3 didn't fill whole row */ memcpy(debayerto + (width * (height - 1) * 3), debayerto + (width * (height - 2) * 3), width * 6); -} \ No newline at end of file +}