Patch Detail
Show a patch.
GET /api/1.1/patches/24279/?format=api
{ "id": 24279, "url": "https://patchwork.libcamera.org/api/1.1/patches/24279/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24279/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250901141643.29136-2-mzamazal@redhat.com>", "date": "2025-09-01T14:16:42", "name": "[v2,1/1] apps: cam: Support PPM output for other RGB formats", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7112d7c8298d5d4bdd4d9e1c3fe1d766cae90a01", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24279/mbox/", "series": [ { "id": 5420, "url": "https://patchwork.libcamera.org/api/1.1/series/5420/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5420", "date": "2025-09-01T14:16:41", "name": "PPM output for RGB formats", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5420/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24279/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24279/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E28BEBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 1 Sep 2025 14:17:01 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8D49B69323;\n\tMon, 1 Sep 2025 16:17:01 +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 DD4B169323\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 1 Sep 2025 16:16:58 +0200 (CEST)", "from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-642-gZKJRV9JM6SKMJ1nLivJJA-1;\n\tMon, 01 Sep 2025 10:16:54 -0400", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 970531955F26; Mon, 1 Sep 2025 14:16:53 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.12])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 17DC31800280; Mon, 1 Sep 2025 14:16:50 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"iAbByE51\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1756736217;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Hi9eIU1jnMUh3zOi9qd6XoTX8yK4IVT7e8jbhZK9cgw=;\n\tb=iAbByE51Jiuyq+Llyz+GhmEVRuhyY4k0ki0IfEmThaLGXsrjfNjKhPp/Y2FVKAVRSnFO3T\n\tVKxiadrXAGmi8KajNEbcdnljknEg0clK5rJr13OzG91PTRsXu9jhdN5Q9zBOcyJgzo3vns\n\t56+wGSAKhh22C/eumwCmZ7brkeejrSE=", "X-MC-Unique": "gZKJRV9JM6SKMJ1nLivJJA-1", "X-Mimecast-MFC-AGG-ID": "gZKJRV9JM6SKMJ1nLivJJA_1756736213", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\t\"Bryan O'Donoghue\" <bryan.odonoghue@linaro.org>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPavel Machek <pavel@ucw.cz>", "Subject": "[PATCH v2 1/1] apps: cam: Support PPM output for other RGB formats", "Date": "Mon, 1 Sep 2025 16:16:42 +0200", "Message-ID": "<20250901141643.29136-2-mzamazal@redhat.com>", "In-Reply-To": "<20250901141643.29136-1-mzamazal@redhat.com>", "References": "<20250901141643.29136-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "FMuo2LrT-jF3lelFvAwwuWGEixCzXd3MQUMzuSrnPuQ_1756736213", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "GPU ISP can produce only 32-bit output. Let's add support to the PPM\nwriter for all the common RGB image formats so that we can store GPU ISP\noutput as PPM files. Contingent alpha values are ignored as there is no\nsupport for the alpha channel in PPM.\n\nThere is no obvious performance penalty in my environment compared to\noutput in the raw format.\n\nCo-developed-by: Pavel Machek <pavel@ucw.cz>\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/apps/common/ppm_writer.cpp | 66 ++++++++++++++++++++++++++++++++--\n 1 file changed, 63 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp\nindex 368de8bf6..9ba0216a0 100644\n--- a/src/apps/common/ppm_writer.cpp\n+++ b/src/apps/common/ppm_writer.cpp\n@@ -10,6 +10,8 @@\n #include <errno.h>\n #include <fstream>\n #include <iostream>\n+#include <stddef.h>\n+#include <vector>\n \n #include <libcamera/formats.h>\n #include <libcamera/pixel_format.h>\n@@ -20,8 +22,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+\tsize_t rPos, gPos, bPos, bytesPerPixel;\n+\tswitch (config.pixelFormat) {\n+\tcase libcamera::formats::R8:\n+\t\trPos = 0;\n+\t\tgPos = 0;\n+\t\tbPos = 0;\n+\t\tbytesPerPixel = 1;\n+\t\tbreak;\n+\tcase libcamera::formats::RGB888:\n+\t\trPos = 2;\n+\t\tgPos = 1;\n+\t\tbPos = 0;\n+\t\tbytesPerPixel = 3;\n+\t\tbreak;\n+\tcase libcamera::formats::BGR888:\n+\t\trPos = 0;\n+\t\tgPos = 1;\n+\t\tbPos = 2;\n+\t\tbytesPerPixel = 3;\n+\t\tbreak;\n+\tcase libcamera::formats::ARGB8888:\n+\tcase libcamera::formats::XRGB8888:\n+\t\trPos = 2;\n+\t\tgPos = 1;\n+\t\tbPos = 0;\n+\t\tbytesPerPixel = 4;\n+\t\tbreak;\n+\tcase libcamera::formats::RGBA8888:\n+\tcase libcamera::formats::RGBX8888:\n+\t\trPos = 3;\n+\t\tgPos = 2;\n+\t\tbPos = 1;\n+\t\tbytesPerPixel = 4;\n+\t\tbreak;\n+\tcase libcamera::formats::ABGR8888:\n+\tcase libcamera::formats::XBGR8888:\n+\t\trPos = 0;\n+\t\tgPos = 1;\n+\t\tbPos = 2;\n+\t\tbytesPerPixel = 4;\n+\t\tbreak;\n+\tcase libcamera::formats::BGRA8888:\n+\tcase libcamera::formats::BGRX8888:\n+\t\trPos = 1;\n+\t\tgPos = 2;\n+\t\tbPos = 3;\n+\t\tbytesPerPixel = 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@@ -42,8 +92,18 @@ int PPMWriter::write(const char *filename,\n \n \tconst unsigned int rowLength = config.size.width * 3;\n \tconst char *row = reinterpret_cast<const char *>(data.data());\n+\tconst bool transform = config.pixelFormat != formats::BGR888;\n+\tstd::vector<char> transformedRow(transform ? rowLength : 0);\n+\n \tfor (unsigned int y = 0; y < config.size.height; y++, row += config.stride) {\n-\t\toutput.write(row, rowLength);\n+\t\tif (transform)\n+\t\t\tfor (unsigned int x = 0; x < config.size.width; x++) {\n+\t\t\t\ttransformedRow[x * 3] = row[x * bytesPerPixel + rPos];\n+\t\t\t\ttransformedRow[x * 3 + 1] = row[x * bytesPerPixel + gPos];\n+\t\t\t\ttransformedRow[x * 3 + 2] = row[x * bytesPerPixel + bPos];\n+\t\t\t}\n+\n+\t\toutput.write((transform ? transformedRow.data() : row), 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", "prefixes": [ "v2", "1/1" ] }