{"id":11141,"url":"https://patchwork.libcamera.org/api/patches/11141/?format=json","web_url":"https://patchwork.libcamera.org/patch/11141/","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":"<20210204100541.657503-4-hiroh@chromium.org>","date":"2021-02-04T10:05:38","name":"[libcamera-devel,RFC,3/6] android: camera_stream: Pass post processor in configure()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e2f7492e61312044cf572ce859a83d133326b59a","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/11141/mbox/","series":[{"id":1650,"url":"https://patchwork.libcamera.org/api/series/1650/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1650","date":"2021-02-04T10:05:35","name":"Support stream mapping in Android HAL adaptation layer","version":1,"mbox":"https://patchwork.libcamera.org/series/1650/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11141/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11141/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 077AEBD162\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 10:05:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CC23F61433;\n\tThu,  4 Feb 2021 11:05:56 +0100 (CET)","from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com\n\t[IPv6:2607:f8b0:4864:20::52c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2788761402\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 11:05:55 +0100 (CET)","by mail-pg1-x52c.google.com with SMTP id z21so1756362pgj.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 04 Feb 2021 02:05:55 -0800 (PST)","from hiroh.c.googlers.com.com\n\t(128.141.236.35.bc.googleusercontent.com. [35.236.141.128])\n\tby smtp.gmail.com with ESMTPSA id\n\tj9sm5808418pgb.47.2021.02.04.02.05.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 04 Feb 2021 02:05:52 -0800 (PST)"],"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=\"YN5y9JVg\"; 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=7yERyDLtas5GQ4jIrAxedsZX+9qroAgVoDq37BZqW9A=;\n\tb=YN5y9JVgKRLIK+mCIKs4cLBRnsYzwCl0pY+lWoAdcRvjaHUz7oo8Mh32bNeTDWu1dZ\n\tHoY0VxwFwZj4o03su1Sj5jt/tz3IyiAJNjwstFpcLPAe1cLxBUMowz7ifWwtEkufsuOp\n\tdpDlXGYEV6JnxE93SLyIXuiX6ZLmIHIcnnS+8=","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=7yERyDLtas5GQ4jIrAxedsZX+9qroAgVoDq37BZqW9A=;\n\tb=Wyb1bw+d5uPGSkM4who3rvePSJK5+j+WWe04cy8cifQB95GG0z/LK17BdEgcFkO/+H\n\tAksQlfO+eM2Wzlbr0epiFJ06R9iCiIQeB4yBJ2tWJ4H2GV378icKIXLYpzWpwRt10WKz\n\t9yaflkm/FsOJwoHznHOYGWmXNN4tgVRQ43BB/s6sVwX8p+EEQ+V6hyJndYlLI0bDtMR+\n\tD5JHyjORE5wYf4HCM30OZmlIO9ALat/mSnbIWiHkauY+IThMGbA7h4Jps4ikVSYlQtDy\n\tIioO0iN0HZsyTOX9bbpZ4K+KYRE11+FMwOeNakv3p94O5+Uasg82j5DSXR+c5GDTcRfE\n\t3B5g==","X-Gm-Message-State":"AOAM531O6StcGdbPwFcGfqLUGzSlko4Dn0o6jT9UMrNxkEYiyAcy4cHC\n\tcco/FJ7ixwISsMgYecyDg13EWfOOeb5VPkia","X-Google-Smtp-Source":"ABdhPJxdRs4jbnDDIKlEXJ2lL3HhxyoJWHCL5ELPWnA7PKmO4dSvMwcS5f1sA1PABkEWe1d2R+9//A==","X-Received":"by 2002:a63:d5e:: with SMTP id 30mr7428446pgn.178.1612433153227; \n\tThu, 04 Feb 2021 02:05:53 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  4 Feb 2021 10:05:38 +0000","Message-Id":"<20210204100541.657503-4-hiroh@chromium.org>","X-Mailer":"git-send-email 2.30.0.365.g02bc693789-goog","In-Reply-To":"<20210204100541.657503-1-hiroh@chromium.org>","References":"<20210204100541.657503-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH 3/6] android: camera_stream: Pass post\n\tprocessor 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>","Cc":"hanlinchen@chromium.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"CameraStream creates PostProcessor in its constructor and\nconfigures the PostProcessor() in its configure(). The\nexisting code hard-codes them for PostProcessorJpeg. It is\ndifficult to generalize the code for other PostProcessor.\nA client of CameraStream should know what post processor\nis needed and how to configure it. Therefore, this changes\nCameraStream::configure() interface to take a post processor.\nA client of CameraStream creates and configures a post\nprocessor before calling configure().\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 21 ++++++++++++++++++++-\n src/android/camera_stream.cpp | 31 ++++++++-----------------------\n src/android/camera_stream.h   |  2 +-\n 3 files changed, 29 insertions(+), 25 deletions(-)\n\n--\n2.30.0.365.g02bc693789-goog","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex a50b0ebf..752e17ba 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -8,6 +8,7 @@\n #include \"camera_device.h\"\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n+#include \"jpeg/post_processor_jpeg.h\"\n\n #include <fstream>\n #include <sys/mman.h>\n@@ -1613,7 +1614,25 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t * the Android camera3_stream_t.\n \t */\n \tfor (CameraStream &cameraStream : streams_) {\n-\t\tret = cameraStream.configure();\n+\t\tstd::unique_ptr<PostProcessor> postProcessor;\n+\n+\t\tif (cameraStream.type() == CameraStream::Type::Internal ||\n+\t\t    cameraStream.type() == CameraStream::Type::Mapped) {\n+\t\t\tpostProcessor =\n+\t\t\t\tstd::make_unique<PostProcessorJpeg>(this);\n+\n+\t\t\tauto output = cameraStream.configuration();\n+\t\t\toutput.pixelFormat = formats::MJPEG;\n+\t\t\tpostProcessor->configure(cameraStream.configuration(),\n+\t\t\t\t\t\t output);\n+\t\t\tif (ret) {\n+\t\t\t\tLOG(HAL, Error) << \"Failed to configure \"\n+\t\t\t\t\t\t<< \"PostProcessorJpeg\";\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\n+\t\tret = cameraStream.configure(std::move(postProcessor));\n \t\tif (ret) {\n \t\t\tLOG(HAL, Error) << \"Failed to configure camera stream\";\n \t\t\treturn ret;\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 611ec0d1..ed6c5265 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -9,7 +9,7 @@\n\n #include \"camera_device.h\"\n #include \"camera_metadata.h\"\n-#include \"jpeg/post_processor_jpeg.h\"\n+#include \"post_processor.h\"\n\n #include <libcamera/formats.h>\n\n@@ -38,22 +38,13 @@ LOG_DECLARE_CATEGORY(HAL)\n  * and buffer allocation.\n  */\n\n-CameraStream::CameraStream(CameraDevice *const cameraDevice, Type type,\n-\t\t\t   camera3_stream_t *camera3Stream, unsigned int index)\n+CameraStream::CameraStream(CameraDevice *const cameraDevice,\n+\t\t\t   Type type, camera3_stream_t *camera3Stream,\n+\t\t\t   unsigned int index)\n \t: cameraDevice_(cameraDevice),\n-\t  config_(cameraDevice->cameraConfiguration()), type_(type),\n-\t  camera3Stream_(camera3Stream), index_(index)\n+\t  config_(cameraDevice->cameraConfiguration()),\n+ \t  type_(type), 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@@ -70,15 +61,9 @@ Stream *CameraStream::stream() const\n \treturn configuration().stream();\n }\n\n-int CameraStream::configure()\n+int CameraStream::configure(std::unique_ptr<PostProcessor> postProcessor)\n {\n-\tif (postProcessor_) {\n-\t\tStreamConfiguration output = configuration();\n-\t\toutput.pixelFormat = formats::MJPEG;\n-\t\tint ret = postProcessor_->configure(configuration(), output);\n-\t\tif (ret)\n-\t\t\treturn ret;\n-\t}\n+\tpostProcessor_ = std::move(postProcessor);\n\n \tif (allocator_) {\n \t\tint ret = allocator_->allocate(stream());\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex fc242b2a..faafc934 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -118,7 +118,7 @@ public:\n \tconst libcamera::StreamConfiguration &configuration() const;\n \tlibcamera::Stream *stream() const;\n\n-\tint configure();\n+\tint configure(std::unique_ptr<PostProcessor> postProcessor);\n \tint process(const libcamera::FrameBuffer &source,\n \t\t    libcamera::MappedBuffer *destination,\n \t\t    const CameraMetadata &requestMetadata,\n","prefixes":["libcamera-devel","RFC","3/6"]}