[{"id":30930,"web_url":"https://patchwork.libcamera.org/comment/30930/","msgid":"<ftv5cmf6qzw53oa6wdrdw5w7ugohnrtmvqtx6v3ebrmdk4ghgo@m26b2p7phw4y>","date":"2024-08-27T16:39:06","subject":"Re: [PATCH v9 6/8] libcamera: pipeline: Shift test pattern by 1\n\tpixel left every frame","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi\n\nOn Tue, Aug 20, 2024 at 04:23:37PM GMT, Harvey Yang wrote:\n> From: Konami Shu <konamiz@google.com>\n>\n> - This write the buffer every frame\n> - Shifting makes the frame rate dropped from about 160 to 40\n>\n> Patchset1->2\n> - Use constant instead of using a magic number\n>\n> Patchset2->3\n> - Make shiftLeft() private\n>\n> Signed-off-by: Konami Shu <konamiz@google.com>\n> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> Co-developed-by: Yunke Cao <yunkec@chromium.org>\n> Co-developed-by: Tomasz Figa <tfiga@chromium.org>\n> ---\n>  .../pipeline/virtual/data/virtual.yaml        |  4 +--\n\nThis can be squashed in 5/8\n\n>  .../virtual/test_pattern_generator.cpp        | 36 +++++++++++++++++++\n\nAnd this in 4/8\n\nOr is there a reason I'm missing why these changes have to be\nintroduced later ?\n\n>  2 files changed, 38 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/virtual/data/virtual.yaml b/src/libcamera/pipeline/virtual/data/virtual.yaml\n> index 4eb239e24..b8956f2d4 100644\n> --- a/src/libcamera/pipeline/virtual/data/virtual.yaml\n> +++ b/src/libcamera/pipeline/virtual/data/virtual.yaml\n> @@ -28,8 +28,8 @@\n>    model: \"Virtual Video Device1\"\n>  \"Virtual2\":\n>    supported_formats:\n> -  - width: 100\n> -    height: 100\n> +  - width: 400\n> +    height: 300\n>    test_pattern: \"lines\"\n>    location: \"front\"\n>    model: \"Virtual Video Device2\"\n> diff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp\n> index 8dfe626e5..6df9b31e9 100644\n> --- a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp\n> +++ b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp\n> @@ -28,6 +28,9 @@ void TestPatternGenerator::generateFrame(\n>\n>  \tauto planes = mappedFrameBuffer.planes();\n>\n> +\t/* TODO: select whether to do shifting or not */\n\nWho selects this ? and how ?\n\nI'm a bit confused :)\n\n> +\tshiftLeft(size);\n> +\n>  \t/* Convert the template_ to the frame buffer */\n>  \tint ret = libyuv::ARGBToNV12(\n>  \t\ttemplate_.get(), /*src_stride_argb=*/size.width * kARGBSize,\n> @@ -39,6 +42,39 @@ void TestPatternGenerator::generateFrame(\n>  \t}\n>  }\n>\n> +void TestPatternGenerator::shiftLeft(const Size &size)\n> +{\n> +\t/* Store the first column temporarily */\n> +\tuint8_t firstColumn[size.height * kARGBSize];\n> +\tfor (size_t h = 0; h < size.height; h++) {\n> +\t\tunsigned int index = h * size.width * kARGBSize;\n> +\t\tunsigned int index1 = h * kARGBSize;\n> +\t\tfirstColumn[index1] = template_[index];\n> +\t\tfirstColumn[index1 + 1] = template_[index + 1];\n> +\t\tfirstColumn[index1 + 2] = template_[index + 2];\n> +\t\tfirstColumn[index1 + 3] = 0x00;\n> +\t}\n> +\n> +\t/* Overwrite template_ */\n> +\tuint8_t *buf = template_.get();\n> +\tfor (size_t h = 0; h < size.height; h++) {\n> +\t\tfor (size_t w = 0; w < size.width - 1; w++) {\n> +\t\t\t/* Overwrite with the pixel on the right */\n> +\t\t\tunsigned int index = (h * size.width + w + 1) * kARGBSize;\n> +\t\t\t*buf++ = template_[index]; // B\n> +\t\t\t*buf++ = template_[index + 1]; // G\n> +\t\t\t*buf++ = template_[index + 2]; // R\n> +\t\t\t*buf++ = 0x00; // A\n> +\t\t}\n> +\t\t/* Overwrite the new last column with the original first column */\n> +\t\tunsigned int index1 = h * kARGBSize;\n> +\t\t*buf++ = firstColumn[index1]; // B\n> +\t\t*buf++ = firstColumn[index1 + 1]; // G\n> +\t\t*buf++ = firstColumn[index1 + 2]; // R\n> +\t\t*buf++ = 0x00; // A\n> +\t}\n> +}\n> +\n>  std::unique_ptr<ColorBarsGenerator> ColorBarsGenerator::create()\n>  {\n>  \treturn std::make_unique<ColorBarsGenerator>();\n> --\n> 2.46.0.184.g6999bdac58-goog\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 0BE27C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Aug 2024 16:39:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB41363460;\n\tTue, 27 Aug 2024 18:39:13 +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 7BD1561901\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Aug 2024 18:39:12 +0200 (CEST)","from ideasonboard.com (mob-5-90-141-165.net.vodafone.it\n\t[5.90.141.165])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 29E51A34;\n\tTue, 27 Aug 2024 18:38:02 +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=\"fyNsIF7Q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724776682;\n\tbh=egEX4SBXsU4TZhzocCPZO3qUxzUe90PCfI88RlftAK4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fyNsIF7QTEtCtCtwsZVPRuVnmXMHEu9nyWx2uyGPCRq/o/jCZf6TjYSwJgjjr3bgH\n\tbZGeKbOj4hQ3X/edTnUL+xXja2JOUtfZETun/d8Qps840GXJ0TU58adfFmEsuAKyuQ\n\txGNoZ8IGhDCcfSHmDL7vI9hzJM241jJiAspiRwQE=","Date":"Tue, 27 Aug 2024 18:39:06 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Harvey Yang <chenghaoyang@chromium.org>","Cc":"libcamera-devel@lists.libcamera.org, Konami Shu <konamiz@google.com>, \n\tYunke Cao <yunkec@chromium.org>, Tomasz Figa <tfiga@chromium.org>","Subject":"Re: [PATCH v9 6/8] libcamera: pipeline: Shift test pattern by 1\n\tpixel left every frame","Message-ID":"<ftv5cmf6qzw53oa6wdrdw5w7ugohnrtmvqtx6v3ebrmdk4ghgo@m26b2p7phw4y>","References":"<20240820172202.526547-1-chenghaoyang@google.com>\n\t<20240820172202.526547-7-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240820172202.526547-7-chenghaoyang@google.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>"}}]