summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuiere <hub@figuiere.net>2008-05-30 10:38:54 -0400
committerHubert Figuiere <hub@figuiere.net>2008-05-30 10:38:54 -0400
commit54b1654dbdf2cc5de2ac7ba289cad91ad199184e (patch)
treed00084c5d2ce1445d81f0101248ad45f9b41d85a
parent4a22051cabcb353dfce5b894e72b847303155a2b (diff)
* include/libopenraw++/rawdata.h,
include/libopenraw/rawdata.h, include/libopenraw/rawfile.h: lib/capi/rawdata.cpp, lib/ljpegdecompressor.cpp, lib/mrwfile.cpp, lib/rawdata.cpp, testsuite/testsuite.cpp, testsuite/testsuite.h, testsuite/testsuitehandler.cpp, testsuite/testsuitetags.txt, tools/ordiag.cpp: Initial support for min and max values for the CFA to be able to "scale" the colors. Support CR2 and MRW.
-rw-r--r--ChangeLog11
-rw-r--r--NEWS1
-rw-r--r--include/libopenraw++/rawdata.h12
-rw-r--r--include/libopenraw/rawdata.h11
-rw-r--r--include/libopenraw/rawfile.h2
-rw-r--r--lib/capi/rawdata.cpp15
-rw-r--r--lib/ljpegdecompressor.cpp21
-rw-r--r--lib/mrwfile.cpp6
-rw-r--r--lib/rawdata.cpp26
-rw-r--r--testsuite/testsuite.cpp45
-rw-r--r--testsuite/testsuite.h2
-rw-r--r--testsuite/testsuite.xml8
-rw-r--r--testsuite/testsuitehandler.cpp3
-rw-r--r--testsuite/testsuitetags.txt2
-rw-r--r--tools/ordiag.cpp4
15 files changed, 151 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f6ecf8..6e67373 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-05-30 Hubert Figuiere <hub@figuiere.net>
+
+ * include/libopenraw++/rawdata.h,
+ include/libopenraw/rawdata.h, include/libopenraw/rawfile.h:
+ lib/capi/rawdata.cpp, lib/ljpegdecompressor.cpp,
+ lib/mrwfile.cpp, lib/rawdata.cpp, testsuite/testsuite.cpp,
+ testsuite/testsuite.h, testsuite/testsuitehandler.cpp,
+ testsuite/testsuitetags.txt, tools/ordiag.cpp:
+ Initial support for min and max values for the CFA to
+ be able to "scale" the colors. Support CR2 and MRW.
+
2008-05-13 Hubert Figuiere <hub@figuiere.net>
* lib/crwfile.{cpp,h}, include/libopenraw/consts.h,
diff --git a/NEWS b/NEWS
index bf625a0..d561dba 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ libopenraw 0.0.6
a memory buffer.
- NEW: API or_rawfile_get_typeid() and the associated consts.
- NEW: API or_demosaic() for low-level acces to demosaic.
+ - NEW: API or_rawdata_get_minmax()
- NEW: GtkPixbuf loader.
- TODO: fix detection by content.
- TODO: apply the coefficients.
diff --git a/include/libopenraw++/rawdata.h b/include/libopenraw++/rawdata.h
index a0b7d55..0b75149 100644
--- a/include/libopenraw++/rawdata.h
+++ b/include/libopenraw++/rawdata.h
@@ -1,7 +1,7 @@
/*
* libopenraw - rawdata.h
*
- * Copyright (C) 2007 Hubert Figuiere
+ * Copyright (C) 2007-2008 Hubert Figuiere
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -35,12 +35,18 @@ namespace OpenRaw {
{
public:
typedef or_cfa_pattern CfaPattern;
- static RawData * getAndExtractRawData(const char* filename, uint32_t options,
- or_error & err);
+ static RawData * getAndExtractRawData(const char* filename,
+ uint32_t options,
+ or_error & err);
RawData();
virtual ~RawData();
+ uint16_t min();
+ uint16_t max();
+ void setMin(uint16_t _m);
+ void setMax(uint16_t _m);
+
/** swap the two objects data. */
void swap(RawData & with);
diff --git a/include/libopenraw/rawdata.h b/include/libopenraw/rawdata.h
index e24456e..326fb9f 100644
--- a/include/libopenraw/rawdata.h
+++ b/include/libopenraw/rawdata.h
@@ -67,6 +67,17 @@ extern "C" {
or_cfa_pattern
or_rawdata_get_cfa_pattern(ORRawDataRef rawdata);
+ /** Return the minimum and maximum values for the raw data.
+ * This are possible values, not actual values.
+ * @param rawdata the raw data object
+ * @param min the pointer to the minimum value.
+ * @param max the pointer to the maximum value.
+ * @return the error code.
+ */
+ or_error
+ or_rawdata_get_minmax(ORRawDataRef rawdata, uint16_t *min, uint16_t *max);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/include/libopenraw/rawfile.h b/include/libopenraw/rawfile.h
index 57808d6..5d5f785 100644
--- a/include/libopenraw/rawfile.h
+++ b/include/libopenraw/rawfile.h
@@ -1,7 +1,7 @@
/*
* libopenraw - rawfile.h
*
- * Copyright (C) 2007 Hubert Figuiere
+ * Copyright (C) 2007-2008 Hubert Figuiere
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
diff --git a/lib/capi/rawdata.cpp b/lib/capi/rawdata.cpp
index c4c4abf..0c9e98a 100644
--- a/lib/capi/rawdata.cpp
+++ b/lib/capi/rawdata.cpp
@@ -81,7 +81,7 @@ extern "C" {
void
or_rawdata_dimensions(ORRawDataRef rawdata,
- uint32_t *x, uint32_t *y)
+ uint32_t *x, uint32_t *y)
{
RawData* t = reinterpret_cast<RawData *>(rawdata);
if (x != NULL) {
@@ -104,4 +104,17 @@ extern "C" {
return reinterpret_cast<RawData *>(rawdata)->cfaPattern();
}
+ or_error
+ or_rawdata_get_minmax(ORRawDataRef rawdata, uint16_t *min, uint16_t *max)
+ {
+ RawData* t = reinterpret_cast<RawData *>(rawdata);
+ if(min) {
+ *min = t->min();
+ }
+ if(max) {
+ *max = t->max();
+ }
+ return OR_ERROR_NONE;
+ }
+
}
diff --git a/lib/ljpegdecompressor.cpp b/lib/ljpegdecompressor.cpp
index 108cc4f..ae64c47 100644
--- a/lib/ljpegdecompressor.cpp
+++ b/lib/ljpegdecompressor.cpp
@@ -1550,24 +1550,25 @@ namespace OpenRaw {
bitmap->setDataType(OR_DATA_TYPE_CFA);
// bpc is a multiple of 8
uint32_t bpc = dcInfo.dataPrecision;
- if(bpc % 8) {
- bpc = ((bpc / 8) + 1) * 8;
- }
+// if(bpc % 8) {
+// bpc = ((bpc / 8) + 1) * 8;
+// }
bitmap->setBpc(bpc);
+ bitmap->setMax((1 << bpc) - 1);
/*uint16_t *dataPtr = (uint16_t*)*/
bitmap->allocData(dcInfo.imageWidth
- * sizeof(uint16_t)
- * dcInfo.imageHeight
- * dcInfo.numComponents);
+ * sizeof(uint16_t)
+ * dcInfo.imageHeight
+ * dcInfo.numComponents);
Trace(DEBUG1) << "dc width = " << dcInfo.imageWidth
- << " dc height = " << dcInfo.imageHeight
- << "\n";
+ << " dc height = " << dcInfo.imageHeight
+ << "\n";
/* currently if the CFA is not sliced, it's this is half what it is */
uint32_t width = (isSliced() ? dcInfo.imageWidth * m_slices.size()
- : dcInfo.imageWidth * dcInfo.numComponents);
+ : dcInfo.imageWidth * dcInfo.numComponents);
bitmap->setDimensions(width,
- dcInfo.imageHeight);
+ dcInfo.imageHeight);
bitmap->setSlices(m_slices);
DecoderStructInit(&dcInfo);
HuffDecoderInit(&dcInfo);
diff --git a/lib/mrwfile.cpp b/lib/mrwfile.cpp
index e1d75bf..457127d 100644
--- a/lib/mrwfile.cpp
+++ b/lib/mrwfile.cpp
@@ -197,7 +197,8 @@ namespace OpenRaw {
/* Obtain sensor dimensions from PRD block. */
uint16_t y = mc->prd->uint16_val (MRW::PRD_SENSOR_LENGTH);
uint16_t x = mc->prd->uint16_val (MRW::PRD_SENSOR_WIDTH);
-
+ uint8_t bpc = mc->prd->uint8_val (MRW::PRD_PIXEL_SIZE);
+
bool is_compressed = (mc->prd->uint8_val(MRW::PRD_STORAGE_TYPE) == 0x59);
/* Allocate space for and retrieve pixel data.
* Currently only for cameras that don't compress pixel data.
@@ -216,6 +217,9 @@ namespace OpenRaw {
else {
data.setDataType (OR_DATA_TYPE_CFA);
}
+ data.setBpc(bpc);
+ // this seems to be the hardcoded value.
+ data.setMax(0xf7d);
Trace(DEBUG1) << "datalen = " << datalen <<
" final datalen = " << finaldatalen << "\n";
void *p = data.allocData(finaldatalen);
diff --git a/lib/rawdata.cpp b/lib/rawdata.cpp
index 9f9c7c0..3d5444d 100644
--- a/lib/rawdata.cpp
+++ b/lib/rawdata.cpp
@@ -28,6 +28,7 @@ namespace OpenRaw {
class RawData::Private {
public:
RawData *self;
+ uint16_t min, max;
CfaPattern cfa_pattern;
uint32_t compression;
uint8_t *pos;
@@ -40,7 +41,9 @@ namespace OpenRaw {
std::vector<uint16_t> slices;
Private(RawData *_self)
- : self(_self), cfa_pattern(OR_CFA_PATTERN_NONE),
+ : self(_self),
+ min(0), max(0),
+ cfa_pattern(OR_CFA_PATTERN_NONE),
compression(0),
pos(NULL), offset(0),
row_offset(0),
@@ -90,6 +93,25 @@ namespace OpenRaw {
delete d;
}
+ uint16_t RawData::min()
+ {
+ return d->min;
+ }
+
+ uint16_t RawData::max()
+ {
+ return d->max;
+ }
+
+ void RawData::setMin(uint16_t m)
+ {
+ d->min = m;
+ }
+
+ void RawData::setMax(uint16_t m)
+ {
+ d->max = m;
+ }
void RawData::swap(RawData & with)
{
@@ -162,7 +184,7 @@ namespace OpenRaw {
RawData &RawData::append(uint16_t c)
{
assert(d->pos);
-// assert(d->offset < d->data_size);
+ assert(d->offset < size());
*(d->pos) = c & 0xff;
*(d->pos + 1) = (c >> 8) & 0xff;
d->advance(sizeof(c));
diff --git a/testsuite/testsuite.cpp b/testsuite/testsuite.cpp
index 83e5d54..6f2d18b 100644
--- a/testsuite/testsuite.cpp
+++ b/testsuite/testsuite.cpp
@@ -373,6 +373,45 @@ bool Test::testRawCfaPattern(const std::string & result)
RETURN_TEST(equalCfaPattern(result, m_rawdata->cfaPattern()), result);
}
+bool Test::testRawMinValue(const std::string & result)
+{
+ if(m_rawdata == NULL) {
+ m_rawdata = loadRawData(m_rawfile);
+ if(m_rawdata == NULL) {
+ RETURN_FAIL("failed to get rawData", result);
+ }
+ }
+ uint16_t expected;
+ try {
+ expected = boost::lexical_cast<uint16_t>(result);
+ }
+ catch(...)
+ {
+ RETURN_FAIL("conversion failed", result);
+ }
+ RETURN_TEST(m_rawdata->min() == expected, result);
+}
+
+
+bool Test::testRawMaxValue(const std::string & result)
+{
+ if(m_rawdata == NULL) {
+ m_rawdata = loadRawData(m_rawfile);
+ if(m_rawdata == NULL) {
+ RETURN_FAIL("failed to get rawData", result);
+ }
+ }
+ uint16_t expected;
+ try {
+ expected = boost::lexical_cast<uint16_t>(result);
+ }
+ catch(...)
+ {
+ RETURN_FAIL("conversion failed", result);
+ }
+ RETURN_TEST(m_rawdata->max() == expected, result);
+}
+
bool Test::testRawMd5(const std::string & result)
{
if(m_rawdata == NULL) {
@@ -470,6 +509,12 @@ int Test::run()
case XML_rawCfaPattern:
pass = testRawCfaPattern(iter->second);
break;
+ case XML_rawMinValue:
+ pass = testRawMinValue(iter->second);
+ break;
+ case XML_rawMaxValue:
+ pass = testRawMaxValue(iter->second);
+ break;
case XML_rawMd5:
pass = testRawMd5(iter->second);
break;
diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h
index b0d41b6..8b54889 100644
--- a/testsuite/testsuite.h
+++ b/testsuite/testsuite.h
@@ -63,6 +63,8 @@ private:
bool testRawDataSize(const std::string & result);
bool testRawDataDimensions(const std::string & result);
bool testRawCfaPattern(const std::string & result);
+ bool testRawMinValue(const std::string & result);
+ bool testRawMaxValue(const std::string & result);
bool testRawMd5(const std::string & result);
bool testRawDecompressedMd5(const std::string & result);
bool testMetaOrientation(const std::string & result);
diff --git a/testsuite/testsuite.xml b/testsuite/testsuite.xml
index 30b6c65..82a356a 100644
--- a/testsuite/testsuite.xml
+++ b/testsuite/testsuite.xml
@@ -14,6 +14,8 @@
<rawDataSize>16973120</rawDataSize>
<rawDataDimensions>3596 2360</rawDataDimensions>
<rawCfaPattern>RGGB</rawCfaPattern>
+ <rawMinValue>0</rawMinValue>
+ <rawMaxValue>4095</rawMaxValue>
<rawMd5>29</rawMd5>
<metaOrientation>1</metaOrientation>
</results>
@@ -304,6 +306,8 @@
<rawDataSize>6348928</rawDataSize>
<rawDataDimensions>2056 1544</rawDataDimensions>
<rawCfaPattern>RGGB</rawCfaPattern>
+ <rawMinValue>0</rawMinValue>
+ <rawMaxValue>3965</rawMaxValue>
<rawMd5>251</rawMd5>
<metaOrientation>0</metaOrientation>
</results>
@@ -323,6 +327,8 @@
<rawDataSize>9902208</rawDataSize>
<rawDataDimensions>2568 1928</rawDataDimensions>
<rawCfaPattern>RGGB</rawCfaPattern>
+ <rawMinValue>0</rawMinValue>
+ <rawMaxValue>3965</rawMaxValue>
<rawMd5>214</rawMd5>
<metaOrientation>0</metaOrientation>
</results>
@@ -342,6 +348,8 @@
<rawDataSize>9902208</rawDataSize>
<rawDataDimensions>2568 1928</rawDataDimensions>
<rawCfaPattern>RGGB</rawCfaPattern>
+ <rawMinValue>0</rawMinValue>
+ <rawMaxValue>3965</rawMaxValue>
<rawMd5>168</rawMd5>
<metaOrientation>0</metaOrientation>
</results>
diff --git a/testsuite/testsuitehandler.cpp b/testsuite/testsuitehandler.cpp
index 5a70b3c..b64c3bd 100644
--- a/testsuite/testsuitehandler.cpp
+++ b/testsuite/testsuitehandler.cpp
@@ -2,6 +2,7 @@
* libopenraw - testsuitehandler.cpp
*
* Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008 Novell, Inc.
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -63,6 +64,8 @@ xml::ContextPtr TestContext::startElement(int32_t element)
case XML_rawDataSize:
case XML_rawDataDimensions:
case XML_rawCfaPattern:
+ case XML_rawMinValue:
+ case XML_rawMaxValue:
case XML_rawMd5:
case XML_rawDecompressedMd5:
case XML_metaOrientation:
diff --git a/testsuite/testsuitetags.txt b/testsuite/testsuitetags.txt
index baf5904..40285ab 100644
--- a/testsuite/testsuitetags.txt
+++ b/testsuite/testsuitetags.txt
@@ -14,6 +14,8 @@ rawDataType
rawDataSize
rawDataDimensions
rawCfaPattern
+rawMinValue
+rawMaxValue
rawMd5
rawDecompressedMd5
metaOrientation
diff --git a/tools/ordiag.cpp b/tools/ordiag.cpp
index 1caa640..d566c46 100644
--- a/tools/ordiag.cpp
+++ b/tools/ordiag.cpp
@@ -200,6 +200,10 @@ public:
% rd.x() % rd.y();
m_out << boost::format("\t\tBayer Type: %1%\n")
% cfaPatternToString(rd.cfaPattern());
+ m_out << boost::format("\t\tBits per channel: %1%\n")
+ % rd.bpc();
+ m_out << boost::format("\t\tValues: min = %1% max = %2%\n")
+ % rd.min() % rd.max();
}
else {
m_out << boost::format("\tNo Raw Data found! (error = %1%)\n")