RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
Camera.h
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2009-2014 Klaus Post
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#pragma once
22
23#include "rawspeedconfig.h"
24#include "adt/NotARational.h"
25#include "adt/Point.h"
26#include "metadata/BlackArea.h"
29#include <cstdint>
30#include <functional>
31#include <map>
32#include <sstream>
33#include <string>
34#include <utility>
35#include <vector>
36
37#ifdef HAVE_PUGIXML
38
39namespace pugi {
40class xml_node;
41} // namespace pugi
42
43#endif
44
45namespace rawspeed {
46
47class Hints final {
48 std::map<std::string, std::string, std::less<>> data;
49
50public:
51 void add(const std::string& key, const std::string& value) {
52 data.try_emplace(key, value);
53 }
54
55 [[nodiscard]] bool contains(const std::string& key) const {
56 return data.contains(key);
57 }
58
59 template <typename T>
60 [[nodiscard]] T get(const std::string& key, T defaultValue) const {
61 if (auto hint = data.find(key);
62 hint != data.end() && !hint->second.empty()) {
63 std::istringstream iss(hint->second);
64 iss >> defaultValue;
65 }
66 return defaultValue;
67 }
68
69 [[nodiscard]] bool get(const std::string& key, bool defaultValue) const {
70 auto hint = data.find(key);
71 if (hint == data.end())
72 return defaultValue;
73 return "true" == hint->second;
74 }
75};
76
77class Camera final {
78public:
79 enum class SupportStatus : uint8_t {
80 SupportedNoSamples, // Tentatively supported, no RPU samples.
81 Supported, // Claimed as supported (explicitly).
82 Unknown, // Placeholder camera, support is unknown.
83 UnknownCamera, // Not found in database.
84 UnknownNoSamples, // Placeholder camera, no RPU samples, support is unknown.
85 Unsupported, // Claimed as unsupported (explicitly).
86 };
87
88#ifdef HAVE_PUGIXML
89 explicit Camera(const pugi::xml_node& camera);
90#endif
91
92 Camera(const Camera* camera, uint32_t alias_num);
93 [[nodiscard]] const CameraSensorInfo* getSensorInfo(int iso) const;
94 std::string make;
95 std::string model;
96 std::string mode;
97 std::string canonical_make;
98 std::string canonical_model;
99 std::string canonical_alias;
100 std::string canonical_id;
101 std::vector<std::string> aliases;
102 std::vector<std::string> canonical_aliases;
107 std::vector<BlackArea> blackAreas;
108 std::vector<CameraSensorInfo> sensorInfo;
111 std::vector<NotARational<int>> color_matrix;
112 /*
113 Signals if there's a proper crop info available in the database entry.
114 This flag can be used to decide whether to figure out the crop based on
115 the camera vendor specs.
116 */
117 bool cropAvailable = false;
118
119#ifdef HAVE_PUGIXML
120 void parseColorRow(const pugi::xml_node& node);
121 void parseColor(const pugi::xml_node& node);
122 void parseCFA(const pugi::xml_node& node);
123 void parseCrop(const pugi::xml_node& node);
124 void parseBlackAreas(const pugi::xml_node& node);
125 void parseAliases(const pugi::xml_node& node);
126 void parseHints(const pugi::xml_node& node);
127 void parseID(const pugi::xml_node& node);
128 void parseSensor(const pugi::xml_node& node);
129 void parseColorMatrix(const pugi::xml_node& node);
130 void parseColorMatrices(const pugi::xml_node& node);
131
132 void parseCameraChild(const pugi::xml_node& node);
133#endif
134};
135
136} // namespace rawspeed
Camera(const Camera *camera, uint32_t alias_num)
Definition Camera.cpp:90
std::string canonical_id
Definition Camera.h:100
std::string model
Definition Camera.h:95
std::string canonical_alias
Definition Camera.h:99
iPoint2D cropPos
Definition Camera.h:106
std::string canonical_model
Definition Camera.h:98
std::string mode
Definition Camera.h:96
iPoint2D cropSize
Definition Camera.h:105
std::vector< CameraSensorInfo > sensorInfo
Definition Camera.h:108
bool cropAvailable
Definition Camera.h:117
std::vector< std::string > canonical_aliases
Definition Camera.h:102
std::string canonical_make
Definition Camera.h:97
std::vector< BlackArea > blackAreas
Definition Camera.h:107
const CameraSensorInfo * getSensorInfo(int iso) const
Definition Camera.cpp:418
std::vector< std::string > aliases
Definition Camera.h:101
SupportStatus supportStatus
Definition Camera.h:104
std::vector< NotARational< int > > color_matrix
Definition Camera.h:111
ColorFilterArray cfa
Definition Camera.h:103
std::string make
Definition Camera.h:94
void add(const std::string &key, const std::string &value)
Definition Camera.h:51
std::map< std::string, std::string, std::less<> > data
Definition Camera.h:48
bool contains(const std::string &key) const
Definition Camera.h:55
bool get(const std::string &key, bool defaultValue) const
Definition Camera.h:69
T get(const std::string &key, T defaultValue) const
Definition Camera.h:60
throw T(buf.data())