diff options
Diffstat (limited to 'src/ipa/ipu3/algorithms/af.cpp')
-rw-r--r-- | src/ipa/ipu3/algorithms/af.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index f700b01f..8a5a6b1a 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -185,11 +185,11 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo) afIgnoreFrameReset(); /* Initial focus value */ - context.frameContext.af.focus = 0; + context.activeState.af.focus = 0; /* Maximum variance of the AF statistics */ - context.frameContext.af.maxVariance = 0; + context.activeState.af.maxVariance = 0; /* The stable AF value flag. if it is true, the AF should be in a stable state. */ - context.frameContext.af.stable = false; + context.activeState.af.stable = false; return 0; } @@ -211,10 +211,10 @@ void Af::afCoarseScan(IPAContext &context) if (afScan(context, kCoarseSearchStep)) { coarseCompleted_ = true; - context.frameContext.af.maxVariance = 0; - focus_ = context.frameContext.af.focus - - (context.frameContext.af.focus * kFineRange); - context.frameContext.af.focus = focus_; + context.activeState.af.maxVariance = 0; + focus_ = context.activeState.af.focus - + (context.activeState.af.focus * kFineRange); + context.activeState.af.focus = focus_; previousVariance_ = 0; maxStep_ = std::clamp(focus_ + static_cast<uint32_t>((focus_ * kFineRange)), 0U, kMaxFocusSteps); @@ -237,7 +237,7 @@ void Af::afFineScan(IPAContext &context) return; if (afScan(context, kFineSearchStep)) { - context.frameContext.af.stable = true; + context.activeState.af.stable = true; fineCompleted_ = true; } } @@ -254,10 +254,10 @@ void Af::afReset(IPAContext &context) if (afNeedIgnoreFrame()) return; - context.frameContext.af.maxVariance = 0; - context.frameContext.af.focus = 0; + context.activeState.af.maxVariance = 0; + context.activeState.af.focus = 0; focus_ = 0; - context.frameContext.af.stable = false; + context.activeState.af.stable = false; ignoreCounter_ = kIgnoreFrame; previousVariance_ = 0.0; coarseCompleted_ = false; @@ -280,7 +280,7 @@ bool Af::afScan(IPAContext &context, int min_step) { if (focus_ > maxStep_) { /* If reach the max step, move lens to the position. */ - context.frameContext.af.focus = bestFocus_; + context.activeState.af.focus = bestFocus_; return true; } else { /* @@ -288,8 +288,8 @@ bool Af::afScan(IPAContext &context, int min_step) * derivative. If the direction changes, it means we have * passed a maximum one step before. */ - if ((currentVariance_ - context.frameContext.af.maxVariance) >= - -(context.frameContext.af.maxVariance * 0.1)) { + if ((currentVariance_ - context.activeState.af.maxVariance) >= + -(context.activeState.af.maxVariance * 0.1)) { /* * Positive and zero derivative: * The variance is still increasing. The focus could be @@ -298,8 +298,8 @@ bool Af::afScan(IPAContext &context, int min_step) */ bestFocus_ = focus_; focus_ += min_step; - context.frameContext.af.focus = focus_; - context.frameContext.af.maxVariance = currentVariance_; + context.activeState.af.focus = focus_; + context.activeState.af.maxVariance = currentVariance_; } else { /* * Negative derivative: @@ -307,7 +307,7 @@ bool Af::afScan(IPAContext &context, int min_step) * variance is found. Set focus step to previous good one * then return immediately. */ - context.frameContext.af.focus = bestFocus_; + context.activeState.af.focus = bestFocus_; return true; } } @@ -389,13 +389,13 @@ double Af::afEstimateVariance(Span<const y_table_item_t> y_items, bool isY1) bool Af::afIsOutOfFocus(IPAContext context) { const uint32_t diff_var = std::abs(currentVariance_ - - context.frameContext.af.maxVariance); - const double var_ratio = diff_var / context.frameContext.af.maxVariance; + context.activeState.af.maxVariance); + const double var_ratio = diff_var / context.activeState.af.maxVariance; LOG(IPU3Af, Debug) << "Variance change rate: " << var_ratio << " Current VCM step: " - << context.frameContext.af.focus; + << context.activeState.af.focus; if (var_ratio > kMaxChange) return true; @@ -437,7 +437,7 @@ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats) */ currentVariance_ = afEstimateVariance(y_items, !coarseCompleted_); - if (!context.frameContext.af.stable) { + if (!context.activeState.af.stable) { afCoarseScan(context); afFineScan(context); } else { |