libcamera  v0.0.0
Supporting cameras in Linux since 2019
agc.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2021, Ideas On Board
4  *
5  * agc.h - IPU3 AGC/AEC mean-based control algorithm
6  */
7 
8 #pragma once
9 
10 #include <linux/intel-ipu3.h>
11 
12 #include <libcamera/base/utils.h>
13 
14 #include <libcamera/geometry.h>
15 
16 #include "algorithm.h"
17 
18 namespace libcamera {
19 
20 struct IPACameraSensorInfo;
21 
22 namespace ipa::ipu3::algorithms {
23 
24 class Agc : public Algorithm
25 {
26 public:
27  Agc();
28  ~Agc() = default;
29 
30  int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
31  void process(IPAContext &context, IPAFrameContext *frameContext,
32  const ipu3_uapi_stats_3a *stats) override;
33 
34 private:
35  double measureBrightness(const ipu3_uapi_stats_3a *stats,
36  const ipu3_uapi_grid_config &grid) const;
37  utils::Duration filterExposure(utils::Duration currentExposure);
38  void computeExposure(IPAContext &context, IPAFrameContext *frameContext,
39  double yGain, double iqMeanGain);
40  double estimateLuminance(IPAActiveState &activeState,
41  const ipu3_uapi_grid_config &grid,
42  const ipu3_uapi_stats_3a *stats,
43  double gain);
44 
45  uint64_t frameCount_;
46 
47  utils::Duration minShutterSpeed_;
48  utils::Duration maxShutterSpeed_;
49 
50  double minAnalogueGain_;
51  double maxAnalogueGain_;
52 
53  utils::Duration filteredExposure_;
54 
55  uint32_t stride_;
56 };
57 
58 } /* namespace ipa::ipu3::algorithms */
59 
60 } /* namespace libcamera */
The base class for all IPA algorithms.
Definition: algorithm.h:22
A mean-based auto-exposure algorithm.
Definition: agc.h:25
void process(IPAContext &context, IPAFrameContext *frameContext, const ipu3_uapi_stats_3a *stats) override
Process IPU3 statistics, and run AGC operations.
Definition: agc.cpp:326
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override
Configure the AGC given a configInfo.
Definition: agc.cpp:86
Helper class from std::chrono::duration that represents a time duration in nanoseconds with double pr...
Definition: utils.h:330
Data structures related to geometric objects.
Algorithm common interface.
Top-level libcamera namespace.
Definition: backtrace.h:17
The active state of the IPA algorithms.
Definition: ipa_context.h:51
Global IPA context data shared between all algorithms.
Definition: ipa_context.h:92
Context for a frame.
Definition: ipa_context.h:79
Miscellaneous utility functions.