Patch Detail
Show a patch.
GET /api/1.1/patches/14548/?format=api
{ "id": 14548, "url": "https://patchwork.libcamera.org/api/1.1/patches/14548/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14548/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20211111104908.295992-4-hanlinchen@chromium.org>", "date": "2021-11-11T10:49:05", "name": "[libcamera-devel,IPU3-IPA,v3,3/6] ipu3: Set statistics with the effective AE AiqResults", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "74aec7c8ae9729072dc66d6cd7660e60a3fd3639", "submitter": { "id": 98, "url": "https://patchwork.libcamera.org/api/1.1/people/98/?format=api", "name": "Hanlin Chen", "email": "hanlinchen@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14548/mbox/", "series": [ { "id": 2711, "url": "https://patchwork.libcamera.org/api/1.1/series/2711/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2711", "date": "2021-11-11T10:49:02", "name": "*** Enhance image quality for IPU3 with Intel IPA ***", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2711/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14548/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14548/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 44E78BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Nov 2021 10:49:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0072760361;\n\tThu, 11 Nov 2021 11:49:37 +0100 (CET)", "from mail-pl1-x636.google.com (mail-pl1-x636.google.com\n\t[IPv6:2607:f8b0:4864:20::636])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FF1E6032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 11:49:35 +0100 (CET)", "by mail-pl1-x636.google.com with SMTP id u11so5491594plf.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 02:49:35 -0800 (PST)", "from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tfs21sm7444307pjb.1.2021.11.11.02.49.33\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 11 Nov 2021 02:49:33 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"B3xDokDH\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=rdnEleC34M0zr+gS5rQKJvmxxwea1e6rZmRlToyr4Ik=;\n\tb=B3xDokDHVzh4frwnNBeZCl18NWgflfCFzA8jG0rlT0TI1kpcOwlkj+lJN/7qx/5X+/\n\tKqfQGgg0mmglkjGqdFZcWLt3g4kuufpeffKt8SiR1xeUPiO0sU4tiDdnMFmPaec2FQi3\n\t0ahIBJFK0VHFnUmmLMvlKEmhLaLYMo7UfZrxA=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=rdnEleC34M0zr+gS5rQKJvmxxwea1e6rZmRlToyr4Ik=;\n\tb=qujM2e292yo/diOYHJ75HOp+UoODY5/h3lt8lhtnUWsNazpn1XW71R7/aDunpKtYWH\n\tp2UieOmDuCIGfUBkyZpLcNDstEQfS75L+qoiI5vU7oldlxHeKgpLNo8CIRWLak3QY7Ta\n\t4H5SUKd7fqYkH8RM96SITgkpfCFiVOPf62dEPLdtdAljwDMrfbH80CapfP6Cl1/sFUGf\n\tv4H7M/mS+l4QnUuQkN1/oz1AgF2IPTG0FEQhmISyP6dj86AsEiZtMLK13T+9WqBgtlJc\n\tXffkfHmjGQEFlz7Ugcz8ioSZAhKfgCPjNlbjPAxOq6skCKGRFrhuFi2QvHa1zQkCYE0U\n\tZyfg==", "X-Gm-Message-State": "AOAM530TW++cuB1EDPho+/Um/7RcEOaMRliFXuuQaNH16ts4EGi1jcn7\n\tZk5yWJ1ewt8JcNEYId478ugvvzYMJrcbxg==", "X-Google-Smtp-Source": "ABdhPJyabafKp9MqRFwvpPHkm5JnBuBxRKmJDY9V9jSI4HnWr2a2A7nRTTIdRpyD4JWgNOvU3cl8YA==", "X-Received": "by 2002:a17:902:c7d5:b0:143:72b7:2ca5 with SMTP id\n\tr21-20020a170902c7d500b0014372b72ca5mr6602592pla.20.1636627773810; \n\tThu, 11 Nov 2021 02:49:33 -0800 (PST)", "From": "Han-Lin Chen <hanlinchen@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 11 Nov 2021 18:49:05 +0800", "Message-Id": "<20211111104908.295992-4-hanlinchen@chromium.org>", "X-Mailer": "git-send-email 2.34.0.rc1.387.gb447b232ab-goog", "In-Reply-To": "<20211111104908.295992-1-hanlinchen@chromium.org>", "References": "<20211111104908.295992-1-hanlinchen@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [IPU3-IPA PATCH v3 3/6] ipu3: Set statistics with\n\tthe effective AE AiqResults", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Set the statistics with the latest AE AiqResults which has the same\nexposure time and analog gain. The patch reduces the AE hunting during\nthe converging process.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n aiq/aiq_input_parameters.cpp | 2 +-\n ipu3.cpp | 75 ++++++++++++++++++++++++++++--------\n 2 files changed, 61 insertions(+), 16 deletions(-)", "diff": "diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp\nindex bc87b31..46553a6 100644\n--- a/aiq/aiq_input_parameters.cpp\n+++ b/aiq/aiq_input_parameters.cpp\n@@ -130,7 +130,7 @@ AiqInputParameters &AiqInputParameters::operator=(const AiqInputParameters &othe\n \n void AiqInputParameters::setAeAwbAfDefaults()\n {\n-\t/*Ae Params */\n+\t/* Ae Params */\n \taeInputParams.num_exposures = NUM_EXPOSURES;\n \taeInputParams.frame_use = ia_aiq_frame_use_preview;\n \taeInputParams.flash_mode = ia_aiq_flash_mode_off;\ndiff --git a/ipu3.cpp b/ipu3.cpp\nindex 8126e9d..9d07268 100644\n--- a/ipu3.cpp\n+++ b/ipu3.cpp\n@@ -59,7 +59,8 @@ private:\n \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n \tvoid parseStatistics(unsigned int frame,\n \t\t\t int64_t frameTimestamp,\n-\t\t\t const ipu3_uapi_stats_3a *stats);\n+\t\t\t const ipu3_uapi_stats_3a *stats,\n+\t\t\t const ControlList& sensorCtrls);\n \n \tvoid setControls(unsigned int frame);\n \n@@ -83,7 +84,7 @@ private:\n \n \t/* Temporary storage until we have a FrameContext object / struct */\n \taiq::AiqInputParameters aiqInputParams_;\n-\taiq::AiqResults results_;\n+\taiq::AiqResultsRingBuffer resultsHistory_;\n \n \tBinaryData aiqb_;\n \tBinaryData nvm_;\n@@ -282,6 +283,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \t/* Upate the camera controls using the new sensor settings. */\n \tupdateControls(sensorInfo_, ctrls_, ipaControls);\n \n+\tresultsHistory_.reset();\n+\n \treturn 0;\n }\n \n@@ -327,7 +330,10 @@ void IPAIPU3::processEvent(const IPU3Event &event)\n \t\tconst ipu3_uapi_stats_3a *stats =\n \t\t\treinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());\n \n-\t\tparseStatistics(event.frame, event.frameTimestamp, stats);\n+\t\tparseStatistics(event.frame,\n+\t\t\t\tevent.frameTimestamp,\n+\t\t\t\tstats,\n+\t\t\t\tevent.sensorControls);\n \t\tbreak;\n \t}\n \tcase EventFillParams: {\n@@ -374,14 +380,16 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \t*/\n \n \t/* Run algorithms into/using this context structure */\n-\tif (frame % 10 == 0)\n-\t\taiq_.run2a(frame, aiqInputParams_, results_);\n+\tresultsHistory_.extendOne();\n+\taiq::AiqResults& latestResults = resultsHistory_.latest();\n \n-\taic_.updateRuntimeParams(results_);\n+\taiq_.run2a(frame, aiqInputParams_, latestResults);\n+\taic_.updateRuntimeParams(latestResults);\n \taic_.run(params);\n \n-\texposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n-\tgain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n+\texposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n+\tgain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n+\n \tsetControls(frame);\n \n \tIPU3Action op;\n@@ -392,7 +400,8 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \n void IPAIPU3::parseStatistics(unsigned int frame,\n \t\t\t int64_t frameTimestamp,\n-\t\t\t const ipu3_uapi_stats_3a *stats)\n+\t\t\t const ipu3_uapi_stats_3a *stats,\n+\t\t\t const ControlList& sensorCtrls)\n {\n \tControlList ctrls(controls::controls);\n \n@@ -403,10 +412,45 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n \t */\n \n \tASSERT (frameTimestamp > 0);\n-\taiq_.setStatistics(frame, frameTimestamp, results_, stats);\n+\n+\t/* Ae algorithm expects the statistics to be set with its corresponding\n+\t * Ae result, i.e., the Ae result should match the exposure time and\n+\t * analog gain with the the effective sensor controls of the statistics.\n+\t * Search the required Ae result in the result history and combine it\n+\t * with the latest result as the input to AIQ::setStatistics().\n+\t */\n+\n+\tint32_t effectiveExpo = 0;\n+\tint32_t effectiveGain = 0;\n+\tControlValue ctrlValue;\n+\n+\tctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE);\n+\tif (!ctrlValue.isNone())\n+\t\teffectiveExpo = ctrlValue.get<int32_t>();\n+\n+\tctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN);\n+\tif (!ctrlValue.isNone())\n+\t\teffectiveGain = ctrlValue.get<int32_t>();\n+\n+\tauto pred = [effectiveExpo, effectiveGain] (aiq::AiqResults& result) {\n+\t\tia_aiq_exposure_sensor_parameters* sensorExposure =\n+\t\t\tresult.ae()->exposures[0].sensor_exposure;\n+\n+\t\treturn (effectiveExpo == sensorExposure->coarse_integration_time ||\n+\t\t\teffectiveGain == sensorExposure->analog_gain_code_global);\n+\t};\n+\n+\taiq::AiqResults& latestResults = resultsHistory_.latest();\n+\taiq::AiqResults& aeMatchedResults = resultsHistory_.searchBackward(pred, latestResults);\n+\n+\taiq::AiqResults combinedResults = latestResults;\n+\tcombinedResults.setAe(aeMatchedResults.ae());\n+\n+\t/* Aiq library expects timestamp in microseconds */\n+\taiq_.setStatistics(frame, (frameTimestamp / 1000), combinedResults, stats);\n \n \t/* Set frame durations from exposure results */\n-\tia_aiq_exposure_sensor_parameters *sensorExposure = results_.ae()->exposures->sensor_exposure;\n+\tia_aiq_exposure_sensor_parameters *sensorExposure = combinedResults.ae()->exposures->sensor_exposure;\n \tint64_t frameDuration = (sensorExposure->line_length_pixels * sensorExposure->frame_length_lines) /\n \t\t\t\t(sensorInfo_.pixelRate / 1e6);\n \tctrls.set(controls::FrameDuration, frameDuration);\n@@ -423,10 +467,11 @@ void IPAIPU3::setControls(unsigned int frame)\n \tIPU3Action op;\n \top.op = ActionSetSensorControls;\n \n-\tControlList ctrls(ctrls_);\n-\tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure_));\n-\tctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain_));\n-\top.controls = ctrls;\n+\tControlList sensorCtrls(ctrls_);\n+\tsensorCtrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure_));\n+\tsensorCtrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain_));\n+\n+\top.sensorControls = sensorCtrls;\n \n \tqueueFrameAction.emit(frame, op);\n }\n", "prefixes": [ "libcamera-devel", "IPU3-IPA", "v3", "3/6" ] }