Skip to content

Commit a39c010

Browse files
authored
Merge pull request #336 from LebedevRI/no-samples
Change lack-of-samples into a noisy warning (Refs. #335) To be reverted in December 2022 (~+11 months from the date of this commit), see #335 (comment)
2 parents a571881 + e96a4d1 commit a39c010

File tree

8 files changed

+183
-149
lines changed

8 files changed

+183
-149
lines changed

data/cameras.xml

Lines changed: 138 additions & 138 deletions
Large diffs are not rendered by default.

data/cameras.xsd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,11 @@
511511
</xs:simpleType>
512512
<xs:simpleType name="CameraTypeSupportedType">
513513
<xs:restriction base="xs:string">
514-
<xs:pattern value="no"/>
514+
<xs:pattern value="(no|no-samples)"/>
515515
<xs:minLength value="2"/>
516-
<xs:maxLength value="2"/>
516+
<xs:maxLength value="10"/>
517517
<xs:enumeration value="no"/>
518+
<xs:enumeration value="no-samples"/>
518519
</xs:restriction>
519520
</xs:simpleType>
520521
<xs:complexType name="CameraType">

src/librawspeed/decoders/RawDecoder.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,20 @@ bool RawDecoder::checkCameraSupported(const CameraMetaData* meta,
173173
return false;
174174
}
175175

176-
if (!cam->supported)
176+
switch (cam->supportStatus) {
177+
case Camera::SupportStatus::Supported:
178+
break; // Yay us!
179+
case Camera::SupportStatus::Unsupported:
177180
ThrowRDE("Camera not supported (explicit). Sorry.");
181+
case Camera::SupportStatus::NoSamples:
182+
noSamples = true;
183+
writeLog(DEBUG_PRIO::WARNING,
184+
"Camera support status is unknown: '%s' '%s' '%s'\n"
185+
"Please consider providing samples on <https://raw.pixls.us/> "
186+
"if you wish for the support to not be discontinued, thanks!",
187+
make.c_str(), model.c_str(), mode.c_str());
188+
break; // WYSIWYG.
189+
}
178190

179191
if (cam->decoderVersion > getDecoderVersion())
180192
ThrowRDE("Camera not supported in this version. Update RawSpeed for support.");

src/librawspeed/decoders/RawDecoder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ class RawDecoder
109109
explicit operator bool() const { return quadrantMultipliers /*|| ...*/; }
110110
} iiq;
111111

112+
// Indicate if the cameras.xml says that the camera support status is unknown
113+
// due to the lack of RPU samples
114+
bool noSamples = false;
115+
112116
protected:
113117
/* Attempt to decode the image */
114118
/* A RawDecoderException will be thrown if the image cannot be decoded, */

src/librawspeed/metadata/Camera.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ Camera::Camera(const pugi::xml_node& camera) : cfa(iPoint2D(0, 0)) {
5555

5656
canonical_id = make + " " + model;
5757

58-
supported =
59-
camera.attribute("supported").as_string("yes") == std::string("yes");
58+
supportStatus = [&camera]() {
59+
const std::string_view v = camera.attribute("supported").as_string("yes");
60+
if (v == "yes")
61+
return Camera::SupportStatus::Supported;
62+
if (v == "no")
63+
return Camera::SupportStatus::Unsupported;
64+
if (v == "no-samples")
65+
return Camera::SupportStatus::NoSamples;
66+
ThrowCME("Attribute 'supported' has unknown value.");
67+
}();
6068
mode = camera.attribute("mode").as_string("");
6169
decoderVersion = camera.attribute("decoder_version").as_int(0);
6270

src/librawspeed/metadata/Camera.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ class Hints
7777
class Camera
7878
{
7979
public:
80+
enum class SupportStatus {
81+
Unsupported,
82+
Supported,
83+
NoSamples,
84+
};
85+
8086
#ifdef HAVE_PUGIXML
8187
explicit Camera(const pugi::xml_node& camera);
8288
#endif
@@ -93,7 +99,7 @@ class Camera
9399
std::vector<std::string> aliases;
94100
std::vector<std::string> canonical_aliases;
95101
ColorFilterArray cfa;
96-
bool supported;
102+
SupportStatus supportStatus;
97103
iPoint2D cropSize;
98104
iPoint2D cropPos;
99105
std::vector<BlackArea> blackAreas;

src/librawspeed/metadata/CameraMetaData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ const Camera* CameraMetaData::addCamera(std::unique_ptr<Camera> cam) {
149149
void CameraMetaData::disableMake(std::string_view make) const {
150150
for (const auto& cam : cameras) {
151151
if (cam.second->make == make)
152-
cam.second->supported = false;
152+
cam.second->supportStatus = Camera::SupportStatus::Unsupported;
153153
}
154154
}
155155

156156
void CameraMetaData::disableCamera(std::string_view make,
157157
std::string_view model) const {
158158
for (const auto& cam : cameras) {
159159
if (cam.second->make == make && cam.second->model == model)
160-
cam.second->supported = false;
160+
cam.second->supportStatus = Camera::SupportStatus::Unsupported;
161161
}
162162
}
163163

src/utilities/rstest/rstest.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ APPEND(ostringstream* oss, const char* format, ...) {
152152
*oss << line.data();
153153
}
154154

155-
std::string img_hash(const RawImage& r) {
155+
std::string img_hash(const RawImage& r, bool noSamples) {
156156
ostringstream oss;
157157

158+
if (noSamples)
159+
APPEND(&oss, "camera support status is unknown due to lack of samples\n");
158160
APPEND(&oss, "make: %s\n", r->metadata.make.c_str());
159161
APPEND(&oss, "model: %s\n", r->metadata.model.c_str());
160162
APPEND(&oss, "mode: %s\n", r->metadata.mode.c_str());
@@ -363,6 +365,7 @@ size_t process(const std::string& filename, const CameraMetaData* metadata,
363365

364366
decoder->failOnUnknown = false;
365367
decoder->checkSupport(metadata);
368+
bool noSamples = decoder->noSamples;
366369

367370
decoder->decodeRaw();
368371
decoder->decodeMetaData(metadata);
@@ -382,12 +385,12 @@ size_t process(const std::string& filename, const CameraMetaData* metadata,
382385
if (o.create) {
383386
// write the hash. if force is set, then we are potentially overwriting here
384387
ofstream f(hashfile);
385-
f << img_hash(raw);
388+
f << img_hash(raw, noSamples);
386389
if (o.dump)
387390
writeImage(raw, filename);
388391
} else {
389392
// do generate the hash string regardless.
390-
std::string h = img_hash(raw);
393+
std::string h = img_hash(raw, noSamples);
391394

392395
// normally, here we would compare the old hash with the new one
393396
// but if the force is set, and the hash does not exist, do nothing.

0 commit comments

Comments
 (0)