[libcamera-devel] [PATCH v4 18/32] ipa: rkisp1: Use frame number passed to Algorithm::prepare()

Jacopo Mondi jacopo at jmondi.org
Wed Sep 21 20:42:08 CEST 2022


On Tue, Sep 20, 2022 at 03:51:45PM +0100, Kieran Bingham via libcamera-devel wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-09-08 02:41:46)
> > Now that the Algorithm::prepare() function takes a frame number, we can
> > use it to replace the IPAActiveState::frameCount member.
> >
>
> I'm very happy to see this cleaned up.

Likewise :)

Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>

Thanks
  j

>
>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> >  src/ipa/rkisp1/algorithms/agc.cpp  | 5 ++---
> >  src/ipa/rkisp1/algorithms/awb.cpp  | 5 ++---
> >  src/ipa/rkisp1/algorithms/blc.cpp  | 6 +++---
> >  src/ipa/rkisp1/algorithms/dpcc.cpp | 6 +++---
> >  src/ipa/rkisp1/algorithms/dpf.cpp  | 4 ++--
> >  src/ipa/rkisp1/algorithms/gsl.cpp  | 6 +++---
> >  src/ipa/rkisp1/algorithms/lsc.cpp  | 5 ++---
> >  src/ipa/rkisp1/ipa_context.cpp     | 9 ---------
> >  src/ipa/rkisp1/ipa_context.h       | 2 --
> >  src/ipa/rkisp1/rkisp1.cpp          | 3 ---
> >  10 files changed, 17 insertions(+), 34 deletions(-)
> >
> > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> > index e9fab0222ac3..4124c3272bc7 100644
> > --- a/src/ipa/rkisp1/algorithms/agc.cpp
> > +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> > @@ -326,12 +326,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void Agc::prepare(IPAContext &context,
> > -                 [[maybe_unused]] const uint32_t frame,
> > +void Agc::prepare(IPAContext &context, const uint32_t frame,
> >                   [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                   rkisp1_params_cfg *params)
> >  {
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         /* Configure the measurement window. */
> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> > index d3e9aa5334cf..a0bbe5cb8afa 100644
> > --- a/src/ipa/rkisp1/algorithms/awb.cpp
> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> > @@ -74,8 +74,7 @@ uint32_t Awb::estimateCCT(double red, double green, double blue)
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void Awb::prepare(IPAContext &context,
> > -                 [[maybe_unused]] const uint32_t frame,
> > +void Awb::prepare(IPAContext &context, const uint32_t frame,
> >                   [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                   rkisp1_params_cfg *params)
> >  {
> > @@ -88,7 +87,7 @@ void Awb::prepare(IPAContext &context,
> >         params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;
> >
> >         /* If we already have configured the gains and window, return. */
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         /* Configure the gains to apply. */
> > diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp
> > index c4aea0e828ca..500ce94294a2 100644
> > --- a/src/ipa/rkisp1/algorithms/blc.cpp
> > +++ b/src/ipa/rkisp1/algorithms/blc.cpp
> > @@ -65,12 +65,12 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void BlackLevelCorrection::prepare(IPAContext &context,
> > -                                  [[maybe_unused]] const uint32_t frame,
> > +void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
> > +                                  const uint32_t frame,
> >                                    [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                                    rkisp1_params_cfg *params)
> >  {
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         if (!tuningParameters_)
> > diff --git a/src/ipa/rkisp1/algorithms/dpcc.cpp b/src/ipa/rkisp1/algorithms/dpcc.cpp
> > index b61eee022a68..f59d48180eb5 100644
> > --- a/src/ipa/rkisp1/algorithms/dpcc.cpp
> > +++ b/src/ipa/rkisp1/algorithms/dpcc.cpp
> > @@ -258,12 +258,12 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void DefectPixelClusterCorrection::prepare(IPAContext &context,
> > -                                          [[maybe_unused]] const uint32_t frame,
> > +void DefectPixelClusterCorrection::prepare([[maybe_unused]] IPAContext &context,
> > +                                          const uint32_t frame,
> >                                            [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                                            rkisp1_params_cfg *params)
> >  {
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         if (!initialized_)
> > diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp
> > index 8eafbbf85124..94c35c36570c 100644
> > --- a/src/ipa/rkisp1/algorithms/dpf.cpp
> > +++ b/src/ipa/rkisp1/algorithms/dpf.cpp
> > @@ -207,7 +207,7 @@ void Dpf::queueRequest(IPAContext &context,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void Dpf::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
> > +void Dpf::prepare(IPAContext &context, const uint32_t frame,
> >                   [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                   rkisp1_params_cfg *params)
> >  {
> > @@ -216,7 +216,7 @@ void Dpf::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
> >
> >         auto &dpf = context.activeState.dpf;
> >
> > -       if (context.activeState.frameCount == 0) {
> > +       if (frame == 0) {
> >                 params->others.dpf_config = config_;
> >                 params->others.dpf_strength_config = strengthConfig_;
> >
> > diff --git a/src/ipa/rkisp1/algorithms/gsl.cpp b/src/ipa/rkisp1/algorithms/gsl.cpp
> > index ed3104c98e48..44303594bd47 100644
> > --- a/src/ipa/rkisp1/algorithms/gsl.cpp
> > +++ b/src/ipa/rkisp1/algorithms/gsl.cpp
> > @@ -118,12 +118,12 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void GammaSensorLinearization::prepare(IPAContext &context,
> > -                                      [[maybe_unused]] const uint32_t frame,
> > +void GammaSensorLinearization::prepare([[maybe_unused]] IPAContext &context,
> > +                                      const uint32_t frame,
> >                                        [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                                        rkisp1_params_cfg *params)
> >  {
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         if (!initialized_)
> > diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
> > index ed5b988599b8..20111c342bb3 100644
> > --- a/src/ipa/rkisp1/algorithms/lsc.cpp
> > +++ b/src/ipa/rkisp1/algorithms/lsc.cpp
> > @@ -132,12 +132,11 @@ int LensShadingCorrection::configure(IPAContext &context,
> >  /**
> >   * \copydoc libcamera::ipa::Algorithm::prepare
> >   */
> > -void LensShadingCorrection::prepare(IPAContext &context,
> > -                                   [[maybe_unused]] const uint32_t frame,
> > +void LensShadingCorrection::prepare(IPAContext &context, const uint32_t frame,
> >                                     [[maybe_unused]] RkISP1FrameContext &frameContext,
> >                                     rkisp1_params_cfg *params)
> >  {
> > -       if (context.activeState.frameCount > 0)
> > +       if (frame > 0)
> >                 return;
> >
> >         if (!initialized_)
> > diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp
> > index 80fae271a6dc..211428717838 100644
> > --- a/src/ipa/rkisp1/ipa_context.cpp
> > +++ b/src/ipa/rkisp1/ipa_context.cpp
> > @@ -192,15 +192,6 @@ namespace libcamera::ipa::rkisp1 {
> >   * \brief Analogue gain multiplier
> >   */
> >
> > -/**
> > - * \var IPAActiveState::frameCount
> > - * \brief Counter of requests queued to the IPA module
> > - *
> > - * The counter is reset to 0 when the IPA module is configured, and is
> > - * incremented for each request being queued, after calling the
> > - * Algorithm::prepare() function of all algorithms.
> > - */
> > -
> >  /**
> >   * \struct RkISP1FrameContext
> >   * \brief Per-frame context for algorithms
> > diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
> > index 9d89cf0160fc..4e38ef40ed3c 100644
> > --- a/src/ipa/rkisp1/ipa_context.h
> > +++ b/src/ipa/rkisp1/ipa_context.h
> > @@ -87,8 +87,6 @@ struct IPAActiveState {
> >                 uint32_t exposure;
> >                 double gain;
> >         } sensor;
> > -
> > -       unsigned int frameCount;
> >  };
> >
> >  struct RkISP1FrameContext : public FrameContext {
> > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> > index 538401ac89ac..4f6e0b0f87b9 100644
> > --- a/src/ipa/rkisp1/rkisp1.cpp
> > +++ b/src/ipa/rkisp1/rkisp1.cpp
> > @@ -261,8 +261,6 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
> >         context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);
> >         context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);
> >
> > -       context_.activeState.frameCount = 0;
> > -
> >         for (auto const &algo : algorithms()) {
> >                 int ret = algo->configure(context_, info);
> >                 if (ret)
> > @@ -325,7 +323,6 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
> >                 algo->prepare(context_, frame, frameContext, params);
> >
> >         paramsBufferReady.emit(frame);
> > -       context_.activeState.frameCount++;
> >  }
> >
> >  void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
> > --
> > Regards,
> >
> > Laurent Pinchart
> >


More information about the libcamera-devel mailing list