forked from pool/libopenraw
Accepting request 80859 from home:gary_lin:branches:multimedia:libs
- Merge upstream patch libopenraw-detect-compressed-otf.patch to avoid segfault while loading Olympus raw files (.orf) bnc#561232, fdo#26618 - Rebase and merge upstream patch libopenraw-orf-thumbnail.patch to decompress otf bnc#699678 - Add autoreconf to %build to refresh Makefiles - Remove the invalid link in Source0 OBS-URL: https://build.opensuse.org/request/show/80859 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libopenraw?expand=0&rev=14
This commit is contained in:
parent
7d8917c044
commit
245bf4b713
245
libopenraw-detect-compressed-otf.patch
Normal file
245
libopenraw-detect-compressed-otf.patch
Normal file
@ -0,0 +1,245 @@
|
||||
commit 1b15acdcfdc4664bc6c0be473cb6e096071a4e62
|
||||
Author: Hubert Figuiere <hub@figuiere.net>
|
||||
Date: Sat Mar 6 11:41:43 2010 -0800
|
||||
|
||||
- Support (partially) PEF from Pentax K20D.
|
||||
- Detect that ORF file are compressed if they are. (Closes #26618)
|
||||
- Skip compressed CFA when rendering the image. (Closes #25464)
|
||||
|
||||
diff --git a/README b/README
|
||||
index b4716ee..e373a22 100644
|
||||
--- a/README
|
||||
+++ b/README
|
||||
@@ -114,9 +114,9 @@ Olympus ORF Y Y N Y Y Y
|
||||
E-10 B B T
|
||||
E-3 T T T
|
||||
E-300 T T B T T T
|
||||
- E-330 T T T
|
||||
+ E-330 T T N T
|
||||
E-400 T B T T
|
||||
- E-410 B T T T
|
||||
+ E-410 B T N T T
|
||||
E-500 T T T T
|
||||
E-510 B T T T
|
||||
SP-350
|
||||
@@ -143,6 +143,7 @@ Pentax PEF Y Y N Y Y Y
|
||||
K10D T T N T T T
|
||||
K100D T
|
||||
K100D Super T T N T
|
||||
+ K20D T T N T
|
||||
|
||||
Epson ERF Y Y Y Y Y Y
|
||||
Epson RD1 T T T T T T
|
||||
diff --git a/include/libopenraw/consts.h b/include/libopenraw/consts.h
|
||||
index c2d6bf4..de49034 100644
|
||||
--- a/include/libopenraw/consts.h
|
||||
+++ b/include/libopenraw/consts.h
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* libopenraw - consts.h
|
||||
*
|
||||
- * Copyright (C) 2005-2009 Hubert Figuiere
|
||||
* Copyright (c) 2008 Novell, Inc.
|
||||
+ * Copyright (C) 2005-2010 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
|
||||
@@ -204,7 +204,8 @@ extern "C" {
|
||||
OR_TYPEID_PENTAX_IST_D,
|
||||
OR_TYPEID_PENTAX_IST_DL,
|
||||
OR_TYPEID_PENTAX_K100D_PEF,
|
||||
- OR_TYPEID_PENTAX_K100D_SUPER_PEF
|
||||
+ OR_TYPEID_PENTAX_K100D_SUPER_PEF,
|
||||
+ OR_TYPEID_PENTAX_K20D_PEF
|
||||
};
|
||||
|
||||
/** Epson type IDs */
|
||||
diff --git a/lib/orffile.cpp b/lib/orffile.cpp
|
||||
index c9f0181..28980f4 100644
|
||||
--- a/lib/orffile.cpp
|
||||
+++ b/lib/orffile.cpp
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libopenraw - orffile.cpp
|
||||
*
|
||||
- * Copyright (C) 2006, 2008 Hubert Figuiere
|
||||
+ * Copyright (C) 2006, 2008, 2010 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
|
||||
@@ -77,7 +77,7 @@ namespace OpenRaw {
|
||||
|
||||
IFDDir::Ref ORFFile::_locateCfaIfd()
|
||||
{
|
||||
- // in PEF the CFA IFD is the main IFD
|
||||
+ // in ORF the CFA IFD is the main IFD
|
||||
if(!m_mainIfd) {
|
||||
m_mainIfd = _locateMainIfd();
|
||||
}
|
||||
@@ -92,12 +92,37 @@ namespace OpenRaw {
|
||||
|
||||
|
||||
|
||||
- ::or_error ORFFile::_getRawData(RawData & data, uint32_t /*options*/)
|
||||
+ ::or_error ORFFile::_getRawData(RawData & data, uint32_t options)
|
||||
{
|
||||
+ ::or_error err;
|
||||
if(!m_cfaIfd) {
|
||||
m_cfaIfd = _locateCfaIfd();
|
||||
}
|
||||
- return _getRawDataFromDir(data, m_cfaIfd);
|
||||
+ err = _getRawDataFromDir(data, m_cfaIfd);
|
||||
+ if(err == OR_ERROR_NONE) {
|
||||
+ // ORF files seems to be marked as uncompressed even if they are.
|
||||
+ uint32_t x = data.x();
|
||||
+ uint32_t y = data.y();
|
||||
+ uint16_t compression = 0;
|
||||
+ if(data.size() < x * y * 2) {
|
||||
+ compression = 65535;
|
||||
+ data.setCompression(65535);
|
||||
+ data.setDataType(OR_DATA_TYPE_COMPRESSED_CFA);
|
||||
+ }
|
||||
+ else {
|
||||
+ compression = data.compression();
|
||||
+ }
|
||||
+ switch(compression) {
|
||||
+ case 65535:
|
||||
+ if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
|
||||
+ // TODO decompress
|
||||
+ }
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ return err;
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/lib/peffile.cpp b/lib/peffile.cpp
|
||||
index d8849fb..cef6b27 100644
|
||||
--- a/lib/peffile.cpp
|
||||
+++ b/lib/peffile.cpp
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libopenraw - peffile.cpp
|
||||
*
|
||||
- * Copyright (C) 2006-2008 Hubert Figuiere
|
||||
+ * Copyright (C) 2006-2008, 2010 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
|
||||
@@ -48,6 +48,8 @@ namespace OpenRaw {
|
||||
OR_TYPEID_PENTAX_K100D_PEF) },
|
||||
{ "PENTAX K100D Super ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
|
||||
OR_TYPEID_PENTAX_K100D_PEF) },
|
||||
+ { "PENTAX K20D ", OR_MAKE_FILE_TYPEID(OR_TYPEID_VENDOR_PENTAX,
|
||||
+ OR_TYPEID_PENTAX_K20D_PEF) },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@@ -83,7 +85,7 @@ namespace OpenRaw {
|
||||
return m_container->setDirectory(0);
|
||||
}
|
||||
|
||||
- ::or_error PEFFile::_getRawData(RawData & data, uint32_t /*options*/)
|
||||
+ ::or_error PEFFile::_getRawData(RawData & data, uint32_t options)
|
||||
{
|
||||
::or_error err;
|
||||
if(!m_cfaIfd) {
|
||||
@@ -91,14 +93,12 @@ namespace OpenRaw {
|
||||
}
|
||||
err = _getRawDataFromDir(data, m_cfaIfd);
|
||||
if(err == OR_ERROR_NONE) {
|
||||
- uint16_t compression = 0;
|
||||
- m_cfaIfd->getValue(IFD::EXIF_TAG_COMPRESSION, compression);
|
||||
- switch(compression) {
|
||||
- case 1:
|
||||
- data.setDataType(OR_DATA_TYPE_CFA);
|
||||
- break;
|
||||
- case 65535:
|
||||
- // TODO decompress
|
||||
+ uint16_t compression = data.compression();
|
||||
+ switch(compression) {
|
||||
+ case 65535:
|
||||
+ if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
|
||||
+ // TODO decompress
|
||||
+ }
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
diff --git a/lib/rawfile.cpp b/lib/rawfile.cpp
|
||||
index 6b0821b..c1c11cb 100644
|
||||
--- a/lib/rawfile.cpp
|
||||
+++ b/lib/rawfile.cpp
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* libopenraw - rawfile.cpp
|
||||
*
|
||||
- * Copyright (C) 2006-2008 Hubert Figuiere
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
+ * Copyright (C) 2006-2008, 2010 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
|
||||
@@ -379,8 +379,13 @@ const std::vector<uint32_t> & RawFile::listThumbnailSizes(void)
|
||||
::or_error RawFile::getRenderedImage(BitmapData & bitmapdata, uint32_t options)
|
||||
{
|
||||
RawData rawdata;
|
||||
+ Trace(DEBUG1) << "options are " << options << "\n";
|
||||
::or_error ret = getRawData(rawdata, options);
|
||||
if(ret == OR_ERROR_NONE) {
|
||||
+ if(rawdata.dataType() != OR_DATA_TYPE_CFA) {
|
||||
+ Trace(DEBUG1) << "wrong data type\n";
|
||||
+ return OR_ERROR_INVALID_FORMAT;
|
||||
+ }
|
||||
uint32_t x,y;
|
||||
or_cfa_pattern pattern;
|
||||
uint16_t *src;
|
||||
diff --git a/testsuite/testsuite.xml b/testsuite/testsuite.xml
|
||||
index 9f18dec..c5964b4 100644
|
||||
--- a/testsuite/testsuite.xml
|
||||
+++ b/testsuite/testsuite.xml
|
||||
@@ -346,6 +346,42 @@
|
||||
</results>
|
||||
</test>
|
||||
<test>
|
||||
+ <name>ORF-test E330</name>
|
||||
+ <file>/home/hub/samples/300mm_f5.6.ORF</file>
|
||||
+ <source>http://raw.fotosite.pl/download-Olympus_E-330_Sigma_135-400_f4.5-5.6/300mm_f5.6.ORF</source>
|
||||
+ <results>
|
||||
+ <rawType>ORF</rawType>
|
||||
+ <rawTypeId>458757</rawTypeId>
|
||||
+ <thumbNum>1</thumbNum>
|
||||
+ <thumbSizes>160</thumbSizes>
|
||||
+ <thumbFormats>JPEG</thumbFormats>
|
||||
+ <thumbDataSizes>11074</thumbDataSizes>
|
||||
+ <rawDataType>COMP_CFA</rawDataType>
|
||||
+ <rawDataSize>12857600</rawDataSize>
|
||||
+ <rawDataDimensions>3280 2450</rawDataDimensions>
|
||||
+ <rawCfaPattern>RGGB</rawCfaPattern>
|
||||
+ <rawMinValue>0</rawMinValue>
|
||||
+ <rawMaxValue>65535</rawMaxValue>
|
||||
+ <metaOrientation>1</metaOrientation>
|
||||
+ </results>
|
||||
+ </test>
|
||||
+ <test>
|
||||
+ <name>ORF-test E-410</name>
|
||||
+ <file>/home/hub/samples/p1013308.orf</file>
|
||||
+ <results>
|
||||
+ <rawType>ORF</rawType>
|
||||
+ <rawTypeId>458759</rawTypeId>
|
||||
+ <thumbNum>0</thumbNum>
|
||||
+ <rawDataType>COMP_CFA</rawDataType>
|
||||
+ <rawDataSize>8131436</rawDataSize>
|
||||
+ <rawDataDimensions>3720 2800</rawDataDimensions>
|
||||
+ <rawCfaPattern>RGGB</rawCfaPattern>
|
||||
+ <rawMinValue>0</rawMinValue>
|
||||
+ <rawMaxValue>65535</rawMaxValue>
|
||||
+ <metaOrientation>1</metaOrientation>
|
||||
+ </results>
|
||||
+ </test>
|
||||
+ <test>
|
||||
<name>MRW-test Dimage5</name>
|
||||
<file>/home/hub/samples/mrw/Dimage5/dimage5.mrw</file>
|
||||
<source>http://libopenraw.freedesktop.org/samples/mrw/dimage5.mrw</source>
|
582
libopenraw-orf-thumbnail.patch
Normal file
582
libopenraw-orf-thumbnail.patch
Normal file
@ -0,0 +1,582 @@
|
||||
From 9be26e10ecbf89ce99b294906be1208d5a484c7e Mon Sep 17 00:00:00 2001
|
||||
From: Hubert Figuiere <hub@figuiere.net>
|
||||
Date: Fri, 18 Mar 2011 23:41:38 -0700
|
||||
Subject: [PATCH 1/2] Better support for compression ID
|
||||
Implement Olympus decompression (with decompressor borrowed from RawSpeed)
|
||||
|
||||
---
|
||||
AUTHORS | 3 +
|
||||
lib/Makefile.am | 2 +
|
||||
lib/bititerator.cpp | 30 +++++--
|
||||
lib/bititerator.h | 4 +-
|
||||
lib/dngfile.cpp | 2 +-
|
||||
lib/ifd.h | 4 +-
|
||||
lib/ifdfile.cpp | 14 +++-
|
||||
lib/ifdfile.h | 7 ++
|
||||
lib/olympusdecompressor.cpp | 205 +++++++++++++++++++++++++++++++++++++++++++
|
||||
lib/olympusdecompressor.h | 51 +++++++++++
|
||||
lib/orffile.cpp | 28 +++++-
|
||||
lib/orffile.h | 5 +
|
||||
lib/peffile.cpp | 2 +-
|
||||
13 files changed, 338 insertions(+), 19 deletions(-)
|
||||
create mode 100644 lib/olympusdecompressor.cpp
|
||||
create mode 100644 lib/olympusdecompressor.h
|
||||
|
||||
Index: libopenraw-0.0.8/AUTHORS
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/AUTHORS
|
||||
+++ libopenraw-0.0.8/AUTHORS
|
||||
@@ -4,6 +4,9 @@ MRW support: Bradley Broom
|
||||
NEF decompression: Rafael Espíndola
|
||||
Python bindings: Brian Quinlan
|
||||
|
||||
+Indirect contributors:
|
||||
+Klaus Post for code from RawSpeed.
|
||||
+
|
||||
Sponsors:
|
||||
Novell sponsored time to work on libopenraw as part of their ITO programme
|
||||
(and HackWeek in February 2008)
|
||||
Index: libopenraw-0.0.8/lib/Makefile.am
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/Makefile.am
|
||||
+++ libopenraw-0.0.8/lib/Makefile.am
|
||||
@@ -32,6 +32,7 @@ noinst_HEADERS = or_debug.h \
|
||||
ljpegdecompressor.h \
|
||||
ljpegdecompressor_priv.h \
|
||||
crwdecompressor.h \
|
||||
+ olympusdecompressor.h \
|
||||
exception.h \
|
||||
endianutils.h \
|
||||
metavalue.h \
|
||||
@@ -83,6 +84,7 @@ libopenraw_la_SOURCES = \
|
||||
decompressor.cpp \
|
||||
ljpegdecompressor.cpp \
|
||||
crwdecompressor.cpp \
|
||||
+ olympusdecompressor.cpp \
|
||||
metavalue.cpp \
|
||||
unpack.cpp \
|
||||
bimedian_demosaic.cpp demosaic.h \
|
||||
Index: libopenraw-0.0.8/lib/bititerator.cpp
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/bititerator.cpp
|
||||
+++ libopenraw-0.0.8/lib/bititerator.cpp
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
+#include <algorithm>
|
||||
#include "bititerator.h"
|
||||
|
||||
namespace OpenRaw {
|
||||
@@ -53,22 +54,35 @@ void BitIterator::load(size_t numBits)
|
||||
|
||||
uint32_t BitIterator::get(size_t n)
|
||||
{
|
||||
- assert(n <= 25);
|
||||
+ uint32_t ret = peek(n);
|
||||
+
|
||||
+ skip(n);
|
||||
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+uint32_t BitIterator::peek(size_t n)
|
||||
+{
|
||||
+ assert(n <= 25);
|
||||
+
|
||||
if (n == 0)
|
||||
return 0;
|
||||
-
|
||||
+
|
||||
if (n > m_bitsOnBuffer)
|
||||
load(n - m_bitsOnBuffer);
|
||||
-
|
||||
+
|
||||
assert(n <= m_bitsOnBuffer);
|
||||
+
|
||||
+ return m_bitBuffer >> (32 - n);
|
||||
+}
|
||||
|
||||
- uint32_t ret = m_bitBuffer >> (32 - n);
|
||||
- m_bitsOnBuffer -= n;
|
||||
- m_bitBuffer <<= n;
|
||||
-
|
||||
- return ret;
|
||||
+void BitIterator::skip(size_t n)
|
||||
+{
|
||||
+ size_t num_bits = std::min(n, m_bitsOnBuffer);
|
||||
+ m_bitsOnBuffer -= num_bits;
|
||||
+ m_bitBuffer <<= num_bits;
|
||||
}
|
||||
|
||||
+
|
||||
}
|
||||
}
|
||||
Index: libopenraw-0.0.8/lib/bititerator.h
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/bititerator.h
|
||||
+++ libopenraw-0.0.8/lib/bititerator.h
|
||||
@@ -31,12 +31,14 @@ namespace Internals {
|
||||
class BitIterator {
|
||||
const uint8_t* m_p;
|
||||
uint32_t m_bitBuffer;
|
||||
- uint8_t m_bitsOnBuffer;
|
||||
+ size_t m_bitsOnBuffer;
|
||||
void load(size_t numBits);
|
||||
|
||||
public:
|
||||
BitIterator(const void *);
|
||||
uint32_t get(size_t);
|
||||
+ uint32_t peek(size_t);
|
||||
+ void skip(size_t);
|
||||
};
|
||||
|
||||
}
|
||||
Index: libopenraw-0.0.8/lib/dngfile.cpp
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/dngfile.cpp
|
||||
+++ libopenraw-0.0.8/lib/dngfile.cpp
|
||||
@@ -89,7 +89,7 @@ namespace OpenRaw {
|
||||
if(ret == OR_ERROR_NONE) {
|
||||
uint16_t compression = 0;
|
||||
if (m_cfaIfd->getValue(IFD::EXIF_TAG_COMPRESSION, compression) &&
|
||||
- compression == 7) {
|
||||
+ compression == IFD::COMPRESS_LJPEG) {
|
||||
// if the option is not set, decompress
|
||||
if ((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
|
||||
boost::scoped_ptr<IO::Stream> s(new IO::MemStream(data.data(),
|
||||
Index: libopenraw-0.0.8/lib/ifd.h
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/ifd.h
|
||||
+++ libopenraw-0.0.8/lib/ifd.h
|
||||
@@ -69,8 +69,10 @@ namespace OpenRaw {
|
||||
typedef enum {
|
||||
COMPRESS_NONE = 1,
|
||||
COMPRESS_JPEG = 6,
|
||||
+ COMPRESS_LJPEG = 7, /**< Lossless JPEG, see DNG */
|
||||
COMPRESS_NIKON_PACK = 32769,
|
||||
- COMPRESS_NIKON_QUANTIZED = 34713
|
||||
+ COMPRESS_NIKON_QUANTIZED = 34713,
|
||||
+ COMPRESS_CUSTOM = 65535 /**< The value everybody seems to use */
|
||||
} TiffCompress;
|
||||
}
|
||||
}
|
||||
Index: libopenraw-0.0.8/lib/ifdfile.cpp
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/ifdfile.cpp
|
||||
+++ libopenraw-0.0.8/lib/ifdfile.cpp
|
||||
@@ -339,6 +339,15 @@ MetaValue *IFDFile::_getMetaValue(int32_
|
||||
}
|
||||
return val;
|
||||
}
|
||||
+
|
||||
+/** by default we don't translate the compression
|
||||
+ */
|
||||
+uint32_t IFDFile::_translateCompressionType(IFD::TiffCompress tiffCompression)
|
||||
+{
|
||||
+ return (uint32_t)tiffCompression;
|
||||
+}
|
||||
+
|
||||
+
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -541,14 +550,15 @@ static RawData::CfaPattern _getCfaPatter
|
||||
return OR_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
- uint32_t compression = 0;
|
||||
- got_it = dir->getIntegerValue(IFD::EXIF_TAG_COMPRESSION, compression);
|
||||
+ uint16_t tiffCompression = 0;
|
||||
+ got_it = dir->getValue(IFD::EXIF_TAG_COMPRESSION, tiffCompression);
|
||||
if(!got_it)
|
||||
{
|
||||
Trace(DEBUG1) << "Compression type not found\n";
|
||||
}
|
||||
BitmapData::DataType data_type = OR_DATA_TYPE_NONE;
|
||||
|
||||
+ uint32_t compression = _translateCompressionType((IFD::TiffCompress)tiffCompression);
|
||||
switch(compression)
|
||||
{
|
||||
case IFD::COMPRESS_NONE:
|
||||
Index: libopenraw-0.0.8/lib/ifdfile.h
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/ifdfile.h
|
||||
+++ libopenraw-0.0.8/lib/ifdfile.h
|
||||
@@ -102,6 +102,13 @@ namespace OpenRaw {
|
||||
|
||||
virtual MetaValue *_getMetaValue(int32_t meta_index);
|
||||
|
||||
+ /** Translate the compression type from the tiff type (16MSB)
|
||||
+ * to the RAW specific type if needed (16MSB)
|
||||
+ * @param tiffCompression the 16 bits value from TIFF
|
||||
+ * @return the actually value. Anything >= 2^16 is specific the RAW type
|
||||
+ */
|
||||
+ virtual uint32_t _translateCompressionType(IFD::TiffCompress tiffCompression);
|
||||
+
|
||||
IFDDir::Ref m_cfaIfd; /**< the IFD for the CFA */
|
||||
IFDDir::Ref m_mainIfd; /**< the IFD for the main image
|
||||
* does not necessarily reference
|
||||
Index: libopenraw-0.0.8/lib/olympusdecompressor.cpp
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ libopenraw-0.0.8/lib/olympusdecompressor.cpp
|
||||
@@ -0,0 +1,207 @@
|
||||
+/*
|
||||
+ * libopenraw - olympusdecompressor.cpp
|
||||
+ *
|
||||
+ * Copyright (C) 2011 Hubert Figuiere
|
||||
+ * Olympus Decompression copied from RawSpeed
|
||||
+ * Copyright (C) 2009 Klaus Post
|
||||
+ *
|
||||
+ * 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/>.
|
||||
+ */
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
+#include <libopenraw++/rawdata.h>
|
||||
+
|
||||
+#include "io/stream.h"
|
||||
+#include "olympusdecompressor.h"
|
||||
+#include "bititerator.h"
|
||||
+
|
||||
+
|
||||
+namespace OpenRaw {
|
||||
+namespace Internals {
|
||||
+
|
||||
+static void decompressOlympus(const uint8_t* buffer, uint8_t* data, uint32_t w, uint32_t h);
|
||||
+
|
||||
+// decompression ported from RawSpeed.
|
||||
+static void decompressOlympus(const uint8_t* buffer, uint8_t* data, uint32_t w, uint32_t h)
|
||||
+{
|
||||
+ int nbits, sign, low, high, i, wo0, n, nw0, wo1, nw1;
|
||||
+ int acarry0[3], acarry1[3], pred, diff;
|
||||
+
|
||||
+ int pitch = w * 2; //(((w * 2/*bpp*/) + 15) / 16) * 16; // TODO make that part of the outer datas
|
||||
+
|
||||
+ /* Build a table to quickly look up "high" value */
|
||||
+ char bittable[4096];
|
||||
+ for (i = 0; i < 4096; i++) {
|
||||
+ int b = i;
|
||||
+ for (high = 0; high < 12; high++) {
|
||||
+ if ((b>>(11-high))&1) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ bittable[i] = high;
|
||||
+ }
|
||||
+ wo0 = nw0 = wo1 = nw1 = 0;
|
||||
+ buffer += 7;
|
||||
+
|
||||
+ BitIterator bits(buffer);
|
||||
+
|
||||
+ for (uint32_t y = 0; y < h; y++) {
|
||||
+ memset(acarry0, 0, sizeof acarry0);
|
||||
+ memset(acarry1, 0, sizeof acarry1);
|
||||
+ uint16_t* dest = (uint16_t*) & data[y*pitch];
|
||||
+ for (uint32_t x = 0; x < w; x++) {
|
||||
+// bits.checkPos();
|
||||
+// bits.fill();
|
||||
+ i = 2 * (acarry0[2] < 3);
|
||||
+ for (nbits = 2 + i; (uint16_t) acarry0[0] >> (nbits + i); nbits++) {
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ uint32_t b = bits.peek(15);
|
||||
+ sign = (b >> 14) * -1;
|
||||
+ low = (b >> 12) & 3;
|
||||
+ high = bittable[b&4095];
|
||||
+ // Skip bits used above.
|
||||
+ bits.skip(std::min(12+3, high + 1 + 3));
|
||||
+
|
||||
+ if (high == 12) {
|
||||
+ high = bits.get(16 - nbits) >> 1;
|
||||
+ }
|
||||
+
|
||||
+ acarry0[0] = (high << nbits) | bits.get(nbits);
|
||||
+ diff = (acarry0[0] ^ sign) + acarry0[1];
|
||||
+ acarry0[1] = (diff * 3 + acarry0[1]) >> 5;
|
||||
+ acarry0[2] = acarry0[0] > 16 ? 0 : acarry0[2] + 1;
|
||||
+
|
||||
+ if (y < 2 || x < 2) {
|
||||
+ if (y < 2 && x < 2) {
|
||||
+ pred = 0;
|
||||
+ }
|
||||
+ else if (y < 2) {
|
||||
+ pred = wo0;
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = dest[-pitch+((int)x)];
|
||||
+ nw0 = pred;
|
||||
+ }
|
||||
+ dest[x] = pred + ((diff << 2) | low);
|
||||
+ // Set predictor
|
||||
+ wo0 = dest[x];
|
||||
+ }
|
||||
+ else {
|
||||
+ n = dest[-pitch+((int)x)];
|
||||
+ if (((wo0 < nw0) & (nw0 < n)) | ((n < nw0) & (nw0 < wo0))) {
|
||||
+ if (abs(wo0 - nw0) > 32 || abs(n - nw0) > 32) {
|
||||
+ pred = wo0 + n - nw0;
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = (wo0 + n) >> 1;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = abs(wo0 - nw0) > abs(n - nw0) ? wo0 : n;
|
||||
+ }
|
||||
+
|
||||
+ dest[x] = pred + ((diff << 2) | low);
|
||||
+ // Set predictors
|
||||
+ wo0 = dest[x];
|
||||
+ nw0 = n;
|
||||
+ }
|
||||
+ // _ASSERTE(0 == dest[x] >> 12) ;
|
||||
+
|
||||
+ // ODD PIXELS
|
||||
+ x += 1;
|
||||
+// bits.checkPos();
|
||||
+// bits.fill();
|
||||
+ i = 2 * (acarry1[2] < 3);
|
||||
+ for (nbits = 2 + i; (uint16_t) acarry1[0] >> (nbits + i); nbits++) {
|
||||
+
|
||||
+ }
|
||||
+ b = bits.peek(15);
|
||||
+ sign = (b >> 14) * -1;
|
||||
+ low = (b >> 12) & 3;
|
||||
+ high = bittable[b&4095];
|
||||
+ // Skip bits used above.
|
||||
+ bits.skip(std::min(12+3, high + 1 + 3));
|
||||
+
|
||||
+ if (high == 12) {
|
||||
+ high = bits.get(16 - nbits) >> 1;
|
||||
+ }
|
||||
+
|
||||
+ acarry1[0] = (high << nbits) | bits.get(nbits);
|
||||
+ diff = (acarry1[0] ^ sign) + acarry1[1];
|
||||
+ acarry1[1] = (diff * 3 + acarry1[1]) >> 5;
|
||||
+ acarry1[2] = acarry1[0] > 16 ? 0 : acarry1[2] + 1;
|
||||
+
|
||||
+ if (y < 2 || x < 2) {
|
||||
+ if (y < 2 && x < 2) {
|
||||
+ pred = 0;
|
||||
+ }
|
||||
+ else if (y < 2) {
|
||||
+ pred = wo1;
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = dest[-pitch+((int)x)];
|
||||
+ nw1 = pred;
|
||||
+ }
|
||||
+ dest[x] = pred + ((diff << 2) | low);
|
||||
+ // Set predictor
|
||||
+ wo1 = dest[x];
|
||||
+ }
|
||||
+ else {
|
||||
+ n = dest[-pitch+((int)x)];
|
||||
+ if (((wo1 < nw1) & (nw1 < n)) | ((n < nw1) & (nw1 < wo1))) {
|
||||
+ if (abs(wo1 - nw1) > 32 || abs(n - nw1) > 32) {
|
||||
+ pred = wo1 + n - nw1;
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = (wo1 + n) >> 1;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ pred = abs(wo1 - nw1) > abs(n - nw1) ? wo1 : n;
|
||||
+ }
|
||||
+
|
||||
+ dest[x] = pred + ((diff << 2) | low);
|
||||
+
|
||||
+ // Set predictors
|
||||
+ wo1 = dest[x];
|
||||
+ nw1 = n;
|
||||
+ }
|
||||
+ // _ASSERTE(0 == dest[x] >> 12) ;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+RawData *OlympusDecompressor::decompress(RawData *in)
|
||||
+{
|
||||
+ RawData *output;
|
||||
+ if(in) {
|
||||
+ output = in;
|
||||
+ }
|
||||
+ else {
|
||||
+ output = new RawData;
|
||||
+ }
|
||||
+
|
||||
+ output->allocData(m_w * m_h * 2);
|
||||
+ decompressOlympus(m_buffer, (uint8_t*)output->data(), m_w, m_h);
|
||||
+
|
||||
+ return output;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+}
|
||||
+}
|
||||
Index: libopenraw-0.0.8/lib/olympusdecompressor.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ libopenraw-0.0.8/lib/olympusdecompressor.h
|
||||
@@ -0,0 +1,51 @@
|
||||
+/*
|
||||
+ * libopenraw - olympusdecompressor.cpp
|
||||
+ *
|
||||
+ * Copyright (C) 2011 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
|
||||
+ * 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/>.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+#ifndef __OPENRAW_OLYMPUSDECOMPRESSOR_H__
|
||||
+#define __OPENRAW_OLYMPUSDECOMPRESSOR_H__
|
||||
+
|
||||
+#include "decompressor.h"
|
||||
+
|
||||
+namespace OpenRaw {
|
||||
+namespace Internals {
|
||||
+
|
||||
+class OlympusDecompressor
|
||||
+ : public Decompressor
|
||||
+{
|
||||
+public:
|
||||
+ OlympusDecompressor(const uint8_t *buffer,
|
||||
+ RawContainer * container, uint32_t w, uint32_t h)
|
||||
+ : Decompressor(NULL, container)
|
||||
+ , m_buffer(buffer)
|
||||
+ , m_h(h)
|
||||
+ , m_w(w)
|
||||
+ {
|
||||
+ }
|
||||
+ virtual RawData *decompress(RawData *in = NULL);
|
||||
+private:
|
||||
+ const uint8_t *m_buffer;
|
||||
+ uint32_t m_h;
|
||||
+ uint32_t m_w;
|
||||
+};
|
||||
+
|
||||
+}
|
||||
+}
|
||||
+#endif
|
||||
Index: libopenraw-0.0.8/lib/orffile.cpp
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/orffile.cpp
|
||||
+++ libopenraw-0.0.8/lib/orffile.cpp
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "ifddir.h"
|
||||
#include "ifdentry.h"
|
||||
#include "orfcontainer.h"
|
||||
+#include "olympusdecompressor.h"
|
||||
#include "io/file.h"
|
||||
|
||||
using namespace Debug;
|
||||
@@ -103,19 +104,27 @@ namespace OpenRaw {
|
||||
// ORF files seems to be marked as uncompressed even if they are.
|
||||
uint32_t x = data.x();
|
||||
uint32_t y = data.y();
|
||||
- uint16_t compression = 0;
|
||||
+ uint32_t compression = 0;
|
||||
if(data.size() < x * y * 2) {
|
||||
- compression = 65535;
|
||||
- data.setCompression(65535);
|
||||
+ compression = ORF_COMPRESSION;
|
||||
+ data.setCompression(ORF_COMPRESSION);
|
||||
data.setDataType(OR_DATA_TYPE_COMPRESSED_CFA);
|
||||
}
|
||||
else {
|
||||
compression = data.compression();
|
||||
}
|
||||
switch(compression) {
|
||||
- case 65535:
|
||||
+ case ORF_COMPRESSION:
|
||||
if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
|
||||
- // TODO decompress
|
||||
+ OlympusDecompressor decomp((const uint8_t*)data.data(), m_container, x, y);
|
||||
+ RawData *dData = decomp.decompress(NULL);
|
||||
+ if (dData != NULL) {
|
||||
+ dData->setCfaPattern(data.cfaPattern());
|
||||
+ data.swap(*dData);
|
||||
+ data.setDataType(OR_DATA_TYPE_CFA);
|
||||
+ data.setDimensions(x, y);
|
||||
+ delete dData;
|
||||
+ }
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -124,6 +133,15 @@ namespace OpenRaw {
|
||||
}
|
||||
return err;
|
||||
}
|
||||
+
|
||||
+uint32_t ORFFile::_translateCompressionType(IFD::TiffCompress tiffCompression)
|
||||
+{
|
||||
+ if(tiffCompression == IFD::COMPRESS_CUSTOM) {
|
||||
+ return ORF_COMPRESSION;
|
||||
+ }
|
||||
+ return (uint32_t)tiffCompression;
|
||||
+}
|
||||
+
|
||||
|
||||
}
|
||||
}
|
||||
Index: libopenraw-0.0.8/lib/orffile.h
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/orffile.h
|
||||
+++ libopenraw-0.0.8/lib/orffile.h
|
||||
@@ -43,11 +43,16 @@ namespace OpenRaw {
|
||||
ORFFile(IO::Stream *);
|
||||
virtual ~ORFFile();
|
||||
|
||||
+ enum {
|
||||
+ ORF_COMPRESSION = 0x10000
|
||||
+ };
|
||||
+
|
||||
protected:
|
||||
virtual IFDDir::Ref _locateCfaIfd();
|
||||
virtual IFDDir::Ref _locateMainIfd();
|
||||
|
||||
virtual ::or_error _getRawData(RawData & data, uint32_t options);
|
||||
+ virtual uint32_t _translateCompressionType(IFD::TiffCompress tiffCompression);
|
||||
private:
|
||||
static RawFile::TypeId _typeIdFromModel(const std::string & model);
|
||||
|
||||
Index: libopenraw-0.0.8/lib/peffile.cpp
|
||||
===================================================================
|
||||
--- libopenraw-0.0.8.orig/lib/peffile.cpp
|
||||
+++ libopenraw-0.0.8/lib/peffile.cpp
|
||||
@@ -95,7 +95,7 @@ namespace OpenRaw {
|
||||
if(err == OR_ERROR_NONE) {
|
||||
uint16_t compression = data.compression();
|
||||
switch(compression) {
|
||||
- case 65535:
|
||||
+ case IFD::COMPRESS_CUSTOM:
|
||||
if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) {
|
||||
// TODO decompress
|
||||
}
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 5 02:18:19 UTC 2011 - glin@suse.com
|
||||
|
||||
- Merge upstream patch libopenraw-detect-compressed-otf.patch to
|
||||
avoid segfault while loading Olympus raw files (.orf)
|
||||
bnc#561232, fdo#26618
|
||||
- Rebase and merge upstream patch libopenraw-orf-thumbnail.patch to
|
||||
decompress otf bnc#699678
|
||||
- Add autoreconf to %build to refresh Makefiles
|
||||
- Remove the invalid link in Source0
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 11 21:22:12 CEST 2010 - vuntz@opensuse.org
|
||||
|
||||
|
@ -24,10 +24,14 @@ Version: 0.0.8
|
||||
Release: 13
|
||||
License: LGPLv2.1+
|
||||
Group: Development/Libraries/C and C++
|
||||
Source0: http://libopenraw.freedesktop.org/download/%name-%{version}.tar.bz2
|
||||
Source0: %name-%{version}.tar.bz2
|
||||
Source99: baselibs.conf
|
||||
# PATCH-FIX-UPSTREAM libopenraw-gdk-pixbuf-loaders-path.patch fdo29208 -- Install gdk-pixbuf module in the right directory, only works with gdk-pixbuf >= 2.21
|
||||
Patch0: libopenraw-gdk-pixbuf-loaders-path.patch
|
||||
# PATCH-FIX-UPSTREAM libopenraw-detect-compressed-otf.patch bnc561232 fdo26618 glin@suse.com -- Detect the compressed otf file to avoid potential segfault
|
||||
Patch1: libopenraw-detect-compressed-otf.patch
|
||||
# PATCH-FIX-UPSTREAM libopenraw-orf-thumbnail.patch bnc699678 glin@suse.com - Decompress otf files
|
||||
Patch2: libopenraw-orf-thumbnail.patch
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: boost-devel >= 1.33.1
|
||||
BuildRequires: libjpeg-devel
|
||||
@ -73,8 +77,11 @@ libopenraw is a library that aim at decoding digital camera RAW files.
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
|
||||
%build
|
||||
autoreconf
|
||||
%configure --disable-static --with-pic
|
||||
%{__make} %{?jobs:-j%jobs}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user