Patch Detail
Show a patch.
GET /api/patches/18502/?format=api
{ "id": 18502, "url": "https://patchwork.libcamera.org/api/patches/18502/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18502/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20230331072341.24851-7-naush@raspberrypi.com>", "date": "2023-03-31T07:23:37", "name": "[libcamera-devel,v3,06/10] ipa: raspberrypi: Generalise the contrast algorithm", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "232cacec53bcb2219f1ceaf771ad6b8083fdf80a", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18502/mbox/", "series": [ { "id": 3830, "url": "https://patchwork.libcamera.org/api/series/3830/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3830", "date": "2023-03-31T07:23:31", "name": "Raspberry Pi: Generalised algorithms", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3830/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18502/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18502/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 2582FC329D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Mar 2023 07:40:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B3BA46279A;\n\tFri, 31 Mar 2023 09:40:58 +0200 (CEST)", "from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com\n\t[IPv6:2607:f8b0:4864:20::d2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 504206277E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 09:40:55 +0200 (CEST)", "by mail-io1-xd2e.google.com with SMTP id bl9so9384549iob.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 00:40:55 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti17-20020a6bf411000000b0074555814e73sm421943iog.32.2023.03.31.00.40.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 31 Mar 2023 00:40:53 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680248458;\n\tbh=+GFENiSMhQ3HqhhlTZZ9jxVl3H1/G1XEnMd7DpUDotY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=hTZpMMZyqG9cz7cNeVpCyNWKQZi8jceeWEUNPtlS0S4NmAsQw/3Ie6xPH+H11n4Sv\n\t+kO0Hfnx8ZZtSPVsWtHueswrPpx85I4UjjvEW3rOjtPXSPtA3FolVv2QF6VzvfJ1oc\n\tCfYXHQewSrs1IDfU+sngdUpMHV5S7SK7VpxGxcFIVAQibzPv/U2P4w6O+JnGM+jKsm\n\tyHVEJA5JhryQTAccqDVreJ/1c/scj6FlRF7qXs6YGH//WByWDYQ9KfhsFTNownnOek\n\t97ZpdxUEPNle0xDY/ZCvlK8oWTmdM5B0T6OVnotMkvaWdrXHbBIJdhF3mgVSkpFDBn\n\tNdJm9yZXxbHUQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1680248454;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=CBhJt0BIC9Lqwq4l4PQJqQPOKidr71Zuik9quGaeQXo=;\n\tb=qIEZ7HLrdACAYDmlLPtVpqIWy7Rea+VFIgZYUwgZGF8H0ZbEOR9dsjuHoZcO7tM3Zp\n\tmGMUca72yl+xnq0Q9P6r0RegBC2LEtEh3Bg6C0od99ibUgV/ePCkWdpICnYuOKeGfdxW\n\tEdLsRy5qMZ6vuOvkQEn18S7oTa8y1Iqsc4TmZjnvQ4wvSBaLMKSs8GyJEJN9TKnN+U7F\n\t0v1UbCAXz0g31NSdofsLf+fpW3uHMybFYM5upRlrZJNh4e60YBjh4yKuVho2WQGtKhn2\n\t/pHEBmjfD/gc2nGZkSZABOnnV+QBOgPXAlRAeutRH6pk6yUE3aikoDOqc6z5iYVrhqUc\n\tx5mA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"qIEZ7HLr\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680248454;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=CBhJt0BIC9Lqwq4l4PQJqQPOKidr71Zuik9quGaeQXo=;\n\tb=dbmqGMi14J7E0LSqRcRtF4mfKPc/cvej4Lsz4VfKkCYdAZnHRdJzR6EbsRa5hyTa55\n\tAMubmvkH3/we0WqYlxLZes0JjSuf+ufZvhnHuSCdmkINMzvcUWN23dhFhbCQwuXydBC8\n\tNgoxU63wJMfhrcqoDAwAnALjM+HzBcwdwNt9GCpYQucoj9t7pY4cc31ldkKErVVyde2n\n\tzE0o2fCEYqoENh23IFGql4sm+Gat9wSKRH3fSrlTr3ZHXdmz6BBzTwYKjqZWAiBfONXX\n\tpevw8AEwcynnwYi+fQq6841toN8AmvwdU55ZzpI2zX4ubJGlO4X0jS3QCsWopvII8Y5N\n\tFNzQ==", "X-Gm-Message-State": "AO0yUKWbklBHWgoQ0hOQ1fL6Kw9yNto2ojir1ziNG93DmDutoWUEM1k/\n\t/kfwYHs6SWadQI21HVQkWjM5b75uMqVtcKD8tJI/gw==", "X-Google-Smtp-Source": "AK7set+at/3/A6n30NpBjD8Y5w9jFiWISNNVPjiHpLBFcTBUJO5gNRwaLwu684OJYw2GMqyu3+FQOQ==", "X-Received": "by 2002:a5e:8b49:0:b0:758:1db1:ca99 with SMTP id\n\tz9-20020a5e8b49000000b007581db1ca99mr18057445iom.19.1680248453684; \n\tFri, 31 Mar 2023 00:40:53 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 31 Mar 2023 08:23:37 +0100", "Message-Id": "<20230331072341.24851-7-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230331072341.24851-1-naush@raspberrypi.com>", "References": "<20230331072341.24851-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 06/10] ipa: raspberrypi: Generalise the\n\tcontrast algorithm", "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>", "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Generalise the contrast algorithm code by removing any hard-coded\nassumptions about the target hardware platform. Instead, the algorithm\ncode creates a generic Pwl that gets returned to the IPA, where it gets\nconverted to the bcm2835 hardware specific lookup table.\n\nAs a drive-by, remove an unused mutex.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../raspberrypi/controller/contrast_status.h | 11 ++-----\n .../raspberrypi/controller/rpi/contrast.cpp | 30 ++++---------------\n src/ipa/raspberrypi/controller/rpi/contrast.h | 1 -\n src/ipa/raspberrypi/raspberrypi.cpp | 15 +++++++---\n 4 files changed, 20 insertions(+), 37 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/contrast_status.h b/src/ipa/raspberrypi/controller/contrast_status.h\nindex ef2a7c680fc2..fb9fe4bace71 100644\n--- a/src/ipa/raspberrypi/controller/contrast_status.h\n+++ b/src/ipa/raspberrypi/controller/contrast_status.h\n@@ -6,20 +6,15 @@\n */\n #pragma once\n \n+#include \"pwl.h\"\n+\n /*\n * The \"contrast\" algorithm creates a gamma curve, optionally doing a little bit\n * of contrast stretching based on the AGC histogram.\n */\n \n-constexpr unsigned int ContrastNumPoints = 33;\n-\n-struct ContrastPoint {\n-\tuint16_t x;\n-\tuint16_t y;\n-};\n-\n struct ContrastStatus {\n-\tstruct ContrastPoint points[ContrastNumPoints];\n+\tRPiController::Pwl gammaCurve;\n \tdouble brightness;\n \tdouble contrast;\n };\ndiff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp\nindex a4f8c4f04fc4..bee1eadd3657 100644\n--- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp\n@@ -65,34 +65,19 @@ void Contrast::setContrast(double contrast)\n \tcontrast_ = contrast;\n }\n \n-static void fillInStatus(ContrastStatus &status, double brightness,\n-\t\t\t double contrast, Pwl &gammaCurve)\n-{\n-\tstatus.brightness = brightness;\n-\tstatus.contrast = contrast;\n-\tfor (unsigned int i = 0; i < ContrastNumPoints - 1; i++) {\n-\t\tint x = i < 16 ? i * 1024\n-\t\t\t : (i < 24 ? (i - 16) * 2048 + 16384\n-\t\t\t\t\t : (i - 24) * 4096 + 32768);\n-\t\tstatus.points[i].x = x;\n-\t\tstatus.points[i].y = std::min(65535.0, gammaCurve.eval(x));\n-\t}\n-\tstatus.points[ContrastNumPoints - 1].x = 65535;\n-\tstatus.points[ContrastNumPoints - 1].y = 65535;\n-}\n-\n void Contrast::initialise()\n {\n \t/*\n \t * Fill in some default values as Prepare will run before Process gets\n \t * called.\n \t */\n-\tfillInStatus(status_, brightness_, contrast_, config_.gammaCurve);\n+\tstatus_.brightness = brightness_;\n+\tstatus_.contrast = contrast_;\n+\tstatus_.gammaCurve = config_.gammaCurve;\n }\n \n void Contrast::prepare(Metadata *imageMetadata)\n {\n-\tstd::unique_lock<std::mutex> lock(mutex_);\n \timageMetadata->set(\"contrast.status\", status_);\n }\n \n@@ -183,12 +168,9 @@ void Contrast::process(StatisticsPtr &stats,\n \t * And fill in the status for output. Use more points towards the bottom\n \t * of the curve.\n \t */\n-\tContrastStatus status;\n-\tfillInStatus(status, brightness_, contrast_, gammaCurve);\n-\t{\n-\t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\tstatus_ = status;\n-\t}\n+\tstatus_.brightness = brightness_;\n+\tstatus_.contrast = contrast_;\n+\tstatus_.gammaCurve = std::move(gammaCurve);\n }\n \n /* Register algorithm with the system. */\ndiff --git a/src/ipa/raspberrypi/controller/rpi/contrast.h b/src/ipa/raspberrypi/controller/rpi/contrast.h\nindex c68adbc9e463..9c81277a0450 100644\n--- a/src/ipa/raspberrypi/controller/rpi/contrast.h\n+++ b/src/ipa/raspberrypi/controller/rpi/contrast.h\n@@ -46,7 +46,6 @@ private:\n \tdouble brightness_;\n \tdouble contrast_;\n \tContrastStatus status_;\n-\tstd::mutex mutex_;\n };\n \n } /* namespace RPiController */\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex c74558f1dc0c..e2662938c9d3 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1593,14 +1593,21 @@ void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)\n \n void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls)\n {\n+\tconst unsigned int numGammaPoints = controller_.getHardwareConfig().numGammaPoints;\n \tstruct bcm2835_isp_gamma gamma;\n \n-\tgamma.enabled = 1;\n-\tfor (unsigned int i = 0; i < ContrastNumPoints; i++) {\n-\t\tgamma.x[i] = contrastStatus->points[i].x;\n-\t\tgamma.y[i] = contrastStatus->points[i].y;\n+\tfor (unsigned int i = 0; i < numGammaPoints - 1; i++) {\n+\t\tint x = i < 16 ? i * 1024\n+\t\t\t : (i < 24 ? (i - 16) * 2048 + 16384\n+\t\t\t\t\t : (i - 24) * 4096 + 32768);\n+\t\tgamma.x[i] = x;\n+\t\tgamma.y[i] = std::min<uint16_t>(65535, contrastStatus->gammaCurve.eval(x));\n \t}\n \n+\tgamma.x[numGammaPoints - 1] = 65535;\n+\tgamma.y[numGammaPoints - 1] = 65535;\n+\tgamma.enabled = 1;\n+\n \tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(&gamma),\n \t\t\t\t\t sizeof(gamma) });\n \tctrls.set(V4L2_CID_USER_BCM2835_ISP_GAMMA, c);\n", "prefixes": [ "libcamera-devel", "v3", "06/10" ] }