Patch Detail
Show a patch.
GET /api/1.1/patches/14547/?format=api
{ "id": 14547, "url": "https://patchwork.libcamera.org/api/1.1/patches/14547/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14547/", "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-3-hanlinchen@chromium.org>", "date": "2021-11-11T10:49:04", "name": "[libcamera-devel,IPU3-IPA,v3,2/6] ipu3: Add a class AiqResultsRingBuffer to reserve AiqResults history", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "608e96f243f9a7d3a89267322b014abcfa8aae56", "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/14547/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/14547/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14547/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 CE8C2BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Nov 2021 10:49:34 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7CCB06035D;\n\tThu, 11 Nov 2021 11:49:34 +0100 (CET)", "from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A0DB60369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 11:49:33 +0100 (CET)", "by mail-pj1-x1032.google.com with SMTP id x7so3832805pjn.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 02:49:33 -0800 (PST)", "from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tx14sm2217514pjl.27.2021.11.11.02.49.30\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 11 Nov 2021 02:49:31 -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=\"KHjzFO1+\"; 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=79aUadBtYlR09ShcgbybPJ7j1L4UXmL3pC0j4+AsB4Y=;\n\tb=KHjzFO1+egAxmxcSOEtxT0fTrNxgi6FgwvH72GxZAenZVAp9GiUv/KCYmnOX7Cw2Eo\n\tVjiAeYSYM2uT7RWCsQJbqeLlNKDL6ziUXwOXNzRlo1Ejpdw0dJxUp3rO9K3Qo9X3DBGl\n\tdboZuyVttsqwFn/4vzCF/foF5OQIU3B4h1kiw=", "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=79aUadBtYlR09ShcgbybPJ7j1L4UXmL3pC0j4+AsB4Y=;\n\tb=SjK9np4wbQJClDlwUpvgZM25W2w+tsGjIBV3ZRlXvygMlYgk1pjdBp0fQ7CVhEDzRB\n\tp0+v7F71FqZwQ9dWZOkaE2wMzt7r7keRAJI2V1RJlJrunW/yXrEgph34PaBFiQTaQpgJ\n\tyUzCxfkS+1dcxj8GakzU9+2/8w0NRyOLm28xL8Nra6T45uOmIlfeP+UE0k5ghgE0umrI\n\tdcxRpCCEq9mYJjrW2flW7mwFFx3dleGjJdpiDNMLBeGt3WYpVLQWTQktOTTetzy8QZlN\n\tpKFNDIknOZJ/9s1+PkGO+rDQszLXcWYbDpcNwPTJI4Nqx64IWGt0dy2jGLuA5JcOcbkh\n\t2tbg==", "X-Gm-Message-State": "AOAM5333O7iC07j1ThIpCt4iI50pikjsOKEesMvuhfLisFDjOPpgSguz\n\t1Y+rQE0GVbI0G/5dVZn6afolpovQvjuZlg==", "X-Google-Smtp-Source": "ABdhPJycg9H7J2aNpa7+OLnfSdMx8AgtACW+juCDqshGpCxyaAbE/WHYAV8nFNMDCVWV9OGfzWbQ7g==", "X-Received": "by 2002:a17:90b:4f86:: with SMTP id\n\tqe6mr7225147pjb.198.1636627771348; \n\tThu, 11 Nov 2021 02:49:31 -0800 (PST)", "From": "Han-Lin Chen <hanlinchen@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 11 Nov 2021 18:49:04 +0800", "Message-Id": "<20211111104908.295992-3-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 2/6] ipu3: Add a class\n\tAiqResultsRingBuffer to reserve AiqResults history", "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": "The AIQ algorithm expects the statstistics comes with the effective AiqResults\napplied on the sensor, which may not always be the latest AiqResults,\nsince pipeline handler may delay setting the controls based on SOF.\nAdd a class to reserve the history of the AiqResults generated for previous\nframes, so IPA can have a chance to look for the suitable one backwards.\n\nIn details, the patch adds following to AiqResult Class.\n - Make the parameters to setXXX() functions const.\n - Implement copy constructors\n - Implement a RingBuffer to maintain AiqResults History\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n aiq/aiq_results.cpp | 90 +++++++++++++++++++++++++++++++++++++++++----\n aiq/aiq_results.h | 43 ++++++++++++++++++----\n 2 files changed, 117 insertions(+), 16 deletions(-)", "diff": "diff --git a/aiq/aiq_results.cpp b/aiq/aiq_results.cpp\nindex f727f36..befcf7a 100644\n--- a/aiq/aiq_results.cpp\n+++ b/aiq/aiq_results.cpp\n@@ -63,7 +63,34 @@ AiqResults::AiqResults()\n \tsa_.channel_b = channelB_.data();\n }\n \n-void AiqResults::setAe(ia_aiq_ae_results *ae)\n+AiqResults::AiqResults(const AiqResults &other)\n+\t:AiqResults()\n+{\n+\tsetAe(&other.ae_);\n+\tsetAf(&other.af_);\n+\tsetAfBracket(&other.afBracket_);\n+\tsetAwb(&other.awb_);\n+\tsetGbce(&other.gbce_);\n+\tsetDetectedSceneMode(other.detectedSceneMode_);\n+\tsetPa(&other.pa_);\n+\tsetSa(&other.sa_);\n+}\n+\n+AiqResults& AiqResults::operator=(const AiqResults &other)\n+{\n+\tsetAe(&other.ae_);\n+\tsetAf(&other.af_);\n+\tsetAfBracket(&other.afBracket_);\n+\tsetAwb(&other.awb_);\n+\tsetGbce(&other.gbce_);\n+\tsetDetectedSceneMode(other.detectedSceneMode_);\n+\tsetPa(&other.pa_);\n+\tsetSa(&other.sa_);\n+\n+\treturn *this;\n+}\n+\n+void AiqResults::setAe(const ia_aiq_ae_results *ae)\n {\n \t/* Todo: Potentially Requires copying\n \t * ia_aiq_aperture_control *aperture_control;\n@@ -121,7 +148,7 @@ void AiqResults::setAe(ia_aiq_ae_results *ae)\n \t}\n }\n \n-void AiqResults::setAf(ia_aiq_af_results *af)\n+void AiqResults::setAf(const ia_aiq_af_results *af)\n {\n \tASSERT(af);\n \n@@ -133,7 +160,7 @@ void AiqResults::setAf(ia_aiq_af_results *af)\n \taf_.final_lens_position_reached = af->final_lens_position_reached;\n }\n \n-void AiqResults::setAfBracket(ia_aiq_af_bracket_results *afBracket)\n+void AiqResults::setAfBracket(const ia_aiq_af_bracket_results *afBracket)\n {\n \tASSERT(afBracket);\n \n@@ -145,7 +172,7 @@ void AiqResults::setAfBracket(ia_aiq_af_bracket_results *afBracket)\n \tafBracket_.lens_positions_bracketing = afBracket->lens_positions_bracketing;\n }\n \n-void AiqResults::setAwb(ia_aiq_awb_results *awb)\n+void AiqResults::setAwb(const ia_aiq_awb_results *awb)\n {\n \tASSERT(awb);\n \n@@ -157,7 +184,7 @@ void AiqResults::setAwb(ia_aiq_awb_results *awb)\n \tawb_.distance_from_convergence = awb->distance_from_convergence;\n }\n \n-void AiqResults::setGbce(ia_aiq_gbce_results *gbce)\n+void AiqResults::setGbce(const ia_aiq_gbce_results *gbce)\n {\n \tASSERT(gbce);\n \n@@ -181,12 +208,12 @@ void AiqResults::setGbce(ia_aiq_gbce_results *gbce)\n \t}\n }\n \n-void AiqResults::setDetectedSceneMode(ia_aiq_scene_mode dsm)\n+void AiqResults::setDetectedSceneMode(const ia_aiq_scene_mode dsm)\n {\n \tdetectedSceneMode_ = dsm;\n }\n \n-void AiqResults::setPa(ia_aiq_pa_results *pa)\n+void AiqResults::setPa(const ia_aiq_pa_results *pa)\n {\n \tASSERT(pa);\n \n@@ -234,7 +261,7 @@ void AiqResults::setPa(ia_aiq_pa_results *pa)\n \tpa_.brightness_level = pa->brightness_level;\n }\n \n-void AiqResults::setSa(ia_aiq_sa_results *sa)\n+void AiqResults::setSa(const ia_aiq_sa_results *sa)\n {\n \tASSERT(sa && sa->channel_r && sa->channel_gr &&\n \t sa->channel_gb && sa->channel_b);\n@@ -275,6 +302,53 @@ void AiqResults::setSa(ia_aiq_sa_results *sa)\n \tsa_.frame_params = sa->frame_params;\n }\n \n+AiqResults& AiqResultsRingBuffer::operator[](unsigned int index)\n+{\n+\treturn std::array<AiqResults, bufferSize>::operator[](index % bufferSize);\n+}\n+\n+const AiqResults& AiqResultsRingBuffer::operator[](unsigned int index) const\n+{\n+\treturn std::array<AiqResults, bufferSize>::operator[](index % bufferSize);\n+}\n+\n+void AiqResultsRingBuffer::reset()\n+{\n+\tstart_ = end_ = size_ = 0;\n+}\n+\n+void AiqResultsRingBuffer::extendOne()\n+{\n+\tend_ = (end_ + 1) % bufferSize;\n+\tsize_ = std::min(size_ + 1, bufferSize);\n+\tif (size_ == bufferSize) {\n+\t\tstart_ = end_;\n+\t}\n+}\n+\n+AiqResults& AiqResultsRingBuffer::latest()\n+{\n+\tunsigned int i = (end_ + bufferSize - 1) % bufferSize;\n+\treturn operator[](i);\n+}\n+\n+AiqResults& AiqResultsRingBuffer::searchBackward(\n+\t\tconst std::function<bool(AiqResults&)> pred, AiqResults& def)\n+{\n+\tif (size_ == 0)\n+\t\treturn def;\n+\n+\tunsigned int i = (end_ + bufferSize - 1) % bufferSize;\n+\twhile (i != start_) {\n+\t\tif (pred(operator[](i))) {\n+\t\t\treturn operator[](i);\n+\t\t}\n+\t\ti = (i + bufferSize - 1) % bufferSize;\n+\t}\n+\n+\treturn def;\n+}\n+\n } /* namespace ipa::ipu3::aiq */\n \n } /* namespace libcamera */\ndiff --git a/aiq/aiq_results.h b/aiq/aiq_results.h\nindex ae19a6c..8c95852 100644\n--- a/aiq/aiq_results.h\n+++ b/aiq/aiq_results.h\n@@ -8,6 +8,8 @@\n * of the aiq result structures.\n */\n \n+#include <array>\n+#include <functional>\n #include <vector>\n \n #include <ia_imaging/ia_aiq.h>\n@@ -37,6 +39,10 @@ class AiqResults\n {\n public:\n \tAiqResults();\n+\tAiqResults(const AiqResults &other);\n+\tAiqResults &operator=(const AiqResults &other);\n+\tAiqResults(const AiqResults &&other) = delete;\n+\tAiqResults &operator=(const AiqResults &&other) = delete;\n \n \tconst ia_aiq_ae_results *ae() { return &ae_; }\n \tia_aiq_af_results *af() { return &af_; }\n@@ -46,14 +52,14 @@ public:\n \tconst ia_aiq_pa_results *pa() { return &pa_; }\n \tconst ia_aiq_sa_results *sa() { return &sa_; }\n \n-\tvoid setAe(ia_aiq_ae_results *ae);\n-\tvoid setAf(ia_aiq_af_results *af);\n-\tvoid setAfBracket(ia_aiq_af_bracket_results *afBracket);\n-\tvoid setAwb(ia_aiq_awb_results *awb);\n-\tvoid setGbce(ia_aiq_gbce_results *gbce);\n-\tvoid setDetectedSceneMode(ia_aiq_scene_mode dsm);\n-\tvoid setPa(ia_aiq_pa_results *pa);\n-\tvoid setSa(ia_aiq_sa_results *sa);\n+\tvoid setAe(const ia_aiq_ae_results *ae);\n+\tvoid setAf(const ia_aiq_af_results *af);\n+\tvoid setAfBracket(const ia_aiq_af_bracket_results *afBracket);\n+\tvoid setAwb(const ia_aiq_awb_results *awb);\n+\tvoid setGbce(const ia_aiq_gbce_results *gbce);\n+\tvoid setDetectedSceneMode(const ia_aiq_scene_mode dsm);\n+\tvoid setPa(const ia_aiq_pa_results *pa);\n+\tvoid setSa(const ia_aiq_sa_results *sa);\n \n private:\n \tia_aiq_ae_results ae_;\n@@ -109,6 +115,27 @@ private:\n \tstd::vector<float> channelGb_;\n };\n \n+static constexpr unsigned int bufferSize = 16;\n+class AiqResultsRingBuffer: public std::array<AiqResults, bufferSize>\n+{\n+public:\n+\tAiqResults &operator[](unsigned int index);\n+\tconst AiqResults &operator[](unsigned int index) const;\n+\tvoid reset();\n+\tvoid extendOne();\n+\tAiqResults& latest();\n+\tunsigned int size() { return size_; }\n+\tAiqResults& searchBackward(const std::function<bool(AiqResults&)> pred,\n+\t\t\t\t AiqResults& def);\n+\n+private:\n+\tvoid incrementSize();\n+\n+\tunsigned int start_ = 0;\n+\tunsigned int end_ = 0;\n+\tunsigned int size_ = 0;\n+};\n+\n } /* namespace libcamera::ipa::ipu3::aiq */\n \n #endif /* IPA_IPU3_AIQ_RESULTS_H */\n", "prefixes": [ "libcamera-devel", "IPU3-IPA", "v3", "2/6" ] }