summaryrefslogtreecommitdiff
path: root/src/android/camera_hal_config.h
blob: 9df554f9929bb0a9a9ed6f4615ff2c9a917d97cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2021, Google Inc.
 *
 * camera_hal_config.h - Camera HAL configuration file manager
 */

#pragma once

#include <map>
#include <string>

#include <libcamera/base/class.h>

struct CameraConfigData {
	int facing = -1;
	int rotation = -1;
};

class CameraHalConfig final : public libcamera::Extensible
{
	LIBCAMERA_DECLARE_PRIVATE()

public:
	CameraHalConfig();

	bool exists() const { return exists_; }
	bool isValid() const { return valid_; }

	const CameraConfigData *cameraConfigData(const std::string &cameraId) const;

private:
	bool exists_;
	bool valid_;
	std::map<std::string, CameraConfigData> cameras_;

	int parseConfigurationFile();
};
n class="hl opt">- b) * (cumulative_[b + 1] - cumulative_[b]); } double Histogram::Quantile(double q, int first, int last) const { if (first == -1) first = 0; if (last == -1) last = cumulative_.size() - 2; assert(first <= last); uint64_t items = q * Total(); while (first < last) // binary search to find the right bin { int middle = (first + last) / 2; if (cumulative_[middle + 1] > items) last = middle; // between first and middle else first = middle + 1; // after middle } assert(items >= cumulative_[first] && items <= cumulative_[last + 1]); double frac = cumulative_[first + 1] == cumulative_[first] ? 0 : (double)(items - cumulative_[first]) / (cumulative_[first + 1] - cumulative_[first]); return first + frac; } double Histogram::InterQuantileMean(double q_lo, double q_hi) const { assert(q_hi > q_lo); double p_lo = Quantile(q_lo); double p_hi = Quantile(q_hi, (int)p_lo); double sum_bin_freq = 0, cumul_freq = 0; for (double p_next = floor(p_lo) + 1.0; p_next <= ceil(p_hi); p_lo = p_next, p_next += 1.0) { int bin = floor(p_lo); double freq = (cumulative_[bin + 1] - cumulative_[bin]) * (std::min(p_next, p_hi) - p_lo); sum_bin_freq += bin * freq; cumul_freq += freq; } // add 0.5 to give an average for bin mid-points return sum_bin_freq / cumul_freq + 0.5; }