From patchwork Fri Jul 26 09:54:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 20707 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 582DEBDC71 for ; Fri, 26 Jul 2024 09:56:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF50A6337B; Fri, 26 Jul 2024 11:56:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TPrh4kjT"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B84A63371 for ; Fri, 26 Jul 2024 11:56:42 +0200 (CEST) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70d1c8d7d95so516130b3a.2 for ; Fri, 26 Jul 2024 02:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1721987800; x=1722592600; 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=+L09Rrpm/0DeMUNffdDZiAx9/frA5c+esuyG5D4svek=; b=TPrh4kjTXHbg6Naq0qI3JNGW+feBh5HKea9PVLngA8JAHDt+4eH2Ek8IGm+qwzW8l7 e0jqlZ/ThYmcr91MuEaPGNFel8PYkLxETzubn/UqDagHXwZ3mOBdJKG8oDuJKiKpe3Cu wNgLsu7HBuKyHD8t5tNMVL6r2YU4WAhED+j9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721987800; x=1722592600; 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=+L09Rrpm/0DeMUNffdDZiAx9/frA5c+esuyG5D4svek=; b=mFiz7amjWzkyFcoL+XO7ZIZTedV/saoXKl9kAx9sirdymR0MGE8W8VSAYnqxUlhPpA v4FiWQrB8qFI5uhTbhVKfEnl4Q21atVkWL5DlzF9C9mOELPh56e3NnYItD4r9YEGlX5L aLhJXSzzbcp4aP9B6C0/0ebGy9k7ABR6zfFc3HG48vkFJ1Q46uH43D5ifwQn8w3la4NN 7llHwV1Nfc8GX0IfzsCZ+VcUUJPnC/7YoZ+YYTmgwlMudjGohQ1kn1kv7W7UMOk1f1W0 2fAmj90PMplNajTGieHdTCH6cMHfw5Bx05w4bLJUfOvl5WwAkWR+fK6N9mONxtgK7x36 PIDA== X-Gm-Message-State: AOJu0Yy8mG+T06CejcM4d6BQRXMgzd0HOdZsRYA4yuLANjn/JgADWvg5 q7GW5pYuC+Ye/P3re5mjBFYpis6uvZL3n4fF0Vo97lkXRRqCKWVJb5dqzbTWEqAuJpJtE9rLNu9 mnA== X-Google-Smtp-Source: AGHT+IElzz+mOcRObOIuIAJd8AEYYHXvsBa2sm1UALwBK53eOsXXaeRcTNFWm01RB0+tBAQMZPPN4A== X-Received: by 2002:a05:6a20:2452:b0:1c4:936e:b8a2 with SMTP id adf61e73a8af0-1c4936f4f36mr895565637.27.1721987800315; Fri, 26 Jul 2024 02:56:40 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (148.175.199.104.bc.googleusercontent.com. [104.199.175.148]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7c7f63asm28396665ad.46.2024.07.26.02.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 02:56:39 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Konami Shu , Harvey Yang , Yunke Cao , Tomasz Figa Subject: [PATCH v6 6/7] libcamera: pipeline: Shift test pattern by 1 pixel left every frame Date: Fri, 26 Jul 2024 09:54:27 +0000 Message-ID: <20240726095626.3632402-7-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog In-Reply-To: <20240726095626.3632402-1-chenghaoyang@chromium.org> References: <20240726095626.3632402-1-chenghaoyang@chromium.org> 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 Change-Id: Ief9c1e520a4ffb4cf7d47d0b37ad756be40330ea --- .../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 4eb239e24..b8956f2d4 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 b142b522c..d685a4903 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();