Squashed 'rtengine/libraw/' content from commit cccb97647

git-subtree-dir: rtengine/libraw
git-subtree-split: cccb97647fcee56801fa68231fa8a38aa8b52ef7
This commit is contained in:
Lawrence Lee
2023-11-12 11:49:00 -08:00
commit 638ecc4cde
213 changed files with 77043 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
diff --git a/RawSpeed/Common.cpp b/RawSpeed/Common.cpp
index abec232..6990c04 100644
--- a/RawSpeed/Common.cpp
+++ b/RawSpeed/Common.cpp
@@ -31,5 +31,10 @@ void* _aligned_malloc(size_t bytes, size_t alignment) {
else
return NULL;
}
+#include <unistd.h>
+int rawspeed_get_number_of_processor_cores()
+{
+ return sysconf( _SC_NPROCESSORS_ONLN );
+}
#endif

View File

@@ -0,0 +1,84 @@
diff --git a/RawSpeed/rawspeed-lib.pro b/RawSpeed/rawspeed-lib.pro
new file mode 100644
index 0000000..1599ddf
--- /dev/null
+++ b/RawSpeed/rawspeed-lib.pro
@@ -0,0 +1,42 @@
+TEMPLATE=lib
+TARGET=rawspeed
+
+win32:INCLUDEPATH+=d:/Qt/iconv/include d:/Qt/libxml2/include/libxml2 d:/Qt/pthreads/include d:/Qt/libjpeg-turbo/include
+win32:LIBS+=-Ld:/Qt/iconv/lib/x86 -liconv -Ld:/Qt/libxml2/lib/x86 -llibxml2 -Ld:/Qt/pthreads/lib/x86 -lpthreadVC2 -Ld:/Qt/libjpeg-turbo/lib/x86 -ljpeg8
+
+unix:INCLUDEPATH+=/usr/local/include /usr/local/include/libxml2
+unix:CONFIG+=staticlib
+
+INCLUDEPATH+=.
+
+HEADERS = ArwDecoder.h BitPumpJPEG.h BitPumpMSB.h BitPumpMSB32.h \
+ BitPumpPlain.h BlackArea.h ByteStream.h ByteStreamSwap.h \
+ Camera.h CameraMetaData.h CameraMetadataException.h \
+ CameraSensorInfo.h ColorFilterArray.h Common.h Cr2Decoder.h \
+ DngDecoder.h DngDecoderSlices.h DngOpcodes.h FileIOException.h \
+ FileMap.h FileReader.h IOException.h LJpegDecompressor.h \
+ LJpegPlain.h NefDecoder.h NikonDecompressor.h OrfDecoder.h \
+ PefDecoder.h PentaxDecompressor.h Point.h RawDecoder.h \
+ RawDecoderException.h RawImage.h RawParser.h Rw2Decoder.h SrwDecoder.h \
+ StdAfx.h TiffEntry.h TiffEntryBE.h TiffIFD.h TiffIFDBE.h TiffParser.h \
+ TiffParserException.h TiffParserHeaderless.h TiffParserOlympus.h \
+ TiffTag.h dlldef.h
+
+SOURCES = \
+ ArwDecoder.cpp BitPumpJPEG.cpp BitPumpMSB.cpp BitPumpMSB32.cpp \
+ BitPumpPlain.cpp BlackArea.cpp ByteStream.cpp ByteStreamSwap.cpp \
+ Camera.cpp CameraMetaData.cpp CameraMetadataException.cpp \
+ CameraSensorInfo.cpp ColorFilterArray.cpp Common.cpp Cr2Decoder.cpp \
+ DngDecoder.cpp DngDecoderSlices.cpp DngOpcodes.cpp \
+ FileIOException.cpp FileMap.cpp FileReader.cpp IOException.cpp \
+ LJpegDecompressor.cpp LJpegPlain.cpp NefDecoder.cpp \
+ NikonDecompressor.cpp OrfDecoder.cpp PefDecoder.cpp \
+ PentaxDecompressor.cpp RawDecoder.cpp RawDecoderException.cpp \
+ RawImage.cpp RawImageDataFloat.cpp RawImageDataU16.cpp RawParser.cpp \
+ Rw2Decoder.cpp SrwDecoder.cpp TiffEntry.cpp TiffEntryBE.cpp\
+ TiffIFD.cpp TiffIFDBE.cpp TiffParser.cpp TiffParserException.cpp \
+ TiffParserHeaderless.cpp TiffParserOlympus.cpp
+
+DEFINES+=RAWSPEED_BUILDLIB
+CONFIG-=qt
+win32:QMAKE_CXXFLAGS+=/O2 /arch:SSE2 /fp:fast /MP
diff --git a/RawSpeed/rawspeed-test.pro b/RawSpeed/rawspeed-test.pro
new file mode 100644
index 0000000..518aa98
--- /dev/null
+++ b/RawSpeed/rawspeed-test.pro
@@ -0,0 +1,21 @@
+TEMPLATE=app
+TARGET=rawspeed-test
+
+SOURCES=RawSpeed.cpp
+
+win32:CONFIG(debug,debug|release) {
+ LIBDIR = debug
+} else {
+ LIBDIR = release
+}
+
+
+INCLUDEPATH+=../
+
+unix:INCLUDEPATH+=/usr/local/include /usr/local/include/libxml2
+unix:LIBS+=-L. -lrawspeed -L/usr/local/lib -lxml2 -ljpeg
+win32:LIBS+=-L$$LIBDIR -llibrawspeed
+win32:LIBS+=-Ld:/Qt/iconv/lib/x86 -liconv -Ld:/Qt/libxml2/lib/x86 -llibxml2a -Ld:/Qt/pthreads/lib/x86 -lpthreadVC2 -Ld:/Qt/libjpeg-turbo/lib/x86 -ljpeg8
+win32:INCLUDEPATH+=d:/Qt/iconv/include d:/Qt/libxml2/include/libxml2 d:/Qt/pthreads/include d:/Qt/libjpeg-turbo/include
+CONFIG-=qt
+CONFIG+=console
diff --git a/RawSpeed/rawspeed.pro b/RawSpeed/rawspeed.pro
new file mode 100644
index 0000000..df2a0b9
--- /dev/null
+++ b/RawSpeed/rawspeed.pro
@@ -0,0 +1,3 @@
+TEMPLATE=subdirs
+SUBDIRS=rawspeed-lib.pro rawspeed-test.pro
+

