ipa: raspberrypi: Use a unique_ptr for the metadata parser
The derived CamHelper class now allocates a metadata parser object through a unique_ptr that is passed to the base class constructor. This automates the lifetime management of the parser object. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
committed by
Laurent Pinchart
parent
9d44551404
commit
d3ea8e7885
@@ -40,15 +40,14 @@ CamHelper *CamHelper::Create(std::string const &cam_name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CamHelper::CamHelper(MdParser *parser, unsigned int frameIntegrationDiff)
|
||||
: parser_(parser), initialized_(false),
|
||||
CamHelper::CamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff)
|
||||
: parser_(std::move(parser)), initialized_(false),
|
||||
frameIntegrationDiff_(frameIntegrationDiff)
|
||||
{
|
||||
}
|
||||
|
||||
CamHelper::~CamHelper()
|
||||
{
|
||||
delete parser_;
|
||||
}
|
||||
|
||||
void CamHelper::Prepare(Span<const uint8_t> buffer,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/base/span.h>
|
||||
@@ -67,7 +68,7 @@ class CamHelper
|
||||
{
|
||||
public:
|
||||
static CamHelper *Create(std::string const &cam_name);
|
||||
CamHelper(MdParser *parser, unsigned int frameIntegrationDiff);
|
||||
CamHelper(std::unique_ptr<MdParser> parser, unsigned int frameIntegrationDiff);
|
||||
virtual ~CamHelper();
|
||||
void SetCameraMode(const CameraMode &mode);
|
||||
virtual void Prepare(libcamera::Span<const uint8_t> buffer,
|
||||
@@ -92,7 +93,7 @@ protected:
|
||||
void parseEmbeddedData(libcamera::Span<const uint8_t> buffer,
|
||||
Metadata &metadata);
|
||||
|
||||
MdParser *parser_;
|
||||
std::unique_ptr<MdParser> parser_;
|
||||
CameraMode mode_;
|
||||
|
||||
private:
|
||||
|
||||
@@ -58,9 +58,9 @@ private:
|
||||
|
||||
CamHelperImx219::CamHelperImx219()
|
||||
#if ENABLE_EMBEDDED_DATA
|
||||
: CamHelper(new MdParserImx219(), frameIntegrationDiff)
|
||||
: CamHelper(std::make_unique<MdParserImx219>(), frameIntegrationDiff)
|
||||
#else
|
||||
: CamHelper(nullptr, frameIntegrationDiff)
|
||||
: CamHelper({}, frameIntegrationDiff)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
};
|
||||
|
||||
CamHelperImx290::CamHelperImx290()
|
||||
: CamHelper(nullptr, frameIntegrationDiff)
|
||||
: CamHelper({}, frameIntegrationDiff)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
};
|
||||
|
||||
CamHelperImx477::CamHelperImx477()
|
||||
: CamHelper(new MdParserImx477(), frameIntegrationDiff)
|
||||
: CamHelper(std::make_unique<MdParserImx477>(), frameIntegrationDiff)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
*/
|
||||
|
||||
CamHelperOv5647::CamHelperOv5647()
|
||||
: CamHelper(nullptr, frameIntegrationDiff)
|
||||
: CamHelper({}, frameIntegrationDiff)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
*/
|
||||
|
||||
CamHelperOv9281::CamHelperOv9281()
|
||||
: CamHelper(nullptr, frameIntegrationDiff)
|
||||
: CamHelper({}, frameIntegrationDiff)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user