1
From: Hubert Figuiere <hub@figuiere.net>
2
Subject: Support (partially) PEF from Pentax K20D.
3
Detect that ORF file are compressed if they are. (Closes #26618)
4
Skip compressed CFA when rendering the image. (Closes #25464)
5
Origin: upstream, http://cgit.freedesktop.org/libopenraw/commit/?id=1b15acdcfdc4664bc6c0be473cb6e096071a4e62
9
include/libopenraw/consts.h | 5 +++--
10
lib/orffile.cpp | 33 +++++++++++++++++++++++++++++----
11
lib/peffile.cpp | 20 ++++++++++----------
12
lib/rawfile.cpp | 7 ++++++-
13
testsuite/testsuite.xml | 36 ++++++++++++++++++++++++++++++++++++
14
6 files changed, 87 insertions(+), 19 deletions(-)
16
--- libopenraw.orig/README
18
@@ -114,9 +114,9 @@ Olympus ORF Y Y N Y Y Y
30
@@ -143,6 +143,7 @@ Pentax PEF Y Y N Y Y Y
38
--- libopenraw.orig/include/libopenraw/consts.h
39
+++ libopenraw/include/libopenraw/consts.h
42
* libopenraw - consts.h
44
- * Copyright (C) 2005-2009 Hubert Figuiere
45
* Copyright (c) 2008 Novell, Inc.
46
+ * Copyright (C) 2005-2010 Hubert Figuiere
48
* This library is free software: you can redistribute it and/or
49
* modify it under the terms of the GNU Lesser General Public License
50
@@ -204,7 +204,8 @@ extern "C" {
51
OR_TYPEID_PENTAX_IST_D,
52
OR_TYPEID_PENTAX_IST_DL,
53
OR_TYPEID_PENTAX_K100D_PEF,
54
- OR_TYPEID_PENTAX_K100D_SUPER_PEF
55
+ OR_TYPEID_PENTAX_K100D_SUPER_PEF,
56
+ OR_TYPEID_PENTAX_K20D_PEF
60
--- libopenraw.orig/lib/orffile.cpp
61
+++ libopenraw/lib/orffile.cpp
64
* libopenraw - orffile.cpp
66
- * Copyright (C) 2006, 2008 Hubert Figuiere
67
+ * Copyright (C) 2006, 2008, 2010 Hubert Figuiere
69
* This library is free software: you can redistribute it and/or
70
* modify it under the terms of the GNU Lesser General Public License
71
@@ -77,7 +77,7 @@ namespace OpenRaw {
73
IFDDir::Ref ORFFile::_locateCfaIfd()
75
- // in PEF the CFA IFD is the main IFD
76
+ // in ORF the CFA IFD is the main IFD
78
m_mainIfd = _locateMainIfd();
80
@@ -92,12 +92,37 @@ namespace OpenRaw {
84
- ::or_error ORFFile::_getRawData(RawData & data, uint32_t /*options*/)
85
+ ::or_error ORFFile::_getRawData(RawData & data, uint32_t options)
89
m_cfaIfd = _locateCfaIfd();
91
- return _getRawDataFromDir(data, m_cfaIfd);
92
+ err = _getRawDataFromDir(data, m_cfaIfd);
93
+ if(err == OR_ERROR_NONE) {
94
+ // ORF files seems to be marked as uncompressed even if they are.
95
+ uint32_t x = data.x();
96
+ uint32_t y = data.y();
97
+ uint16_t compression = 0;
98
+ if(data.size() < x * y * 2) {
99
+ compression = 65535;
100
+ data.setCompression(65535);
101
+ data.setDataType(OR_DATA_TYPE_COMPRESSED_CFA);
104
+ compression = data.compression();
106
+ switch(compression) {
108
+ if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
120
--- libopenraw.orig/lib/peffile.cpp
121
+++ libopenraw/lib/peffile.cpp
124
* libopenraw - peffile.cpp
126
- * Copyright (C) 2006-2008 Hubert Figuiere
127
+ * Copyright (C) 2006-2008, 2010 Hubert Figuiere
129
* This library is free software: you can redistribute it and/or
130
* modify it under the terms of the GNU Lesser General Public License
131
@@ -48,6 +48,8 @@ namespace OpenRaw {
132
OR_TYPEID_PENTAX_K100D_PEF) },
133
{ "PENTAX K100D Super ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
134
OR_TYPEID_PENTAX_K100D_PEF) },
135
+ { "PENTAX K20D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
136
+ OR_TYPEID_PENTAX_K20D_PEF) },
140
@@ -83,7 +85,7 @@ namespace OpenRaw {
141
return m_container->setDirectory(0);
144
- ::or_error PEFFile::_getRawData(RawData & data, uint32_t /*options*/)
145
+ ::or_error PEFFile::_getRawData(RawData & data, uint32_t options)
149
@@ -91,14 +93,12 @@ namespace OpenRaw {
151
err = _getRawDataFromDir(data, m_cfaIfd);
152
if(err == OR_ERROR_NONE) {
153
- uint16_t compression = 0;
154
- m_cfaIfd->getValue(IFD::EXIF_TAG_COMPRESSION, compression);
155
- switch(compression) {
157
- data.setDataType(OR_DATA_TYPE_CFA);
161
+ uint16_t compression = data.compression();
162
+ switch(compression) {
164
+ if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
170
--- libopenraw.orig/lib/rawfile.cpp
171
+++ libopenraw/lib/rawfile.cpp
174
* libopenraw - rawfile.cpp
176
- * Copyright (C) 2006-2008 Hubert Figuiere
177
* Copyright (C) 2008 Novell, Inc.
178
+ * Copyright (C) 2006-2008, 2010 Hubert Figuiere
180
* This library is free software: you can redistribute it and/or
181
* modify it under the terms of the GNU Lesser General Public License
182
@@ -379,8 +379,13 @@ const std::vector<uint32_t> & RawFile::l
183
::or_error RawFile::getRenderedImage(BitmapData & bitmapdata, uint32_t options)
186
+ Trace(DEBUG1) << "options are " << options << "\n";
187
::or_error ret = getRawData(rawdata, options);
188
if(ret == OR_ERROR_NONE) {
189
+ if(rawdata.dataType() != OR_DATA_TYPE_CFA) {
190
+ Trace(DEBUG1) << "wrong data type\n";
191
+ return OR_ERROR_INVALID_FORMAT;
194
or_cfa_pattern pattern;
196
--- libopenraw.orig/testsuite/testsuite.xml
197
+++ libopenraw/testsuite/testsuite.xml
202
+ <name>ORF-test E330</name>
203
+ <file>/home/hub/samples/300mm_f5.6.ORF</file>
204
+ <source>http://raw.fotosite.pl/download-Olympus_E-330_Sigma_135-400_f4.5-5.6/300mm_f5.6.ORF</source>
206
+ <rawType>ORF</rawType>
207
+ <rawTypeId>458757</rawTypeId>
208
+ <thumbNum>1</thumbNum>
209
+ <thumbSizes>160</thumbSizes>
210
+ <thumbFormats>JPEG</thumbFormats>
211
+ <thumbDataSizes>11074</thumbDataSizes>
212
+ <rawDataType>COMP_CFA</rawDataType>
213
+ <rawDataSize>12857600</rawDataSize>
214
+ <rawDataDimensions>3280 2450</rawDataDimensions>
215
+ <rawCfaPattern>RGGB</rawCfaPattern>
216
+ <rawMinValue>0</rawMinValue>
217
+ <rawMaxValue>65535</rawMaxValue>
218
+ <metaOrientation>1</metaOrientation>
222
+ <name>ORF-test E-410</name>
223
+ <file>/home/hub/samples/p1013308.orf</file>
225
+ <rawType>ORF</rawType>
226
+ <rawTypeId>458759</rawTypeId>
227
+ <thumbNum>0</thumbNum>
228
+ <rawDataType>COMP_CFA</rawDataType>
229
+ <rawDataSize>8131436</rawDataSize>
230
+ <rawDataDimensions>3720 2800</rawDataDimensions>
231
+ <rawCfaPattern>RGGB</rawCfaPattern>
232
+ <rawMinValue>0</rawMinValue>
233
+ <rawMaxValue>65535</rawMaxValue>
234
+ <metaOrientation>1</metaOrientation>
238
<name>MRW-test Dimage5</name>
239
<file>/home/hub/samples/mrw/Dimage5/dimage5.mrw</file>
240
<source>http://libopenraw.freedesktop.org/samples/mrw/dimage5.mrw</source>