Show a patch.

GET /api/patches/21196/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 21196,
    "url": "https://patchwork.libcamera.org/api/patches/21196/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21196/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20240907143110.2210711-5-chenghaoyang@google.com>",
    "date": "2024-09-07T14:28:29",
    "name": "[v11,4/7] libcamera: pipeline: Add test pattern for VirtualPipelineHandler",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "333af82a7f59852718f6621e275050416dfff390",
    "submitter": {
        "id": 117,
        "url": "https://patchwork.libcamera.org/api/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21196/mbox/",
    "series": [
        {
            "id": 4567,
            "url": "https://patchwork.libcamera.org/api/series/4567/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4567",
            "date": "2024-09-07T14:28:25",
            "name": "Add VirtualPipelineHandler",
            "version": 11,
            "mbox": "https://patchwork.libcamera.org/series/4567/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21196/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21196/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 70E12C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  7 Sep 2024 14:31:33 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B59B63500;\n\tSat,  7 Sep 2024 16:31:33 +0200 (CEST)",
            "from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com\n\t[IPv6:2607:f8b0:4864:20::62f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B5A8634F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  7 Sep 2024 16:31:24 +0200 (CEST)",
            "by mail-pl1-x62f.google.com with SMTP id\n\td9443c01a7336-2054e22ce3fso27814185ad.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 07 Sep 2024 07:31:24 -0700 (PDT)",
            "from chenghaoyang-low.c.googlers.com.com\n\t(0.223.81.34.bc.googleusercontent.com. [34.81.223.0])\n\tby smtp.gmail.com with ESMTPSA id\n\td9443c01a7336-20710e33974sm9208935ad.104.2024.09.07.07.31.20\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 07 Sep 2024 07:31:22 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"VwRUkRzc\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1725719482; x=1726324282;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=TPTolxD0dbXfb95Xlm2OYyFA+j4DzV1KmlyOUgwk5UA=;\n\tb=VwRUkRzcQbC/WU+1BwJ5/Uhu8ZZ7xyjfH1puqOVM14ZBHMZpdXfVyF+FkoYhe1g8at\n\tK0iAujpWRzopIkvsU3fGecRr3JIKqY0/lMtvls83xguBz/v7mWt9oNxVJZz5APiEi4hs\n\t1ZlpP8lFA3BlyddI5nKVcjIOKRIg5TeNsupas=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1725719482; x=1726324282;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=TPTolxD0dbXfb95Xlm2OYyFA+j4DzV1KmlyOUgwk5UA=;\n\tb=lVteOtqfPfA0nzNCGWeStLXJttwaOtnd4UxrOYC75lq80uSj+tGzC1DTswY3aF0Sot\n\tUAMj5Hfqqjg4qjdV5o5sdS/hAarAi92okEebGdCtyWRqudTV/ZrUee4nuFYBvGKcc8h9\n\tCjI5+/ws1rSJdd/9714aL1Ej8Kd3ab7bma/GbxD3gtEzzCE1MkBoChpilXKpJ4cIp4k9\n\tE3ujp9Ilg7DTbZIcnBPGpB89XUmyVE3/ECZ5ATIEUMq1dHzfX77n8H6rKMQTmCFs5PuC\n\tyDXnZMnctBgINj+JNJWofyaovCyRI2/xBegN7xmal5IZLK2Tllg5BxbFa3+0kePXZ88n\n\t8bYQ==",
        "X-Gm-Message-State": "AOJu0YwzhA7z2jiMMjdmCh3yYoJXfac5U6wLStvcPgbXg3HNw4uwEmzU\n\tWZTC/N8TtsswYBv56uQ3hcDTQ/DDzZ/l1zqXyzDkqIuG3qNFd9yTtIHWR7VKM2rciDuGhK+UBi8\n\tBzw==",
        "X-Google-Smtp-Source": "AGHT+IFvY4URNakxdhEgiNhWx21n5Mlvg8+rbxwLy1NbMgmmGVZCeUkCBuex4TtUyh+yU448IIC9EA==",
        "X-Received": "by 2002:a17:902:e88a:b0:206:8f21:284e with SMTP id\n\td9443c01a7336-206f05f68b0mr54423435ad.42.1725719482464; \n\tSat, 07 Sep 2024 07:31:22 -0700 (PDT)",
        "From": "Harvey Yang <chenghaoyang@chromium.org>",
        "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Konami Shu <konamiz@google.com>, Harvey Yang <chenghaoyang@chromium.org>,\n\tYunke Cao <yunkec@chromium.org>, Tomasz Figa <tfiga@chromium.org>",
        "Subject": "[PATCH v11 4/7] libcamera: pipeline: Add test pattern for\n\tVirtualPipelineHandler",
        "Date": "Sat,  7 Sep 2024 14:28:29 +0000",
        "Message-ID": "<20240907143110.2210711-5-chenghaoyang@google.com>",
        "X-Mailer": "git-send-email 2.46.0.469.g59c65b2a67-goog",
        "In-Reply-To": "<20240907143110.2210711-1-chenghaoyang@google.com>",
        "References": "<20240907143110.2210711-1-chenghaoyang@google.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "From: Konami Shu <konamiz@google.com>\n\nAdd a test pattern generator class hierarchy for the Virtual\npipeline handler.\n\nImplement two types of test patterns: color bars and diagonal lines\ngenerator and use them in the Virtual pipeline handler.\n\nAdd a dependency for libyuv to the build system to generate images\nin NV12 format from the test pattern.\n\nSigned-off-by: Konami Shu <konamiz@google.com>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nCo-developed-by: Yunke Cao <yunkec@chromium.org>\nCo-developed-by: Tomasz Figa <tfiga@chromium.org>\n\nlibcamera: pipeline: Shift test pattern by 1 pixel left every frame\n\n- This write the buffer every frame\n- Shifting makes the frame rate dropped from about 160 to 40\n\nPatchset1->2\n- Use constant instead of using a magic number\n\nPatchset2->3\n- Make shiftLeft() private\n\nSigned-off-by: Konami Shu <konamiz@google.com>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nCo-developed-by: Yunke Cao <yunkec@chromium.org>\nCo-developed-by: Tomasz Figa <tfiga@chromium.org>\n---\n src/android/meson.build                       |  19 ---\n .../pipeline/virtual/frame_generator.h        |  29 ++++\n src/libcamera/pipeline/virtual/meson.build    |   3 +\n .../virtual/test_pattern_generator.cpp        | 140 ++++++++++++++++++\n .../pipeline/virtual/test_pattern_generator.h |  57 +++++++\n src/libcamera/pipeline/virtual/virtual.cpp    |  38 ++++-\n src/libcamera/pipeline/virtual/virtual.h      |   7 +\n src/meson.build                               |  19 +++\n 8 files changed, 290 insertions(+), 22 deletions(-)\n create mode 100644 src/libcamera/pipeline/virtual/frame_generator.h\n create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.cpp\n create mode 100644 src/libcamera/pipeline/virtual/test_pattern_generator.h",
    "diff": "diff --git a/src/android/meson.build b/src/android/meson.build\nindex 68646120..6341ee8b 100644\n--- a/src/android/meson.build\n+++ b/src/android/meson.build\n@@ -15,25 +15,6 @@ foreach dep : android_deps\n     endif\n endforeach\n \n-libyuv_dep = dependency('libyuv', required : false)\n-\n-# Fallback to a subproject if libyuv isn't found, as it's typically not\n-# provided by distributions.\n-if not libyuv_dep.found()\n-    cmake = import('cmake')\n-\n-    libyuv_vars = cmake.subproject_options()\n-    libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n-    libyuv_vars.set_override_option('cpp_std', 'c++17')\n-    libyuv_vars.append_compile_args('cpp',\n-         '-Wno-sign-compare',\n-         '-Wno-unused-variable',\n-         '-Wno-unused-parameter')\n-    libyuv_vars.append_link_args('-ljpeg')\n-    libyuv = cmake.subproject('libyuv', options : libyuv_vars)\n-    libyuv_dep = libyuv.dependency('yuv')\n-endif\n-\n android_deps += [libyuv_dep]\n \n android_hal_sources = files([\ndiff --git a/src/libcamera/pipeline/virtual/frame_generator.h b/src/libcamera/pipeline/virtual/frame_generator.h\nnew file mode 100644\nindex 00000000..d8727b8f\n--- /dev/null\n+++ b/src/libcamera/pipeline/virtual/frame_generator.h\n@@ -0,0 +1,29 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Google Inc.\n+ *\n+ * frame_generator.h - Virtual cameras helper to generate frames\n+ */\n+\n+#pragma once\n+\n+#include <libcamera/framebuffer.h>\n+#include <libcamera/geometry.h>\n+\n+namespace libcamera {\n+\n+class FrameGenerator\n+{\n+public:\n+\tvirtual ~FrameGenerator() = default;\n+\n+\tvirtual void configure(const Size &size) = 0;\n+\n+\tvirtual void generateFrame(const Size &size,\n+\t\t\t\t   const FrameBuffer *buffer) = 0;\n+\n+protected:\n+\tFrameGenerator() {}\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/virtual/meson.build b/src/libcamera/pipeline/virtual/meson.build\nindex ada1b335..0c537777 100644\n--- a/src/libcamera/pipeline/virtual/meson.build\n+++ b/src/libcamera/pipeline/virtual/meson.build\n@@ -1,5 +1,8 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libcamera_internal_sources += files([\n+    'test_pattern_generator.cpp',\n     'virtual.cpp',\n ])\n+\n+libcamera_deps += [libyuv_dep]\ndiff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp\nnew file mode 100644\nindex 00000000..7094818e\n--- /dev/null\n+++ b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp\n@@ -0,0 +1,140 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Google Inc.\n+ *\n+ * test_pattern_generator.cpp - Derived class of FrameGenerator for\n+ * generating test patterns\n+ */\n+\n+#include \"test_pattern_generator.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+#include \"libcamera/internal/mapped_framebuffer.h\"\n+\n+#include \"libyuv/convert_from_argb.h\"\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(Virtual)\n+\n+static const unsigned int kARGBSize = 4;\n+\n+void TestPatternGenerator::generateFrame(const Size &size,\n+\t\t\t\t\t const FrameBuffer *buffer)\n+{\n+\tMappedFrameBuffer mappedFrameBuffer(buffer,\n+\t\t\t\t\t    MappedFrameBuffer::MapFlag::Write);\n+\n+\tauto planes = mappedFrameBuffer.planes();\n+\n+\tshiftLeft(size);\n+\n+\t/* Convert the template_ to the frame buffer */\n+\tint ret = libyuv::ARGBToNV12(\n+\t\ttemplate_.get(), size.width * kARGBSize,\n+\t\tplanes[0].begin(), size.width,\n+\t\tplanes[1].begin(), size.width,\n+\t\tsize.width, size.height);\n+\tif (ret != 0)\n+\t\tLOG(Virtual, Error) << \"ARGBToNV12() failed with \" << ret;\n+}\n+\n+void TestPatternGenerator::shiftLeft(const Size &size)\n+{\n+\t/* Store the first column temporarily */\n+\tauto firstColumn = std::make_unique<uint8_t[]>(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+ColorBarsGenerator::ColorBarsGenerator() = default;\n+\n+void ColorBarsGenerator::configure(const Size &size)\n+{\n+\tconstexpr uint8_t kColorBar[8][3] = {\n+\t\t//  R,    G,    B\n+\t\t{ 0xff, 0xff, 0xff }, // White\n+\t\t{ 0xff, 0xff, 0x00 }, // Yellow\n+\t\t{ 0x00, 0xff, 0xff }, // Cyan\n+\t\t{ 0x00, 0xff, 0x00 }, // Green\n+\t\t{ 0xff, 0x00, 0xff }, // Magenta\n+\t\t{ 0xff, 0x00, 0x00 }, // Red\n+\t\t{ 0x00, 0x00, 0xff }, // Blue\n+\t\t{ 0x00, 0x00, 0x00 }, // Black\n+\t};\n+\n+\ttemplate_ = std::make_unique<uint8_t[]>(\n+\t\tsize.width * size.height * kARGBSize);\n+\n+\tunsigned int colorBarWidth = size.width / std::size(kColorBar);\n+\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; w++) {\n+\t\t\t/* Repeat when the width is exceed */\n+\t\t\tunsigned int index = (w / colorBarWidth) % std::size(kColorBar);\n+\n+\t\t\t*buf++ = kColorBar[index][2]; /* B */\n+\t\t\t*buf++ = kColorBar[index][1]; /* G */\n+\t\t\t*buf++ = kColorBar[index][0]; /* R */\n+\t\t\t*buf++ = 0x00; /* A */\n+\t\t}\n+\t}\n+}\n+\n+DiagonalLinesGenerator::DiagonalLinesGenerator() = default;\n+\n+void DiagonalLinesGenerator::configure(const Size &size)\n+{\n+\tconstexpr uint8_t kColorBar[8][3] = {\n+\t\t/*  R,    G,    B */\n+\t\t{ 0xff, 0xff, 0xff }, /* White */\n+\t\t{ 0x00, 0x00, 0x00 }, /* Black */\n+\t};\n+\n+\ttemplate_ = std::make_unique<uint8_t[]>(\n+\t\tsize.width * size.height * kARGBSize);\n+\n+\tunsigned int lineWidth = size.width / 10;\n+\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; w++) {\n+\t\t\t/* Repeat when the width is exceed */\n+\t\t\tint index = ((w + h) / lineWidth) % 2;\n+\n+\t\t\t*buf++ = kColorBar[index][2]; /* B */\n+\t\t\t*buf++ = kColorBar[index][1]; /* G */\n+\t\t\t*buf++ = kColorBar[index][0]; /* R */\n+\t\t\t*buf++ = 0x00; /* A */\n+\t\t}\n+\t}\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.h b/src/libcamera/pipeline/virtual/test_pattern_generator.h\nnew file mode 100644\nindex 00000000..11bcb5f0\n--- /dev/null\n+++ b/src/libcamera/pipeline/virtual/test_pattern_generator.h\n@@ -0,0 +1,57 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Google Inc.\n+ *\n+ * test_pattern_generator.h - Derived class of FrameGenerator for\n+ * generating test patterns\n+ */\n+\n+#pragma once\n+\n+#include <memory>\n+\n+#include <libcamera/framebuffer.h>\n+#include <libcamera/geometry.h>\n+\n+#include \"frame_generator.h\"\n+\n+namespace libcamera {\n+\n+enum class TestPattern : char {\n+\tColorBars = 0,\n+\tDiagonalLines = 1,\n+};\n+\n+class TestPatternGenerator : public FrameGenerator\n+{\n+public:\n+\tvoid generateFrame(const Size &size, const FrameBuffer *buffer) override;\n+\n+protected:\n+\t/* Buffer of test pattern template */\n+\tstd::unique_ptr<uint8_t[]> template_;\n+\n+private:\n+\t/* Shift the buffer by 1 pixel left each frame */\n+\tvoid shiftLeft(const Size &size);\n+};\n+\n+class ColorBarsGenerator : public TestPatternGenerator\n+{\n+public:\n+\tColorBarsGenerator();\n+\n+\t/* Generate a template buffer of the color bar test pattern. */\n+\tvoid configure(const Size &size) override;\n+};\n+\n+class DiagonalLinesGenerator : public TestPatternGenerator\n+{\n+public:\n+\tDiagonalLinesGenerator();\n+\n+\t/* Generate a template buffer of the diagonal lines test pattern. */\n+\tvoid configure(const Size &size) override;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp\nindex f85ec3dd..6e64aeee 100644\n--- a/src/libcamera/pipeline/virtual/virtual.cpp\n+++ b/src/libcamera/pipeline/virtual/virtual.cpp\n@@ -173,8 +173,11 @@ int PipelineHandlerVirtual::configure(Camera *camera,\n \t\t\t\t      CameraConfiguration *config)\n {\n \tVirtualCameraData *data = cameraData(camera);\n-\tfor (size_t i = 0; i < config->size(); ++i)\n+\tfor (size_t i = 0; i < config->size(); ++i) {\n \t\tconfig->at(i).setStream(&data->streamConfigs_[i].stream);\n+\t\tdata->streamConfigs_[i].frameGenerator->configure(\n+\t\t\tdata->streamConfigs_[i].stream.configuration().size);\n+\t}\n \n \treturn 0;\n }\n@@ -210,9 +213,24 @@ void PipelineHandlerVirtual::stopDevice([[maybe_unused]] Camera *camera)\n int PipelineHandlerVirtual::queueRequestDevice([[maybe_unused]] Camera *camera,\n \t\t\t\t\t       Request *request)\n {\n+\tVirtualCameraData *data = cameraData(camera);\n+\n \t/* \\todo Read from the virtual video if any. */\n-\tfor (auto it : request->buffers())\n-\t\tcompleteBuffer(request, it.second);\n+\tfor (auto const &[stream, buffer] : request->buffers()) {\n+\t\tbool found = false;\n+\t\t/* map buffer and fill test patterns */\n+\t\tfor (auto &streamConfig : data->streamConfigs_) {\n+\t\t\tif (stream == &streamConfig.stream) {\n+\t\t\t\tfound = true;\n+\t\t\t\tstreamConfig.frameGenerator->generateFrame(\n+\t\t\t\t\tstream->configuration().size, buffer);\n+\t\t\t\tcompleteBuffer(request, buffer);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t\tif (!found)\n+\t\t\tLOG(Virtual, Fatal) << \"Stream not defined\";\n+\t}\n \n \trequest->metadata().set(controls::SensorTimestamp, currentTimestamp());\n \tcompleteRequest(request);\n@@ -257,11 +275,25 @@ bool PipelineHandlerVirtual::match([[maybe_unused]] DeviceEnumerator *enumerator\n \n \tconst std::string id = \"Virtual0\";\n \tstd::shared_ptr<Camera> camera = Camera::create(std::move(data), id, streams);\n+\n+\tinitFrameGenerator(camera.get());\n+\n \tregisterCamera(std::move(camera));\n \n \treturn true;\n }\n \n+void PipelineHandlerVirtual::initFrameGenerator(Camera *camera)\n+{\n+\tauto data = cameraData(camera);\n+\tfor (auto &streamConfig : data->streamConfigs_) {\n+\t\tif (data->testPattern_ == TestPattern::DiagonalLines)\n+\t\t\tstreamConfig.frameGenerator = std::make_unique<DiagonalLinesGenerator>();\n+\t\telse\n+\t\t\tstreamConfig.frameGenerator = std::make_unique<ColorBarsGenerator>();\n+\t}\n+}\n+\n REGISTER_PIPELINE_HANDLER(PipelineHandlerVirtual, \"virtual\")\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/virtual/virtual.h b/src/libcamera/pipeline/virtual/virtual.h\nindex fb3dbcad..09d73051 100644\n--- a/src/libcamera/pipeline/virtual/virtual.h\n+++ b/src/libcamera/pipeline/virtual/virtual.h\n@@ -16,6 +16,8 @@\n #include \"libcamera/internal/dma_buf_allocator.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n \n+#include \"test_pattern_generator.h\"\n+\n namespace libcamera {\n \n class VirtualCameraData : public Camera::Private\n@@ -29,6 +31,7 @@ public:\n \t};\n \tstruct StreamConfig {\n \t\tStream stream;\n+\t\tstd::unique_ptr<FrameGenerator> frameGenerator;\n \t};\n \n \tVirtualCameraData(PipelineHandler *pipe,\n@@ -36,6 +39,8 @@ public:\n \n \t~VirtualCameraData() = default;\n \n+\tTestPattern testPattern_ = TestPattern::ColorBars;\n+\n \tconst std::vector<Resolution> supportedResolutions_;\n \tSize maxResolutionSize_;\n \tSize minResolutionSize_;\n@@ -83,6 +88,8 @@ private:\n \t\treturn static_cast<VirtualCameraData *>(camera->_d());\n \t}\n \n+\tvoid initFrameGenerator(Camera *camera);\n+\n \tDmaBufAllocator dmaBufAllocator_;\n };\n \ndiff --git a/src/meson.build b/src/meson.build\nindex 165a77bb..91bea775 100644\n--- a/src/meson.build\n+++ b/src/meson.build\n@@ -27,6 +27,25 @@ else\n     ipa_sign_module = false\n endif\n \n+libyuv_dep = dependency('libyuv', required : false)\n+\n+# Fallback to a subproject if libyuv isn't found, as it's typically not\n+# provided by distributions.\n+if not libyuv_dep.found()\n+    cmake = import('cmake')\n+\n+    libyuv_vars = cmake.subproject_options()\n+    libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})\n+    libyuv_vars.set_override_option('cpp_std', 'c++17')\n+    libyuv_vars.append_compile_args('cpp',\n+         '-Wno-sign-compare',\n+         '-Wno-unused-variable',\n+         '-Wno-unused-parameter')\n+    libyuv_vars.append_link_args('-ljpeg')\n+    libyuv = cmake.subproject('libyuv', options : libyuv_vars)\n+    libyuv_dep = libyuv.dependency('yuv')\n+endif\n+\n # libcamera must be built first as a dependency to the other components.\n subdir('libcamera')\n \n",
    "prefixes": [
        "v11",
        "4/7"
    ]
}