[PATCH v2 3/8] ipa: libipa: Add ExposureModeHelper

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Apr 24 20:57:59 CEST 2024


On Wed, Apr 24, 2024 at 06:59:24PM +0200, Jacopo Mondi wrote:
> On Tue, Apr 23, 2024 at 03:01:34PM +0000, Barnabás Pőcze wrote:
> > 2024. április 23., kedd 16:41 keltezéssel, Dan Scally írta:
> >
> > > [...]
> > > >> [...]
> > > >> +/**
> > > >> + * \brief Initialize an ExposureModeHelper instance
> > > >> + * \param[in] stages The vector of paired shutter time and gain limits
> > > >> + *
> > > >> + * This function is expected to be called a single time once the algorithm that
> > > >> + * is using these helpers has built the necessary list of shutter and gain pairs
> > > >> + * to use (archetypically by parsing them from a tuning file during the
> > > >> + * algorithm's .init() call).
> > > >> + *
> > > >> + * The input steps are shutter and _total_ gain pairs; the gain encompasses both
> > > >> + * analogue and digital gain.
> > > >> + *
> > > >> + * The vector of stages may be empty. In that case, the helper will simply use
> > > >> + * the runtime limits set through setShutterGainLimits() instead.
> > > >> + */
> > > >> +void ExposureModeHelper::init(const std::vector<std::pair<utils::Duration, double>> stages)
> > > > Any reason for not using span here?
> > >
> > >
> > > The shutter time and gain vectors are initially separate, and need combining like so:
> > >
> > >
> > >  std::vector<std::pair<utils::Duration, double>> stages;
> > >  for (unsigned int i = 0; i < shutters.size(); i++) {
> > >    stages.push_back({
> > >      std::chrono::microseconds(shutters[i]),
> > >      gains[i]
> > >    });
> > >  }
> > >
> > >  std::shared_ptr<ExposureModeHelper> helper =
> > >    std::make_shared<ExposureModeHelper>();
> > >  helper->init(stages);
> > >
> > > So given I have to build a new vector with the paired stages anyway I couldn't
> > > see value in then using a Span for the init() instead of just passing the vector...but quite
> > > possibly I am just not understanding why it's the better choice here.
> >
> > Note that in the code above, there is a copy when calling init(), using a span avoids that.
> 
> Or just by passing the vector by reference and not value.
> The pairs' items will be copied inside the helper anyway.

If we foresee that the caller won't need to retain access to the vector,
passing an rvalue reference would be more efficient and avoid a copy.

> > > [...]

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list