From patchwork Thu Aug 1 07:31:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 20744 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 0E942BDC71 for ; Thu, 1 Aug 2024 07:34:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9FBBE63386; Thu, 1 Aug 2024 09:34:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="OEHy1vd7"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4252D63381 for ; Thu, 1 Aug 2024 09:33:58 +0200 (CEST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fd9e6189d5so53066955ad.3 for ; Thu, 01 Aug 2024 00:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1722497636; x=1723102436; 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=Zdz2HiC4N+RVhABxhJ7B+tzTLBNBTx7Napjziq4G5xk=; b=OEHy1vd7bRWLFAbg8l7kJZAT+UfVwlOBu4PmJf3ItfqS+/w7sTD0gqHuoCOyvS/k7N nOJN2grC+eqO14oAolYuAcyf1mxQFbu/wf0bWxXTQI8NYVgL7MuRf9bKOBJLnaisgBjB YlIptgoHZGcFOi4zR0+x1RllM28hC/DDT6yQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722497636; x=1723102436; 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=Zdz2HiC4N+RVhABxhJ7B+tzTLBNBTx7Napjziq4G5xk=; b=SjVrv8/ZgYewuXrMqg+Whyd7TYioLztkb6qN4vQM9Y09PGCfd7MjNAE9iXE1PIWFyU qs8jWVb6IGrtS+TpiF/TBRCliARc2UeUY6kV3q61hwJIQxyPRwKb2ZlgubmA8fCE8yfe Gylu2f4Bejcspk28mOEcLSX9T0CXYi7h17/XC5cSzi2uEqsrTsUEc2/mlzrpDdlCQ/bR 5YHOebggmNzuu2qBLQUQ21rKTm7VJSCxN1V0VlEunxWgyxPY9zkZ1/38py84QiLW/ZBW VAboYBUxIditS/Xh5p7p/Zbf8MCYLUMcH66aQttKF6UjlHdk9fLKCHSPu+ATSpFGK7Xe fWtA== X-Gm-Message-State: AOJu0Yzlo4u7Ng96/8Y9nJqc3gfbn85SFfKbY7RoLvck4AdxnW/vZYUP wyi054x2Ryj6AIsET8vMsqOtEfA1wG9GYFOgskZG32FbIdeJ79OO8C8VSE0veZij41UVdUUon3S 65g== X-Google-Smtp-Source: AGHT+IE/VvE32lAu8ms4KP5IAA3ALlIOTJOtntA9ZC/VoeleGu4u6DSLv+i9nXwFSX5NxqYq2w1XvQ== X-Received: by 2002:a17:903:234f:b0:1fb:72b4:8775 with SMTP id d9443c01a7336-1ff4d2135c7mr18130925ad.40.1722497635915; Thu, 01 Aug 2024 00:33:55 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (237.198.80.34.bc.googleusercontent.com. [34.80.198.237]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7cd3dcbsm131839165ad.73.2024.08.01.00.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 00:33:55 -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 v7 6/7] libcamera: pipeline: Shift test pattern by 1 pixel left every frame Date: Thu, 1 Aug 2024 07:31:02 +0000 Message-ID: <20240801073339.4061027-7-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog In-Reply-To: <20240801073339.4061027-1-chenghaoyang@google.com> References: <20240801073339.4061027-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();