{"id":13405,"url":"https://patchwork.libcamera.org/api/patches/13405/?format=json","web_url":"https://patchwork.libcamera.org/patch/13405/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210819201214.1554322-2-hiroh@chromium.org>","date":"2021-08-19T20:12:12","name":"[libcamera-devel,v2,1/3] android: camera_stream: Create post porcessor in configure()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"98e3d47099b25c45309d73bc55922e23b58cfccf","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13405/mbox/","series":[{"id":2373,"url":"https://patchwork.libcamera.org/api/series/2373/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2373","date":"2021-08-19T20:12:11","name":"android: Request one stream for identica stream requests","version":2,"mbox":"https://patchwork.libcamera.org/series/2373/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13405/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13405/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 74F2CBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Aug 2021 20:12:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3AC5A688A2;\n\tThu, 19 Aug 2021 22:12:26 +0200 (CEST)","from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com\n\t[IPv6:2607:f8b0:4864:20::1036])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87A3A60264\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Aug 2021 22:12:24 +0200 (CEST)","by mail-pj1-x1036.google.com with SMTP id mq3so5739455pjb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Aug 2021 13:12:24 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:4298:71ae:6ebb:72eb])\n\tby smtp.gmail.com with ESMTPSA id\n\ti11sm4303695pfo.29.2021.08.19.13.12.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Aug 2021 13:12:22 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"hFG9ncmd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=ItosC7NO4CmmUbtu226bOx/Uf1SAKXEzgsrPVIUAUxs=;\n\tb=hFG9ncmdTXDyUHNf+8uKQWATg89M+A34HmLNSWe3QX6QZySr5brSQAgKq1hGv5DzVZ\n\t59icgcSFAAhxuQsmFEkdPr2guZH8QClUXzPyES69G/sjWQpp4EZET5Ym+FMmrK19Acsw\n\t3GOaHji2PQTMrTuYuG9mHGQ19ptpRkjwfpZkw=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=ItosC7NO4CmmUbtu226bOx/Uf1SAKXEzgsrPVIUAUxs=;\n\tb=GlIiv6lXCbeOuXdVFRd0ZhKl24wKUrEbRDP0wT0y+IbutOh4cvtVV3tchD8zDSyXIh\n\tOMJ6Z381poRp4qvlqs3su9Ej3OqM7OfAEhe+gJL8eJPKIQffOFlqM1FQkZA55KX822mX\n\t5+3OMTQuXw4BskAM5VGGJbpAL48pE8iLxkOJ3ZTpCgk3EscGnr7YV3TMTYlgZ8K4dh5R\n\tE8nfQz1UA+rZOefgEDg/P/4jt/R0RE0+VdflJd1sSpG+iIj1nOXG9uf+SiRdzO3XOV53\n\tWJ5juQjAIBsFjqxxtEPi1g3FMM6sofXqKZxF86iBv1ojkwgKMQ7cpQMa348a3XzUykVf\n\t1iJw==","X-Gm-Message-State":"AOAM532kdWbo/9VxmtcAricqdutAUaUKG51FyAxMi+q/f4U4TJq3B4f6\n\txrt2w8OLwIDhGkt3u21swEh3/vnF7KLXTw==","X-Google-Smtp-Source":"ABdhPJx7xWqCNIhY4v1zbo0AyKxS+Y5hnxs8o/8EUdUQ6xCN30Y2KKYOBwRwbleDf3yvdaFb/MwZjg==","X-Received":"by 2002:a17:90b:4b12:: with SMTP id\n\tlx18mr512054pjb.121.1629403942755; \n\tThu, 19 Aug 2021 13:12:22 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 20 Aug 2021 05:12:12 +0900","Message-Id":"<20210819201214.1554322-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.33.0.rc2.250.ged5fa647cd-goog","In-Reply-To":"<20210819201214.1554322-1-hiroh@chromium.org>","References":"<20210819201214.1554322-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/3] android: camera_stream: Create\n\tpost porcessor in configure()","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":"CameraStream creates PostProcessor and FrameBufferAllocator in\nthe constructor. CameraStream assumes that a used post processor\nis JPEG post processor. Since we need to support various post\nprocessors, we would rather move the creation to configure() so\nas to return an error code if no proper post processor is found.\nThis also moves FrameBufferAllocator and Mutex creation for\nconsistency.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.h   |  1 +\n src/android/camera_stream.cpp | 36 ++++++++++++++++++-----------------\n 2 files changed, 20 insertions(+), 17 deletions(-)","diff":"diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex dd9aebba..abe8ca44 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -46,6 +46,7 @@ public:\n \n \tunsigned int id() const { return id_; }\n \tcamera3_device_t *camera3Device() { return &camera3Device_; }\n+\tconst CameraCapabilities *capabilities() const { return &capabilities_; }\n \tconst std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }\n \n \tconst std::string &maker() const { return maker_; }\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 61b44183..c205cd7a 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -10,6 +10,7 @@\n #include <sys/mman.h>\n \n #include \"camera_buffer.h\"\n+#include \"camera_capabilities.h\"\n #include \"camera_device.h\"\n #include \"camera_metadata.h\"\n #include \"jpeg/post_processor_jpeg.h\"\n@@ -47,20 +48,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice,\n \t: cameraDevice_(cameraDevice), config_(config), type_(type),\n \t  camera3Stream_(camera3Stream), index_(index)\n {\n-\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n-\t\t/*\n-\t\t * \\todo There might be multiple post-processors. The logic\n-\t\t * which should be instantiated here, is deferred for the\n-\t\t * future. For now, we only have PostProcessorJpeg and that\n-\t\t * is what we instantiate here.\n-\t\t */\n-\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n-\t}\n-\n-\tif (type == Type::Internal) {\n-\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n-\t\tmutex_ = std::make_unique<std::mutex>();\n-\t}\n }\n \n const StreamConfiguration &CameraStream::configuration() const\n@@ -75,15 +62,30 @@ Stream *CameraStream::stream() const\n \n int CameraStream::configure()\n {\n-\tif (postProcessor_) {\n+\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n+\t\tconst PixelFormat outFormat =\n+\t\t\tcameraDevice_->capabilities()->toPixelFormat(camera3Stream_->format);\n \t\tStreamConfiguration output = configuration();\n-\t\toutput.pixelFormat = formats::MJPEG;\n+\t\toutput.pixelFormat = outFormat;\n+\t\tswitch (outFormat) {\n+\t\tcase formats::MJPEG:\n+\t\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Unsupported format: \" << outFormat;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n \t\tint ret = postProcessor_->configure(configuration(), output);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\tif (allocator_) {\n+\tif (type_ == Type::Internal) {\n+\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n+\t\tmutex_ = std::make_unique<std::mutex>();\n+\n \t\tint ret = allocator_->allocate(stream());\n \t\tif (ret < 0)\n \t\t\treturn ret;\n","prefixes":["libcamera-devel","v2","1/3"]}