libcamera: ipa: raspberrypi: ALSC: Resample luminance table

This fixes a bug where the luminance correction table was not being
resampled according to the camera mode, in the same way as the colour
tables. This could be noticeable if any camera modes crop
aggressively.

This resampling can be done "up front" in the SwitchMode, as we have
only a single fixed luminance table. In order to protect the
recalculation of the table from the asynchronous thread (which reads
it) I've elected to wait for that thread to go idle (though I doubt it
would have mattered much). As a by-product of stopping the thread, it
no longer needs its own copy of the camera mode (async_camera_mode_).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
David Plowman 2020-08-01 09:01:50 +01:00 committed by Laurent Pinchart
parent db552b0b92
commit 7f6b9121cc
2 changed files with 28 additions and 14 deletions

View file

@ -60,10 +60,10 @@ private:
AlscConfig config_;
bool first_time_;
CameraMode camera_mode_;
double luminance_table_[ALSC_CELLS_X * ALSC_CELLS_Y];
std::thread async_thread_;
void asyncFunc(); // asynchronous thread function
std::mutex mutex_;
CameraMode async_camera_mode_;
// condvar for async thread to wait on
std::condition_variable async_signal_;
// condvar for synchronous thread to wait on
@ -86,6 +86,7 @@ private:
int frame_count2_;
double sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X];
double prev_sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X];
void waitForAysncThread();
// The following are for the asynchronous thread to use, though the main
// thread can set/reset them if the async thread is known to be idle:
void restartAsync(StatisticsPtr &stats, Metadata *image_metadata);