Blob Blame History Raw
From 74b4a5ebf05f795a84a1e0e6c149464717921b73 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Thu, 28 Dec 2017 02:31:04 -0500
Subject: [PATCH 2/2] Fix ACE when # rows is not divisible by CPU count.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 src/pillowfight/_ace.c                  |   8 ++++++--
 tests/data/black_border_problem_all.jpg | Bin 1107404 -> 1107290 bytes
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/pillowfight/_ace.c b/src/pillowfight/_ace.c
index f3dd5f8..ebd5886 100644
--- a/src/pillowfight/_ace.c
+++ b/src/pillowfight/_ace.c
@@ -321,7 +321,9 @@ void pf_ace(const struct pf_bitmap *in, struct pf_bitmap *out,
 		adj_params[i]->start.x = 0;
 		adj_params[i]->start.y = (i * nb_lines_per_thread);
 		adj_params[i]->stop.x = in->size.x;
-		adj_params[i]->stop.y = MIN((i + 1) * nb_lines_per_thread, in->size.y);
+		adj_params[i]->stop.y = (i + 1) * nb_lines_per_thread;
+		if (i == nb_threads - 1)
+			adj_params[i]->stop.y = in->size.y;
 
 		adj_params[i]->slope = slope;
 		adj_params[i]->limit = limit;
@@ -362,7 +364,9 @@ void pf_ace(const struct pf_bitmap *in, struct pf_bitmap *out,
 		scaling_params[i]->start.x = 0;
 		scaling_params[i]->start.y = (i * nb_lines_per_thread);
 		scaling_params[i]->stop.x = in->size.x;
-		scaling_params[i]->stop.y = MIN((i + 1) * nb_lines_per_thread, in->size.y);
+		scaling_params[i]->stop.y = (i + 1) * nb_lines_per_thread;
+		if (i == nb_threads - 1)
+			scaling_params[i]->stop.y = in->size.y;
 		scaling_params[i]->rscore = &rscore;
 
 		scaling_params[i]->out = out;
-- 
2.13.6