[{"id":33942,"web_url":"https://patchwork.libcamera.org/comment/33942/","msgid":"<20250413235352.GD12286@pendragon.ideasonboard.com>","date":"2025-04-13T23:53:52","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Pavel,\n\nThank you for the patch.\n\nOn Sun, Apr 13, 2025 at 10:21:33AM +0200, Pavel Machek wrote:\n> swIsp with libcamera produces ARGB data by default, which needs\n> conversion during write. Implement it and similar conversions.\n>     \n> Signed-off-by: Pavel Machek <pavel@ucw.cz>\n> \n> diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp\n> index 368de8bf..ddbd3263 100644\n> --- a/src/apps/common/ppm_writer.cpp\n> +++ b/src/apps/common/ppm_writer.cpp\n> @@ -20,8 +20,56 @@ int PPMWriter::write(const char *filename,\n>  \t\t     const StreamConfiguration &config,\n>  \t\t     const Span<uint8_t> &data)\n>  {\n> -\tif (config.pixelFormat != formats::BGR888) {\n> -\t\tstd::cerr << \"Only BGR888 output pixel format is supported (\"\n> +\tint r_pos, g_pos, b_pos, bpp;\n> +\tswitch (config.pixelFormat) {\n> +\tcase libcamera::formats::R8:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 0;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 1;\n> +\t\tbreak;\n> +\tcase libcamera::formats::RGB888:\n> +\t\tr_pos = 2;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 3;\n> +\t\tbreak;\n> +\tcase libcamera::formats::BGR888:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 2;\n> +\t\tbpp = 3;\n> +\t\tbreak;\n> +\tcase libcamera::formats::ARGB8888:\n> +\tcase libcamera::formats::XRGB8888:\n> +\t\tr_pos = 2;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::RGBA8888:\n> +\tcase libcamera::formats::RGBX8888:\n> +\t\tr_pos = 3;\n> +\t\tg_pos = 2;\n> +\t\tb_pos = 1;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::ABGR8888:\n> +\tcase libcamera::formats::XBGR8888:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 2;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::BGRA8888:\n> +\tcase libcamera::formats::BGRX8888:\n> +\t\tr_pos = 1;\n> +\t\tg_pos = 2;\n> +\t\tb_pos = 3;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tstd::cerr << \"Only RGB output pixel formats are supported (\"\n>  \t\t\t  << config.pixelFormat << \" requested)\" << std::endl;\n>  \t\treturn -EINVAL;\n>  \t}\n> @@ -41,14 +89,35 @@ int PPMWriter::write(const char *filename,\n>  \t}\n>  \n>  \tconst unsigned int rowLength = config.size.width * 3;\n> -\tconst char *row = reinterpret_cast<const char *>(data.data());\n> -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> -\t\toutput.write(row, rowLength);\n> +\t// Output without any conversion will be slightly faster\n\nWe use C-style coments.\n\n> +\tif (config.pixelFormat == formats::BGR888) {\n> +\t\tconst char *row = reinterpret_cast<const char *>(data.data());\n> +\t\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> +\t\t\toutput.write(row, rowLength);\n> +\t\t\tif (!output) {\n> +\t\t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n> +\t\t\t\treturn -EIO;\n> +\t\t\t}\n> +\t\t}\n> +\t\treturn 0;\n> +\t}\n> +\n> +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n> +\t// Create a temporary buffer to hold one output row.\n> +\tstd::vector<char> rowBuffer(rowLength);\n> +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n> +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n> +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n> +\t\t\tconst uint8_t *pixel = row + x * bpp;\n> +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n> +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n> +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n> +\t\t}\n\nI'm curious, what's the performance impact of the conversion ?\n\n> +\t\toutput.write(rowBuffer.data(), rowLength);\n>  \t\tif (!output) {\n>  \t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n>  \t\t\treturn -EIO;\n>  \t\t}\n>  \t}\n> -\n>  \treturn 0;\n>  }\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 BBEE4C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 13 Apr 2025 23:53:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3279268AB5;\n\tMon, 14 Apr 2025 01:53:55 +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 A3857617EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Apr 2025 01:53:53 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5DC35475;\n\tMon, 14 Apr 2025 01:51:52 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"G2Fc6JFP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744588312;\n\tbh=wGcZui7Delxiy8GXm4Lnek5xpatxcGpu73kvX3vmD7I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=G2Fc6JFPR2zg1OQP/X8XaBoG7eGBIpGDaf2kzQbmb/ix06NEO5nHsQrWSWg52Iio3\n\tPOoHXKE0QlKJzqdAST2lN0Ktc7P0ezleadEzP+/0rPs7NMcGV1hM5hO0m7ATiqui/V\n\tziqMDnHGWnNlp21XXAefl12oNhEhvdnZ8M1HbNYI=","Date":"Mon, 14 Apr 2025 02:53:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Pavel Machek <pavel@ucw.cz>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<20250413235352.GD12286@pendragon.ideasonboard.com>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>","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>"}},{"id":33971,"web_url":"https://patchwork.libcamera.org/comment/33971/","msgid":"<aAN1brt7x2Kz09aQ@duo.ucw.cz>","date":"2025-04-19T10:05:34","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> Thank you for the patch.\n> \n> On Sun, Apr 13, 2025 at 10:21:33AM +0200, Pavel Machek wrote:\n> > swIsp with libcamera produces ARGB data by default, which needs\n> > conversion during write. Implement it and similar conversions.\n> >     \n> > Signed-off-by: Pavel Machek <pavel@ucw.cz>\n\n> > +\tcase libcamera::formats::BGRA8888:\n> > +\tcase libcamera::formats::BGRX8888:\n> > +\t\tr_pos = 1;\n> > +\t\tg_pos = 2;\n> > +\t\tb_pos = 3;\n> > +\t\tbpp = 4;\n> > +\t\tbreak;\n> > +\tdefault:\n> > +\t\tstd::cerr << \"Only RGB output pixel formats are supported (\"\n> >  \t\t\t  << config.pixelFormat << \" requested)\" << std::endl;\n> >  \t\treturn -EINVAL;\n> >  \t}\n> > @@ -41,14 +89,35 @@ int PPMWriter::write(const char *filename,\n> >  \t}\n> >  \n> >  \tconst unsigned int rowLength = config.size.width * 3;\n> > -\tconst char *row = reinterpret_cast<const char *>(data.data());\n> > -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> > -\t\toutput.write(row, rowLength);\n> > +\t// Output without any conversion will be slightly faster\n> \n> We use C-style coments.\n\nCan you adjust that while applying?\n\n> > +\tif (config.pixelFormat == formats::BGR888) {\n> > +\t\tconst char *row = reinterpret_cast<const char *>(data.data());\n> > +\t\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> > +\t\t\toutput.write(row, rowLength);\n> > +\t\t\tif (!output) {\n> > +\t\t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n> > +\t\t\t\treturn -EIO;\n> > +\t\t\t}\n> > +\t\t}\n> > +\t\treturn 0;\n> > +\t}\n> > +\n> > +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n> > +\t// Create a temporary buffer to hold one output row.\n> > +\tstd::vector<char> rowBuffer(rowLength);\n> > +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n> > +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n> > +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n> > +\t\t\tconst uint8_t *pixel = row + x * bpp;\n> > +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n> > +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n> > +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n> > +\t\t}\n> \n> I'm curious, what's the performance impact of the conversion ?\n\nI hacked Librem 5 a lot to get libcamera working, and previous config\nwas not working at all, so ... I can't easily benchmark that.\n\nSo, this one is not free as it does one more copy of image\ndata. Compared to swIsp, it is going to be lost in the noise.\n\nThere's easy optimalization in the original case not to do writes per\nrow if width == stride. There are other options, but they will\ncomplicate the code.\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 85995BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 19 Apr 2025 10:05:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD2C368AC7;\n\tSat, 19 Apr 2025 12:05:36 +0200 (CEST)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F78068AC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Apr 2025 12:05:35 +0200 (CEST)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid BD6E11C01AA; Sat, 19 Apr 2025 12:05:34 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"THhstmqI\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1745057134;\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=a+FsMX7P9ujL28UElSVjIQfCmw0v2vf02GCqB2YMJCw=;\n\tb=THhstmqIaI58gSRE5A5H9Hj8cB6CFBL4L61ogz5K/2Jp8U/r19uVv0MXhxq8COQrzsC9Go\n\tfd6uL7AWE0YlrHcuRzH1sduYEZpnON2fjI32c/1SkuC/rmDRkT71XysRUlJhmS6LDcsvj5\n\tLCS623zgxxq3LT3u93mYcX21rAP6pzY=","Date":"Sat, 19 Apr 2025 12:05:34 +0200","From":"Pavel Machek <pavel@ucw.cz>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<aAN1brt7x2Kz09aQ@duo.ucw.cz>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"nhVvQ5tHxGu0+B55\"","Content-Disposition":"inline","In-Reply-To":"<20250413235352.GD12286@pendragon.ideasonboard.com>","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>"}},{"id":33977,"web_url":"https://patchwork.libcamera.org/comment/33977/","msgid":"<20250421141606.GO29483@pendragon.ideasonboard.com>","date":"2025-04-21T14:16:06","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Pavel,\n\nOn Sat, Apr 19, 2025 at 12:05:34PM +0200, Pavel Machek wrote:\n> Hi!\n> \n> > Thank you for the patch.\n> > \n> > On Sun, Apr 13, 2025 at 10:21:33AM +0200, Pavel Machek wrote:\n> > > swIsp with libcamera produces ARGB data by default, which needs\n> > > conversion during write. Implement it and similar conversions.\n> > >     \n> > > Signed-off-by: Pavel Machek <pavel@ucw.cz>\n> \n> > > +\tcase libcamera::formats::BGRA8888:\n> > > +\tcase libcamera::formats::BGRX8888:\n> > > +\t\tr_pos = 1;\n> > > +\t\tg_pos = 2;\n> > > +\t\tb_pos = 3;\n> > > +\t\tbpp = 4;\n> > > +\t\tbreak;\n> > > +\tdefault:\n> > > +\t\tstd::cerr << \"Only RGB output pixel formats are supported (\"\n> > >  \t\t\t  << config.pixelFormat << \" requested)\" << std::endl;\n> > >  \t\treturn -EINVAL;\n> > >  \t}\n> > > @@ -41,14 +89,35 @@ int PPMWriter::write(const char *filename,\n> > >  \t}\n> > >  \n> > >  \tconst unsigned int rowLength = config.size.width * 3;\n> > > -\tconst char *row = reinterpret_cast<const char *>(data.data());\n> > > -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> > > -\t\toutput.write(row, rowLength);\n> > > +\t// Output without any conversion will be slightly faster\n> > \n> > We use C-style coments.\n> \n> Can you adjust that while applying?\n\nIf that's the only change required, yes.\n\n> > > +\tif (config.pixelFormat == formats::BGR888) {\n> > > +\t\tconst char *row = reinterpret_cast<const char *>(data.data());\n> > > +\t\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> > > +\t\t\toutput.write(row, rowLength);\n> > > +\t\t\tif (!output) {\n> > > +\t\t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n> > > +\t\t\t\treturn -EIO;\n> > > +\t\t\t}\n> > > +\t\t}\n> > > +\t\treturn 0;\n> > > +\t}\n> > > +\n> > > +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n> > > +\t// Create a temporary buffer to hold one output row.\n> > > +\tstd::vector<char> rowBuffer(rowLength);\n> > > +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n> > > +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n> > > +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n> > > +\t\t\tconst uint8_t *pixel = row + x * bpp;\n> > > +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n> > > +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n> > > +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n> > > +\t\t}\n> > \n> > I'm curious, what's the performance impact of the conversion ?\n> \n> I hacked Librem 5 a lot to get libcamera working, and previous config\n> was not working at all, so ... I can't easily benchmark that.\n> \n> So, this one is not free as it does one more copy of image\n> data. Compared to swIsp, it is going to be lost in the noise.\n> \n> There's easy optimalization in the original case not to do writes per\n> row if width == stride. There are other options, but they will\n> complicate the code.\n\nI wonder if it would make sense for the soft ISP to support other RGB\nformats. CC'ing Milan and Hans to get their opinion.","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 DE184BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Apr 2025 14:16:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1657D68ACA;\n\tMon, 21 Apr 2025 16:16:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F5E168AC2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Apr 2025 16:16:08 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0F2E6D6;\n\tMon, 21 Apr 2025 16:14:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sH8VHl0U\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745244841;\n\tbh=HmK2CFGdxsbky2vEje8uZ630Hb6+KcVTUBwzOE6sVCw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sH8VHl0U40JKA+VYugskWhlZZ1zhboTKDUU8mpTeakRplZlAMBzdrLMY+l+jk56EU\n\tpzsnP3C2X6BJTAVVHWV9ktl075N6DN/bEZCi2Tm9XO3jg8eqEcmIKjbJjQsy1kmx9b\n\t5Aba87I0SnH4Wg43Uucc6jpp2vjiCxQv1d0m85VM=","Date":"Mon, 21 Apr 2025 17:16:06 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Pavel Machek <pavel@ucw.cz>","Cc":"libcamera-devel@lists.libcamera.org, Milan Zamazal <mzamazal@redhat.com>,\n\tHans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<20250421141606.GO29483@pendragon.ideasonboard.com>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<aAN1brt7x2Kz09aQ@duo.ucw.cz>","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>"}},{"id":33978,"web_url":"https://patchwork.libcamera.org/comment/33978/","msgid":"<aAa1f0J1kidzxAxf@duo.ucw.cz>","date":"2025-04-21T21:15:43","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> > > > swIsp with libcamera produces ARGB data by default, which needs\n> > > > conversion during write. Implement it and similar conversions.\n> > > >     \n> > > > Signed-off-by: Pavel Machek <pavel@ucw.cz>\n\n> > > > -\tconst char *row = reinterpret_cast<const char *>(data.data());\n> > > > -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> > > > -\t\toutput.write(row, rowLength);\n> > > > +\t// Output without any conversion will be slightly faster\n> > > \n> > > We use C-style coments.\n> > \n> > Can you adjust that while applying?\n> \n> If that's the only change required, yes.\n\nThanks!\n\n> > > > +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n> > > > +\t// Create a temporary buffer to hold one output row.\n> > > > +\tstd::vector<char> rowBuffer(rowLength);\n> > > > +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n> > > > +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n> > > > +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n> > > > +\t\t\tconst uint8_t *pixel = row + x * bpp;\n> > > > +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n> > > > +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n> > > > +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n> > > > +\t\t}\n> > > \n> > > I'm curious, what's the performance impact of the conversion ?\n> > \n> > I hacked Librem 5 a lot to get libcamera working, and previous config\n> > was not working at all, so ... I can't easily benchmark that.\n> > \n> > So, this one is not free as it does one more copy of image\n> > data. Compared to swIsp, it is going to be lost in the noise.\n> > \n> > There's easy optimalization in the original case not to do writes per\n> > row if width == stride. There are other options, but they will\n> > complicate the code.\n> \n> I wonder if it would make sense for the soft ISP to support other RGB\n> formats. CC'ing Milan and Hans to get their opinion.\n\nFrom looking at the code, soft ISP seemed to be able to do other stuff\nthan ARGB, but for some reason ARGB is selected by default, and I\nguess I can get better performance by forcing right format.\n\nConversion will still be useful for when hardware produces some other\npermutation than BGR.\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 AEE29C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Apr 2025 21:15:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A069968AC7;\n\tMon, 21 Apr 2025 23:15:46 +0200 (CEST)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27E3868ABA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Apr 2025 23:15:45 +0200 (CEST)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid 6FDE41C01AA; Mon, 21 Apr 2025 23:15:44 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"W8bEKsCX\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1745270144;\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=a52idzh6+54LRrdS4xjWDq4dcpWAtHog8gpB+EDRjRQ=;\n\tb=W8bEKsCXj7miJKjYLtAKMIBKzhM52Bunv4DcHkwMihYMypmI3k4sNb0PcV4dkYvSleRLAI\n\tEc0qFdz3Azt2Cqk31m4k2ac3tkb/Cdy+xHDt9meYxUEIDjlIznaF0QiwJttCf7YD1TvZzj\n\tKfCuKhE067ptHJGLAwZLKtaxk9ItBkw=","Date":"Mon, 21 Apr 2025 23:15:43 +0200","From":"Pavel Machek <pavel@ucw.cz>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Milan Zamazal <mzamazal@redhat.com>,\n\tHans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<aAa1f0J1kidzxAxf@duo.ucw.cz>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>\n\t<20250421141606.GO29483@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"pE6+rwBwSireTcZk\"","Content-Disposition":"inline","In-Reply-To":"<20250421141606.GO29483@pendragon.ideasonboard.com>","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>"}},{"id":34005,"web_url":"https://patchwork.libcamera.org/comment/34005/","msgid":"<6989e227-d1e1-4add-95c3-b6e7efc833e5@ideasonboard.com>","date":"2025-04-23T07:52:34","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\n2025. 04. 13. 10:21 keltezéssel, Pavel Machek írta:\n> swIsp with libcamera produces ARGB data by default, which needs\n> conversion during write. Implement it and similar conversions.\n>      \n> Signed-off-by: Pavel Machek <pavel@ucw.cz>\n> \n> diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp\n> index 368de8bf..ddbd3263 100644\n> --- a/src/apps/common/ppm_writer.cpp\n> +++ b/src/apps/common/ppm_writer.cpp\n> @@ -20,8 +20,56 @@ int PPMWriter::write(const char *filename,\n>   \t\t     const StreamConfiguration &config,\n>   \t\t     const Span<uint8_t> &data)\n>   {\n> -\tif (config.pixelFormat != formats::BGR888) {\n> -\t\tstd::cerr << \"Only BGR888 output pixel format is supported (\"\n> +\tint r_pos, g_pos, b_pos, bpp;\n\nI think the \"pos\" variables should probably be camelCase.\nAnd please add an empty line after them.\n\n\n> +\tswitch (config.pixelFormat) {\n> +\tcase libcamera::formats::R8:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 0;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 1;\n> +\t\tbreak;\n> +\tcase libcamera::formats::RGB888:\n> +\t\tr_pos = 2;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 3;\n> +\t\tbreak;\n> +\tcase libcamera::formats::BGR888:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 2;\n> +\t\tbpp = 3;\n> +\t\tbreak;\n> +\tcase libcamera::formats::ARGB8888:\n> +\tcase libcamera::formats::XRGB8888:\n> +\t\tr_pos = 2;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 0;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::RGBA8888:\n> +\tcase libcamera::formats::RGBX8888:\n> +\t\tr_pos = 3;\n> +\t\tg_pos = 2;\n> +\t\tb_pos = 1;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::ABGR8888:\n> +\tcase libcamera::formats::XBGR8888:\n> +\t\tr_pos = 0;\n> +\t\tg_pos = 1;\n> +\t\tb_pos = 2;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::BGRA8888:\n> +\tcase libcamera::formats::BGRX8888:\n> +\t\tr_pos = 1;\n> +\t\tg_pos = 2;\n> +\t\tb_pos = 3;\n> +\t\tbpp = 4;\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tstd::cerr << \"Only RGB output pixel formats are supported (\"\n>   \t\t\t  << config.pixelFormat << \" requested)\" << std::endl;\n>   \t\treturn -EINVAL;\n>   \t}\n> @@ -41,14 +89,35 @@ int PPMWriter::write(const char *filename,\n>   \t}\n>   \n>   \tconst unsigned int rowLength = config.size.width * 3;\n> -\tconst char *row = reinterpret_cast<const char *>(data.data());\n> -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> -\t\toutput.write(row, rowLength);\n> +\t// Output without any conversion will be slightly faster\n> +\tif (config.pixelFormat == formats::BGR888) {\n> +\t\tconst char *row = reinterpret_cast<const char *>(data.data());\n> +\t\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n> +\t\t\toutput.write(row, rowLength);\n> +\t\t\tif (!output) {\n> +\t\t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n> +\t\t\t\treturn -EIO;\n> +\t\t\t}\n> +\t\t}\n> +\t\treturn 0;\n> +\t}\n> +\n> +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n\nWhat is the reasoning for saving this into a separate variable here? But not above in\nthe `BGR888` case? And not `config.size`?\n\nAnd why \"should be >= width * 4\"?\n\n\n> +\t// Create a temporary buffer to hold one output row.\n> +\tstd::vector<char> rowBuffer(rowLength);\n> +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n> +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n> +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n> +\t\t\tconst uint8_t *pixel = row + x * bpp;\n> +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n> +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n> +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n> +\t\t}\n\nEmpty line here please.\n\n\n> +\t\toutput.write(rowBuffer.data(), rowLength);\n>   \t\tif (!output) {\n>   \t\t\tstd::cerr << \"Failed to write image data at row \" << y << std::endl;\n>   \t\t\treturn -EIO;\n>   \t\t}\n>   \t}\n> -\n\nDon't remove this.\n\n\n>   \treturn 0;\n>   }\n> \n\n\nAs for performance, I have briefly taken a look at the x86 assembly of the inner\nloop, it looks pretty acceptable to me. Apart from the fact that the vector's\noperator[] adds three branches because meson sets `_GLIBCXX_ASSERTIONS=1` unless\n`b_ndebug=true`. So that is not too good, but it is probably not too significant.\n\nBut whether or not the soft ISP will support other formats, I think it's useful to\nsupport multiple formats here, even at the cost of conversion. Especially since PPM\nis not a container or such, so if the user explicitly selects it, I think they\nexpect that anything coming out of the camera will be converted appropriately.\n\nIn addition, it appears to me that qcam already has a sizable set of format\nconversions implemented. I wonder if those could be used somehow.\n\n\nRegards,\nBarnabás Pőcze","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 C25F2C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Apr 2025 07:52:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0650A68AC5;\n\tWed, 23 Apr 2025 09:52:41 +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 9B8EF617E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Apr 2025 09:52:38 +0200 (CEST)","from [192.168.33.13] (185.221.143.16.nat.pool.zt.hu\n\t[185.221.143.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2EC4722A;\n\tWed, 23 Apr 2025 09:52:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QgSusdy7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745394757;\n\tbh=DERFMEq1Ebvs8PXa1fC9kabIlh8lCfGz17mlyj/VsCM=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=QgSusdy7Xidbrj6g+y3r97LU7+PbluWIifokIkkRzV7KSEKmNRkWUDtpWfkJxvnGA\n\tEvSbl0dW+0sU7meLdjrWnyL3qHIJkVmyfVYJV5144cJBibGybxkJwu0id34Abd/+Wm\n\tTMP+whhD25AuRKx5cfH8cw9QesuxaVnEK6goNfg8=","Message-ID":"<6989e227-d1e1-4add-95c3-b6e7efc833e5@ideasonboard.com>","Date":"Wed, 23 Apr 2025 09:52:34 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","To":"Pavel Machek <pavel@ucw.cz>, laurent.pinchart@ideasonboard.com,\n\tlibcamera-devel@lists.libcamera.org","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}},{"id":34060,"web_url":"https://patchwork.libcamera.org/comment/34060/","msgid":"<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-04-26T18:30:44","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Pavel,\n\nPavel Machek <pavel@ucw.cz> writes:\n\n> Hi!\n>\n>> > > > swIsp with libcamera produces ARGB data by default, which needs\n>> > > > conversion during write. Implement it and similar conversions.\n>> > > >     \n>> > > > Signed-off-by: Pavel Machek <pavel@ucw.cz>\n>\n>> > > > -\tconst char *row = reinterpret_cast<const char *>(data.data());\n>> > > > -\tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n>> > > > -\t\toutput.write(row, rowLength);\n>> > > > +\t// Output without any conversion will be slightly faster\n>> > > \n>> > > We use C-style coments.\n>> > \n>> > Can you adjust that while applying?\n>> \n>> If that's the only change required, yes.\n>\n> Thanks!\n>\n>> > > > +\tconst unsigned int inputRowBytes = config.stride; // should be >= width * 4\n>> > > > +\t// Create a temporary buffer to hold one output row.\n>> > > > +\tstd::vector<char> rowBuffer(rowLength);\n>> > > > +\tconst uint8_t *row = reinterpret_cast<const uint8_t *>(data.data());\n>> > > > +\tfor (unsigned int y = 0; y < config.size.height; y++, row += inputRowBytes) {\n>> > > > +\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n>> > > > +\t\t\tconst uint8_t *pixel = row + x * bpp;\n>> > > > +\t\t\trowBuffer[x * 3 + 0] = static_cast<char>(pixel[r_pos]);\n>> > > > +\t\t\trowBuffer[x * 3 + 1] = static_cast<char>(pixel[g_pos]);\n>> > > > +\t\t\trowBuffer[x * 3 + 2] = static_cast<char>(pixel[b_pos]);\n>> > > > +\t\t}\n>> > > \n>> > > I'm curious, what's the performance impact of the conversion ?\n>> > \n>> > I hacked Librem 5 a lot to get libcamera working, and previous config\n>> > was not working at all, so ... I can't easily benchmark that.\n>> > \n>> > So, this one is not free as it does one more copy of image\n>> > data. Compared to swIsp, it is going to be lost in the noise.\n>> > \n>> > There's easy optimalization in the original case not to do writes per\n>> > row if width == stride. There are other options, but they will\n>> > complicate the code.\n>> \n>> I wonder if it would make sense for the soft ISP to support other RGB\n>> formats. CC'ing Milan and Hans to get their opinion.\n>\n> From looking at the code, soft ISP seemed to be able to do other stuff\n> than ARGB, but for some reason ARGB is selected by default, and I\n> guess I can get better performance by forcing right format.\n\nSoftware ISP debayering supports multiple output formats and `cam' can\nrequest a particular output format.  For example,\n\n  cam -c1 -C4 -s pixelformat=BGR888 -Ffoo#.ppm\n\noutputs the right thing.  Example of requesting an output in a different\nformat:\n\n  cam -c1 -C4 -s pixelformat=ARGB8888 -Ffoo#.raw\n\nIt works; is it a problem in your application?\n\nI don't mind enhancing the PPM writer but maybe you don't need the\nconversion there in the first place.\n\n> Conversion will still be useful for when hardware produces some other\n> permutation than BGR.\n>\n> Best 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 28928C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 26 Apr 2025 18:30:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 20C2068ACD;\n\tSat, 26 Apr 2025 20:30:53 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AAA34617E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Apr 2025 20:30:50 +0200 (CEST)","from mail-ej1-f71.google.com (mail-ej1-f71.google.com\n\t[209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-504-JQQ7X8MyP7WND3iegRBXZg-1; Sat, 26 Apr 2025 14:30:47 -0400","by mail-ej1-f71.google.com with SMTP id\n\ta640c23a62f3a-ac6b047c0dcso285123766b.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Apr 2025 11:30:47 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-ace6e4e6efcsm324411566b.44.2025.04.26.11.30.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 26 Apr 2025 11:30:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"JOdxEyRx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1745692249;\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=u3y9b5nnFWwJkBPrRahsVRhBS2cGGPfm4rtmGHpJPCY=;\n\tb=JOdxEyRxfE5Q31IeYND4LfxGpgVmov8oVVCTtp7YifnFfVp/iEjx/aSKgYnq5ak6Oyw0KD\n\tZcWtgU4utcbJeTdLacZPcsyXfnYp1ZMppLitgUmlL1ueClj6d6xEnRSZfDgFhkZm/t9HID\n\tbu9uOOsk7R6EZFwsYOVjo9SXeNOVCtA=","X-MC-Unique":"JQQ7X8MyP7WND3iegRBXZg-1","X-Mimecast-MFC-AGG-ID":"JQQ7X8MyP7WND3iegRBXZg_1745692246","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1745692246; x=1746297046;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=u3y9b5nnFWwJkBPrRahsVRhBS2cGGPfm4rtmGHpJPCY=;\n\tb=w4BlVtifxsxyMsW1VogZnYtONj6iBZLQaTaIN+49bsKVY2qA5GfnZyFGX9EERWy90h\n\tQntruvTsVsONPpkwrrMaNbcc+VpbFsOvFT5ueGr0sJaRN5DB/6UuSs7xgtzAQGSQJG8j\n\tW378PzupP7UpHqbO45Kbm1S3m1gzIgzKHiUsrLKWyhO4vPYkPje9W99SsX4Z/vf0wGVQ\n\tIQEf5t4GAj6U0I0tcoAKCnGnGTx2P8cei9PK5L69GeOxLJXmSwIwGb2F81VGTOzTw8vg\n\tSmTPkqEjUldwSrsP+jLye6M/XIlnGT4p5XAaqkdABJCWpFekf6wfLdxGS6s7WAcW4fYA\n\tdnhA==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCXryS19DuOFxVDLTMhFw+uzGFOy/DBaET1ZnIa9xdRagUuYk1gagI4cWANhLMxS/Fmi5I9tag/qURyqf3u8t7E=@lists.libcamera.org","X-Gm-Message-State":"AOJu0YzPwIvKf43SlBlRT/r0gLmdYClo3vMh/gsK/1cX5PiBp+dlrm6j\n\t7Mas8ntscO5NiCBribraJ/EKi3uI2fc2Zb9lHwtmky5rsuClrbZu+KdyfLk2pCbS7+I8n9XafXd\n\tI/FVgqtcQjMwoZItVcjcQFHlNszFW1WUL/1kOTx1ilDq9BglUgRbcVViEcKI8R+CrmYTUIa9QzM\n\tNaB/M=","X-Gm-Gg":"ASbGncvpbPOuIAzW9BZjSMLim2OB2/lOstdTqUPNrfkuknV/iGiSYx0u9PnNFav13S9\n\t+jAUmCKKYrBKWjJX4UU4d7NbyivyzBndKM5h3SYD8/irdaWvgPxNlSpPCfPPdjvtE+NfYMDW5bC\n\tnAh2tPhVWPofajKXqtl6ICi1f+/n7j6H8KZsVB/LAK89ZzuNvp7cl/EoEm4EGLdVrpYdVyGzCI+\n\tb2bXDoQZMQYLJIKe8a1Fm8ruIox5sDU1YXmBqcOT8ayoCzCNYBICn6vVg1Pf7KAsvfbK+B612R7\n\tIONwgBrUbxhaIAZa7kLzghU9CYv5C5Et0O5iQBUO3P7ISopeBpIrrRQmd+jhEdoA","X-Received":["by 2002:a17:907:60cc:b0:ab7:6606:a8b9 with SMTP id\n\ta640c23a62f3a-ace84a914c2mr289110366b.42.1745692246071; \n\tSat, 26 Apr 2025 11:30:46 -0700 (PDT)","by 2002:a17:907:60cc:b0:ab7:6606:a8b9 with SMTP id\n\ta640c23a62f3a-ace84a914c2mr289108966b.42.1745692245680; \n\tSat, 26 Apr 2025 11:30:45 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IHDm64ckhnZ+94Pjj3l7xy1k31kP9a3T+jBjbuWamXF3GQQhrDr9t/4/gnu6H5NsnsX0WTzow==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Pavel Machek <pavel@ucw.cz>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org, Hans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","In-Reply-To":"<aAa1f0J1kidzxAxf@duo.ucw.cz> (Pavel Machek's message of \"Mon,\n\t21 Apr 2025 23:15:43 +0200\")","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>\n\t<20250421141606.GO29483@pendragon.ideasonboard.com>\n\t<aAa1f0J1kidzxAxf@duo.ucw.cz>","Date":"Sat, 26 Apr 2025 20:30:44 +0200","Message-ID":"<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"e063TCFbNMnulIETqfJKtfPz9dIHbF82OLabm2E6wXc_1745692246","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":34122,"web_url":"https://patchwork.libcamera.org/comment/34122/","msgid":"<aBUmEin82Ond8Pt1@duo.ucw.cz>","date":"2025-05-02T20:07:46","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> > From looking at the code, soft ISP seemed to be able to do other stuff\n> > than ARGB, but for some reason ARGB is selected by default, and I\n> > guess I can get better performance by forcing right format.\n> \n> Software ISP debayering supports multiple output formats and `cam' can\n> request a particular output format.  For example,\n> \n>   cam -c1 -C4 -s pixelformat=BGR888 -Ffoo#.ppm\n> \n> outputs the right thing.  Example of requesting an output in a different\n> format:\n> \n>   cam -c1 -C4 -s pixelformat=ARGB8888 -Ffoo#.raw\n> \n> It works; is it a problem in your application?\n\nWell, problem is that if you do something like \"cam -c1 -Ffoo#.ppm\" it\ndecides to use ARGB8888 and fails writing into ppm. That is not great.\n\n> I don't mind enhancing the PPM writer but maybe you don't need the\n> conversion there in the first place.\n\nAgreed, I don't need it. People with hardware outputting RGB888 or\nARGB variants might like it.\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 E25C2C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 May 2025 20:07:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B9DC68ADC;\n\tFri,  2 May 2025 22:07:49 +0200 (CEST)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B1A168AD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 May 2025 22:07:48 +0200 (CEST)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid 680BF1C01AC; Fri,  2 May 2025 22:07:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"NE717QI9\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1746216467;\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=NtwPs0IZ4WDax2h6xVZMJ8fOlH8dxTcHYGIU3GXJ8wc=;\n\tb=NE717QI9Mvn5EKatb3YCxT/xD3dUb0lTp41UQsLpXG46fSDoxRlB65py4CcNEu/a6O9Ydd\n\t+erffCZ/zKRi9wJBuV2MJ7Lu/iwqOzSDn/NPOgrriCPP4XkAy30xcfmHvmTjn0eAbjGPHD\n\t5FxIsy9+x834FvRfhLFP+TzalJ0gfT0=","Date":"Fri, 2 May 2025 22:07:46 +0200","From":"Pavel Machek <pavel@ucw.cz>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org, Hans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<aBUmEin82Ond8Pt1@duo.ucw.cz>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>\n\t<20250421141606.GO29483@pendragon.ideasonboard.com>\n\t<aAa1f0J1kidzxAxf@duo.ucw.cz>\n\t<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"BhCcDJn1YINghmdp\"","Content-Disposition":"inline","In-Reply-To":"<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","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>"}},{"id":34123,"web_url":"https://patchwork.libcamera.org/comment/34123/","msgid":"<aBUnOoz6NoVIQK8I@duo.ucw.cz>","date":"2025-05-02T20:12:42","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/people/49/","name":"Pavel Machek","email":"pavel@ucw.cz"},"content":"Hi!\n\n> > swIsp with libcamera produces ARGB data by default, which needs\n> > conversion during write. Implement it and similar conversions.\n> > Signed-off-by: Pavel Machek <pavel@ucw.cz>\n> > \n> > diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp\n> > index 368de8bf..ddbd3263 100644\n> > --- a/src/apps/common/ppm_writer.cpp\n> > +++ b/src/apps/common/ppm_writer.cpp\n> > @@ -20,8 +20,56 @@ int PPMWriter::write(const char *filename,\n> >   \t\t     const StreamConfiguration &config,\n> >   \t\t     const Span<uint8_t> &data)\n> >   {\n> > -\tif (config.pixelFormat != formats::BGR888) {\n> > -\t\tstd::cerr << \"Only BGR888 output pixel format is supported (\"\n> > +\tint r_pos, g_pos, b_pos, bpp;\n> \n> I think the \"pos\" variables should probably be camelCase.\n> And please add an empty line after them.\n\n...thanks for comments, I can fix the style. Laurent, is there still\ninterest in this patch? swIsp does not really need it, but some\nhardware might and tiff writer has similar conversions.\n\n> As for performance, I have briefly taken a look at the x86 assembly of the inner\n> loop, it looks pretty acceptable to me. Apart from the fact that the vector's\n> operator[] adds three branches because meson sets `_GLIBCXX_ASSERTIONS=1` unless\n> `b_ndebug=true`. So that is not too good, but it is probably not too significant.\n\nWell, I strongly suspect reducing ammount of write syscalls (writev)\nwould help significantly. But that's already problem with existing\ncode and would make code more complex.\n\n> But whether or not the soft ISP will support other formats, I think it's useful to\n> support multiple formats here, even at the cost of conversion. Especially since PPM\n> is not a container or such, so if the user explicitly selects it, I think they\n> expect that anything coming out of the camera will be converted appropriately.\n> \n> In addition, it appears to me that qcam already has a sizable set of format\n> conversions implemented. I wonder if those could be used somehow.\n\nOk, someone let me know if I should clean this up and retry.\n\nBest regards,\n\t\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 9B53ABE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 May 2025 20:12:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0958A68AD8;\n\tFri,  2 May 2025 22:12:45 +0200 (CEST)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 09A1F68AD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 May 2025 22:12:43 +0200 (CEST)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid AF8921C01BA; Fri,  2 May 2025 22:12:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ucw.cz header.i=@ucw.cz header.b=\"bSwYIUGh\";\n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1;\n\tt=1746216762;\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=y8RmMZ+r6e/JJN9NNqenMWVvnmH4rcEJdwJLZxoy0eU=;\n\tb=bSwYIUGhw7hJ9Q2gzU4M7Jb6PCH/bifwXfuWzI8wWeTxjoUPDRa6Hf8VgoM/5ZbqBVv4G0\n\tLFZoj+xkJnBVNgxm4tyk0rcaCA0naNAKN17IrtAGB9qOR9+3VJCJ2OaZ6e1ueP5XMFUd/I\n\tPpmWh3Qmky0AC3DbfcAK3f098RfUNRo=","Date":"Fri, 2 May 2025 22:12:42 +0200","From":"Pavel Machek <pavel@ucw.cz>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"laurent.pinchart@ideasonboard.com, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","Message-ID":"<aBUnOoz6NoVIQK8I@duo.ucw.cz>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<6989e227-d1e1-4add-95c3-b6e7efc833e5@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"n4TtDsY0aYrHqhBQ\"","Content-Disposition":"inline","In-Reply-To":"<6989e227-d1e1-4add-95c3-b6e7efc833e5@ideasonboard.com>","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>"}},{"id":34205,"web_url":"https://patchwork.libcamera.org/comment/34205/","msgid":"<85cycdpv4n.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-05-12T18:00:08","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Pavel Machek <pavel@ucw.cz> writes:\n\n> Hi!\n>\n>> > From looking at the code, soft ISP seemed to be able to do other stuff\n>> > than ARGB, but for some reason ARGB is selected by default, and I\n>> > guess I can get better performance by forcing right format.\n>> \n>> Software ISP debayering supports multiple output formats and `cam' can\n>> request a particular output format.  For example,\n>> \n>>   cam -c1 -C4 -s pixelformat=BGR888 -Ffoo#.ppm\n>> \n>> outputs the right thing.  Example of requesting an output in a different\n>> format:\n>> \n>>   cam -c1 -C4 -s pixelformat=ARGB8888 -Ffoo#.raw\n>> \n>> It works; is it a problem in your application?\n>\n> Well, problem is that if you do something like \"cam -c1 -Ffoo#.ppm\" it\n> decides to use ARGB8888 and fails writing into ppm. That is not great.\n\nMaybe `cam' could be enhanced to select BGR888, if available, in case\nppm file output is requested.","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 CBA4DC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 May 2025 18:00:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF87E68B40;\n\tMon, 12 May 2025 20:00:16 +0200 (CEST)","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 A7617614E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 May 2025 20:00:15 +0200 (CEST)","from mail-lf1-f69.google.com (mail-lf1-f69.google.com\n\t[209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-651-1gdfKfLSNQKLNWWmuusiTQ-1; Mon, 12 May 2025 14:00:13 -0400","by mail-lf1-f69.google.com with SMTP id\n\t2adb3069b0e04-54e8141b4adso3179983e87.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 May 2025 11:00:12 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t2adb3069b0e04-54fc644faf1sm1577852e87.14.2025.05.12.11.00.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 12 May 2025 11:00:10 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"ITvl5o50\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1747072814;\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=5mtjm0ElrrqfpBrYeyXYzwrlpRtbvgXdALTNJO/oqDk=;\n\tb=ITvl5o50yC3HXUwaGR0c9v25pkMluiMJVkvQv0T+Xb1Qye6AnoFb4UMjqmLpRWpTYYYCnu\n\tbOG4zb7ehL3mXaGrXx6XUHqaz4W5Tm67dHPiaEYV2TQ9NaodXK8IcCha1r6J5TZ9pr5QJo\n\txrH3leZTkeBKM9XIGGZo5dceO3j/KcM=","X-MC-Unique":"1gdfKfLSNQKLNWWmuusiTQ-1","X-Mimecast-MFC-AGG-ID":"1gdfKfLSNQKLNWWmuusiTQ_1747072812","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1747072811; x=1747677611;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=5mtjm0ElrrqfpBrYeyXYzwrlpRtbvgXdALTNJO/oqDk=;\n\tb=UtVD1MZvLaxoidmqNTYlo8J1FffnudhCXQE/1QvBLtCp5lAsLy+NDy6FbAEHFEeR7O\n\tWYLtXIcnvvfaen3IegtP/fW0X4eMIZkoHRDU+XJlc7Sb8oLMkN7gAPsWkpfhWi0hMn+x\n\twLliqzjze2FrjzsCRNYegtEIMN5alHGghYxAQuROoJ2WzekFH3wxpVmbb4oq7u8z/q9h\n\tRM2oh6l02/wKeHDGsmCLK79lXPPaCZ+fr+FB4IyHICQ7uJou6slr+Nz3LVJpAW+lEeCn\n\t423Pwe7YMyHs1WJ69N4U6q4VEqvQ3Tay9ftHlWbrID33onjSJs39UN8mNITXr+zFwn+b\n\t3lMA==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCVKPetW+21y9ETv4TjvVsG5C1/TExFuLALMsDtAjco1y7D7q7RRAUhOiHlL43N8oJgacGMdQh2S5nnndIykzRc=@lists.libcamera.org","X-Gm-Message-State":"AOJu0YyBHWSV+GZimvSgB+0SkGN6MMQ3+VyWFl1U5wfIJEQUmjiA/nGn\n\tCZQoQvjyyCgXxj8txDpvXj0bpyI4uOI3CxGiafEYnD9cIFGvG4/Mmmuothucn3kTgKBuJqgoENM\n\tIBRUTXMA0ZgBXGeimBGgidUVEiEzhAMad0lfilZkoQpboHpu70cR3J2xLovyAra9Xqtlcc1U=","X-Gm-Gg":"ASbGnctJ+o1PrQkCEhAMgRlnFrjIaO+U2KDJayjFL48VNkeWo5VOdVEZoiHKj30KI4d\n\tYAhHDdns7XFlZsFz/ycE6Xl0EwVF0XAPXKIiI1NPBiHxHmXD5t12L39IweyM+MzpQX/0ZTYexXn\n\tUPPyN/lMJ9Kw1OO4XCLfIIY1kMFyWhs8IbiS0d6ldcD42HCuCsJiVNYfQ4OEPnPf2YGVUNRQwte\n\tpykn3UKKyxLhxgCWNBPJjNGCmZxxYDvejfbkqgVjFdCTP8PjQcHsQMU4I8SvPcNczuYEELnCo6Y\n\tNZtGCEq3K6DZgU03itJ+z/HpwGpazKQQ1IPnrCODKqR0cwlEej6B3HtK0pUS3dY3","X-Received":["by 2002:a05:6512:460d:b0:54e:a262:c960 with SMTP id\n\t2adb3069b0e04-54fc67c98f6mr4446663e87.20.1747072811510; \n\tMon, 12 May 2025 11:00:11 -0700 (PDT)","by 2002:a05:6512:460d:b0:54e:a262:c960 with SMTP id\n\t2adb3069b0e04-54fc67c98f6mr4446649e87.20.1747072811089; \n\tMon, 12 May 2025 11:00:11 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IHxuOEBC/gTFvQNZDmz4rHqaAb7vGeaxkQ1Qpp7anMkOH3EcTpID2ZRUUTIy09azyZCaBSkNA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Pavel Machek <pavel@ucw.cz>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org, Hans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","In-Reply-To":"<aBUmEin82Ond8Pt1@duo.ucw.cz> (Pavel Machek's message of \"Fri, 2\n\tMay 2025 22:07:46 +0200\")","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>\n\t<20250421141606.GO29483@pendragon.ideasonboard.com>\n\t<aAa1f0J1kidzxAxf@duo.ucw.cz>\n\t<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<aBUmEin82Ond8Pt1@duo.ucw.cz>","Date":"Mon, 12 May 2025 20:00:08 +0200","Message-ID":"<85cycdpv4n.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"iSp_61hweU5C5R2L94xQ4Cp8Cqb9qcB5f4LblWciFJA_1747072812","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":34210,"web_url":"https://patchwork.libcamera.org/comment/34210/","msgid":"<174708602155.2817274.9200377335557697319@ping.linuxembedded.co.uk>","date":"2025-05-12T21:40:21","subject":"Re: [PATCH] cam: Convert RGB variations to BGR","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-05-12 19:00:08)\n> Pavel Machek <pavel@ucw.cz> writes:\n> \n> > Hi!\n> >\n> >> > From looking at the code, soft ISP seemed to be able to do other stuff\n> >> > than ARGB, but for some reason ARGB is selected by default, and I\n> >> > guess I can get better performance by forcing right format.\n> >> \n> >> Software ISP debayering supports multiple output formats and `cam' can\n> >> request a particular output format.  For example,\n> >> \n> >>   cam -c1 -C4 -s pixelformat=BGR888 -Ffoo#.ppm\n> >> \n> >> outputs the right thing.  Example of requesting an output in a different\n> >> format:\n> >> \n> >>   cam -c1 -C4 -s pixelformat=ARGB8888 -Ffoo#.raw\n> >> \n> >> It works; is it a problem in your application?\n> >\n> > Well, problem is that if you do something like \"cam -c1 -Ffoo#.ppm\" it\n> > decides to use ARGB8888 and fails writing into ppm. That is not great.\n> \n> Maybe `cam' could be enhanced to select BGR888, if available, in case\n> ppm file output is requested.\n\nI've long wanted cam to be able to negotiate between the capabilities of\nthe camera and the output sink and report (or use) the intersection of\nsupported formats ;-)\n\n(Which means I think we could still add conversions in cam file sinks -\nbut perhaps try to prioritise formats that do not do conversions in any\nformat negotations)\n--\nKieran\n\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 D47B1C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 May 2025 21:40:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0825668B55;\n\tMon, 12 May 2025 23:40:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BBED617C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 May 2025 23:40:24 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3EFB88CB;\n\tMon, 12 May 2025 23:40:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sbyHZcTE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1747086009;\n\tbh=YyMMWQfTLvPZV5hSzVz9aLaxfL+8P3JnLXZG9Bf194Y=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=sbyHZcTErhV0wWAcMxjFZtO4Ro4j8F/hbvq76UgA5kEpsX5oP4Gd1kHVqhJv0EpI9\n\tPx8Rf0/Cs0FuPV8OIrNo60TBCEl2woYoV3acUptQ6Cec7Rb2IVy7kWj82DgbisUuz/\n\t+HtD3y/kS4l7WIogA6g2hRtSkL0rfkTeqNPdKh7I=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<85cycdpv4n.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","References":"<Z/t0DbvYXAjjRmVB@duo.ucw.cz>\n\t<20250413235352.GD12286@pendragon.ideasonboard.com>\n\t<aAN1brt7x2Kz09aQ@duo.ucw.cz>\n\t<20250421141606.GO29483@pendragon.ideasonboard.com>\n\t<aAa1f0J1kidzxAxf@duo.ucw.cz>\n\t<85frhuzsff.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<aBUmEin82Ond8Pt1@duo.ucw.cz>\n\t<85cycdpv4n.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","Subject":"Re: [PATCH] cam: Convert RGB variations to BGR","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org, Hans de Goede <hdegoede@redhat.com>","To":"Milan Zamazal <mzamazal@redhat.com>, Pavel Machek <pavel@ucw.cz>","Date":"Mon, 12 May 2025 22:40:21 +0100","Message-ID":"<174708602155.2817274.9200377335557697319@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]