Skip to content

Commit ce5624e

Browse files
committed
Improve the AWB stats cell size calculation
Round to the nearest even number. The previous calculation was rounding up over-aggressively, occasionally leaving the final row of cells without any pixels at all. Signed-off-by: David Plowman <[email protected]>
1 parent 6f1f25c commit ce5624e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libpisp/frontend/frontend.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,13 @@ void finalise_agc(pisp_fe_agc_stats_config &agc, uint16_t width, uint16_t height
102102
void finalise_awb(pisp_fe_awb_stats_config &awb, uint16_t width, uint16_t height)
103103
{
104104
// Just a warning that ACLS algorithms might want the size calculations
105-
// here to match the Back End LSC.
105+
// here to match the Back End LSC. Here we round the cell width and height
106+
// to the nearest even number.
106107
if (awb.size_x == 0)
107-
awb.size_x = std::max(2, ((width - 2 * awb.offset_x + PISP_AWB_STATS_SIZE - 1) / PISP_AWB_STATS_SIZE));
108-
awb.size_x += (awb.size_x & 1);
108+
awb.size_x = 2 * std::max(1, ((width - 2 * awb.offset_x + PISP_AWB_STATS_SIZE) / (2 * PISP_AWB_STATS_SIZE)));
109109

110110
if (awb.size_y == 0)
111-
awb.size_y = std::max(2, ((height - 2 * awb.offset_y + PISP_AWB_STATS_SIZE - 1) / PISP_AWB_STATS_SIZE));
112-
awb.size_y += (awb.size_y & 1);
111+
awb.size_y = 2 * std::max(1, ((height - 2 * awb.offset_y + PISP_AWB_STATS_SIZE) / (2 * PISP_AWB_STATS_SIZE)));
113112
}
114113

115114
void finalise_cdaf(pisp_fe_cdaf_stats_config &cdaf, uint16_t width, uint16_t height)

0 commit comments

Comments
 (0)