View File

@@ -0,0 +1,39 @@
diff --git a/RawSpeed/SrwDecoder.cpp b/RawSpeed/SrwDecoder.cpp
index fa46499..1aff689 100644
--- a/RawSpeed/SrwDecoder.cpp
+++ b/RawSpeed/SrwDecoder.cpp
@@ -141,7 +141,7 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw )
// First we decode even pixels
for (int c = 0; c < 16; c += 2) {
int b = len[(c >> 3)];
- int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b));
+ int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0;
img[c] = adj + img_up[c];
}
// Now we decode odd pixels
@@ -149,7 +149,7 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw )
// is beyond me, it will hurt compression a deal.
for (int c = 1; c < 16; c += 2) {
int b = len[2 | (c >> 3)];
- int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b));
+ int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0;
img[c] = adj + img_up2[c];
}
} else {
@@ -158,14 +158,14 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw )
int pred_left = x ? img[-2] : 128;
for (int c = 0; c < 16; c += 2) {
int b = len[(c >> 3)];
- int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b));
+ int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0;
img[c] = adj + pred_left;
}
// Now we decode odd pixels
pred_left = x ? img[-1] : 128;
for (int c = 1; c < 16; c += 2) {
int b = len[2 | (c >> 3)];
- int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b));
+ int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0;
img[c] = adj + pred_left;
}
}

View File

