From patchwork Tue Sep 22 09:50:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9697 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 81EF3C3B5B for ; Tue, 22 Sep 2020 09:50:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3CC6062FD2; Tue, 22 Sep 2020 11:50:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="n75ciYk2"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3089262FAD for ; Tue, 22 Sep 2020 11:50:35 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id c18so16322928wrm.9 for ; Tue, 22 Sep 2020 02:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2kvmZTp1lcP7EVgB+p8ftux8nQarryqK5aJ+Qp0MEN0=; b=n75ciYk2wljI78QOVZaHBiLpzJy/JBtcmUv/SOSl0tx7ipn7g3NAetkNP2W6H2nnmL 0kNDg4Zq5ukn40e4pYpLMwCcD/IdwN1COFotMH61SnWZzYVDhWJV0A9n7priRTIItGub J5AMAUd1eQmtx9TUvdjl2FtUo9U+EB8STcX+5M2gL3o72JcH82Zg4FuYGAJQ0ZhpZx3d xoAoeP2G+ZeQBtUTDOp+Dz3E49DISfVoyJLhwnWLwp/1zVyEbQNVHvs3IpKSeSvYwzcP Dj7xVNET08KY/wxjye+T1OdxFNY0Hgi2aQq5IiEOE0p3hs5r3unb7xrFcTptSNa3UbDs XMzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2kvmZTp1lcP7EVgB+p8ftux8nQarryqK5aJ+Qp0MEN0=; b=lve8QgvIQeMC676WIodfbJODAzSGnT//Gzeyd19HCWz7rDxpE6H4WzabScYJ75/uof gUljR7kH/evEF9NeB9lE/jRCTXf3F7AMnsPH5UfqfHHwK9xN9cB1YZFQFanf3HaaWwlN 2X0/0BxwZzWViSG0RPjgs0CfZUiftf7TxZeSf6TRq4zqjSuUExO/mTs8drvkmP6BAdOC jHQdLslWML8rVrqM2G8XVpq24OClWuqI9NRmShFBXVsLH5844JKExkji5VjOaABX1xYf CggnFBpqxfbdmdI/JHz6K9EUy/0TDg+bS6S0q/7TmypAoSumIG/YYnO7tO1Q/L11snNE OHOA== X-Gm-Message-State: AOAM5308fveO8ojjjhuIvsFOg4ELFVivxeP31OpB+DewcLEgaaPUVl38 B+47sn8DUna7aprtiQVGyAQtt9nELTGUeQ== X-Google-Smtp-Source: ABdhPJzkW8ue7pCGHpAtiTA0fwi3p0t5rruFJnTUKS7sLZWkhpTakcY9m4ge76S51y5xL57m+gs44A== X-Received: by 2002:a5d:5602:: with SMTP id l2mr4646289wrv.410.1600768234317; Tue, 22 Sep 2020 02:50:34 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id h204sm3776187wmf.35.2020.09.22.02.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 02:50:33 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Sep 2020 10:50:18 +0100 Message-Id: <20200922095018.68434-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922095018.68434-1-naush@raspberrypi.com> References: <20200922095018.68434-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] ipa: raspberrypi: Tidy up variable names to be consistent X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Change variable names to camel case to be consistent with the rest of the source files. Remove #define consts and replace with constexpr. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/ipa/raspberrypi.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 178 +++++++++--------- .../pipeline/raspberrypi/raspberrypi.cpp | 2 +- 3 files changed, 91 insertions(+), 91 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index c9d4aa81..b3041591 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -41,7 +41,7 @@ enum BufferMask { }; /* Size of the LS grid allocation. */ -#define MAX_LS_GRID_SIZE (32 << 10) +static constexpr unsigned int MaxLsGridSize = 32 << 10; /* List of controls handled by the Raspberry Pi IPA */ static const ControlInfoMap Controls = { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 0c0dc743..c240eae8 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -55,8 +55,8 @@ namespace libcamera { /* Configure the sensor with these values initially. */ -#define DEFAULT_ANALOGUE_GAIN 1.0 -#define DEFAULT_EXPOSURE_TIME 20000 +constexpr unsigned int DefaultAnalogueGain = 1.0; +constexpr unsigned int DefaultExposureTime = 20000; LOG_DEFINE_CATEGORY(IPARPI) @@ -65,7 +65,7 @@ class IPARPi : public IPAInterface public: IPARPi() : lastMode_({}), controller_(), controllerInit_(false), - frame_count_(0), check_count_(0), mistrust_count_(0), + frameCount_(0), checkCount_(0), mistrustCount_(0), lsTable_(nullptr) { } @@ -73,7 +73,7 @@ public: ~IPARPi() { if (lsTable_) - munmap(lsTable_, MAX_LS_GRID_SIZE); + munmap(lsTable_, RPi::MaxLsGridSize); } int init(const IPASettings &settings) override; @@ -108,13 +108,13 @@ private: void applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls); void applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls); void applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls); - void resampleTable(uint16_t dest[], double const src[12][16], int dest_w, int dest_h); + void resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH); std::map buffers_; std::map buffersMemory_; - ControlInfoMap unicam_ctrls_; - ControlInfoMap isp_ctrls_; + ControlInfoMap unicamCtrls_; + ControlInfoMap ispCtrls_; ControlList libcameraMetadata_; /* IPA configuration. */ @@ -134,11 +134,11 @@ private: * We count frames to decide if the frame must be hidden (e.g. from * display) or mistrusted (i.e. not given to the control algos). */ - uint64_t frame_count_; + uint64_t frameCount_; /* For checking the sequencing of Prepare/Process calls. */ - uint64_t check_count_; + uint64_t checkCount_; /* How many frames we should avoid running control algos on. */ - unsigned int mistrust_count_; + unsigned int mistrustCount_; /* LS table allocation passed in from the pipeline handler. */ FileDescriptor lsTableHandle_; void *lsTable_; @@ -199,8 +199,8 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, result->operation = 0; - unicam_ctrls_ = entityControls.at(0); - isp_ctrls_ = entityControls.at(1); + unicamCtrls_ = entityControls.at(0); + ispCtrls_ = entityControls.at(1); /* Setup a metadata ControlList to output metadata. */ libcameraMetadata_ = ControlList(controls::controls); @@ -238,18 +238,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, *"mistrusted", which depends on whether this is a startup from cold, * or merely a mode switch in a running system. */ - frame_count_ = 0; - check_count_ = 0; - unsigned int drop_frame = 0; + frameCount_ = 0; + checkCount_ = 0; + unsigned int dropFrame = 0; if (controllerInit_) { - drop_frame = helper_->HideFramesModeSwitch(); - mistrust_count_ = helper_->MistrustFramesModeSwitch(); + dropFrame = helper_->HideFramesModeSwitch(); + mistrustCount_ = helper_->MistrustFramesModeSwitch(); } else { - drop_frame = helper_->HideFramesStartup(); - mistrust_count_ = helper_->MistrustFramesStartup(); + dropFrame = helper_->HideFramesStartup(); + mistrustCount_ = helper_->MistrustFramesStartup(); } - result->data.push_back(drop_frame); + result->data.push_back(dropFrame); result->operation |= RPi::IPA_CONFIG_DROP_FRAMES; struct AgcStatus agcStatus; @@ -264,8 +264,8 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, controllerInit_ = true; /* Supply initial values for gain and exposure. */ - agcStatus.shutter_time = DEFAULT_EXPOSURE_TIME; - agcStatus.analogue_gain = DEFAULT_ANALOGUE_GAIN; + agcStatus.shutter_time = DefaultExposureTime; + agcStatus.analogue_gain = DefaultAnalogueGain; } RPiController::Metadata metadata; @@ -274,7 +274,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, /* SwitchMode may supply updated exposure/gain values to use. */ metadata.Get("agc.status", agcStatus); if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) { - ControlList ctrls(unicam_ctrls_); + ControlList ctrls(unicamCtrls_); applyAGC(&agcStatus, ctrls); result->controls.push_back(ctrls); @@ -287,14 +287,14 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, if (ipaConfig.operation & RPi::IPA_CONFIG_LS_TABLE) { /* Remove any previous table, if there was one. */ if (lsTable_) { - munmap(lsTable_, MAX_LS_GRID_SIZE); + munmap(lsTable_, RPi::MaxLsGridSize); lsTable_ = nullptr; } /* Map the LS table buffer into user space. */ lsTableHandle_ = FileDescriptor(ipaConfig.data[0]); if (lsTableHandle_.isValid()) { - lsTable_ = mmap(nullptr, MAX_LS_GRID_SIZE, PROT_READ | PROT_WRITE, + lsTable_ = mmap(nullptr, RPi::MaxLsGridSize, PROT_READ | PROT_WRITE, MAP_SHARED, lsTableHandle_.fd(), 0); if (lsTable_ == MAP_FAILED) { @@ -343,9 +343,9 @@ void IPARPi::processEvent(const IPAOperationData &event) case RPi::IPA_EVENT_SIGNAL_STAT_READY: { unsigned int bufferId = event.data[0]; - if (++check_count_ != frame_count_) /* assert here? */ + if (++checkCount_ != frameCount_) /* assert here? */ LOG(IPARPI, Error) << "WARNING: Prepare/Process mismatch!!!"; - if (frame_count_ > mistrust_count_) + if (frameCount_ > mistrustCount_) processStats(bufferId); reportMetadata(); @@ -368,7 +368,7 @@ void IPARPi::processEvent(const IPAOperationData &event) * they are "unreliable". */ prepareISP(embeddedbufferId); - frame_count_++; + frameCount_++; /* Ready to push the input buffer into the ISP. */ IPAOperationData op; @@ -713,7 +713,7 @@ void IPARPi::prepareISP(unsigned int bufferId) returnEmbeddedBuffer(bufferId); if (success) { - ControlList ctrls(isp_ctrls_); + ControlList ctrls(ispCtrls_); rpiMetadata_.Clear(); rpiMetadata_.Set("device.status", deviceStatus); @@ -785,19 +785,19 @@ bool IPARPi::parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &devic if (status != RPiController::MdParser::Status::OK) { LOG(IPARPI, Error) << "Embedded Buffer parsing failed, error " << status; } else { - uint32_t exposure_lines, gain_code; - if (helper_->Parser().GetExposureLines(exposure_lines) != RPiController::MdParser::Status::OK) { + uint32_t exposureLines, gainCode; + if (helper_->Parser().GetExposureLines(exposureLines) != RPiController::MdParser::Status::OK) { LOG(IPARPI, Error) << "Exposure time failed"; return false; } - deviceStatus.shutter_speed = helper_->Exposure(exposure_lines); - if (helper_->Parser().GetGainCode(gain_code) != RPiController::MdParser::Status::OK) { + deviceStatus.shutter_speed = helper_->Exposure(exposureLines); + if (helper_->Parser().GetGainCode(gainCode) != RPiController::MdParser::Status::OK) { LOG(IPARPI, Error) << "Gain failed"; return false; } - deviceStatus.analogue_gain = helper_->Gain(gain_code); + deviceStatus.analogue_gain = helper_->Gain(gainCode); LOG(IPARPI, Debug) << "Metadata - Exposure : " << deviceStatus.shutter_speed << " Gain : " << deviceStatus.analogue_gain; @@ -820,7 +820,7 @@ void IPARPi::processStats(unsigned int bufferId) struct AgcStatus agcStatus; if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { - ControlList ctrls(unicam_ctrls_); + ControlList ctrls(unicamCtrls_); applyAGC(&agcStatus, ctrls); IPAOperationData op; @@ -832,14 +832,14 @@ void IPARPi::processStats(unsigned int bufferId) void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) { - const auto gainR = isp_ctrls_.find(V4L2_CID_RED_BALANCE); - if (gainR == isp_ctrls_.end()) { + const auto gainR = ispCtrls_.find(V4L2_CID_RED_BALANCE); + if (gainR == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find red gain control"; return; } - const auto gainB = isp_ctrls_.find(V4L2_CID_BLUE_BALANCE); - if (gainB == isp_ctrls_.end()) { + const auto gainB = ispCtrls_.find(V4L2_CID_BLUE_BALANCE); + if (gainB == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find blue gain control"; return; } @@ -855,31 +855,31 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) { - int32_t gain_code = helper_->GainCode(agcStatus->analogue_gain); - int32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time); + int32_t gainCode = helper_->GainCode(agcStatus->analogue_gain); + int32_t exposureLines = helper_->ExposureLines(agcStatus->shutter_time); - if (unicam_ctrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicam_ctrls_.end()) { + if (unicamCtrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicamCtrls_.end()) { LOG(IPARPI, Error) << "Can't find analogue gain control"; return; } - if (unicam_ctrls_.find(V4L2_CID_EXPOSURE) == unicam_ctrls_.end()) { + if (unicamCtrls_.find(V4L2_CID_EXPOSURE) == unicamCtrls_.end()) { LOG(IPARPI, Error) << "Can't find exposure control"; return; } LOG(IPARPI, Debug) << "Applying AGC Exposure: " << agcStatus->shutter_time - << " (Shutter lines: " << exposure_lines << ") Gain: " + << " (Shutter lines: " << exposureLines << ") Gain: " << agcStatus->analogue_gain << " (Gain Code: " - << gain_code << ")"; + << gainCode << ")"; - ctrls.set(V4L2_CID_ANALOGUE_GAIN, gain_code); - ctrls.set(V4L2_CID_EXPOSURE, exposure_lines); + ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode); + ctrls.set(V4L2_CID_EXPOSURE, exposureLines); } void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_DIGITAL_GAIN) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_DIGITAL_GAIN) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find digital gain control"; return; } @@ -890,7 +890,7 @@ void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find CCM control"; return; } @@ -911,7 +911,7 @@ void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls) void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_GAMMA) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GAMMA) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find Gamma control"; return; } @@ -930,7 +930,7 @@ void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find black level control"; return; } @@ -948,7 +948,7 @@ void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, Co void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_GEQ) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GEQ) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find geq control"; return; } @@ -966,7 +966,7 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls) void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_DENOISE) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DENOISE) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find denoise control"; return; } @@ -986,7 +986,7 @@ void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ct void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_SHARPEN) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_SHARPEN) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find sharpen control"; return; } @@ -1007,7 +1007,7 @@ void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_DPC) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DPC) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find DPC control"; return; } @@ -1023,7 +1023,7 @@ void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls) void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) { - if (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING) == isp_ctrls_.end()) { + if (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING) == ispCtrls_.end()) { LOG(IPARPI, Error) << "Can't find LS control"; return; } @@ -1032,18 +1032,18 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) * Program lens shading tables into pipeline. * Choose smallest cell size that won't exceed 63x48 cells. */ - const int cell_sizes[] = { 16, 32, 64, 128, 256 }; - unsigned int num_cells = ARRAY_SIZE(cell_sizes); - unsigned int i, w, h, cell_size; - for (i = 0; i < num_cells; i++) { - cell_size = cell_sizes[i]; - w = (mode_.width + cell_size - 1) / cell_size; - h = (mode_.height + cell_size - 1) / cell_size; + const int cellSizes[] = { 16, 32, 64, 128, 256 }; + unsigned int numCells = ARRAY_SIZE(cellSizes); + unsigned int i, w, h, cellSize; + for (i = 0; i < numCells; i++) { + cellSize = cellSizes[i]; + w = (mode_.width + cellSize - 1) / cellSize; + h = (mode_.height + cellSize - 1) / cellSize; if (w < 64 && h <= 48) break; } - if (i == num_cells) { + if (i == numCells) { LOG(IPARPI, Error) << "Cannot find cell size"; return; } @@ -1052,7 +1052,7 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) w++, h++; bcm2835_isp_lens_shading ls = { .enabled = 1, - .grid_cell_size = cell_size, + .grid_cell_size = cellSize, .grid_width = w, .grid_stride = w, .grid_height = h, @@ -1062,7 +1062,7 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) .gain_format = GAIN_FORMAT_U4P10 }; - if (!lsTable_ || w * h * 4 * sizeof(uint16_t) > MAX_LS_GRID_SIZE) { + if (!lsTable_ || w * h * 4 * sizeof(uint16_t) > RPi::MaxLsGridSize) { LOG(IPARPI, Error) << "Do not have a correctly allocate lens shading table!"; return; } @@ -1083,41 +1083,41 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) } /* - * Resamples a 16x12 table with central sampling to dest_w x dest_h with corner + * Resamples a 16x12 table with central sampling to destW x destH with corner * sampling. */ void IPARPi::resampleTable(uint16_t dest[], double const src[12][16], - int dest_w, int dest_h) + int destW, int destH) { /* * Precalculate and cache the x sampling locations and phases to * save recomputing them on every row. */ - assert(dest_w > 1 && dest_h > 1 && dest_w <= 64); - int x_lo[64], x_hi[64]; + assert(destW > 1 && destH > 1 && destW <= 64); + int xLo[64], xHi[64]; double xf[64]; - double x = -0.5, x_inc = 16.0 / (dest_w - 1); - for (int i = 0; i < dest_w; i++, x += x_inc) { - x_lo[i] = floor(x); - xf[i] = x - x_lo[i]; - x_hi[i] = x_lo[i] < 15 ? x_lo[i] + 1 : 15; - x_lo[i] = x_lo[i] > 0 ? x_lo[i] : 0; + double x = -0.5, xInc = 16.0 / (destW - 1); + for (int i = 0; i < destW; i++, x += xInc) { + xLo[i] = floor(x); + xf[i] = x - xLo[i]; + xHi[i] = xLo[i] < 15 ? xLo[i] + 1 : 15; + xLo[i] = xLo[i] > 0 ? xLo[i] : 0; } /* Now march over the output table generating the new values. */ - double y = -0.5, y_inc = 12.0 / (dest_h - 1); - for (int j = 0; j < dest_h; j++, y += y_inc) { - int y_lo = floor(y); - double yf = y - y_lo; - int y_hi = y_lo < 11 ? y_lo + 1 : 11; - y_lo = y_lo > 0 ? y_lo : 0; - double const *row_above = src[y_lo]; - double const *row_below = src[y_hi]; - for (int i = 0; i < dest_w; i++) { - double above = row_above[x_lo[i]] * (1 - xf[i]) - + row_above[x_hi[i]] * xf[i]; - double below = row_below[x_lo[i]] * (1 - xf[i]) - + row_below[x_hi[i]] * xf[i]; + double y = -0.5, yInc = 12.0 / (destH - 1); + for (int j = 0; j < destH; j++, y += yInc) { + int yLo = floor(y); + double yf = y - yLo; + int yHi = yLo < 11 ? yLo + 1 : 11; + yLo = yLo > 0 ? yLo : 0; + double const *rowAbove = src[yLo]; + double const *rowBelow = src[yHi]; + for (int i = 0; i < destW; i++) { + double above = rowAbove[xLo[i]] * (1 - xf[i]) + + rowAbove[xHi[i]] * xf[i]; + double below = rowBelow[xLo[i]] * (1 - xf[i]) + + rowBelow[xHi[i]] * xf[i]; int result = floor(1024 * (above * (1 - yf) + below * yf) + .5); *(dest++) = result > 16383 ? 16383 : result; /* want u4.10 */ } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 35dbe0fb..8d40b0ed 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1012,7 +1012,7 @@ int RPiCameraData::configureIPA() /* Allocate the lens shading table via dmaHeap and pass to the IPA. */ if (!lsTable_.isValid()) { - lsTable_ = dmaHeap_.alloc("ls_grid", MAX_LS_GRID_SIZE); + lsTable_ = dmaHeap_.alloc("ls_grid", RPi::MaxLsGridSize); if (!lsTable_.isValid()) return -ENOMEM;