Skip to content

Commit

Permalink
Improve the AWB stats cell size calculation
Browse files Browse the repository at this point in the history
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 <david.plowman@raspberrypi.com>
  • Loading branch information
davidplowman committed Oct 16, 2023
1 parent 6f1f25c commit ce5624e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/libpisp/frontend/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ void finalise_agc(pisp_fe_agc_stats_config &agc, uint16_t width, uint16_t height
void finalise_awb(pisp_fe_awb_stats_config &awb, uint16_t width, uint16_t height)
{
// Just a warning that ACLS algorithms might want the size calculations
// here to match the Back End LSC.
// here to match the Back End LSC. Here we round the cell width and height
// to the nearest even number.
if (awb.size_x == 0)
awb.size_x = std::max(2, ((width - 2 * awb.offset_x + PISP_AWB_STATS_SIZE - 1) / PISP_AWB_STATS_SIZE));
awb.size_x += (awb.size_x & 1);
awb.size_x = 2 * std::max(1, ((width - 2 * awb.offset_x + PISP_AWB_STATS_SIZE) / (2 * PISP_AWB_STATS_SIZE)));

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

void finalise_cdaf(pisp_fe_cdaf_stats_config &cdaf, uint16_t width, uint16_t height)
Expand Down

0 comments on commit ce5624e

Please sign in to comment.