@@ -0,0 +1,13 @@
diff --git a/RawSpeed/DngDecoder.cpp b/RawSpeed/DngDecoder.cpp
index 56c701b..98f2474 100644
--- a/RawSpeed/DngDecoder.cpp
+++ b/RawSpeed/DngDecoder.cpp
@@ -216,7 +216,7 @@ RawImage DngDecoder::decodeRawInternal() {
if (bps != 8 && bps != 16)
big_endian = true;
try {
- readUncompressedRaw(in, size, pos, width*bps / 8, bps, big_endian ? BitOrder_Jpeg : BitOrder_Plain);
+ readUncompressedRaw(in, size, pos, mRaw->getCpp()*width*bps / 8, bps, big_endian ? BitOrder_Jpeg : BitOrder_Plain);
} catch(IOException &ex) {
if (i > 0)
mRaw->setError(ex.what());

View File

@@ -0,0 +1,186 @@
diff --git a/RawSpeed/Camera.h b/RawSpeed/Camera.h
index 7b3045d..4363c1b 100644
--- a/RawSpeed/Camera.h
+++ b/RawSpeed/Camera.h
@@ -6,6 +6,7 @@
#include <libxml/parser.h>
#include "BlackArea.h"
#include "CameraMetadataException.h"
+#include "dlldef.h"
/*
RawSpeed - RAW file decoder.
@@ -30,7 +31,7 @@
namespace RawSpeed {
-class Camera
+class DllDef Camera
{
public:
Camera(xmlDocPtr doc, xmlNodePtr cur);
diff --git a/RawSpeed/CameraMetaData.h b/RawSpeed/CameraMetaData.h
index 616b2bb..c6b8031 100644
--- a/RawSpeed/CameraMetaData.h
+++ b/RawSpeed/CameraMetaData.h
@@ -27,9 +27,10 @@
http://www.klauspost.com
*/
+#include "dlldef.h"
namespace RawSpeed {
-class CameraMetaData
+class DllDef CameraMetaData
{
public:
CameraMetaData();
diff --git a/RawSpeed/CameraMetadataException.h b/RawSpeed/CameraMetadataException.h
index 55a2814..52d5ea1 100644
--- a/RawSpeed/CameraMetadataException.h
+++ b/RawSpeed/CameraMetadataException.h
@@ -22,10 +22,11 @@
#ifndef CAMERA_METADATA_EXCEPTION_H
#define CAMERA_METADATA_EXCEPTION_H
+#include "dlldef.h"
namespace RawSpeed {
-void ThrowCME(const char* fmt, ...);
+void DllDef ThrowCME(const char* fmt, ...);
class CameraMetadataException :
public std::runtime_error
diff --git a/RawSpeed/FileMap.h b/RawSpeed/FileMap.h
index 5c15918..bcd2a79 100644
--- a/RawSpeed/FileMap.h
+++ b/RawSpeed/FileMap.h
@@ -25,6 +25,7 @@
*/
#include "IOException.h"
+#include "dlldef.h"
namespace RawSpeed {
@@ -36,7 +37,7 @@ namespace RawSpeed {
* This can also be done as a MemMap
*
*****************************/
-class FileMap
+class DllDef FileMap
{
public:
FileMap(uint32 _size); // Allocates the data array itself
diff --git a/RawSpeed/FileReader.h b/RawSpeed/FileReader.h
index 7448ec2..fb42ac0 100644
--- a/RawSpeed/FileReader.h
+++ b/RawSpeed/FileReader.h
@@ -24,10 +24,11 @@
#include "FileIOException.h"
#include "FileMap.h"
+#include "dlldef.h"
namespace RawSpeed {
-class FileReader
+class DllDef FileReader
{
public:
FileReader(LPCWSTR filename);
diff --git a/RawSpeed/RawDecoder.h b/RawSpeed/RawDecoder.h
index a6c4708..b35cae5 100644
--- a/RawSpeed/RawDecoder.h
+++ b/RawSpeed/RawDecoder.h
@@ -9,6 +9,7 @@
#include "BitPumpPlain.h"
#include "CameraMetaData.h"
#include "TiffIFD.h"
+#include "dlldef.h"
/*
RawSpeed - RAW file decoder.
@@ -48,7 +49,7 @@ class RawDecoderThread
RawDecoder* parent;
};
-class RawDecoder
+class DllDef RawDecoder
{
public:
/* Construct decoder instance - FileMap is a filemap of the file to be decoded */
diff --git a/RawSpeed/RawImage.h b/RawSpeed/RawImage.h
index 5741760..74cea96 100644
--- a/RawSpeed/RawImage.h
+++ b/RawSpeed/RawImage.h
@@ -26,13 +26,15 @@
http://www.klauspost.com
*/
+#include "dlldef.h"
+
namespace RawSpeed {
class RawImage;
class RawImageWorker;
typedef enum {TYPE_USHORT16, TYPE_FLOAT32} RawImageType;
-class RawImageData
+class DllDef RawImageData
{
friend class RawImageWorker;
public:
@@ -125,7 +127,7 @@ protected:
int end_y;
};
- class RawImage {
+ class DllDef RawImage {
public:
static RawImage create(RawImageType type = TYPE_USHORT16);
static RawImage create(iPoint2D dim, RawImageType type = TYPE_USHORT16, uint32 componentsPerPixel = 1);
diff --git a/RawSpeed/RawParser.h b/RawSpeed/RawParser.h
index 9ef86e3..1b3cb83 100644
--- a/RawSpeed/RawParser.h
+++ b/RawSpeed/RawParser.h
@@ -25,10 +25,11 @@
#include "FileMap.h"
#include "RawDecoder.h"
+#include "dlldef.h"
namespace RawSpeed {
-class RawParser
+class DllDef RawParser
{
public:
RawParser(FileMap* input);
diff --git a/RawSpeed/dlldef.h b/RawSpeed/dlldef.h
new file mode 100644
index 0000000..c806451
--- /dev/null
+++ b/RawSpeed/dlldef.h
@@ -0,0 +1,20 @@
+#ifndef DLLDEF_H
+#define DLLDEF_H
+
+#ifdef _WIN32
+#ifdef _MSC_VER
+#pragma warning( disable: 4251 )
+#endif
+#ifdef RAWSPEED_NODLL
+# define DllDef
+#else
+# ifdef RAWSPEED_BUILDLIB
+# define DllDef __declspec( dllexport )
+# else
+# define DllDef __declspec( dllimport )
+# endif
+#endif
+#else
+# define DllDef
+#endif
+#endif

File diff suppressed because it is too large Load Diff