[{"id":28312,"web_url":"https://patchwork.libcamera.org/comment/28312/","msgid":"<de211b15-4f5f-42a0-a0f5-dd3a93d90a22@redhat.com>","date":"2023-12-13T11:03:37","subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/people/102/","name":"Hans de Goede","email":"hdegoede@redhat.com"},"content":"Hi Pavel,\n\nOn 12/13/23 00:00, Pavel Machek wrote:\n> Hi!\n> \n>> ATM the statistics and debayer classes are mostly ready,\n>> but I need to merge this with Andrey's v2 RFC and\n>> then produce a clean new series from this\n>> (assuming people like the approach).\n> \n> Could I get you to apply this?\n\nI can give it a try and assuming it does not cause\na performance regression I would be happy to\nsquash this in.\n\nWhich brings the question of crediting the change,\nI can add a:\n\nSuggested-by: Pavel Machek <pavel@ucw.cz>\n\nfor these bits, or:\n\nCo-authored-by: Pavel Machek <pavel@ucw.cz>\n\nbut then I'm going to need a Signed-off-by from you\n(just reply here with it).\n\nEither way let me know which way you want to be credited?\n\nThe same question (how to credit) you also applies to\nthe suggested debayering changes ?\n\nBTW did you see that I added a x_shift_ variable\nto both the swstats and the debayer_cpu classes?\n\nThis allows shifting the input data start one\npixel to the right, changing e.g. RGGB to GRBG\nso that we need less debayer functions.\n\nUnfortunately this trick will not work for\n10bpp packed formats because there we have:\nMSB MSB MSB MSB LSBS in memory so we cannot\njust shift things by skipping the first column\nbecause then we end up with:\nMSB MSB MSB LSBS MSB instead, which breaks\nthe debayer / stats functions expectations.\n\nWhat we can do even with 10bpp packed is swap\nline0 / line1 pointers, so that e.g. RGGB becomes\nGBRG using the same stats / debayer functions.\n\nTogether with the x_shift_ thing this means that\nfor 8bits and 10 bits unpacked we will only need\n1 line0 and line1 debayer function to cover all\n4 basic bayer variants.\n\nRegards,\n\nHans\n\n\n\n\n> diff --git a/src/libcamera/software_isp/swstats_linaro.cpp b/src/libcamera/software_isp/swstats_linaro.cpp\n> index 0323f45f..2f203b17 100644\n> --- a/src/libcamera/software_isp/swstats_linaro.cpp\n> +++ b/src/libcamera/software_isp/swstats_linaro.cpp\n> @@ -38,80 +38,55 @@ static const unsigned int RED_Y_MUL = 77;\t\t/* 0.30 * 256 */\n>  static const unsigned int GREEN_Y_MUL = 150;\t\t/* 0.59 * 256 */\n>  static const unsigned int BLUE_Y_MUL = 29;\t\t/* 0.11 * 256 */\n>  \n> -/*\n> - * These need to be macros because it accesses a whole bunch of local\n> - * variables (and copy and pasting this x times is undesirable)\n> - */\n> -#define SWISP_LINARO_START_LINE_STATS()\t\t\t\\\n> -\tuint8_t r, g, b;\t\t\t\t\\\n> -\tunsigned int y_val;\t\t\t\t\\\n> -\t\t\t\t\t\t\t\\\n> -\tunsigned int sumR = 0;\t\t\t\t\\\n> -\tunsigned int sumG = 0;\t\t\t\t\\\n> -\tunsigned int sumB = 0;\t\t\t\t\\\n> -\t\t\t\t\t\t\t\\\n> -\tunsigned int bright_sum = 0;\t\t\t\\\n> -\tunsigned int too_bright_sum = 0;\n> -\n> -#define SWISP_LINARO_ACCUMULATE_LINE_STATS()\t\t\\\n> -\tsumR += r;\t\t\t\t\t\\\n> -\tsumG += g;\t\t\t\t\t\\\n> -\tsumB += b;\t\t\t\t\t\\\n> -\t\t\t\t\t\t\t\\\n> -\ty_val = r * RED_Y_MUL;\t\t\t\t\\\n> -\ty_val += g * GREEN_Y_MUL;\t\t\t\\\n> -\ty_val += b * BLUE_Y_MUL;\t\t\t\\\n> -\tif (y_val > BRIGHT_LVL) ++bright_sum;\t\t\\\n> -\tif (y_val > TOO_BRIGHT_LVL) ++too_bright_sum;\n> -\n> -#define SWISP_LINARO_FINISH_LINE_STATS()\t\t\\\n> -\tstats_.sumR_ += sumR;\t\t\t\t\\\n> -\tstats_.sumG_ += sumG;\t\t\t\t\\\n> -\tstats_.sumB_ += sumB;\t\t\t\t\\\n> -\t\t\t\t\t\t\t\\\n> -\tbright_sum_ += bright_sum;\t\t\t\\\n> -\ttoo_bright_sum_ += too_bright_sum;\n> -\n> -void SwStatsLinaro::statsBGGR10PLine(const uint8_t *src0, const uint8_t *src1)\n> +static void inline statsBayer(const int width, const uint8_t *src0, const uint8_t *src1, bool bggr, unsigned int &bright_sum, unsigned int &too_bright_sum, StatsLinaro &stats)\n>  {\n> -\tconst int width_in_bytes = width_ * 5 / 4;\n> -\tuint8_t g2;\n> +\tconst int width_in_bytes = width * 5 / 4;\n> +\tuint8_t r, g, b, g2;\n> +\tunsigned int y_val;\n>  \n> -\tSWISP_LINARO_START_LINE_STATS()\n> +\tstats.sumR_ = 0;\n> +\tstats.sumG_ = 0;\n> +\tstats.sumB_ = 0;\n>  \n> -\tfor (int x = 0; x < width_in_bytes; x += 5) {\n> -\t\t/* BGGR */\n> -\t\tb  = src0[x];\n> -\t\tg  = src0[x + 1];\n> -\t\tg2 = src1[x];\n> -\t\tr  = src1[x + 1];\n> +\tbright_sum = 0;\n> +\ttoo_bright_sum = 0;\n>  \n> +\tfor (int x = 0; x < width_in_bytes; x += 5) {\n> +\t\tif (bggr) {\n> +\t\t\t/* BGGR */\n> +\t\t\tb  = src0[x];\n> +\t\t\tg  = src0[x + 1];\n> +\t\t\tg2 = src1[x];\n> +\t\t\tr  = src1[x + 1];\n> +\t\t} else {\n> +\t\t\t/* GBRG */\n> +\t\t\tg  = src0[x];\n> +\t\t\tb  = src0[x + 1];\n> +\t\t\tr  = src1[x];\n> +\t\t\tg2 = src1[x + 1];\n> +\t\t}\n>  \t\tg = g + g2 / 2;\n>  \n> -\t\tSWISP_LINARO_ACCUMULATE_LINE_STATS()\n> +\t\tstats.sumR_ += r;\n> +\t\tstats.sumG_ += g;\n> +\t\tstats.sumB_ += b;\n> +\n> +\t\ty_val = r * RED_Y_MUL;\n> +\t\ty_val += g * GREEN_Y_MUL;\n> +\t\ty_val += b * BLUE_Y_MUL;\n> +\t\tif (y_val > BRIGHT_LVL) ++bright_sum;\n> +\t\tif (y_val > TOO_BRIGHT_LVL) ++too_bright_sum;\n>  \t}\n> -\tSWISP_LINARO_FINISH_LINE_STATS()\n>  }\n>  \n> -void SwStatsLinaro::statsGBRG10PLine(const uint8_t *src0, const uint8_t *src1)\n> +void SwStatsLinaro::statsBGGR10PLine(const uint8_t *src0, const uint8_t *src1)\n>  {\n> -\tconst int width_in_bytes = width_ * 5 / 4;\n> -\tuint8_t g2;\n> -\n> -\tSWISP_LINARO_START_LINE_STATS()\n> -\n> -\tfor (int x = 0; x < width_in_bytes; x += 5) {\n> -\t\t/* GBRG */\n> -\t\tg  = src0[x];\n> -\t\tb  = src0[x + 1];\n> -\t\tr  = src1[x];\n> -\t\tg2 = src1[x + 1];\n> -\n> -\t\tg = g + g2 / 2;\n> +\tstatsBayer(width_, src0, src1, true, bright_sum_, too_bright_sum_, stats_);\n> +}\n>  \n> -\t\tSWISP_LINARO_ACCUMULATE_LINE_STATS()\n> -\t}\n> -\tSWISP_LINARO_FINISH_LINE_STATS()\n> +void SwStatsLinaro::statsGBRG10PLine(const uint8_t *src0, const uint8_t *src1)\n> +{\n> +\tstatsBayer(width_, src0, src1, false, bright_sum_, too_bright_sum_, stats_);\n>  }\n>  \n>  void SwStatsLinaro::statsBGGR10PLine0(const uint8_t *src, unsigned int stride)\n>","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 DCA3DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Dec 2023 11:03:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0EA0362B32;\n\tWed, 13 Dec 2023 12:03:45 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 18D01629DF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 12:03:42 +0100 (CET)","from mail-ej1-f70.google.com (mail-ej1-f70.google.com\n\t[209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-217-B8758GIPPT2rIMpDf5aiAg-1; Wed, 13 Dec 2023 06:03:40 -0500","by mail-ej1-f70.google.com with SMTP id\n\ta640c23a62f3a-a1eb3f3dc2eso151818266b.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 03:03:40 -0800 (PST)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\tsk26-20020a170906631a00b00a1f7852c877sm6823829ejc.142.2023.12.13.03.03.37\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 13 Dec 2023 03:03:38 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702465425;\n\tbh=LudGL9P/tiz5bKA2wQ1GpoNpl2xat7hCD1anjZ93phk=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=m+UjBnq1WXgas04q6/7aN3gVMKAf2+7xfQNZ1TRyo8T7GskypPaoi5q5+bye1rVjx\n\tV8k1aY44x86Mhzsz4GCpUTl7bIfscHHMlU5DjiUbYLXXBhMLbnTyOtOv6ZFXdoDWe4\n\th31VGxPCPuVv1gDUm1i4ycCh7tO7VIhwe6VY/E/y2MM6rncQBDjK66FK5IKfnJJi2D\n\tfLoFUUz4Mc7niEQbnONKkzz55C5rXQqfYmhBV2yuQVEiND3ettHX7Lf2G7iS7eWEBX\n\tCSWNgvUODeNqIdthrZDKoZd/KsnqoXpGFoJ5PBOoA2UwJKIt5PiKZ1PnpQz+bAAkAi\n\taO+8bxgYgXXzg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1702465422;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=fayPz5xKsBtubcTfDVj5SYh0wD/ILW5k+Q+LtaD1P58=;\n\tb=CGbQsiR0By5S6/Ogf2nT7rWPEgEwum+eHkTiSiyTLfF6/4jYs9i3oa8jvvjrnQqcRsGgWE\n\t1CqlKwanOp+sijDv5lYO70rI1TJKhI4sTwv3ewrjuNptOy6f2nvYrAwUZ2jMEH5tmB9m/g\n\tKD90jbaK10VN4CPTCEcXauosu3Lb89s="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"CGbQsiR0\"; \n\tdkim-atps=neutral","X-MC-Unique":"B8758GIPPT2rIMpDf5aiAg-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1702465419; x=1703070219;\n\th=content-transfer-encoding:in-reply-to:from:references:cc:to\n\t:content-language:subject:user-agent:mime-version:date:message-id\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=fayPz5xKsBtubcTfDVj5SYh0wD/ILW5k+Q+LtaD1P58=;\n\tb=mYxwEM0lo0I2Rp30iTFleqrUpBEryI/1NnKmLbFqjUG0bHcR/wyilwkQ0ddsvJAtWB\n\tzk5rgjCLbEuOvvhCXaiXt4fh17IK9uSZZAC0CLKGxdHPaG+eeOnAaXzGIfurm0tmK9yU\n\tFRbD6kwQx+odxD33F4ON5kzA96l7x8AgsaVA9qiwT7g3vXcRKNAJRXveyEfeBSKtdI3x\n\tIeJTGSlaXZSFC5nwC1CmjXituZoH0xmD/l3qEfVTtsUfFsnmWf3tk7052C2JLRPambSB\n\tWm6MiFQsPfqzrw3YikSWvb50VHEv9+dIXmCsNYapEuiipzv2072w57SNfhpPZXmsXCbB\n\tbKdg==","X-Gm-Message-State":"AOJu0YxqwYTYwInBQeIG6HipKXecoDf1ib3wPvkVXdErgqwpx++1boFl\n\tRTq9zWdX/PMjf7Z6i53E0/+wp1vSX31I/cOB5BVCSeUndWV6ixvJQfNlvHBFxEc30NC9Mfv1Y//\n\t41GtYa4B0AQ4WbkXbdjG7YPqBBRrrxRTm8Q==","X-Received":["by 2002:a17:906:73d0:b0:a22:f58e:ed09 with SMTP id\n\tn16-20020a17090673d000b00a22f58eed09mr545216ejl.153.1702465419373; \n\tWed, 13 Dec 2023 03:03:39 -0800 (PST)","by 2002:a17:906:73d0:b0:a22:f58e:ed09 with SMTP id\n\tn16-20020a17090673d000b00a22f58eed09mr545213ejl.153.1702465419066; \n\tWed, 13 Dec 2023 03:03:39 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IFXa6vUE0SiKccr5aXqxZ+tPf6nQFWrbc+J9zkwCDGc8zSzARFUT724tw6QjQ1dv4rl5QzShw==","Message-ID":"<de211b15-4f5f-42a0-a0f5-dd3a93d90a22@redhat.com>","Date":"Wed, 13 Dec 2023 12:03:37 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","To":"Pavel Machek <pavel@ucw.cz>","References":"<20231212115046.102726-1-andrey.konovalov@linaro.org>\n\t<20231212115046.102726-5-andrey.konovalov@linaro.org>\n\t<ZXiBbvEBns4mdU9/@duo.ucw.cz>\n\t<170239706778.3044059.6462285174630637754@ping.linuxembedded.co.uk>\n\t<dfb2a76c-13ca-4c0b-8d90-a226e83b35f0@linaro.org>\n\t<170239891199.3044059.3154360492786632784@ping.linuxembedded.co.uk>\n\t<ZXiMNSek6vsOi4tA@duo.ucw.cz>\n\t<4dc8535c-53da-4c96-a2c0-1f786a8857f9@redhat.com>\n\t<ZXjl/SEqU3X6skMC@duo.ucw.cz>","In-Reply-To":"<ZXjl/SEqU3X6skMC@duo.ucw.cz>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US, nl","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","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":"Hans de Goede via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Hans de Goede <hdegoede@redhat.com>","Cc":"mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tPavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>, \n\tsrinivas.kandagatla@linaro.org, bryan.odonoghue@linaro.org,\n\tadmin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28313,"web_url":"https://patchwork.libcamera.org/comment/28313/","msgid":"<ZXmrEfBlakPdjRDP@duo.ucw.cz>","date":"2023-12-13T13:01:05","subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> >> ATM the statistics and debayer classes are mostly ready,\n> >> but I need to merge this with Andrey's v2 RFC and\n> >> then produce a clean new series from this\n> >> (assuming people like the approach).\n> > \n> > Could I get you to apply this?\n> \n> I can give it a try and assuming it does not cause\n> a performance regression I would be happy to\n> squash this in.\n> \n> Which brings the question of crediting the change,\n> I can add a:\n> \n> Suggested-by: Pavel Machek <pavel@ucw.cz>\n\nThis one will be fine.\n\n> but then I'm going to need a Signed-off-by from you\n> (just reply here with it).\n\nSigned-off-by: Pavel Machek <pavel@ucw.cz>\n\n> Either way let me know which way you want to be credited?\n> \n> The same question (how to credit) you also applies to\n> the suggested debayering changes ?\n\nSuggested-by will be fine... and\n\nSigned-off-by: Pavel Machek <pavel@ucw.cz>\n\nfor that as well.\n\n> BTW did you see that I added a x_shift_ variable\n> to both the swstats and the debayer_cpu classes?\n> \n> This allows shifting the input data start one\n> pixel to the right, changing e.g. RGGB to GRBG\n> so that we need less debayer functions.\n> \n> Unfortunately this trick will not work for\n> 10bpp packed formats because there we have:\n> MSB MSB MSB MSB LSBS in memory so we cannot\n> just shift things by skipping the first column\n> because then we end up with:\n> MSB MSB MSB LSBS MSB instead, which breaks\n> the debayer / stats functions expectations.\n\nAha, neat trick I did not notice. I'll take a look. At some point, I\nguess we'll need better abstractions that separate getting bayer data\n(there are at least 8, 10, 10p, 12 variants -- and some people will\nwant to use the low bits) and actual debayer algorithm (you have\nbi-linear, but there's also nearest point, and there are also higher\nquality variants).\n\nBut, this all can wait.\n\nI believe first step is getting your series merged. Adding 8bpp to\nthat should be easy after it is in, and makes pinephone useful. (And\nlikely helps to others).\n\nThen... I guess doing debayer+downscale for preview makes sense. Doing\nit in one step should save significant CPU. But then \"what to do with\nrgb stream for video recording\" is a good question. May need better\nquality than we have (use full 10 bits, lens shading compensation),\nand is still performance sensitive, and maybe clipping to odd\nresolution as we currently do will be a problem there.\n\nBest regards,\n\t\t\t\t\t\t\t\tPavel","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 B4739C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Dec 2023 13:01:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0419962B2A;\n\tWed, 13 Dec 2023 14:01:09 +0100 (CET)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 82CE7629DF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 14:01:06 +0100 (CET)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid D8C931C006F; Wed, 13 Dec 2023 14:01:05 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702472469;\n\tbh=nHpAz3BEsl54pM0qF4UxNtD+GgaFNMu3UdGlB9cw5v4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=lsek2uGL6gw9Iuhlta0g08/sr+R2JCXkfcx5RnfRA9Ly7KCrqGkLksiar0i/CZ+/3\n\tuOtqbucGQrH6E9yWubtYx5LivlUc+6iPKRieRJIdDvS/Jx0YE3fIhp7MDsMqrmDi0Z\n\tHv0aZG6uIhJKznpZ+7oQdjlzw+uuk0QPUJV4dWQPLMrO5pMCrjUNJ/decaGLTXjhBo\n\tzpNYBHFYXtU1Kww/0duiIVwt4KSoLWnSfoJWxo8Hq7DA0LBvx9CJTUix2Mj9ioOm9f\n\tzOMFothbYCeiZMdCvpJZSRNYaqE6+OkWh9Mc/E8a/Al6LjgggoTHHNE4wC83wpukE9\n\tmJ8GhWb3CBNtw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1702472465;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=xweXTBjXc+o8wboRappsKSPHxS4wgHbtYpnWTik85i8=;\n\tb=hqniLJVQUFNhitXaJe5OFaP4NbeVGPXytQBsruYTaj/8L1absHNoABeq1eBWeajCzfmVSS\n\tCPsgC8RQ87/cGcOWOf/F3WXLCJ9peb+qV1gUj9cUMoX0TYn3Ia7VJTlZrMaJt1orqGqobs\n\t/l3+NyGFx3MnLYlKhbGFofKo+rMiVLQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ucw.cz header.i=@ucw.cz\n\theader.b=\"hqniLJVQ\"; dkim-atps=neutral","Date":"Wed, 13 Dec 2023 14:01:05 +0100","To":"Hans de Goede <hdegoede@redhat.com>","Message-ID":"<ZXmrEfBlakPdjRDP@duo.ucw.cz>","References":"<20231212115046.102726-1-andrey.konovalov@linaro.org>\n\t<20231212115046.102726-5-andrey.konovalov@linaro.org>\n\t<ZXiBbvEBns4mdU9/@duo.ucw.cz>\n\t<170239706778.3044059.6462285174630637754@ping.linuxembedded.co.uk>\n\t<dfb2a76c-13ca-4c0b-8d90-a226e83b35f0@linaro.org>\n\t<170239891199.3044059.3154360492786632784@ping.linuxembedded.co.uk>\n\t<ZXiMNSek6vsOi4tA@duo.ucw.cz>\n\t<4dc8535c-53da-4c96-a2c0-1f786a8857f9@redhat.com>\n\t<ZXjl/SEqU3X6skMC@duo.ucw.cz>\n\t<de211b15-4f5f-42a0-a0f5-dd3a93d90a22@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"GyGBLpVfQOwi0GEr\"","Content-Disposition":"inline","In-Reply-To":"<de211b15-4f5f-42a0-a0f5-dd3a93d90a22@redhat.com>","Subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","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":"Pavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Pavel Machek <pavel@ucw.cz>","Cc":"mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tPavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>, \n\tsrinivas.kandagatla@linaro.org, bryan.odonoghue@linaro.org,\n\tadmin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28315,"web_url":"https://patchwork.libcamera.org/comment/28315/","msgid":"<e643b5c3-e0aa-429b-b884-24485ec78c70@redhat.com>","date":"2023-12-13T20:38:58","subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","submitter":{"id":102,"url":"https://patchwork.libcamera.org/api/people/102/","name":"Hans de Goede","email":"hdegoede@redhat.com"},"content":"Hi,\n\nOn 12/13/23 00:00, Pavel Machek wrote:\n> Hi!\n> \n>> ATM the statistics and debayer classes are mostly ready,\n>> but I need to merge this with Andrey's v2 RFC and\n>> then produce a clean new series from this\n>> (assuming people like the approach).\n> \n> Could I get you to apply this?\n> \n> My camera is bayer8, so this is compile-tested only, but should give\n> same performance with shorter and more readable source. (It will also\n> allow me to add bayer8 statistics with little modifications).\n> \n> Thank you and best regards,\n> \t\t\t\t\t\t\t\tPavel\n\nThank you.\n\nNote your implementation was broken because you were resetting\nthe per frame stats every line. The idea is to use a local variable\n(hopefully a register) to gather the local r + g + b sums and\nthen at the end of processing the entire line increase\nthe per frame stats using the local variable.\n\nI have merged / squashed a fixed version with some further cleanups:\n\nFrom ea1be60a181fad3a782fe970198906593601c3d3 Mon Sep 17 00:00:00 2001\nFrom: Pavel Machek <pavel@ucw.cz>\nDate: Wed, 13 Dec 2023 00:00:13 +0100\nSubject: [PATCH] Pavel swstats changes\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n .../internal/software_isp/swstats_cpu.h       |   2 -\n src/libcamera/software_isp/swstats_cpu.cpp    | 120 +++++++-----------\n 2 files changed, 46 insertions(+), 76 deletions(-)\n\ndiff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\nindex 993ade3e..0ceb995f 100644\n--- a/include/libcamera/internal/software_isp/swstats_cpu.h\n+++ b/include/libcamera/internal/software_isp/swstats_cpu.h\n@@ -29,8 +29,6 @@ public:\n \t/* FIXME this should be dropped once AWB has moved to the IPA */\n \tSwIspStats getStats() { return *sharedStats_; }\n private:\n-\tvoid statsBGGR10PLine(const uint8_t *src0, const uint8_t *src1);\n-\tvoid statsGBRG10PLine(const uint8_t *src0, const uint8_t *src1);\n \tvoid statsBGGR10PLine0(const uint8_t *src, unsigned int stride);\n \tvoid statsGBRG10PLine0(const uint8_t *src, unsigned int stride);\n \tvoid statsGRBG10PLine0(const uint8_t *src, unsigned int stride);\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 161dd033..84edadd8 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -36,102 +36,74 @@ static const unsigned int RED_Y_MUL = 77;\t\t/* 0.30 * 256 */\n static const unsigned int GREEN_Y_MUL = 150;\t\t/* 0.59 * 256 */\n static const unsigned int BLUE_Y_MUL = 29;\t\t/* 0.11 * 256 */\n \n-/*\n- * These need to be macros because it accesses a whole bunch of local\n- * variables (and copy and pasting this x times is undesirable)\n- */\n-#define SWISP_LINARO_START_LINE_STATS()\t\t\t\\\n-\tuint8_t r, g, b;\t\t\t\t\\\n-\tunsigned int y_val;\t\t\t\t\\\n-\t\t\t\t\t\t\t\\\n-\tunsigned int sumR = 0;\t\t\t\t\\\n-\tunsigned int sumG = 0;\t\t\t\t\\\n-\tunsigned int sumB = 0;\t\t\t\t\\\n-\t\t\t\t\t\t\t\\\n-\tunsigned int bright_sum = 0;\t\t\t\\\n+static inline __attribute__((always_inline)) void\n+statsBayer10P(const int width, const uint8_t *src0, const uint8_t *src1, bool bggr, unsigned int &bright_sum_, unsigned int &too_bright_sum_, SwIspStats &stats_)\n+{\n+\tconst int width_in_bytes = width * 5 / 4;\n+\tuint8_t r, g, b, g2;\n+\tunsigned int y_val;\n+\tunsigned int sumR = 0;\n+\tunsigned int sumG = 0;\n+\tunsigned int sumB = 0;\n+\n+\tunsigned int bright_sum = 0;\n \tunsigned int too_bright_sum = 0;\n \n-#define SWISP_LINARO_ACCUMULATE_LINE_STATS()\t\t\\\n-\tsumR += r;\t\t\t\t\t\\\n-\tsumG += g;\t\t\t\t\t\\\n-\tsumB += b;\t\t\t\t\t\\\n-\t\t\t\t\t\t\t\\\n-\ty_val = r * RED_Y_MUL;\t\t\t\t\\\n-\ty_val += g * GREEN_Y_MUL;\t\t\t\\\n-\ty_val += b * BLUE_Y_MUL;\t\t\t\\\n-\tif (y_val > BRIGHT_LVL) ++bright_sum;\t\t\\\n-\tif (y_val > TOO_BRIGHT_LVL) ++too_bright_sum;\n+\tfor (int x = 0; x < width_in_bytes; x += 5) {\n+\t\tif (bggr) {\n+\t\t\t/* BGGR */\n+\t\t\tb  = src0[x];\n+\t\t\tg  = src0[x + 1];\n+\t\t\tg2 = src1[x];\n+\t\t\tr  = src1[x + 1];\n+\t\t} else {\n+\t\t\t/* GBRG */\n+\t\t\tg  = src0[x];\n+\t\t\tb  = src0[x + 1];\n+\t\t\tr  = src1[x];\n+\t\t\tg2 = src1[x + 1];\n+\t\t}\n+\t\tg = g + g2 / 2;\n \n-#define SWISP_LINARO_FINISH_LINE_STATS()\t\t\\\n-\tstats_.sumR_ += sumR;\t\t\t\t\\\n-\tstats_.sumG_ += sumG;\t\t\t\t\\\n-\tstats_.sumB_ += sumB;\t\t\t\t\\\n-\t\t\t\t\t\t\t\\\n-\tbright_sum_ += bright_sum;\t\t\t\\\n+\t\tsumR += r;\n+\t\tsumG += g;\n+\t\tsumB += b;\n+\n+\t\ty_val = r * RED_Y_MUL;\n+\t\ty_val += g * GREEN_Y_MUL;\n+\t\ty_val += b * BLUE_Y_MUL;\n+\t\tif (y_val > BRIGHT_LVL) ++bright_sum;\n+\t\tif (y_val > TOO_BRIGHT_LVL) ++too_bright_sum;\n+\t}\n+\n+\tstats_.sumR_ += sumR;\n+\tstats_.sumG_ += sumG;\n+\tstats_.sumB_ += sumB;\n+\n+\tbright_sum_ += bright_sum;\n \ttoo_bright_sum_ += too_bright_sum;\n-\n-void SwStatsCpu::statsBGGR10PLine(const uint8_t *src0, const uint8_t *src1)\n-{\n-\tconst int width_in_bytes = window_.width * 5 / 4;\n-\tuint8_t g2;\n-\n-\tSWISP_LINARO_START_LINE_STATS()\n-\n-\tfor (int x = 0; x < width_in_bytes; x += 5) {\n-\t\t/* BGGR */\n-\t\tb  = src0[x];\n-\t\tg  = src0[x + 1];\n-\t\tg2 = src1[x];\n-\t\tr  = src1[x + 1];\n-\n-\t\tg = g + g2 / 2;\n-\n-\t\tSWISP_LINARO_ACCUMULATE_LINE_STATS()\n-\t}\n-\tSWISP_LINARO_FINISH_LINE_STATS()\n-}\n-\n-void SwStatsCpu::statsGBRG10PLine(const uint8_t *src0, const uint8_t *src1)\n-{\n-\tconst int width_in_bytes = window_.width * 5 / 4;\n-\tuint8_t g2;\n-\n-\tSWISP_LINARO_START_LINE_STATS()\n-\n-\tfor (int x = 0; x < width_in_bytes; x += 5) {\n-\t\t/* GBRG */\n-\t\tg  = src0[x];\n-\t\tb  = src0[x + 1];\n-\t\tr  = src1[x];\n-\t\tg2 = src1[x + 1];\n-\n-\t\tg = g + g2 / 2;\n-\n-\t\tSWISP_LINARO_ACCUMULATE_LINE_STATS()\n-\t}\n-\tSWISP_LINARO_FINISH_LINE_STATS()\n }\n \n void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src, unsigned int stride)\n {\n-\tstatsBGGR10PLine(src, src + stride);\n+\tstatsBayer10P(window_.width, src, src + stride, true, bright_sum_, too_bright_sum_, stats_);\n }\n \n void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src, unsigned int stride)\n {\n-\tstatsGBRG10PLine(src, src + stride);\n+\tstatsBayer10P(window_.width, src, src + stride, false, bright_sum_, too_bright_sum_, stats_);\n }\n \n void SwStatsCpu::statsGRBG10PLine0(const uint8_t *src, unsigned int stride)\n {\n \t/* GRBG is BGGR with the lines swapped */\n-\tstatsBGGR10PLine(src + stride, src);\n+\tstatsBayer10P(window_.width, src + stride, src, true, bright_sum_, too_bright_sum_, stats_);\n }\n \n void SwStatsCpu::statsRGGB10PLine0(const uint8_t *src, unsigned int stride)\n {\n \t/* RGGB is GBRG with the lines swapped */\n-\tstatsGBRG10PLine(src + stride, src);\n+\tstatsBayer10P(window_.width, src + stride, src, false, bright_sum_, too_bright_sum_, stats_);\n }\n \n void SwStatsCpu::resetStats(void)","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 56D08C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Dec 2023 20:39:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F2F2562B2A;\n\tWed, 13 Dec 2023 21:39:06 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A256629DF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 21:39:05 +0100 (CET)","from mail-lf1-f71.google.com (mail-lf1-f71.google.com\n\t[209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-537-ebz1KFRVNKmXQrJpmxYnvQ-1; Wed, 13 Dec 2023 15:39:01 -0500","by mail-lf1-f71.google.com with SMTP id\n\t2adb3069b0e04-50bea1c4468so6635293e87.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 12:39:01 -0800 (PST)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\twb8-20020a170907d50800b00a1cb351dd4fsm8379879ejc.9.2023.12.13.12.38.58\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 13 Dec 2023 12:38:59 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702499947;\n\tbh=bwueSQBGg2LMQJ9LpItlLg3FNsA7oJwlWKsXfTStBSQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QJQZfu6tDZ90alVhI83+5Nc0xgTv8f1NEaOPNayhAjDKaQHQoCLqo/O8d5oQ7QuBW\n\tJgS0QFE28blKkLd8Cs3zJUmNFOCM8S6z8Ojc3A6lkLDoM7geOO2+O6eJAT62R8MwL2\n\tIpKjzGpYZiLq4SXLtWTKVG01Ss+p1BmbU+kV3KO8hJ9uLGkFJGpHYWwVf842u3RABb\n\tyXSW6oqnKS0e3T1x7CvfNRqO1HWl9bnya04Jb08mKPALEwf8o29VH4c2onqLTV3Q6l\n\tN3sRfG9xRWUNeaW2/166TMhNRYTSbDtp5aDNesll4amnjrBaenmA64JEEYkQxwvvx/\n\thXtY6ostcceJQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1702499944;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=L72BYYosfHDA9Nb+NaesoFLmntIGqDFpLpSuF51Xjfo=;\n\tb=N5nsimCv/WH0Z1Xa/ndNtQhwmy9EJ+x0Uyj/ZMtHZdzzjVok2GbzgYeMcRrbdflWhc9mGi\n\tpTWQT0q0VtK0S/yuulJgBh8F1wdzfB1BAN+g0Sqy/QX+QZoQWzXksQll138Bc84OuOw7Y1\n\ty/G3udSWGYywDoyp0YrF/eqzCBAPDxg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"N5nsimCv\"; \n\tdkim-atps=neutral","X-MC-Unique":"ebz1KFRVNKmXQrJpmxYnvQ-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1702499940; x=1703104740;\n\th=content-transfer-encoding:in-reply-to:from:references:cc:to\n\t:content-language:subject:user-agent:mime-version:date:message-id\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=L72BYYosfHDA9Nb+NaesoFLmntIGqDFpLpSuF51Xjfo=;\n\tb=qu1AjjWpMAVqTIcOIzYavShbzUJhvEJv7BX8MxfrxVX9AW8y99hzfbfFTl7ndd+Tzt\n\txXkCn+vBdGzQ1aFtfiMX3qtIKheNtsISrovNYcrJvUEDj9ym5RXuY7uFrE9iuizrrTbQ\n\tEgzviUT/RL8MfV53T3ynYudQL6ZT5KtIPekrbIlZ+YL469MFsB+C5ynJqDV0NEFUInwM\n\t/26pMVTj6y+jrBOKWd91BbK7b8T5/K328OyzUqHh/w0ejJHXrhsEWHFgWA+pDg5TyvJw\n\tlAXNTSid3fLjWtOzsoFh9OknuoJcj9SSb0vlQOS+kZxKJo7w3eb6ywhTs/SGUYGN5jmx\n\tD3/A==","X-Gm-Message-State":"AOJu0Yzsf0eOa3QNnfJ3uiHH04z6gXSF8T1NrqQLdNobGu4gxS2wjHUB\n\t79s3LLP5C3lq/Zs3GYJRK8OjAFZVe1nCfaI2cJ8XWqILFRdIdO944slg2AfjOhtsMWTPsMqrFPd\n\tmj7u4avckJw/REUXzPyFffNFpvMsVcJdSyw==","X-Received":["by 2002:a05:6512:3b21:b0:50d:f93b:d13f with SMTP id\n\tf33-20020a0565123b2100b0050df93bd13fmr4491130lfv.137.1702499940520; \n\tWed, 13 Dec 2023 12:39:00 -0800 (PST)","by 2002:a05:6512:3b21:b0:50d:f93b:d13f with SMTP id\n\tf33-20020a0565123b2100b0050df93bd13fmr4491123lfv.137.1702499940147; \n\tWed, 13 Dec 2023 12:39:00 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IHe+QFY46OGfEo28WFQT9RhgPHST8djHDfJc7Xe+tXt+LZGqqDeZVCrfLpQMiseMBbABtg0Lw==","Message-ID":"<e643b5c3-e0aa-429b-b884-24485ec78c70@redhat.com>","Date":"Wed, 13 Dec 2023 21:38:58 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","To":"Pavel Machek <pavel@ucw.cz>","References":"<20231212115046.102726-1-andrey.konovalov@linaro.org>\n\t<20231212115046.102726-5-andrey.konovalov@linaro.org>\n\t<ZXiBbvEBns4mdU9/@duo.ucw.cz>\n\t<170239706778.3044059.6462285174630637754@ping.linuxembedded.co.uk>\n\t<dfb2a76c-13ca-4c0b-8d90-a226e83b35f0@linaro.org>\n\t<170239891199.3044059.3154360492786632784@ping.linuxembedded.co.uk>\n\t<ZXiMNSek6vsOi4tA@duo.ucw.cz>\n\t<4dc8535c-53da-4c96-a2c0-1f786a8857f9@redhat.com>\n\t<ZXjl/SEqU3X6skMC@duo.ucw.cz>","In-Reply-To":"<ZXjl/SEqU3X6skMC@duo.ucw.cz>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Language":"en-US, nl","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","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":"Hans de Goede via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Hans de Goede <hdegoede@redhat.com>","Cc":"mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tPavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>, \n\tsrinivas.kandagatla@linaro.org, bryan.odonoghue@linaro.org,\n\tadmin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28317,"web_url":"https://patchwork.libcamera.org/comment/28317/","msgid":"<ZXokgpKY7bo9n4pZ@duo.ucw.cz>","date":"2023-12-13T21:39:14","subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> Note your implementation was broken because you were resetting\n> the per frame stats every line. The idea is to use a local variable\n> (hopefully a register) to gather the local r + g + b sums and\n> then at the end of processing the entire line increase\n> the per frame stats using the local variable.\n\nYes, I seen that optimalization, I just hoped that compiler is able to\nthis on its own when it has enough registers.\n\n> I have merged / squashed a fixed version with some further cleanups:\n\nThank you, looks good.\n\nDid we decide on the name? swisp_cpu or something like that was\nmentioned, but perhaps we cpuisp is shorter and also should be unique\nenough?\n\nBest regards,\n\t\t\t\t\t\t\tPavel","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 50EF6C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Dec 2023 21:39:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8AA5E62B2A;\n\tWed, 13 Dec 2023 22:39:17 +0100 (CET)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C22E629DF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Dec 2023 22:39:15 +0100 (CET)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid 1C2731C006F; Wed, 13 Dec 2023 22:39:15 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702503557;\n\tbh=TyLXMavBCuHAnkhlzxmohpFWVUE1kscM5US6XtMUzoM=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=EX3OP5ips4u/bZYkp6w8Hu2sO9wZRjEAKGXQTKovJ1A4QWydHqLsUGWSeAs6VnsG4\n\tt6kPKpPkFRTIHCoTHQc+WkfidodKFvhZ6G3uGspQu3iECnH8L9c4oMs1jL+c82oJyQ\n\tkF8NuL0HhQPM7bw8w5tCh8V7F4shC0QDtvWDSMtCyYhz+ulteVKyQyJLynhkK+xsjp\n\tMTv/0Xr+XbRshWe8Zf2cPKyoGLLEbi7ZbtUmByFeudZY4GaxWOUzWYIj0hXlnY6QsD\n\tRj/13CpeDDd2Yy6R/T+qZz1fex5XWjcO4QVTbG+2+uVXM/fuJkgBCzTWeJe28xCTED\n\tIbdUPOC7lflsg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1702503555;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=OIfEGBo20xhHX3D+3nx6yr5voFwadSXWZQ9uV9Ve79o=;\n\tb=DXVrBZTl1r7hz/4/enROpPo7PhBsq7ibYkAT1eiBZrf0sDzvD6WYTydYvm7Jk+P3KyPaO6\n\tdzj+hQJnQOFiLRRtsfma/h15eCJ0ouyhF2Yi3SMkPgJPPJCgyOlVnkcTEI/xLWjUkT41xr\n\tq4whWg1bkgzntJoqhHqRkvn7xHLrrlg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ucw.cz header.i=@ucw.cz\n\theader.b=\"DXVrBZTl\"; dkim-atps=neutral","Date":"Wed, 13 Dec 2023 22:39:14 +0100","To":"Hans de Goede <hdegoede@redhat.com>","Message-ID":"<ZXokgpKY7bo9n4pZ@duo.ucw.cz>","References":"<20231212115046.102726-1-andrey.konovalov@linaro.org>\n\t<20231212115046.102726-5-andrey.konovalov@linaro.org>\n\t<ZXiBbvEBns4mdU9/@duo.ucw.cz>\n\t<170239706778.3044059.6462285174630637754@ping.linuxembedded.co.uk>\n\t<dfb2a76c-13ca-4c0b-8d90-a226e83b35f0@linaro.org>\n\t<170239891199.3044059.3154360492786632784@ping.linuxembedded.co.uk>\n\t<ZXiMNSek6vsOi4tA@duo.ucw.cz>\n\t<4dc8535c-53da-4c96-a2c0-1f786a8857f9@redhat.com>\n\t<ZXjl/SEqU3X6skMC@duo.ucw.cz>\n\t<e643b5c3-e0aa-429b-b884-24485ec78c70@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"dMeVZkK3vgCNQ5cT\"","Content-Disposition":"inline","In-Reply-To":"<e643b5c3-e0aa-429b-b884-24485ec78c70@redhat.com>","Subject":"Re: [libcamera-devel] statistics cleanup was Re: ... libcamera:\n\tipa: Soft IPA: add a Soft IPA implementation","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":"Pavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Pavel Machek <pavel@ucw.cz>","Cc":"mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tPavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>, \n\tsrinivas.kandagatla@linaro.org, bryan.odonoghue@linaro.org,\n\tadmin@dennisbonke.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]