[{"id":17909,"web_url":"https://patchwork.libcamera.org/comment/17909/","msgid":"<28a16e7e-7646-ec00-f7e9-44f56f134ad5@ideasonboard.com>","date":"2021-06-29T10:48:26","subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: raspberrypi: Use a\n\tunique_ptr for the metadata parser","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nOn 29/06/2021 11:44, Naushir Patuck wrote:\n> The derived CamHelper class now allocates a metadata parser object through a\n> unique_ptr that is passed to the base class constructor. This automates the\n> lifetime management of the parser object.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nLooks OK here.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp        | 5 ++---\n>  src/ipa/raspberrypi/cam_helper.hpp        | 5 +++--\n>  src/ipa/raspberrypi/cam_helper_imx219.cpp | 4 ++--\n>  src/ipa/raspberrypi/cam_helper_imx290.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_imx477.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_ov5647.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_ov9281.cpp | 2 +-\n>  7 files changed, 11 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\n> index 062e94c4fef3..90498c37af98 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -40,15 +40,14 @@ CamHelper *CamHelper::Create(std::string const &cam_name)\n>  \treturn nullptr;\n>  }\n>  \n> -CamHelper::CamHelper(MdParser *parser, unsigned int frameIntegrationDiff)\n> -\t: parser_(parser), initialized_(false),\n> +CamHelper::CamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff)\n> +\t: parser_(std::move(parser)), initialized_(false),\n>  \t  frameIntegrationDiff_(frameIntegrationDiff)\n>  {\n>  }\n>  \n>  CamHelper::~CamHelper()\n>  {\n> -\tdelete parser_;\n>  }\n>  \n>  void CamHelper::Prepare(Span<const uint8_t> buffer,\n> diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp\n> index b19c95f67453..fc3139e22be0 100644\n> --- a/src/ipa/raspberrypi/cam_helper.hpp\n> +++ b/src/ipa/raspberrypi/cam_helper.hpp\n> @@ -6,6 +6,7 @@\n>   */\n>  #pragma once\n>  \n> +#include <memory>\n>  #include <string>\n>  \n>  #include <libcamera/base/span.h>\n> @@ -67,7 +68,7 @@ class CamHelper\n>  {\n>  public:\n>  \tstatic CamHelper *Create(std::string const &cam_name);\n> -\tCamHelper(MdParser *parser, unsigned int frameIntegrationDiff);\n> +\tCamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff);\n>  \tvirtual ~CamHelper();\n>  \tvoid SetCameraMode(const CameraMode &mode);\n>  \tvirtual void Prepare(libcamera::Span<const uint8_t> buffer,\n> @@ -92,7 +93,7 @@ protected:\n>  \tvoid parseEmbeddedData(libcamera::Span<const uint8_t> buffer,\n>  \t\t\t       Metadata &metadata);\n>  \n> -\tMdParser *parser_;\n> +\tstd::unique_ptr<MdParser> parser_;\n>  \tCameraMode mode_;\n>  \n>  private:\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> index ec218dce5456..c85044a5fa6d 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> @@ -58,9 +58,9 @@ private:\n>  \n>  CamHelperImx219::CamHelperImx219()\n>  #if ENABLE_EMBEDDED_DATA\n> -\t: CamHelper(new MdParserImx219(), frameIntegrationDiff)\n> +\t: CamHelper(std::make_unique<MdParserImx219>(), frameIntegrationDiff)\n>  #else\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  #endif\n>  {\n>  }\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> index 6f412e403f16..871c1f8eaec4 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> @@ -30,7 +30,7 @@ private:\n>  };\n>  \n>  CamHelperImx290::CamHelperImx290()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> index 25b36bce0dac..d72a9be0438e 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> @@ -50,7 +50,7 @@ private:\n>  };\n>  \n>  CamHelperImx477::CamHelperImx477()\n> -\t: CamHelper(new MdParserImx477(), frameIntegrationDiff)\n> +\t: CamHelper(std::make_unique<MdParserImx477>(), frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> index 12be6bf931a8..702c2d07f73a 100644\n> --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> @@ -38,7 +38,7 @@ private:\n>   */\n>  \n>  CamHelperOv5647::CamHelperOv5647()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> index 54091f835565..9de868c31dc0 100644\n> --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> @@ -34,7 +34,7 @@ private:\n>   */\n>  \n>  CamHelperOv9281::CamHelperOv9281()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>  \n>","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 09E40C321F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Jun 2021 10:48:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 798EC684EA;\n\tTue, 29 Jun 2021 12:48:30 +0200 (CEST)","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 4A489684CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jun 2021 12:48:29 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9920B8A;\n\tTue, 29 Jun 2021 12:48:28 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XwbSt3xz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624963709;\n\tbh=g2JgaezBHxSQ5t2pE8cNG+BTiWKJTgkUHN0cGkotGsc=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=XwbSt3xzkBRQ7nsT8uG4pdcY7T/VyIoLTiXsOxoCHMG+GlMMG6Avw+RsaBa5rIKpk\n\tUhvwSU1VuoE1J3zQUfPDFEGx/t2+7gbqLalcgDSOZrvF35T6ETnE3BAwWxfrrHJC0Z\n\tR9o/APXSfgKd84fh5lymwYecUAt8yUTuylRq0Rq0=","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210629104500.51672-1-naush@raspberrypi.com>\n\t<20210629104500.51672-2-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<28a16e7e-7646-ec00-f7e9-44f56f134ad5@ideasonboard.com>","Date":"Tue, 29 Jun 2021 11:48:26 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210629104500.51672-2-naush@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: raspberrypi: Use a\n\tunique_ptr for the metadata parser","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>"}},{"id":17917,"web_url":"https://patchwork.libcamera.org/comment/17917/","msgid":"<YNstxvmkCYwsL7rd@pendragon.ideasonboard.com>","date":"2021-06-29T14:27:18","subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: raspberrypi: Use a\n\tunique_ptr for the metadata parser","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Tue, Jun 29, 2021 at 11:44:59AM +0100, Naushir Patuck wrote:\n> The derived CamHelper class now allocates a metadata parser object through a\n> unique_ptr that is passed to the base class constructor. This automates the\n> lifetime management of the parser object.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp        | 5 ++---\n>  src/ipa/raspberrypi/cam_helper.hpp        | 5 +++--\n>  src/ipa/raspberrypi/cam_helper_imx219.cpp | 4 ++--\n>  src/ipa/raspberrypi/cam_helper_imx290.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_imx477.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_ov5647.cpp | 2 +-\n>  src/ipa/raspberrypi/cam_helper_ov9281.cpp | 2 +-\n>  7 files changed, 11 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\n> index 062e94c4fef3..90498c37af98 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -40,15 +40,14 @@ CamHelper *CamHelper::Create(std::string const &cam_name)\n>  \treturn nullptr;\n>  }\n>  \n> -CamHelper::CamHelper(MdParser *parser, unsigned int frameIntegrationDiff)\n> -\t: parser_(parser), initialized_(false),\n> +CamHelper::CamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff)\n> +\t: parser_(std::move(parser)), initialized_(false),\n>  \t  frameIntegrationDiff_(frameIntegrationDiff)\n>  {\n>  }\n>  \n>  CamHelper::~CamHelper()\n>  {\n> -\tdelete parser_;\n>  }\n>  \n>  void CamHelper::Prepare(Span<const uint8_t> buffer,\n> diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp\n> index b19c95f67453..fc3139e22be0 100644\n> --- a/src/ipa/raspberrypi/cam_helper.hpp\n> +++ b/src/ipa/raspberrypi/cam_helper.hpp\n> @@ -6,6 +6,7 @@\n>   */\n>  #pragma once\n>  \n> +#include <memory>\n>  #include <string>\n>  \n>  #include <libcamera/base/span.h>\n> @@ -67,7 +68,7 @@ class CamHelper\n>  {\n>  public:\n>  \tstatic CamHelper *Create(std::string const &cam_name);\n> -\tCamHelper(MdParser *parser, unsigned int frameIntegrationDiff);\n> +\tCamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff);\n>  \tvirtual ~CamHelper();\n>  \tvoid SetCameraMode(const CameraMode &mode);\n>  \tvirtual void Prepare(libcamera::Span<const uint8_t> buffer,\n> @@ -92,7 +93,7 @@ protected:\n>  \tvoid parseEmbeddedData(libcamera::Span<const uint8_t> buffer,\n>  \t\t\t       Metadata &metadata);\n>  \n> -\tMdParser *parser_;\n> +\tstd::unique_ptr<MdParser> parser_;\n>  \tCameraMode mode_;\n>  \n>  private:\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> index ec218dce5456..c85044a5fa6d 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp\n> @@ -58,9 +58,9 @@ private:\n>  \n>  CamHelperImx219::CamHelperImx219()\n>  #if ENABLE_EMBEDDED_DATA\n> -\t: CamHelper(new MdParserImx219(), frameIntegrationDiff)\n> +\t: CamHelper(std::make_unique<MdParserImx219>(), frameIntegrationDiff)\n>  #else\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  #endif\n>  {\n>  }\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> index 6f412e403f16..871c1f8eaec4 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> @@ -30,7 +30,7 @@ private:\n>  };\n>  \n>  CamHelperImx290::CamHelperImx290()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> index 25b36bce0dac..d72a9be0438e 100644\n> --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp\n> @@ -50,7 +50,7 @@ private:\n>  };\n>  \n>  CamHelperImx477::CamHelperImx477()\n> -\t: CamHelper(new MdParserImx477(), frameIntegrationDiff)\n> +\t: CamHelper(std::make_unique<MdParserImx477>(), frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> index 12be6bf931a8..702c2d07f73a 100644\n> --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n> @@ -38,7 +38,7 @@ private:\n>   */\n>  \n>  CamHelperOv5647::CamHelperOv5647()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>  \n> diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> index 54091f835565..9de868c31dc0 100644\n> --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> @@ -34,7 +34,7 @@ private:\n>   */\n>  \n>  CamHelperOv9281::CamHelperOv9281()\n> -\t: CamHelper(nullptr, frameIntegrationDiff)\n> +\t: CamHelper({}, frameIntegrationDiff)\n>  {\n>  }\n>","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 4E9E1C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Jun 2021 14:27:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 901C2684E9;\n\tTue, 29 Jun 2021 16:27:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A93E684CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jun 2021 16:27:23 +0200 (CEST)","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 497C34AD;\n\tTue, 29 Jun 2021 16:27:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PPex0fja\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624976842;\n\tbh=EMkjRt/+u9Wq+EEGnEBOPz8IUvjSrSeRiws7l4JuNt4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PPex0fja/IlQ9Tyow64s7TQWxvNZYcx1iv+SGMCwPhchbsuotB293D3d9ulyg08cQ\n\tvb0j7kmof6gaTCsCEKXo6KsXJHAvWrVJLJVB6Y91TBirP8apOV0Fjr32L55onorSVM\n\tqQ1uyWrqpn9NTyZN4BGeYsZ7X078jIYtNWzSTyv8=","Date":"Tue, 29 Jun 2021 17:27:18 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YNstxvmkCYwsL7rd@pendragon.ideasonboard.com>","References":"<20210629104500.51672-1-naush@raspberrypi.com>\n\t<20210629104500.51672-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210629104500.51672-2-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] ipa: raspberrypi: Use a\n\tunique_ptr for the metadata parser","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]