summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHubert Figuière <hub@figuiere.net>2018-09-16 21:47:05 -0400
committerHubert Figuière <hub@figuiere.net>2018-09-16 21:47:05 -0400
commitefac2290ccefccc309c0042def913b1f61927124 (patch)
tree69359977079d6513e32de5d06aad58c7cced62e2 /test
parent3af99386d07b95cceadadf8c3f0ec0d3b4351f37 (diff)
test: added missingcoefficients internal test
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am5
-rw-r--r--test/missingcoefficients.cpp92
2 files changed, 96 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 7c521ab..271861e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib
check_PROGRAMS = fileio testoption ciffcontainertest ljpegtest testunpack\
- extensions
+ extensions missingcoefficients
EXTRA_DIST = ljpegtest1.jpg
@@ -33,3 +33,6 @@ ljpegtest_LDADD = $(OPENRAW_LIB) @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
testunpack_SOURCES = testunpack.cpp
testunpack_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
testunpack_LDADD = $(OPENRAW_LIB) @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
+
+missingcoefficients_SOURCES = missingcoefficients.cpp
+missingcoefficients_LDADD = $(OPENRAW_LIB)
diff --git a/test/missingcoefficients.cpp b/test/missingcoefficients.cpp
new file mode 100644
index 0000000..42c4799
--- /dev/null
+++ b/test/missingcoefficients.cpp
@@ -0,0 +1,92 @@
+/*
+ * libopenraw - missingcoefficients.cpp
+ *
+ * Copyright (C) 2018 Hubert Figuière
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+
+/* @brief a utility to list the missing coefficients */
+/*
+ * This code hooks to internals of libopenraw and is not to be interpreted
+ * as a sample code. It is instead a helper used by developers to make sure
+ * of the support of various cameras.
+ */
+
+#include <iostream>
+#include <memory>
+
+#include "../lib/rawfile.hpp"
+#include "../lib/rawfile_private.hpp"
+#include "../lib/arwfile.hpp"
+#include "../lib/cr2file.hpp"
+#include "../lib/cr3file.hpp"
+#include "../lib/crwfile.hpp"
+#include "../lib/erffile.hpp"
+#include "../lib/mrwfile.hpp"
+#include "../lib/neffile.hpp"
+#include "../lib/orffile.hpp"
+#include "../lib/peffile.hpp"
+#include "../lib/raffile.hpp"
+#include "../lib/rw2file.hpp"
+#include "../lib/io/memstream.hpp"
+
+using namespace OpenRaw;
+using namespace OpenRaw::Internals;
+
+
+namespace OpenRaw {
+namespace Internals {
+
+template<typename T>
+void audit_coefficients()
+{
+ IO::Stream::Ptr s = std::make_shared<IO::MemStream>(nullptr, 0);
+ T t(s);
+ const BuiltinColourMatrix* matrices = t._getMatrices();
+ const RawFile::camera_ids_t* def = T::s_def;
+ for (auto current = def; current->model; current++) {
+ bool found = false;
+ for (auto current_mat = matrices; current_mat->camera != 0; current_mat++) {
+ if (current_mat->camera == current->type_id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ std::cout << "Missing coefficient for " << current->model << std::endl;
+ }
+ }
+}
+
+}
+}
+
+
+int main(int, char**)
+{
+ OpenRaw::Internals::audit_coefficients<ArwFile>();
+ OpenRaw::Internals::audit_coefficients<Cr2File>();
+ OpenRaw::Internals::audit_coefficients<Cr3File>();
+ OpenRaw::Internals::audit_coefficients<CRWFile>();
+ OpenRaw::Internals::audit_coefficients<ERFFile>();
+ OpenRaw::Internals::audit_coefficients<MRWFile>();
+ OpenRaw::Internals::audit_coefficients<NefFile>();
+ OpenRaw::Internals::audit_coefficients<OrfFile>();
+ OpenRaw::Internals::audit_coefficients<PEFFile>();
+ OpenRaw::Internals::audit_coefficients<RafFile>();
+ OpenRaw::Internals::audit_coefficients<Rw2File>();
+}