From patchwork Mon Aug 5 13:48:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 20783 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C6D29BE173 for ; Mon, 5 Aug 2024 13:51:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 751796338C; Mon, 5 Aug 2024 15:51:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iqK4Wa9h"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F3FBF63387 for ; Mon, 5 Aug 2024 15:51:09 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3684e8220f9so3150816f8f.1 for ; Mon, 05 Aug 2024 06:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1722865869; x=1723470669; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IwO+Szbax0/PsyYsuXawn4mzMae1KrfmYICm2SjNpoA=; b=iqK4Wa9hdSQoVdgJCaJ0E8zJDjtgFPKeoiW2izRANds5iqJP+guG7O0YL8B2c/gt0m X7EwfBn5p62+596jFdHBnSzQWkEw3i+6oCcTSHuG5tyPgT17AC3Cyi+hbfTg2gsgE8qk Gi1H+Cc5ZpiHU/Ln3nah1bTdeKoFR4XdPeUWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722865869; x=1723470669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IwO+Szbax0/PsyYsuXawn4mzMae1KrfmYICm2SjNpoA=; b=CX5hMdHTStrvk/byEv7Xo9heY85Kku4vrd76qaxqKvWaIMYF97Otr1mkJ6FFry9TXW fWVDboVDwQtCV/8mJwvXdr0RHQgQT0R5NX3lt0YBJEt1RU+thkgdJejvxWYoXpQXPSo3 nZk6jANCS4+23evQTh7n1v5zWbV5wTCY4o9uLRTaIueRya5xLOrVNLOuT8wXIcX82DgQ DKx47Xk9UoI8hDgosIuGld+r7LabeiobbYTLXFcGPltQvubykRquokdPXPF0cXWhcyOR uyg0YHyKQfWqGrWEn2TTHh75mnvWYFBXjj60jsivvWoTrJ9XKKVuO4EK8oceuNCQj86P TNEQ== X-Gm-Message-State: AOJu0YyuRxLsC4M5zcOaUnVtZs/lU1VdZBbnCWAIw+qISVDxmxDXoUfe hqUZyM9WyhgBIdwz3kPT+X5Pe6AXwyM3efeT7+EYnCGdx4eTyGZuDRWnfT7l5LAPMQFZAL4tE1t B8//rixE= X-Google-Smtp-Source: AGHT+IHlbYv8kW8InlDU23KP9xERoG4NOVnyDjXQbo/A/n+1DaBVK0HmQt2X4qDDiaeEd2/ARL3OPg== X-Received: by 2002:adf:b184:0:b0:366:eadc:573f with SMTP id ffacd0b85a97d-36bb35dfd67mr10031360f8f.27.1722865869166; Mon, 05 Aug 2024 06:51:09 -0700 (PDT) Received: from chenghaoyang-germany.c.googlers.com.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e8d6555fsm137146675e9.26.2024.08.05.06.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 06:51:08 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Konami Shu , Harvey Yang , Yunke Cao , Tomasz Figa Subject: [PATCH v8 6/8] libcamera: pipeline: Shift test pattern by 1 pixel left every frame Date: Mon, 5 Aug 2024 13:48:37 +0000 Message-ID: <20240805135104.139932-7-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805135104.139932-1-chenghaoyang@google.com> References: <20240805135104.139932-1-chenghaoyang@google.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Konami Shu - This write the buffer every frame - Shifting makes the frame rate dropped from about 160 to 40 Patchset1->2 - Use constant instead of using a magic number Patchset2->3 - Make shiftLeft() private Signed-off-by: Konami Shu Co-developed-by: Harvey Yang Co-developed-by: Yunke Cao Co-developed-by: Tomasz Figa --- .../pipeline/virtual/data/virtual.yaml | 4 +-- .../virtual/test_pattern_generator.cpp | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/virtual/data/virtual.yaml b/src/libcamera/pipeline/virtual/data/virtual.yaml index 4eb239e2..b8956f2d 100644 --- a/src/libcamera/pipeline/virtual/data/virtual.yaml +++ b/src/libcamera/pipeline/virtual/data/virtual.yaml @@ -28,8 +28,8 @@ model: "Virtual Video Device1" "Virtual2": supported_formats: - - width: 100 - height: 100 + - width: 400 + height: 300 test_pattern: "lines" location: "front" model: "Virtual Video Device2" diff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp index 8dfe626e..6df9b31e 100644 --- a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp +++ b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp @@ -28,6 +28,9 @@ void TestPatternGenerator::generateFrame( auto planes = mappedFrameBuffer.planes(); + /* TODO: select whether to do shifting or not */ + shiftLeft(size); + /* Convert the template_ to the frame buffer */ int ret = libyuv::ARGBToNV12( template_.get(), /*src_stride_argb=*/size.width * kARGBSize, @@ -39,6 +42,39 @@ void TestPatternGenerator::generateFrame( } } +void TestPatternGenerator::shiftLeft(const Size &size) +{ + /* Store the first column temporarily */ + uint8_t firstColumn[size.height * kARGBSize]; + for (size_t h = 0; h < size.height; h++) { + unsigned int index = h * size.width * kARGBSize; + unsigned int index1 = h * kARGBSize; + firstColumn[index1] = template_[index]; + firstColumn[index1 + 1] = template_[index + 1]; + firstColumn[index1 + 2] = template_[index + 2]; + firstColumn[index1 + 3] = 0x00; + } + + /* Overwrite template_ */ + uint8_t *buf = template_.get(); + for (size_t h = 0; h < size.height; h++) { + for (size_t w = 0; w < size.width - 1; w++) { + /* Overwrite with the pixel on the right */ + unsigned int index = (h * size.width + w + 1) * kARGBSize; + *buf++ = template_[index]; // B + *buf++ = template_[index + 1]; // G + *buf++ = template_[index + 2]; // R + *buf++ = 0x00; // A + } + /* Overwrite the new last column with the original first column */ + unsigned int index1 = h * kARGBSize; + *buf++ = firstColumn[index1]; // B + *buf++ = firstColumn[index1 + 1]; // G + *buf++ = firstColumn[index1 + 2]; // R + *buf++ = 0x00; // A + } +} + std::unique_ptr ColorBarsGenerator::create() { return std::make_unique();