[{"id":14725,"web_url":"https://patchwork.libcamera.org/comment/14725/","msgid":"<YAvv/ed+ueFrvLvb@pendragon.ideasonboard.com>","date":"2021-01-23T09:44:29","subject":"Re: [libcamera-devel] [PATCH v3 7/8] android: camera_device: Cache\n\trequest metadata","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Sat, Jan 23, 2021 at 02:17:03PM +0900, Paul Elder wrote:\n> The settings in an android capture request may be null, in which case\n> the settings from the most recently submitted capture request should be\n> used. Cache the request settings to achieve this.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - rebase on \"android: camera device and metatada improvements\", so it's\n>   a bit cleaner\n> \n> New in v2\n> ---\n>  src/android/camera_device.cpp | 9 ++++++---\n>  src/android/camera_device.h   | 2 ++\n>  2 files changed, 8 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index d0922db7..a2484fdd 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -343,7 +343,8 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()\n>  \n>  CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)\n>  \t: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),\n> -\t  facing_(CAMERA_FACING_FRONT), orientation_(0)\n> +\t  facing_(CAMERA_FACING_FRONT), orientation_(0),\n> +\t  lastSettings_(CameraMetadata(0, 0))\n\nCameraMetadata has a default constructor, wouldn't it be enough ? You\ncould then drop this hunk completely.\n\n>  {\n>  \tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n>  \n> @@ -1688,10 +1689,12 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n>  \t * The descriptor and the associated memory reserved here are freed\n>  \t * at request complete time.\n>  \t */\n> -\t/* \\todo Handle null request settings */\n> -\tCameraMetadata settings(camera3Request->settings);\n>  \tCamera3RequestDescriptor *descriptor =\n>  \t\tnew Camera3RequestDescriptor(camera_.get(), camera3Request);\n> +\tif (camera3Request->settings)\n> +\t\tlastSettings_ = camera3Request->settings;\n> +\telse\n> +\t\tdescriptor->settings_ = lastSettings_;\n\nWe will likely need something a bit more elaborate in the future. For\ninstance, if a request contains ANDROID_JPEG_THUMBNAIL_SIZE and the next\none doesn't, we should use the previous thumbnail size. The cache should\nthus be populated incrementaly. This is good enough for now, but maybe\nwe should record a \\todo ? It should mention checking whether\nincremental handling of the cache is required, maybe the Android camera\nservice does so already and guarantees either null or fully populated\nrequest settings.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n>  \tLOG(HAL, Debug) << \"Queueing Request to libcamera with \"\n>  \t\t\t<< descriptor->numBuffers_ << \" HAL streams\";\n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index 058a3f9a..fa4fb544 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -134,6 +134,8 @@ private:\n>  \tint orientation_;\n>  \n>  \tunsigned int maxJpegBufferSize_;\n> +\n> +\tCameraMetadata lastSettings_;\n>  };\n>  \n>  #endif /* __ANDROID_CAMERA_DEVICE_H__ */","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 44689BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 23 Jan 2021 09:44:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BACC968293;\n\tSat, 23 Jan 2021 10:44:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 469576827C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Jan 2021 10:44:49 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A043C3E;\n\tSat, 23 Jan 2021 10:44:48 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Cv4Fdyi5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611395088;\n\tbh=NGDo7yPBWmVT12LL6tTiikpBZGvYuG0s6pChC+9VnT4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Cv4Fdyi5QcVowjKKSnRSa671CxhMEJ3sgeIsZxQk6oiseJgjqgeXIVRYjFxJ7gvjc\n\t5ABGnRGSlszmLoLvwuIaGt8ZIidbjYsksId2nLUZB2duu8szUvyBwLz8ydxhlCrtOh\n\tgkOR51q/fp9p60gc0i0+ckgmzJbDZuOY/tws7jQU=","Date":"Sat, 23 Jan 2021 11:44:29 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YAvv/ed+ueFrvLvb@pendragon.ideasonboard.com>","References":"<20210123051704.188117-1-paul.elder@ideasonboard.com>\n\t<20210123051704.188117-8-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210123051704.188117-8-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] android: camera_device: Cache\n\trequest metadata","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":"libcamera-devel@lists.libcamera.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>"}}]