[{"id":26673,"web_url":"https://patchwork.libcamera.org/comment/26673/","msgid":"<20230319201559.GI13726@pendragon.ideasonboard.com>","date":"2023-03-19T23:34:04","subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Dan,\n\nThank you for the patch.\n\nOn Sat, Mar 18, 2023 at 11:40:12PM +0000, Daniel Scally via libcamera-devel wrote:\n> Add support for the IPU3_Y10 format to the FormatConverter.\n\nBefore reviewing this patch in details, I'd like to know if there would\nbe a way to use the ImgU to convert the IPU3-packed greyscale format to\na more standard format. Is this something you have considered ?\n\n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>  src/apps/qcam/format_converter.cpp | 50 ++++++++++++++++++++++++++++++\n>  src/apps/qcam/format_converter.h   |  2 ++\n>  2 files changed, 52 insertions(+)\n> \n> diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp\n> index de76b32c..7f5648f3 100644\n> --- a/src/apps/qcam/format_converter.cpp\n> +++ b/src/apps/qcam/format_converter.cpp\n> @@ -169,6 +169,10 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>  \t\tformatFamily_ = MJPEG;\n>  \t\tbreak;\n>  \n> +\tcase libcamera::formats::Y10_IPU3:\n> +\t\tformatFamily_ = IPU3Packed;\n> +\t\tbreak;\n> +\n>  \tdefault:\n>  \t\treturn -EINVAL;\n>  \t};\n> @@ -199,6 +203,9 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n>  \tcase YUVPlanar:\n>  \t\tconvertYUVPlanar(src, dst->bits());\n>  \t\tbreak;\n> +\tcase IPU3Packed:\n> +\t\tconvertIPU3Packed(src, dst->bits(), size);\n> +\t\tbreak;\n>  \t};\n>  }\n>  \n> @@ -357,3 +364,46 @@ void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char\n>  \t\t}\n>  \t}\n>  }\n> +\n> +void FormatConverter::convertIPU3Packed(const Image *srcImage, unsigned char *dst, size_t size)\n> +{\n> +\tconst unsigned char *src = srcImage->data(0).data();\n> +\tunsigned int bytesprocessed = 0;\n> +\tunsigned int lsb_shift;\n> +\tunsigned int msb_shift;\n> +\tunsigned int index;\n> +\tunsigned int x = 0;\n> +\tuint16_t pixel;\n> +\n> +\twhile (bytesprocessed < size) {\n> +\t\tfor (unsigned int i = 0; i < 25; ++i) {\n> +\t\t\tindex = (i * 10) / 8;\n> +\t\t\tlsb_shift = (i * 10) % 8;\n> +\t\t\tmsb_shift = 8 - lsb_shift;\n> +\n> +\t\t\t/*\n> +\t\t\t * The IPU3-packed format can result in padding at the\n> +\t\t\t * end of a 32-byte block if the last pixel in a row is\n> +\t\t\t * within that block. Check whether we're on the line's\n> +\t\t\t * last pixel and skip the rest of the block if so.\n> +\t\t\t */\n> +\t\t\tif (x == width_) {\n> +\t\t\t\tx = 0;\n> +\t\t\t\tdst += width_ * 4;\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\n> +\t\t\tpixel = (((src + bytesprocessed)[index+1] << msb_shift) & 0x3ff)\n> +\t\t\t      | (((src + bytesprocessed)[index+0] >> lsb_shift) & 0x3ff);\n> +\n> +\t\t\tdst[4 * x + 0] = (pixel >> 2) & 0xff;\n> +\t\t\tdst[4 * x + 1] = (pixel >> 2) & 0xff;\n> +\t\t\tdst[4 * x + 2] = (pixel >> 2) & 0xff;\n> +\t\t\tdst[4 * x + 3] = 0xff;\n> +\n> +\t\t\tx++;\n> +\t\t}\n> +\n> +\t\tbytesprocessed += 32;\n> +\t}\n> +}\n> diff --git a/src/apps/qcam/format_converter.h b/src/apps/qcam/format_converter.h\n> index 37dbfae2..940f8b6b 100644\n> --- a/src/apps/qcam/format_converter.h\n> +++ b/src/apps/qcam/format_converter.h\n> @@ -31,12 +31,14 @@ private:\n>  \t\tYUVPacked,\n>  \t\tYUVPlanar,\n>  \t\tYUVSemiPlanar,\n> +\t\tIPU3Packed,\n>  \t};\n>  \n>  \tvoid convertRGB(const Image *src, unsigned char *dst);\n>  \tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n>  \tvoid convertYUVPlanar(const Image *src, unsigned char *dst);\n>  \tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n> +\tvoid convertIPU3Packed(const Image *src, unsigned char *dst, size_t size);\n>  \n>  \tlibcamera::PixelFormat format_;\n>  \tunsigned int width_;","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 4E2AFBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 19 Mar 2023 23:34:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1ADDD626D4;\n\tMon, 20 Mar 2023 00:34:02 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE1A4603AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Mar 2023 00:34:00 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E3E3113FF;\n\tMon, 20 Mar 2023 00:33:59 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679268842;\n\tbh=G2xpIdNUVwhLGQr64D2kfUj5hi/4OdZV6BphjouWq3E=;\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=3EHaedjDjfD0F5oaUQsV8Z2Wgtc+MWZduI/WBwngvRAvIo/hAsctksat2xSq3Tbcl\n\t867bQmko/hqiDkeLoqP5qUnj8DzxhCMp3NKcmxjJGrP0wHFK6WD41v5sQ8/R4na1SP\n\tNNtTvcfYROJvtUxs4VclLMbh9QiIP1rCA750inL45XOs/Gmg80Zwg/xT2wgqMs8M92\n\ty4E8eDS05EuVkrA8lhPD486LNeeCfcuB2E7JWPm5fYavkHc9f+1l6wONrT0o0buT5e\n\tbRzhjWTTvVNMHxf99WFmh/ahSKvvVvR+VhuOMOJT2jYAOXTRoxi2GtHHkJ3APakj/Y\n\t02GwGs1GEdc4Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1679268840;\n\tbh=G2xpIdNUVwhLGQr64D2kfUj5hi/4OdZV6BphjouWq3E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PxecG3X73SSjtTl2He+JLjW7AN4B61Mv1yUXD1djWFb7m/OsFaCuf9ljpiNtzSmB3\n\thdBCHkA27Tvj83+es2oZza60o4EyTDcsuUfDNWHwsd7l4GFmzYYeTP3dLBdHHwNwDa\n\tlpuuEKtl9ABQ20Ua5OljknXsvH5Dzandf1ijDnMQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"PxecG3X7\"; dkim-atps=neutral","Date":"Mon, 20 Mar 2023 01:34:04 +0200","To":"Daniel Scally <dan.scally@ideasonboard.com>","Message-ID":"<20230319201559.GI13726@pendragon.ideasonboard.com>","References":"<20230318234014.29506-1-dan.scally@ideasonboard.com>\n\t<20230318234014.29506-10-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230318234014.29506-10-dan.scally@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26887,"web_url":"https://patchwork.libcamera.org/comment/26887/","msgid":"<c3fe582b-95f9-bd21-ad2e-b56ee922ff8e@ideasonboard.com>","date":"2023-04-17T09:59:43","subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Laurent\n\nOn 19/03/2023 23:34, Laurent Pinchart wrote:\n> Hi Dan,\n>\n> Thank you for the patch.\n>\n> On Sat, Mar 18, 2023 at 11:40:12PM +0000, Daniel Scally via libcamera-devel wrote:\n>> Add support for the IPU3_Y10 format to the FormatConverter.\n> Before reviewing this patch in details, I'd like to know if there would\n> be a way to use the ImgU to convert the IPU3-packed greyscale format to\n> a more standard format. Is this something you have considered ?\n\n\nSorry for the delay on this. I had concluded some time ago that this wasn't possible, so I hadn't \nparticularly considered it lately. Since you ask I have been double checking and the conclusion \nseems to hold - I talked to the ipu3/cio2 maintainers and my understanding from those conversations \nis that the Imgu supports bayer input only, and the CIO2 can only output packed data, so I think we \nare stuck with this or something like this.\n\n>\n>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n>> ---\n>>   src/apps/qcam/format_converter.cpp | 50 ++++++++++++++++++++++++++++++\n>>   src/apps/qcam/format_converter.h   |  2 ++\n>>   2 files changed, 52 insertions(+)\n>>\n>> diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp\n>> index de76b32c..7f5648f3 100644\n>> --- a/src/apps/qcam/format_converter.cpp\n>> +++ b/src/apps/qcam/format_converter.cpp\n>> @@ -169,6 +169,10 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>>   \t\tformatFamily_ = MJPEG;\n>>   \t\tbreak;\n>>   \n>> +\tcase libcamera::formats::Y10_IPU3:\n>> +\t\tformatFamily_ = IPU3Packed;\n>> +\t\tbreak;\n>> +\n>>   \tdefault:\n>>   \t\treturn -EINVAL;\n>>   \t};\n>> @@ -199,6 +203,9 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n>>   \tcase YUVPlanar:\n>>   \t\tconvertYUVPlanar(src, dst->bits());\n>>   \t\tbreak;\n>> +\tcase IPU3Packed:\n>> +\t\tconvertIPU3Packed(src, dst->bits(), size);\n>> +\t\tbreak;\n>>   \t};\n>>   }\n>>   \n>> @@ -357,3 +364,46 @@ void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char\n>>   \t\t}\n>>   \t}\n>>   }\n>> +\n>> +void FormatConverter::convertIPU3Packed(const Image *srcImage, unsigned char *dst, size_t size)\n>> +{\n>> +\tconst unsigned char *src = srcImage->data(0).data();\n>> +\tunsigned int bytesprocessed = 0;\n>> +\tunsigned int lsb_shift;\n>> +\tunsigned int msb_shift;\n>> +\tunsigned int index;\n>> +\tunsigned int x = 0;\n>> +\tuint16_t pixel;\n>> +\n>> +\twhile (bytesprocessed < size) {\n>> +\t\tfor (unsigned int i = 0; i < 25; ++i) {\n>> +\t\t\tindex = (i * 10) / 8;\n>> +\t\t\tlsb_shift = (i * 10) % 8;\n>> +\t\t\tmsb_shift = 8 - lsb_shift;\n>> +\n>> +\t\t\t/*\n>> +\t\t\t * The IPU3-packed format can result in padding at the\n>> +\t\t\t * end of a 32-byte block if the last pixel in a row is\n>> +\t\t\t * within that block. Check whether we're on the line's\n>> +\t\t\t * last pixel and skip the rest of the block if so.\n>> +\t\t\t */\n>> +\t\t\tif (x == width_) {\n>> +\t\t\t\tx = 0;\n>> +\t\t\t\tdst += width_ * 4;\n>> +\t\t\t\tbreak;\n>> +\t\t\t}\n>> +\n>> +\t\t\tpixel = (((src + bytesprocessed)[index+1] << msb_shift) & 0x3ff)\n>> +\t\t\t      | (((src + bytesprocessed)[index+0] >> lsb_shift) & 0x3ff);\n>> +\n>> +\t\t\tdst[4 * x + 0] = (pixel >> 2) & 0xff;\n>> +\t\t\tdst[4 * x + 1] = (pixel >> 2) & 0xff;\n>> +\t\t\tdst[4 * x + 2] = (pixel >> 2) & 0xff;\n>> +\t\t\tdst[4 * x + 3] = 0xff;\n>> +\n>> +\t\t\tx++;\n>> +\t\t}\n>> +\n>> +\t\tbytesprocessed += 32;\n>> +\t}\n>> +}\n>> diff --git a/src/apps/qcam/format_converter.h b/src/apps/qcam/format_converter.h\n>> index 37dbfae2..940f8b6b 100644\n>> --- a/src/apps/qcam/format_converter.h\n>> +++ b/src/apps/qcam/format_converter.h\n>> @@ -31,12 +31,14 @@ private:\n>>   \t\tYUVPacked,\n>>   \t\tYUVPlanar,\n>>   \t\tYUVSemiPlanar,\n>> +\t\tIPU3Packed,\n>>   \t};\n>>   \n>>   \tvoid convertRGB(const Image *src, unsigned char *dst);\n>>   \tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n>>   \tvoid convertYUVPlanar(const Image *src, unsigned char *dst);\n>>   \tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n>> +\tvoid convertIPU3Packed(const Image *src, unsigned char *dst, size_t size);\n>>   \n>>   \tlibcamera::PixelFormat format_;\n>>   \tunsigned int width_;","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 A179FBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Apr 2023 09:59:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBDCE61EBA;\n\tMon, 17 Apr 2023 11:59:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A82E4603A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Apr 2023 11:59:46 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 27C38DE6;\n\tMon, 17 Apr 2023 11:59:41 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681725588;\n\tbh=N+aFHK7ubblKI3cbJLbeh/z4wlXhM595kr3wrM3W93A=;\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=AMDqPkParwQ3YV5koJC2a6E0t2hAROoa79bL8v1e2CecvDKcOP4M+XyRV4IXPQaW+\n\torMXsPRcbh8GZJpdA49isoNuSNtz1v92RFFHDRmKfJsjczmJjGjQHPwpc5P332D0B4\n\tM7K9X7Was8ai8I9emu4qejFgwB1Qm1KE2pdtqu0fPaPvJgghI2Rq2MAX9tGe3br+L+\n\tDrdKZ5J3O7OJGSuOiRmMFp2oGXr/zwHp5AaW0mJT8vHyA+vSmScBiaPc5uwoTPO14o\n\tJAcskqjc7psPj0IysMz3HJ2XdsV16nWfzAv9Y8dFPXfTN/93C0Q/BpwkeUiCG6FuR+\n\tV1RJn/uh4xdCA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681725581;\n\tbh=N+aFHK7ubblKI3cbJLbeh/z4wlXhM595kr3wrM3W93A=;\n\th=Date:To:Cc:References:From:Subject:In-Reply-To:From;\n\tb=qWXs8ckVq4/8iYr8T3pPsE1xR1mNqNELU//1izG0ctJYnXaEv9hg+w4FVXlBtDM56\n\tq8xhnAZL4uz7VNCs/dUM38yea6l7d0u820DINcdHs8e17S7+W2O+Y+1QyyTgKK7J7N\n\ts1x+2G+qVAGXm10XqARluQooDOzQm/jUxz+pX8LQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"qWXs8ckV\"; dkim-atps=neutral","Message-ID":"<c3fe582b-95f9-bd21-ad2e-b56ee922ff8e@ideasonboard.com>","Date":"Mon, 17 Apr 2023 10:59:43 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.9.0","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20230318234014.29506-1-dan.scally@ideasonboard.com>\n\t<20230318234014.29506-10-dan.scally@ideasonboard.com>\n\t<20230319201559.GI13726@pendragon.ideasonboard.com>","In-Reply-To":"<20230319201559.GI13726@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","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":"Dan Scally via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Dan Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26895,"web_url":"https://patchwork.libcamera.org/comment/26895/","msgid":"<20230418163703.GK30837@pendragon.ideasonboard.com>","date":"2023-04-18T16:37:03","subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Dan,\n\nOn Mon, Apr 17, 2023 at 10:59:43AM +0100, Dan Scally wrote:\n> On 19/03/2023 23:34, Laurent Pinchart wrote:\n> > On Sat, Mar 18, 2023 at 11:40:12PM +0000, Daniel Scally via libcamera-devel wrote:\n> >> Add support for the IPU3_Y10 format to the FormatConverter.\n> >\n> > Before reviewing this patch in details, I'd like to know if there would\n> > be a way to use the ImgU to convert the IPU3-packed greyscale format to\n> > a more standard format. Is this something you have considered ?\n> \n> Sorry for the delay on this. I had concluded some time ago that this\n> wasn't possible, so I hadn't particularly considered it lately. Since\n> you ask I have been double checking and the conclusion seems to hold -\n> I talked to the ipu3/cio2 maintainers and my understanding from those\n> conversations is that the Imgu supports bayer input only, and the CIO2\n> can only output packed data, so I think we are stuck with this or\n> something like this.\n\nOK, thanks for checking.\n\n> >> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> >> ---\n> >>   src/apps/qcam/format_converter.cpp | 50 ++++++++++++++++++++++++++++++\n> >>   src/apps/qcam/format_converter.h   |  2 ++\n> >>   2 files changed, 52 insertions(+)\n> >>\n> >> diff --git a/src/apps/qcam/format_converter.cpp b/src/apps/qcam/format_converter.cpp\n> >> index de76b32c..7f5648f3 100644\n> >> --- a/src/apps/qcam/format_converter.cpp\n> >> +++ b/src/apps/qcam/format_converter.cpp\n> >> @@ -169,6 +169,10 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n> >>   \t\tformatFamily_ = MJPEG;\n> >>   \t\tbreak;\n> >>   \n> >> +\tcase libcamera::formats::Y10_IPU3:\n> >> +\t\tformatFamily_ = IPU3Packed;\n> >> +\t\tbreak;\n> >> +\n> >>   \tdefault:\n> >>   \t\treturn -EINVAL;\n> >>   \t};\n> >> @@ -199,6 +203,9 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n> >>   \tcase YUVPlanar:\n> >>   \t\tconvertYUVPlanar(src, dst->bits());\n> >>   \t\tbreak;\n> >> +\tcase IPU3Packed:\n> >> +\t\tconvertIPU3Packed(src, dst->bits(), size);\n> >> +\t\tbreak;\n\nWill we need to soon write a generic-purpose format conversion library ?\n:-(\n\n> >>   \t};\n> >>   }\n> >>   \n> >> @@ -357,3 +364,46 @@ void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char\n> >>   \t\t}\n> >>   \t}\n> >>   }\n> >> +\n> >> +void FormatConverter::convertIPU3Packed(const Image *srcImage, unsigned char *dst, size_t size)\n> >> +{\n> >> +\tconst unsigned char *src = srcImage->data(0).data();\n> >> +\tunsigned int bytesprocessed = 0;\n> >> +\tunsigned int lsb_shift;\n> >> +\tunsigned int msb_shift;\n> >> +\tunsigned int index;\n> >> +\tunsigned int x = 0;\n> >> +\tuint16_t pixel;\n> >> +\n> >> +\twhile (bytesprocessed < size) {\n> >> +\t\tfor (unsigned int i = 0; i < 25; ++i) {\n> >> +\t\t\tindex = (i * 10) / 8;\n> >> +\t\t\tlsb_shift = (i * 10) % 8;\n> >> +\t\t\tmsb_shift = 8 - lsb_shift;\n> >> +\n> >> +\t\t\t/*\n> >> +\t\t\t * The IPU3-packed format can result in padding at the\n> >> +\t\t\t * end of a 32-byte block if the last pixel in a row is\n> >> +\t\t\t * within that block. Check whether we're on the line's\n> >> +\t\t\t * last pixel and skip the rest of the block if so.\n> >> +\t\t\t */\n> >> +\t\t\tif (x == width_) {\n> >> +\t\t\t\tx = 0;\n> >> +\t\t\t\tdst += width_ * 4;\n> >> +\t\t\t\tbreak;\n> >> +\t\t\t}\n> >> +\n> >> +\t\t\tpixel = (((src + bytesprocessed)[index+1] << msb_shift) & 0x3ff)\n> >> +\t\t\t      | (((src + bytesprocessed)[index+0] >> lsb_shift) & 0x3ff);\n> >> +\n> >> +\t\t\tdst[4 * x + 0] = (pixel >> 2) & 0xff;\n> >> +\t\t\tdst[4 * x + 1] = (pixel >> 2) & 0xff;\n> >> +\t\t\tdst[4 * x + 2] = (pixel >> 2) & 0xff;\n> >> +\t\t\tdst[4 * x + 3] = 0xff;\n> >> +\n> >> +\t\t\tx++;\n> >> +\t\t}\n> >> +\n> >> +\t\tbytesprocessed += 32;\n\nThere's probably room for improvement when it comes to efficiency here.\nWe can optimize the code later, but I wonder if \n\n\t\t\tpixel = ((src[index+1] << msb_shift) & 0x3ff)\n\t\t\t      | ((src[index+0] >> lsb_shift) & 0x3ff);\n\n\t\t...\n\n\t\tbytesprocessed += 32;\n\t\tsrc += 32;\n\ncouldn't help already. Doing something similar with dst to avoid the 4*x\noffset could also possibly help.\n\n> >> +\t}\n> >> +}\n> >> diff --git a/src/apps/qcam/format_converter.h b/src/apps/qcam/format_converter.h\n> >> index 37dbfae2..940f8b6b 100644\n> >> --- a/src/apps/qcam/format_converter.h\n> >> +++ b/src/apps/qcam/format_converter.h\n> >> @@ -31,12 +31,14 @@ private:\n> >>   \t\tYUVPacked,\n> >>   \t\tYUVPlanar,\n> >>   \t\tYUVSemiPlanar,\n> >> +\t\tIPU3Packed,\n> >>   \t};\n> >>   \n> >>   \tvoid convertRGB(const Image *src, unsigned char *dst);\n> >>   \tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n> >>   \tvoid convertYUVPlanar(const Image *src, unsigned char *dst);\n> >>   \tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n> >> +\tvoid convertIPU3Packed(const Image *src, unsigned char *dst, size_t size);\n> >>   \n> >>   \tlibcamera::PixelFormat format_;\n> >>   \tunsigned int width_;","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 EDC40BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Apr 2023 16:36:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 58ACC603A2;\n\tTue, 18 Apr 2023 18:36:53 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 339AF603A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Apr 2023 18:36:52 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0B43BDE5;\n\tTue, 18 Apr 2023 18:36:44 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681835813;\n\tbh=MYOx4stfVTe4497O9w1GkIlJONXe6m2Y1eNmyi6qf1c=;\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=Y0Lpzh0ynsByMS2z7hdWu0s4EBqZL2+qw/ATZenr3t471KQYo069PZ8y4Ri6+nJTc\n\tHf2WWGpq7l+Gz/xuOElrB1uuB33XoXjkfC8wTq/8s4GSHpCmCa85TCmt7+eCU4BMPT\n\tHFQFQVgTLHnlfjT45czEHy4/JvvsecNLQV/wljXBlf1N3KqqSrramNbw8zaXSkMRCa\n\tbcL90lpdwUoBugv3mqzEdO2fvsY/88dm/M+KBrbymf7T/EhbddkwebGH/QWc/iMcqQ\n\t3DbqT4jcHdDWn6Ijs3q7JymPIlGve+bplxwCmc7+CMZQIu0hhZPSFLEDU4k+YniyC0\n\tGi58ZM4cFWw9A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681835806;\n\tbh=MYOx4stfVTe4497O9w1GkIlJONXe6m2Y1eNmyi6qf1c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YIne1J9Y4mTXCLc/6dqixb8fD4QfUj2DBnzxdJ/17iNzs2Xw67FX8wF09NRJF2gIC\n\te5gUuG365LBSGYnWrwvWIol84s49fcIyafGc5Oi8/MycWUC9k00roTQjQVE5hpvQtZ\n\tqIxNKHN/H61UVWk59RNRkEQ8XRIRGKlXDViS8onw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YIne1J9Y\"; dkim-atps=neutral","Date":"Tue, 18 Apr 2023 19:37:03 +0300","To":"Dan Scally <dan.scally@ideasonboard.com>","Message-ID":"<20230418163703.GK30837@pendragon.ideasonboard.com>","References":"<20230318234014.29506-1-dan.scally@ideasonboard.com>\n\t<20230318234014.29506-10-dan.scally@ideasonboard.com>\n\t<20230319201559.GI13726@pendragon.ideasonboard.com>\n\t<c3fe582b-95f9-bd21-ad2e-b56ee922ff8e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<c3fe582b-95f9-bd21-ad2e-b56ee922ff8e@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 09/11] apps: qcam: Add support for\n\tIPU3_Y10","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]