libcamera  v0.2.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, const uint32_t frame,
32  IPAFrameContext &frameContext,
33  const ipu3_uapi_stats_3a *stats,
34  ControlList &metadata) override;
35 
36 private:
37  double measureBrightness(const ipu3_uapi_stats_3a *stats,
38  const ipu3_uapi_grid_config &grid) const;
39  utils::Duration filterExposure(utils::Duration currentExposure);
40  void computeExposure(IPAContext &context, IPAFrameContext &frameContext,
41  double yGain, double iqMeanGain);
42  double estimateLuminance(IPAActiveState &activeState,
43  const ipu3_uapi_grid_config &grid,
44  const ipu3_uapi_stats_3a *stats,
45  double gain);
46 
47  uint64_t frameCount_;
48 
49  utils::Duration minShutterSpeed_;
50  utils::Duration maxShutterSpeed_;
51 
52  double minAnalogueGain_;
53  double maxAnalogueGain_;
54 
55  utils::Duration filteredExposure_;
56 
57  uint32_t stride_;
58 };
59 
60 } /* namespace ipa::ipu3::algorithms */
61 
62 } /* namespace libcamera */
Associate a list of ControlId with their values for an object.
Definition: controls.h:350
The base class for all IPA algorithms.
Definition: algorithm.h:23
A mean-based auto-exposure algorithm.
Definition: agc.h:25
void process(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const ipu3_uapi_stats_3a *stats, ControlList &metadata) override
Process IPU3 statistics, and run AGC operations.
Definition: agc.cpp:328
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:48
Global IPA context data shared between all algorithms.
Definition: ipa_context.h:83
IPU3-specific FrameContext.
Definition: ipa_context.h:76
Miscellaneous utility functions.