├── .ci ├── .gitattributes ├── Brewfile ├── ci-script.sh ├── coverity_model.cpp ├── obs-workflows.yml ├── oss-fuzz.sh └── sonar-project.properties ├── .clang-format ├── .clang-format-ignore ├── .clang-tidy ├── .gitattributes ├── .github ├── CODEOWNERS ├── codecov.yml └── workflows │ ├── CI-codecov.yml │ ├── CI-linux.yml │ ├── CI-macOS.yml │ ├── CI-ossfuzz.yml │ ├── CI-rpuu.yml │ ├── CI-windows-msys2.yml │ ├── CI.yml │ ├── clang-format.yml │ ├── docs.yml │ └── validate-pr-source-and-target-branches.yml ├── .gitignore ├── .mailmap ├── CMakeLists.txt ├── LICENSE ├── README.rst ├── bench ├── CMakeLists.txt └── librawspeed │ ├── CMakeLists.txt │ ├── adt │ ├── CMakeLists.txt │ ├── CoalescingOutputIteratorBenchmark.cpp │ ├── DefaultInitAllocatorAdaptorBenchmark.cpp │ └── VariableLengthLoadBenchmark.cpp │ ├── bench │ ├── CMakeLists.txt │ ├── Common.cpp │ └── Common.h │ ├── bitstreams │ ├── BitStreamJPEGUtils.cpp │ ├── BitStreamJPEGUtils.h │ ├── BitStreamerBenchmark.cpp │ ├── BitStreamerJPEGBenchmark.cpp │ ├── BitVacuumerBenchmark.cpp │ ├── BitVacuumerJPEGBenchmark.cpp │ └── CMakeLists.txt │ ├── common │ ├── CMakeLists.txt │ └── CommonBenchmark.cpp │ ├── decompressors │ ├── CMakeLists.txt │ ├── DeflateDecompressorBenchmark.cpp │ └── UncompressedDecompressorBenchmark.cpp │ ├── interpolators │ ├── CMakeLists.txt │ └── Cr2sRawInterpolatorBenchmark.cpp │ └── metadata │ ├── CMakeLists.txt │ └── CameraMetaDataBenchmark.cpp ├── cmake ├── Modules │ ├── CheckCXXCompilerFlagAndEnableIt.cmake │ ├── CheckJPEGSymbols.cmake │ ├── CheckZLIB.cmake │ ├── CpuMarch.cmake │ ├── FindCppFilt.cmake │ ├── FindDemangler.cmake │ ├── FindFind.cmake │ ├── FindGCCAr.cmake │ ├── FindGCCNm.cmake │ ├── FindGCCRanLib.cmake │ ├── FindGCov.cmake │ ├── FindGenHtml.cmake │ ├── FindLCov.cmake │ ├── FindLLVMAr.cmake │ ├── FindLLVMCXXFilt.cmake │ ├── FindLLVMClangTidy.cmake │ ├── FindLLVMCov.cmake │ ├── FindLLVMLLD.cmake │ ├── FindLLVMNm.cmake │ ├── FindLLVMObjCopy.cmake │ ├── FindLLVMObjDump.cmake │ ├── FindLLVMOptViewer.cmake │ ├── FindLLVMProfData.cmake │ ├── FindLLVMRanLib.cmake │ ├── FindLibFuzzingEngine.cmake │ ├── FindPugixml.cmake │ ├── FindSphinx.cmake │ ├── FindXMLLINT.cmake │ ├── GoogleBenchmark.cmake │ ├── GoogleBenchmark.cmake.in │ ├── GoogleTest.cmake │ ├── GoogleTest.cmake.in │ ├── LLVMOpenMP.cmake │ ├── LLVMOpenMP.cmake.in │ ├── LibFindMacros.cmake │ ├── Pugixml.cmake │ ├── Pugixml.cmake.in │ ├── Zlib.cmake │ ├── Zlib.cmake.in │ ├── cpu-cache-line-size.cmake │ ├── cpu-cache-line-size.cpp │ ├── cpu-large-page-size.cmake │ ├── cpu-large-page-size.cpp │ ├── cpu-page-size.cmake │ ├── cpu-page-size.cpp │ ├── run-xmllint.cmake │ └── thread-local.cmake ├── build-type.cmake ├── clang-tidy.cmake ├── cmake-command-wrappers.cmake ├── compiler-flags.cmake ├── compiler-versions.cmake ├── compiler-warnings-clang.cmake ├── compiler-warnings-gcc.cmake ├── compiler-warnings.cmake ├── debug-info.cmake ├── gcc-coverage.cmake ├── gcc-gcov.cmake ├── gcc-toolchain.cmake ├── genhtml.cmake ├── lcov.cmake ├── libc++.cmake ├── llvm-cov.cmake ├── llvm-opt-report.cmake ├── llvm-profdata.cmake ├── llvm-toolchain.cmake ├── sample-based-testing.cmake └── src-dependencies.cmake ├── credits.txt ├── data ├── CMakeLists.txt ├── README.md ├── cameras.xml ├── cameras.xsd └── showcameras.xsl ├── docs ├── CMakeLists.txt ├── CameraSupport.rst ├── Doxyfile.in ├── Doxygen.rst ├── IntegrationTesting.rst ├── ReferenceSampleArchive.rst ├── conf.py ├── index.rst ├── lnt │ └── index.rst └── sphinx-pyexec.py ├── fuzz ├── CMakeLists.txt ├── all-fuzzers.txt ├── common.dict ├── corpora │ ├── .gitignore │ └── CMakeLists.txt ├── libFuzzer_dummy_main.cpp ├── librawspeed │ ├── CMakeLists.txt │ ├── bitstreams │ │ ├── BitVacuumerRoundtrip.cpp │ │ └── CMakeLists.txt │ ├── codes │ │ ├── CMakeLists.txt │ │ ├── PrefixCodeDecoder │ │ │ ├── CMakeLists.txt │ │ │ ├── Common.h │ │ │ ├── Dual.cpp │ │ │ └── Solo.cpp │ │ └── PrefixCodeEncoder │ │ │ ├── CMakeLists.txt │ │ │ └── PrefixCodeEncoder.cpp │ ├── common │ │ ├── CMakeLists.txt │ │ └── DngOpcodes.cpp │ ├── decoders │ │ ├── CMakeLists.txt │ │ └── TiffDecoders │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ ├── decompressors │ │ ├── CMakeLists.txt │ │ ├── Cr2Decompressor.cpp │ │ ├── Cr2LJpegDecoder.cpp │ │ ├── CrwDecompressor.cpp │ │ ├── DummyLJpegDecoder.cpp │ │ ├── FujiDecompressor.cpp │ │ ├── HasselbladDecompressor.cpp │ │ ├── HasselbladLJpegDecoder.cpp │ │ ├── KodakDecompressor.cpp │ │ ├── LJpegDecoder.cpp │ │ ├── LJpegDecompressor.cpp │ │ ├── NikonDecompressor.cpp │ │ ├── OlympusDecompressor.cpp │ │ ├── PanasonicV4Decompressor.cpp │ │ ├── PanasonicV5Decompressor.cpp │ │ ├── PanasonicV6Decompressor.cpp │ │ ├── PanasonicV7Decompressor.cpp │ │ ├── PanasonicV8Decompressor.cpp │ │ ├── PentaxDecompressor.cpp │ │ ├── PhaseOneDecompressor.cpp │ │ ├── SamsungV0Decompressor.cpp │ │ ├── SamsungV1Decompressor.cpp │ │ ├── SamsungV2Decompressor.cpp │ │ ├── SonyArw1Decompressor.cpp │ │ ├── SonyArw2Decompressor.cpp │ │ ├── UncompressedDecompressor.cpp │ │ └── VC5Decompressor.cpp │ ├── fuzz │ │ ├── CMakeLists.txt │ │ ├── Common.cpp │ │ ├── Common.h │ │ └── RawSpeed.cpp │ └── parsers │ │ ├── CMakeLists.txt │ │ └── main.cpp └── rawspeed │ ├── CMakeLists.txt │ └── main.cpp ├── lnt ├── CMakeLists.txt ├── README.rst ├── RawSpeed.cpp ├── build-lit.local.cfg ├── lit.local.cfg ├── litsupport_rawspeed │ ├── __init__.py │ └── modules │ │ ├── __init__.py │ │ └── rsbench.py └── raw-sample-archive │ ├── CMakeLists.txt │ ├── lit.local.cfg │ └── rsbench │ ├── CMakeLists.txt │ └── lit.local.cfg ├── src ├── CMakeLists.txt ├── config.h.in ├── external │ ├── AddressSanitizer.h │ ├── CMakeLists.txt │ ├── MemorySanitizer.h │ ├── ThreadSafetyAnalysis.h │ └── gopro │ │ └── vc5 │ │ └── table17.inc ├── librawspeed │ ├── CMakeLists.txt │ ├── README.md │ ├── RawSpeed-API.h │ ├── adt │ │ ├── AlignedAllocator.h │ │ ├── Array1DRef.h │ │ ├── Array1DRefExtras.h │ │ ├── Array2DRef.h │ │ ├── Bit.h │ │ ├── BitIterator.h │ │ ├── CMakeLists.txt │ │ ├── Casts.h │ │ ├── CoalescingOutputIterator.h │ │ ├── CroppedArray1DRef.h │ │ ├── CroppedArray2DRef.h │ │ ├── DefaultInitAllocatorAdaptor.h │ │ ├── Invariant.h │ │ ├── Mutex.h │ │ ├── NORangesSet.h │ │ ├── NotARational.h │ │ ├── Optional.h │ │ ├── PartitioningOutputIterator.h │ │ ├── Point.h │ │ ├── Range.h │ │ ├── TiledArray2DRef.h │ │ ├── VariableLengthLoad.h │ │ └── iterator_range.h │ ├── bitstreams │ │ ├── BitStream.h │ │ ├── BitStreamJPEG.h │ │ ├── BitStreamLSB.h │ │ ├── BitStreamMSB.h │ │ ├── BitStreamMSB16.h │ │ ├── BitStreamMSB32.h │ │ ├── BitStreamPosition.h │ │ ├── BitStreamer.cpp │ │ ├── BitStreamer.h │ │ ├── BitStreamerJPEG.h │ │ ├── BitStreamerLSB.h │ │ ├── BitStreamerMSB.h │ │ ├── BitStreamerMSB16.h │ │ ├── BitStreamerMSB32.h │ │ ├── BitStreams.h │ │ ├── BitVacuumer.h │ │ ├── BitVacuumerJPEG.h │ │ ├── BitVacuumerLSB.h │ │ ├── BitVacuumerMSB.h │ │ ├── BitVacuumerMSB16.h │ │ ├── BitVacuumerMSB32.h │ │ └── CMakeLists.txt │ ├── codes │ │ ├── AbstractPrefixCode.h │ │ ├── AbstractPrefixCodeDecoder.h │ │ ├── AbstractPrefixCodeEncoder.h │ │ ├── AbstractPrefixCodeTranscoder.h │ │ ├── BinaryPrefixTree.h │ │ ├── CMakeLists.txt │ │ ├── DummyPrefixCodeDecoder.h │ │ ├── HuffmanCode.h │ │ ├── PrefixCode.h │ │ ├── PrefixCodeDecoder.h │ │ ├── PrefixCodeLUTDecoder.h │ │ ├── PrefixCodeLookupDecoder.h │ │ ├── PrefixCodeTreeDecoder.h │ │ ├── PrefixCodeVectorDecoder.h │ │ └── PrefixCodeVectorEncoder.h │ ├── common │ │ ├── BayerPhase.h │ │ ├── CMakeLists.txt │ │ ├── ChecksumFile.cpp │ │ ├── ChecksumFile.h │ │ ├── Common.cpp │ │ ├── Common.h │ │ ├── CpuFeatures.cpp │ │ ├── CpuFeatures.h │ │ ├── DngOpcodes.cpp │ │ ├── DngOpcodes.h │ │ ├── ErrorLog.cpp │ │ ├── ErrorLog.h │ │ ├── FloatingPoint.h │ │ ├── GetNumberOfProcessorCores.cpp │ │ ├── RawImage.cpp │ │ ├── RawImage.h │ │ ├── RawImageDataFloat.cpp │ │ ├── RawImageDataU16.cpp │ │ ├── RawspeedException.cpp │ │ ├── RawspeedException.h │ │ ├── SimpleLUT.h │ │ ├── Spline.h │ │ ├── TableLookUp.cpp │ │ ├── TableLookUp.h │ │ └── XTransPhase.h │ ├── decoders │ │ ├── AbstractTiffDecoder.cpp │ │ ├── AbstractTiffDecoder.h │ │ ├── ArwDecoder.cpp │ │ ├── ArwDecoder.h │ │ ├── CMakeLists.txt │ │ ├── Cr2Decoder.cpp │ │ ├── Cr2Decoder.h │ │ ├── CrwDecoder.cpp │ │ ├── CrwDecoder.h │ │ ├── DcrDecoder.cpp │ │ ├── DcrDecoder.h │ │ ├── DcsDecoder.cpp │ │ ├── DcsDecoder.h │ │ ├── DngDecoder.cpp │ │ ├── DngDecoder.h │ │ ├── ErfDecoder.cpp │ │ ├── ErfDecoder.h │ │ ├── IiqDecoder.cpp │ │ ├── IiqDecoder.h │ │ ├── KdcDecoder.cpp │ │ ├── KdcDecoder.h │ │ ├── MefDecoder.cpp │ │ ├── MefDecoder.h │ │ ├── MosDecoder.cpp │ │ ├── MosDecoder.h │ │ ├── MrwDecoder.cpp │ │ ├── MrwDecoder.h │ │ ├── NakedDecoder.cpp │ │ ├── NakedDecoder.h │ │ ├── NefDecoder.cpp │ │ ├── NefDecoder.h │ │ ├── OrfDecoder.cpp │ │ ├── OrfDecoder.h │ │ ├── PefDecoder.cpp │ │ ├── PefDecoder.h │ │ ├── RafDecoder.cpp │ │ ├── RafDecoder.h │ │ ├── RawDecoder.cpp │ │ ├── RawDecoder.h │ │ ├── RawDecoderException.cpp │ │ ├── RawDecoderException.h │ │ ├── Rw2Decoder.cpp │ │ ├── Rw2Decoder.h │ │ ├── SimpleTiffDecoder.cpp │ │ ├── SimpleTiffDecoder.h │ │ ├── SrwDecoder.cpp │ │ ├── SrwDecoder.h │ │ ├── StiDecoder.cpp │ │ ├── StiDecoder.h │ │ ├── ThreefrDecoder.cpp │ │ └── ThreefrDecoder.h │ ├── decompressors │ │ ├── AbstractDecompressor.h │ │ ├── AbstractDngDecompressor.cpp │ │ ├── AbstractDngDecompressor.h │ │ ├── AbstractLJpegDecoder.cpp │ │ ├── AbstractLJpegDecoder.h │ │ ├── AbstractSamsungDecompressor.h │ │ ├── CMakeLists.txt │ │ ├── Cr2Decompressor.cpp │ │ ├── Cr2Decompressor.h │ │ ├── Cr2DecompressorImpl.h │ │ ├── Cr2LJpegDecoder.cpp │ │ ├── Cr2LJpegDecoder.h │ │ ├── CrwDecompressor.cpp │ │ ├── CrwDecompressor.h │ │ ├── DeflateDecompressor.cpp │ │ ├── DeflateDecompressor.h │ │ ├── FujiDecompressor.cpp │ │ ├── FujiDecompressor.h │ │ ├── HasselbladDecompressor.cpp │ │ ├── HasselbladDecompressor.h │ │ ├── HasselbladLJpegDecoder.cpp │ │ ├── HasselbladLJpegDecoder.h │ │ ├── JpegDecompressor.cpp │ │ ├── JpegDecompressor.h │ │ ├── JpegMarkers.h │ │ ├── KodakDecompressor.cpp │ │ ├── KodakDecompressor.h │ │ ├── LJpegDecoder.cpp │ │ ├── LJpegDecoder.h │ │ ├── LJpegDecompressor.cpp │ │ ├── LJpegDecompressor.h │ │ ├── NikonDecompressor.cpp │ │ ├── NikonDecompressor.h │ │ ├── OlympusDecompressor.cpp │ │ ├── OlympusDecompressor.h │ │ ├── PanasonicV4Decompressor.cpp │ │ ├── PanasonicV4Decompressor.h │ │ ├── PanasonicV5Decompressor.cpp │ │ ├── PanasonicV5Decompressor.h │ │ ├── PanasonicV6Decompressor.cpp │ │ ├── PanasonicV6Decompressor.h │ │ ├── PanasonicV7Decompressor.cpp │ │ ├── PanasonicV7Decompressor.h │ │ ├── PanasonicV8Decompressor.cpp │ │ ├── PanasonicV8Decompressor.h │ │ ├── PentaxDecompressor.cpp │ │ ├── PentaxDecompressor.h │ │ ├── PhaseOneDecompressor.cpp │ │ ├── PhaseOneDecompressor.h │ │ ├── SamsungV0Decompressor.cpp │ │ ├── SamsungV0Decompressor.h │ │ ├── SamsungV1Decompressor.cpp │ │ ├── SamsungV1Decompressor.h │ │ ├── SamsungV2Decompressor.cpp │ │ ├── SamsungV2Decompressor.h │ │ ├── SonyArw1Decompressor.cpp │ │ ├── SonyArw1Decompressor.h │ │ ├── SonyArw2Decompressor.cpp │ │ ├── SonyArw2Decompressor.h │ │ ├── UncompressedDecompressor.cpp │ │ ├── UncompressedDecompressor.h │ │ ├── VC5Decompressor.cpp │ │ └── VC5Decompressor.h │ ├── interpolators │ │ ├── CMakeLists.txt │ │ ├── Cr2sRawInterpolator.cpp │ │ └── Cr2sRawInterpolator.h │ ├── io │ │ ├── Buffer.h │ │ ├── ByteStream.h │ │ ├── CMakeLists.txt │ │ ├── Endianness.h │ │ ├── FileIO.h │ │ ├── FileIOException.cpp │ │ ├── FileIOException.h │ │ ├── FileReader.cpp │ │ ├── FileReader.h │ │ ├── FileWriter.cpp │ │ ├── FileWriter.h │ │ ├── IOException.cpp │ │ ├── IOException.h │ │ ├── MMapReader.cpp │ │ └── MMapReader.h │ ├── metadata │ │ ├── BlackArea.h │ │ ├── CMakeLists.txt │ │ ├── Camera.cpp │ │ ├── Camera.h │ │ ├── CameraMetaData.cpp │ │ ├── CameraMetaData.h │ │ ├── CameraMetadataException.cpp │ │ ├── CameraMetadataException.h │ │ ├── CameraSensorInfo.cpp │ │ ├── CameraSensorInfo.h │ │ ├── ColorFilterArray.cpp │ │ └── ColorFilterArray.h │ ├── parsers │ │ ├── CMakeLists.txt │ │ ├── CiffParser.cpp │ │ ├── CiffParser.h │ │ ├── CiffParserException.cpp │ │ ├── CiffParserException.h │ │ ├── FiffParser.cpp │ │ ├── FiffParser.h │ │ ├── FiffParserException.cpp │ │ ├── FiffParserException.h │ │ ├── RawParser.cpp │ │ ├── RawParser.h │ │ ├── RawParserException.cpp │ │ ├── RawParserException.h │ │ ├── TiffParser.cpp │ │ ├── TiffParser.h │ │ ├── TiffParserException.cpp │ │ └── TiffParserException.h │ └── tiff │ │ ├── CMakeLists.txt │ │ ├── CiffEntry.cpp │ │ ├── CiffEntry.h │ │ ├── CiffIFD.cpp │ │ ├── CiffIFD.h │ │ ├── CiffTag.h │ │ ├── TiffEntry.cpp │ │ ├── TiffEntry.h │ │ ├── TiffIFD.cpp │ │ ├── TiffIFD.h │ │ └── TiffTag.h └── utilities │ ├── CMakeLists.txt │ ├── identify │ ├── CMakeLists.txt │ └── rawspeed-identify.cpp │ ├── rsbench │ ├── CMakeLists.txt │ └── main.cpp │ └── rstest │ ├── CMakeLists.txt │ ├── MD5Benchmark.cpp │ ├── MD5Test.cpp │ ├── md5.cpp │ ├── md5.h │ └── rstest.cpp └── test ├── .clang-tidy ├── CMakeLists.txt └── librawspeed ├── CMakeLists.txt ├── adt ├── BitTest.cpp ├── CMakeLists.txt ├── CoalescingOutputIteratorTest.cpp ├── NORangesSetTest.cpp ├── PartitioningOutputIteratorTest.cpp ├── PointTest.cpp ├── RangeTest.cpp ├── RangeTest.h └── VariableLengthLoadTest.cpp ├── bitstreams ├── BitSteramerMSBTest.cpp ├── BitStreamerJPEGTest.cpp ├── BitStreamerLSBTest.cpp ├── BitStreamerMSB16Test.cpp ├── BitStreamerMSB32Test.cpp ├── BitStreamerTest.h ├── BitVacuumerJPEGTest.cpp ├── BitVacuumerLSBTest.cpp ├── BitVacuumerMSB16Test.cpp ├── BitVacuumerMSB32Test.cpp ├── BitVacuumerMSBTest.cpp └── CMakeLists.txt ├── codes ├── CMakeLists.txt ├── HuffmanCodeTest.cpp └── HuffmanTableTest.cpp ├── common ├── BayerPhaseTest.cpp ├── CMakeLists.txt ├── ChecksumFileTest.cpp ├── CommonTest.cpp ├── CpuidTest.cpp └── SplineTest.cpp ├── io ├── CMakeLists.txt ├── EndiannessTest.cpp └── EndiannessTest.h ├── metadata ├── BlackAreaTest.cpp ├── CMakeLists.txt ├── CameraMetaDataTest.cpp ├── CameraSensorInfoTest.cpp ├── CameraTest.cpp └── ColorFilterArrayTest.cpp └── test ├── CMakeLists.txt ├── ExceptionsTest.cpp └── RawSpeed.cpp /.ci/.gitattributes: -------------------------------------------------------------------------------- 1 | wro_deploy.enc binary 2 | -------------------------------------------------------------------------------- /.ci/Brewfile: -------------------------------------------------------------------------------- 1 | brew 'cmake' 2 | brew 'git' 3 | brew 'libomp' 4 | brew 'jpeg-turbo' 5 | brew 'ninja' 6 | brew 'pugixml' 7 | -------------------------------------------------------------------------------- /.ci/coverity_model.cpp: -------------------------------------------------------------------------------- 1 | /* Coverity Scan model 2 | * 3 | * This is a modeling file for Coverity Scan. Modeling helps to avoid false 4 | * positives. 5 | * 6 | * - A model file can't import any header files. 7 | * - Therefore only some built-in primitives like int, char and void are 8 | * available but not wchar_t, NULL etc. 9 | * - Modeling doesn't need full structs and typedefs. Rudimentary structs 10 | * and similar types are sufficient. 11 | * - An uninitialized local pointer is not an error. It signifies that the 12 | * variable could be either NULL or have some data. 13 | * 14 | * Coverity Scan doesn't pick up modifications automatically. The model file 15 | * must be uploaded by an admin in the analysis settings of 16 | * https://scan.coverity.com/projects/darktable-org-rawspeed 17 | */ 18 | 19 | int rand(void) { /* ignore */ 20 | } 21 | 22 | namespace std { 23 | int rand(void) { /* ignore */ 24 | } 25 | } // namespace std 26 | -------------------------------------------------------------------------------- /.ci/obs-workflows.yml: -------------------------------------------------------------------------------- 1 | develop: 2 | steps: 3 | - trigger_services: 4 | project: graphics:darktable:master 5 | package: rawspeed 6 | filters: 7 | event: push 8 | branches: 9 | only: 10 | - develop 11 | pr: 12 | steps: 13 | - branch_package: 14 | source_project: graphics:darktable:master 15 | source_package: rawspeed 16 | target_project: graphics:darktable:github 17 | filters: 18 | event: pull_request 19 | -------------------------------------------------------------------------------- /.ci/sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectName=RawSpeed 2 | sonar.projectDescription=fast raw decoding library 3 | sonar.links.homepage=https://github.com/darktable-org/rawspeed 4 | sonar.links.ci=https://github.com/darktable-org/rawspeed/actions 5 | sonar.links.issue=https://github.com/darktable-org/rawspeed/issues 6 | sonar.links.scm=https://github.com/darktable-org/rawspeed.git 7 | 8 | sonar.sources=src 9 | sonar.scm.provider=git 10 | sonar.scm.forceReloadAll=true 11 | 12 | sonar.sourceEncoding=UTF-8 13 | sonar.lang.patterns.c=**/*.c 14 | sonar.lang.patterns.cpp=**/*.cpp,**/*.cc,**/*.cxx,**/*.c++,**/*.h,**/*.hpp,**/*.hh,**/*.hxx,**/*.h++ 15 | 16 | sonar.test.inclusions=**/test/**/* 17 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | Standard: c++20 5 | # Force pointers to the type for C++. 6 | DerivePointerAlignment: false 7 | PointerAlignment: Left 8 | IncludeCategories: 9 | - Regex: '^[<"]rawspeedconfig\.h[">]$' 10 | Priority: -20 11 | - Regex: '^[<"]RawSpeed-API\.h[">]$' 12 | Priority: -10 13 | - Regex: '^[<"](gtest|gmock|benchmark)/' 14 | Priority: 20 15 | - Regex: '.*' 16 | Priority: 10 17 | IncludeBlocks: Merge 18 | IncludeIsMainRegex: '' 19 | ... 20 | -------------------------------------------------------------------------------- /.clang-format-ignore: -------------------------------------------------------------------------------- 1 | **/*\.cfg$ 2 | **/*\.cmake$ 3 | **/*\.cmake\.in$ 4 | **/*\.md$ 5 | **/*\.py$ 6 | **/*\.rst$ 7 | **/*\.yml$ 8 | **/\.clang-tidy$ 9 | **/CMakeLists\.txt$ 10 | \.ci/**/* 11 | \.clang-format$ 12 | \.clang-format-ignore$ 13 | \.clang-tidy$ 14 | \.gitattributes$ 15 | \.github/**/* 16 | \.gitignore$ 17 | \.mailmap$ 18 | CMakeLists\.txt$ 19 | LICENSE$ 20 | docs/Doxyfile\.in$ 21 | fuzz/all-fuzzers\.txt$ 22 | fuzz/common\.dict$ 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # No binary files in here. 2 | * text 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @LebedevRI 2 | -------------------------------------------------------------------------------- /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | max_report_age: off 3 | notify: 4 | after_n_builds: 7 5 | coverage: 6 | status: 7 | project: 8 | default: 9 | target: 0% 10 | informational: true 11 | -------------------------------------------------------------------------------- /.github/workflows/CI-ossfuzz.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_call: 3 | inputs: 4 | sanitizer: 5 | required: true 6 | type: string 7 | 8 | jobs: 9 | linux: 10 | runs-on: ubuntu-latest 11 | timeout-minutes: 60 12 | steps: 13 | - name: (OSS-FUZZ) Building with ${{ inputs.sanitizer }} sanitizer 14 | timeout-minutes: 15 15 | id: build 16 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 17 | with: 18 | oss-fuzz-project-name: 'librawspeed' 19 | dry-run: false 20 | language: c++ 21 | sanitizer: ${{ inputs.sanitizer }} 22 | - name: (OSS-FUZZ) Running ${{ inputs.sanitizer }}-sanitized fuzzers 23 | timeout-minutes: 45 24 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 25 | with: 26 | oss-fuzz-project-name: 'librawspeed' 27 | fuzz-seconds: 1800 28 | dry-run: false 29 | sanitizer: ${{ inputs.sanitizer }} 30 | - name: Upload Crash 31 | timeout-minutes: 1 32 | uses: actions/upload-artifact@v4 33 | if: failure() && steps.build.outcome == 'success' 34 | with: 35 | name: artifacts 36 | path: ./out/artifacts 37 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Docs building 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * SUN" 6 | workflow_dispatch: 7 | 8 | 9 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 10 | permissions: 11 | contents: read 12 | pages: write 13 | id-token: write 14 | 15 | # Allow one concurrent deployment 16 | concurrency: 17 | group: "pages" 18 | cancel-in-progress: true 19 | 20 | # Default to bash 21 | defaults: 22 | run: 23 | shell: bash 24 | 25 | jobs: 26 | build-docs: 27 | strategy: 28 | matrix: 29 | os: [ linux ] 30 | compiler: 31 | - { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } 32 | flavor: [ WWW ] 33 | uses: ./.github/workflows/CI-linux.yml 34 | with: 35 | os: ${{ matrix.os }} 36 | distro: ${{ matrix.compiler.distro }} 37 | compiler-family: ${{ matrix.compiler.family }} 38 | compiler-version: ${{ matrix.compiler.version }} 39 | compiler-CC: ${{ matrix.compiler.CC }} 40 | compiler-CXX: ${{ matrix.compiler.CXX }} 41 | flavor: ${{ matrix.flavor }} 42 | publish-pages: 43 | needs: build-docs 44 | runs-on: ubuntu-latest 45 | environment: 46 | name: github-pages 47 | url: ${{ steps.deployment.outputs.page_url }} 48 | steps: 49 | - name: Setup Pages 50 | id: pages 51 | uses: actions/configure-pages@v2 52 | - name: Deploy to GitHub Pages 53 | id: deployment 54 | uses: actions/deploy-pages@v4 55 | -------------------------------------------------------------------------------- /.github/workflows/validate-pr-source-and-target-branches.yml: -------------------------------------------------------------------------------- 1 | name: Validate source/target branches of Pull Request 2 | 3 | on: 4 | pull_request_target: 5 | types: [ opened, reopened ] 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | validation: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Fetch/Checkout RawSpeed git repo 16 | timeout-minutes: 1 17 | uses: actions/checkout@v4 18 | with: 19 | path: 'rawspeed' 20 | - if: github.event_name == 'pull_request_target' && github.base_ref != 'develop' 21 | name: Close Pull if PR is to a wrong branch 22 | env: 23 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | run: | 25 | cd rawspeed 26 | gh pr close --comment "Pull Requests should only be submitted to `develop` branch" ${{ github.event.number }} 27 | exit 1 28 | - if: github.event_name == 'pull_request_target' && github.head_ref == github.base_ref 29 | name: Close Pull if PR is not from a proper branch 30 | env: 31 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | run: | 33 | cd rawspeed 34 | gh pr close --comment "Pull Requests source branch should be branched off of the Pull Request's target branch" ${{ github.event.number }} 35 | exit 1 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # cmake out-of-source build tree 2 | build*/ 3 | 4 | # tmp files 5 | *~ 6 | .DS_Store 7 | cscope.out 8 | .*.swp 9 | 10 | # project files 11 | *.kdev4 12 | *.sln 13 | *.vcproj 14 | *.vcxproj 15 | .vscode/ 16 | 17 | # Compiled Object files 18 | *.slo 19 | *.lo 20 | *.o 21 | *.obj 22 | *.pyc 23 | 24 | # Compiled Dynamic libraries 25 | *.so 26 | *.dylib 27 | *.dll 28 | 29 | # Compiled Static libraries 30 | *.lai 31 | *.la 32 | *.a 33 | *.lib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | testimg 40 | Release-* 41 | Debug-* 42 | 43 | # sonarqube 44 | .scannerwork/ 45 | bw-output/ 46 | 47 | # coverage 48 | *.gcno 49 | *.gcda 50 | *.gcov 51 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Klaus Post 2 | Klaus Post post 3 | 4 | Anders Brander 5 | Anders Brander abrander 6 | 7 | Stefan Schöfegger 8 | 9 | Roman Lebedev 10 | 11 | Axel Waggershauser 12 | Axel Waggershauser axxel 13 | 14 | Peter Budai 15 | Peter Budai peterbud 16 | 17 | Matthieu Volat 18 | Matthieu Volat Matthieu 19 | Matthieu Volat Matthieu Volat 20 | 21 | Shita Yuuma 22 | 23 | Hanno Schwalm 24 | Hanno Schwalm hanno@schwalm-bremen.de 25 | -------------------------------------------------------------------------------- /bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (DISABLED_WARNING_FLAGS 2 | "global-constructors" 3 | ) 4 | 5 | foreach(warning ${DISABLED_WARNING_FLAGS}) 6 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-${warning}) 7 | endforeach() 8 | 9 | add_subdirectory(librawspeed) 10 | -------------------------------------------------------------------------------- /bench/librawspeed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(RAWSPEED_COVERAGE_BUILD) 2 | # want all the symbols. 3 | rawspeed_add_library(rawspeed_bench SHARED) 4 | else() 5 | rawspeed_add_library(rawspeed_bench STATIC) 6 | endif() 7 | 8 | target_link_libraries(rawspeed_bench PUBLIC rawspeed) 9 | target_link_libraries(rawspeed_bench PUBLIC benchmark) 10 | target_include_directories(rawspeed_bench PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") 11 | 12 | function(add_rs_bench src) 13 | get_filename_component(BENCHNAME ${src} NAME_WE) 14 | rawspeed_add_executable(${BENCHNAME} ${src}) 15 | target_link_libraries(${BENCHNAME} PUBLIC rawspeed) 16 | target_link_libraries(${BENCHNAME} PUBLIC rawspeed_bench) 17 | 18 | rawspeed_add_test(NAME ${BENCHNAME}-Dummy COMMAND ${BENCHNAME} --help) 19 | set_tests_properties(${BENCHNAME}-Dummy PROPERTIES LABELS "benchmark;dummy") 20 | if(WIN32) 21 | set_tests_properties(${BENCHNAME}-Dummy PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") 22 | endif() 23 | 24 | rawspeed_add_test(NAME ${BENCHNAME} COMMAND ${BENCHNAME} --benchmark_min_time=1x) 25 | set_tests_properties(${BENCHNAME} PROPERTIES LABELS "benchmark") 26 | set_tests_properties(${BENCHNAME} PROPERTIES ENVIRONMENT "RAWSPEED_BENCHMARK_DRYRUN=1") 27 | if(WIN32) 28 | set_tests_properties(${BENCHNAME} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") 29 | endif() 30 | 31 | add_dependencies(benchmarks ${BENCHNAME}) 32 | endfunction() 33 | 34 | add_subdirectory(adt) 35 | add_subdirectory(bench) 36 | add_subdirectory(bitstreams) 37 | add_subdirectory(common) 38 | add_subdirectory(decompressors) 39 | add_subdirectory(interpolators) 40 | add_subdirectory(metadata) 41 | -------------------------------------------------------------------------------- /bench/librawspeed/adt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 2 | "CoalescingOutputIteratorBenchmark.cpp" 3 | "DefaultInitAllocatorAdaptorBenchmark.cpp" 4 | "VariableLengthLoadBenchmark.cpp" 5 | ) 6 | 7 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 8 | add_rs_bench("${SRC}") 9 | endforeach() 10 | -------------------------------------------------------------------------------- /bench/librawspeed/bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_BENCH_SOURCES 2 | "${CMAKE_SOURCE_DIR}/test/librawspeed/test/RawSpeed.cpp" 3 | "Common.cpp" 4 | "Common.h" 5 | ) 6 | 7 | target_sources(rawspeed_bench PRIVATE 8 | ${RAWSPEED_BENCH_SOURCES} 9 | ) 10 | -------------------------------------------------------------------------------- /bench/librawspeed/bench/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "rawspeedconfig.h" 24 | #include "adt/Point.h" 25 | #include 26 | 27 | bool RAWSPEED_READNONE benchmarkDryRun(); 28 | 29 | rawspeed::iPoint2D RAWSPEED_READNONE 30 | areaToRectangle(uint64_t area, rawspeed::iPoint2D aspect = {2, 2}); 31 | -------------------------------------------------------------------------------- /bench/librawspeed/bitstreams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_BENCH_SOURCES 2 | "BitStreamJPEGUtils.cpp" 3 | "BitStreamJPEGUtils.h" 4 | ) 5 | 6 | target_sources(rawspeed_bench PRIVATE 7 | ${RAWSPEED_BENCH_SOURCES} 8 | ) 9 | 10 | 11 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 12 | "BitStreamerBenchmark.cpp" 13 | "BitStreamerJPEGBenchmark.cpp" 14 | "BitVacuumerBenchmark.cpp" 15 | "BitVacuumerJPEGBenchmark.cpp" 16 | ) 17 | 18 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 19 | add_rs_bench("${SRC}") 20 | endforeach() 21 | -------------------------------------------------------------------------------- /bench/librawspeed/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 2 | "CommonBenchmark.cpp" 3 | ) 4 | 5 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 6 | add_rs_bench("${SRC}") 7 | endforeach() 8 | -------------------------------------------------------------------------------- /bench/librawspeed/decompressors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(HAVE_ZLIB) 2 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 3 | "DeflateDecompressorBenchmark.cpp" 4 | "UncompressedDecompressorBenchmark.cpp" 5 | ) 6 | 7 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 8 | add_rs_bench("${SRC}") 9 | endforeach() 10 | 11 | target_link_libraries(DeflateDecompressorBenchmark PRIVATE rawspeed_get_number_of_processor_cores) 12 | target_link_libraries(DeflateDecompressorBenchmark PRIVATE ZLIB::ZLIB) 13 | endif() 14 | -------------------------------------------------------------------------------- /bench/librawspeed/interpolators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 2 | "Cr2sRawInterpolatorBenchmark.cpp" 3 | ) 4 | 5 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 6 | add_rs_bench("${SRC}") 7 | endforeach() 8 | 9 | target_link_libraries(Cr2sRawInterpolatorBenchmark PRIVATE rawspeed_get_number_of_processor_cores) 10 | -------------------------------------------------------------------------------- /bench/librawspeed/metadata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT HAVE_PUGIXML) 2 | return() 3 | endif() 4 | 5 | FILE(GLOB RAWSPEED_BENCHS_SOURCES 6 | "CameraMetaDataBenchmark.cpp" 7 | ) 8 | 9 | foreach(SRC ${RAWSPEED_BENCHS_SOURCES}) 10 | add_rs_bench("${SRC}") 11 | endforeach() 12 | 13 | target_link_libraries(CameraMetaDataBenchmark PRIVATE Pugixml::Pugixml) 14 | -------------------------------------------------------------------------------- /cmake/Modules/CheckCXXCompilerFlagAndEnableIt.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlag) 2 | 3 | function(mangle_flag_name PREFIX FLAG OUTPUT) 4 | string(TOUPPER "${PREFIX}_${FLAG}" MANGLED_FLAG) 5 | string(REPLACE "+" "X" MANGLED_FLAG ${MANGLED_FLAG}) 6 | string(REGEX REPLACE "[^A-Za-z_0-9]" "_" MANGLED_FLAG ${MANGLED_FLAG}) 7 | string(REGEX REPLACE "_+" "_" MANGLED_FLAG ${MANGLED_FLAG}) 8 | set(${OUTPUT} "${MANGLED_FLAG}" PARENT_SCOPE) 9 | endfunction() 10 | 11 | macro (CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT _FLAG) 12 | mangle_flag_name("RAWSPEED_HAVE_CXX_FLAG" "${_FLAG}" _RESULT) 13 | 14 | set(CMAKE_REQUIRED_FLAGS_ORIG "${CMAKE_REQUIRED_FLAGS}") 15 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS}") 16 | 17 | CHECK_CXX_COMPILER_FLAG("${_FLAG}" ${_RESULT}) 18 | 19 | if(${${_RESULT}}) 20 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FLAG}") 21 | endif() 22 | 23 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIG}") 24 | endmacro () 25 | -------------------------------------------------------------------------------- /cmake/Modules/CheckJPEGSymbols.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXSymbolExists) 2 | 3 | set(CMAKE_REQUIRED_INCLUDES_SAVE "${CMAKE_REQUIRED_INCLUDES}") 4 | set(CMAKE_REQUIRED_LIBRARIES_SAVE "${CMAKE_REQUIRED_LIBRARIES}") 5 | set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}") 6 | 7 | # Workaround cmake-3.25 bug. 8 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-newline-eof") 9 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-old-style-cast") 10 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-unsafe-buffer-usage") 11 | 12 | set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES_SAVE};${JPEG_INCLUDE_DIRS}") 13 | set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAVE};${JPEG_LIBRARIES}") 14 | 15 | CHECK_CXX_SYMBOL_EXISTS(jpeg_mem_src "cstdio;jpeglib.h" HAVE_JPEG_MEM_SRC) 16 | 17 | set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES_SAVE}") 18 | set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAVE}") 19 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}") 20 | -------------------------------------------------------------------------------- /cmake/Modules/CpuMarch.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlag) 2 | 3 | if(NOT DEFINED RAWSPEED_MARCH) 4 | if(NOT BINARY_PACKAGE_BUILD) 5 | message(STATUS "Checking for -march=native support") 6 | CHECK_CXX_COMPILER_FLAG("-march=native" RAWSPEED_MARCHNATIVE) 7 | if(RAWSPEED_MARCHNATIVE) 8 | message(STATUS "Checking for -march=native support - works") 9 | set(RAWSPEED_MARCH "-march=native") 10 | else() 11 | message(STATUS "Checking for -mtune=native support") 12 | CHECK_CXX_COMPILER_FLAG("-mtune=native" RAWSPEED_MTUNENATIVE) 13 | if(RAWSPEED_MTUNENATIVE) 14 | message(STATUS "Checking for -mtune=native support - works") 15 | set(RAWSPEED_MARCH "-mtune=native") 16 | else() 17 | message(STATUS "Checking for -mtune=generic support") 18 | CHECK_CXX_COMPILER_FLAG("-mtune=generic" RAWSPEED_MTUNEGENERIC) 19 | if(RAWSPEED_MTUNEGENERIC) 20 | message(STATUS "Checking for -mtune=generic support - works") 21 | set(RAWSPEED_MARCH "-mtune=generic") 22 | else() 23 | message(WARNING "Do not know which -march/-mtune to pass! Resulting binaries may be broken!") 24 | endif() 25 | endif() 26 | endif() 27 | else() 28 | message(STATUS "Checking for -mtune=generic support") 29 | CHECK_CXX_COMPILER_FLAG("-mtune=generic" RAWSPEED_MTUNEGENERIC) 30 | if(RAWSPEED_MTUNEGENERIC) 31 | message(STATUS "Checking for -mtune=generic support - works") 32 | set(RAWSPEED_MARCH "-mtune=generic") 33 | else() 34 | message(WARNING "Do not know which -march/-mtune to pass! Resulting binaries may be broken!") 35 | endif() 36 | endif() 37 | 38 | set(RAWSPEED_MARCH ${RAWSPEED_MARCH} CACHE INTERNAL "") 39 | endif() 40 | 41 | ADD_DEFINITIONS(${RAWSPEED_MARCH}) 42 | -------------------------------------------------------------------------------- /cmake/Modules/FindCppFilt.cmake: -------------------------------------------------------------------------------- 1 | find_program(CPPFILT_EXECUTABLE 2 | NAMES c++filt 3 | DOC "The c++filt executable" 4 | ) 5 | 6 | include(FindPackageHandleStandardArgs) 7 | find_package_handle_standard_args(CppFilt 8 | DEFAULT_MSG 9 | CPPFILT_EXECUTABLE) 10 | 11 | add_executable(c++filt IMPORTED GLOBAL) 12 | set_property(TARGET c++filt PROPERTY IMPORTED_LOCATION "${CPPFILT_EXECUTABLE}") 13 | 14 | SET_PACKAGE_PROPERTIES(CppFilt PROPERTIES 15 | URL https://sourceware.org/binutils/docs/binutils/c_002b_002bfilt.html 16 | DESCRIPTION "Demangler for C++ symbols" 17 | PURPOSE "Used for demangling of symbols in llvm-cov reports" 18 | ) 19 | -------------------------------------------------------------------------------- /cmake/Modules/FindDemangler.cmake: -------------------------------------------------------------------------------- 1 | set(_demangler "NOTFOUND") 2 | 3 | function(findDemangler package target) 4 | if(_demangler) 5 | return() 6 | endif() 7 | 8 | find_package(${package}) 9 | 10 | if(NOT DEFINED ${package}_FOUND OR NOT ${package}_FOUND OR NOT TARGET ${target}) 11 | return() 12 | endif() 13 | 14 | set_package_properties(Demangler PROPERTIES 15 | DESCRIPTION "Just an alias for ${package}") 16 | 17 | get_property(_demangler TARGET ${target} PROPERTY IMPORTED_LOCATION) 18 | set_package_properties(${package} PROPERTIES 19 | TYPE REQUIRED) 20 | 21 | set(_demangler "${_demangler}" PARENT_SCOPE) 22 | endfunction() 23 | 24 | findDemangler(LLVMCXXFilt llvm-cxxfilt) 25 | findDemangler(CppFilt c++filt) 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(Demangler 29 | DEFAULT_MSG 30 | _demangler) 31 | 32 | add_executable(demangler IMPORTED GLOBAL) 33 | set_property(TARGET demangler PROPERTY IMPORTED_LOCATION "${_demangler}") 34 | -------------------------------------------------------------------------------- /cmake/Modules/FindFind.cmake: -------------------------------------------------------------------------------- 1 | find_program(FIND_PATH NAMES find) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(Find 5 | DEFAULT_MSG 6 | FIND_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(Find PROPERTIES 9 | URL https://www.gnu.org/software/findutils/ 10 | DESCRIPTION "Search for files in a directory hierarchy" 11 | PURPOSE "Used to find specific files at cmake build execution time" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindGCCAr.cmake: -------------------------------------------------------------------------------- 1 | find_program(GCCAR_EXECUTABLE NAMES gcc-ar) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(GCCAr 5 | DEFAULT_MSG 6 | GCCAR_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(GCCAr PROPERTIES 9 | URL https://sourceware.org/binutils/docs/binutils/ar.html 10 | DESCRIPTION "create, modify, and extract from archives" 11 | PURPOSE "A wrapper around ar adding the --plugin option" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindGCCNm.cmake: -------------------------------------------------------------------------------- 1 | find_program(GCCNM_EXECUTABLE NAMES gcc-nm) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(GCCNm 5 | DEFAULT_MSG 6 | GCCNM_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(GCCNm PROPERTIES 9 | URL https://sourceware.org/binutils/docs/binutils/nm.html 10 | DESCRIPTION "list GCC bitcode and object file’s symbol table" 11 | PURPOSE "A wrapper around ar adding the --plugin option" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindGCCRanLib.cmake: -------------------------------------------------------------------------------- 1 | find_program(GCCRANLIB_EXECUTABLE NAMES gcc-ranlib) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(GCCRanLib 5 | DEFAULT_MSG 6 | GCCRANLIB_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(GCCRanLib PROPERTIES 9 | URL https://sourceware.org/binutils/docs/binutils/ranlib.html 10 | DESCRIPTION "generate index for GCC archive" 11 | PURPOSE "A wrapper around ar adding the --plugin option" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindGCov.cmake: -------------------------------------------------------------------------------- 1 | if(DEFINED ENV{GCOV}) 2 | find_program(GCOV_PATH NAMES "$ENV{GCOV}") 3 | else() 4 | find_program(GCOV_PATH NAMES gcov) 5 | endif() 6 | 7 | include(FindPackageHandleStandardArgs) 8 | find_package_handle_standard_args(GCov 9 | DEFAULT_MSG 10 | GCOV_PATH) 11 | 12 | SET_PACKAGE_PROPERTIES(GCov PROPERTIES 13 | URL https://gcc.gnu.org/onlinedocs/gcc/Gcov.html 14 | DESCRIPTION "Coverage testing tool" 15 | PURPOSE "Used for preprocessing *.gcno files into *.gcov" 16 | ) 17 | -------------------------------------------------------------------------------- /cmake/Modules/FindGenHtml.cmake: -------------------------------------------------------------------------------- 1 | find_program(GENHTML_PATH NAMES genhtml) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(GenHtml 5 | DEFAULT_MSG 6 | GENHTML_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(GenHtml PROPERTIES 9 | URL http://ltp.sourceforge.net/coverage/lcov/genhtml.1.php 10 | DESCRIPTION " Generates HTML view from LCOV coverage data files" 11 | PURPOSE "Used for final rendering coverage reports into HTML" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindLCov.cmake: -------------------------------------------------------------------------------- 1 | find_program(LCOV_PATH NAMES lcov) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LCov 5 | DEFAULT_MSG 6 | LCOV_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(LCov PROPERTIES 9 | URL http://ltp.sourceforge.net/coverage/lcov.php 10 | DESCRIPTION "A graphical GCOV front-end" 11 | PURPOSE "Used for collection of line coverage info" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMAr.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMAR_EXECUTABLE NAMES llvm-ar llvm-ar-10 llvm-ar-9 llvm-ar-8 llvm-ar-7 llvm-ar-6.0 llvm-ar-5.0 llvm-ar-4.0 llvm-ar-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMAr 5 | DEFAULT_MSG 6 | LLVMAR_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMAr PROPERTIES 9 | URL https://llvm.org/docs/CommandGuide/llvm-ar.html 10 | DESCRIPTION "create, modify, and extract from archives" 11 | ) 12 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMCXXFilt.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMCXXFilt_EXECUTABLE 2 | NAMES llvm-cxxfilt llvm-cxxfilt-10 llvm-cxxfilt-9 llvm-cxxfilt-8 llvm-cxxfilt-7 llvm-cxxfilt-6.0 llvm-cxxfilt-5.0 llvm-cxxfilt-4.0 llvm-cxxfilt-3.9 3 | DOC "The llvm-cxxfilt executable" 4 | ) 5 | 6 | include(FindPackageHandleStandardArgs) 7 | find_package_handle_standard_args(LLVMCXXFilt 8 | DEFAULT_MSG 9 | LLVMCXXFilt_EXECUTABLE) 10 | 11 | add_executable(llvm-cxxfilt IMPORTED GLOBAL) 12 | set_property(TARGET llvm-cxxfilt PROPERTY IMPORTED_LOCATION "${LLVMCXXFilt_EXECUTABLE}") 13 | 14 | SET_PACKAGE_PROPERTIES(LLVMCXXFilt PROPERTIES 15 | DESCRIPTION "LLVM demangler for C++ symbols" 16 | PURPOSE "Used for demangling of symbols in llvm-cov reports" 17 | ) 18 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMClangTidy.cmake: -------------------------------------------------------------------------------- 1 | find_program(CLANGTIDY_PATH NAMES "$ENV{CLANG_TIDY}" clang-tidy) 2 | 3 | if(CLANGTIDY_PATH) 4 | execute_process(COMMAND "${CLANGTIDY_PATH}" --version OUTPUT_VARIABLE CLANG_TIDY_VERSION) 5 | string(REGEX MATCH "(([0-9]+)\\.([0-9]+)\\.([0-9]+))" 6 | CLANG_TIDY_VERSION ${CLANG_TIDY_VERSION}) 7 | set(CLANG_TIDY_VERSION_MAJOR ${CMAKE_MATCH_2}) 8 | set(CLANG_TIDY_VERSION_MINOR ${CMAKE_MATCH_3}) 9 | set(CLANG_TIDY_VERSION_PATCH ${CMAKE_MATCH_4}) 10 | endif() 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(LLVMClangTidy 14 | REQUIRED_VARS CLANGTIDY_PATH CLANG_TIDY_VERSION 15 | VERSION_VAR CLANG_TIDY_VERSION) 16 | 17 | SET_PACKAGE_PROPERTIES(LLVMClangTidy PROPERTIES 18 | URL https://clang.llvm.org/extra/clang-tidy/ 19 | DESCRIPTION "a clang-based C++ “linter” tool" 20 | PURPOSE "Used for enforcing some quality level for the source code" 21 | ) 22 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMCov.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMCOV_PATH NAMES llvm-cov llvm-cov-10 llvm-cov-9 llvm-cov-8 llvm-cov-7 llvm-cov-6.0 llvm-cov-5.0 llvm-cov-4.0 llvm-cov-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMCov 5 | DEFAULT_MSG 6 | LLVMCOV_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMCov PROPERTIES 9 | URL https://llvm.org/docs/CommandGuide/llvm-cov.html 10 | DESCRIPTION "Tool to show code coverage information" 11 | PURPOSE "Used for rendering *.profdata into HTML coverage report" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMLLD.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMLLD_EXECUTABLE NAMES ld.lld lld lld-10 lld-9 lld-8 lld-7 lld-6.0 lld-5.0 lld-4.0 lld-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMLLD 5 | DEFAULT_MSG 6 | LLVMLLD_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMLLD PROPERTIES 9 | URL https://lld.llvm.org/ 10 | DESCRIPTION "the LLVM Linker" 11 | ) 12 | 13 | set(LLVMLLD_INCREMENTAL_CACHE_PATH "${CMAKE_BINARY_DIR}/clang-thinlto-cache" 14 | CACHE PATH "The location of clang's ThinLTO Incremental cache." FORCE) 15 | 16 | # For unoptimized {A+UB}SAN build with all debug info - fresh cache is ~492Mb. 17 | # For -O3 + {A+UB}SAN build with all debug info - fresh cache is ~320Mb. 18 | set(LLVMLLD_INCREMENTAL_CACHE_CACHE_SIZE_BYTES "1g" 19 | CACHE STRING "The maximum size for the ThinLTO Incremental cache directory, X{,k,m,g} bytes" FORCE) 20 | 21 | set(LLVMLLD_INCREMENTAL_LDFLAGS 22 | "-Wl,--thinlto-cache-dir=\"${LLVMLLD_INCREMENTAL_CACHE_PATH}\" -Wl,--thinlto-cache-policy,cache_size_bytes=${LLVMLLD_INCREMENTAL_CACHE_CACHE_SIZE_BYTES}" 23 | CACHE STRING "(Clang only) Add -flto=thin flag to the compile and link command lines, enabling link-time optimization." FORCE) 24 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMNm.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMNM_EXECUTABLE NAMES llvm-nm llvm-nm-10 llvm-nm-9 llvm-nm-8 llvm-nm-7 llvm-nm-6.0 llvm-nm-5.0 llvm-nm-4.0 llvm-nm-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMNm 5 | DEFAULT_MSG 6 | LLVMNM_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMNm PROPERTIES 9 | URL https://llvm.org/docs/CommandGuide/llvm-nm.html 10 | DESCRIPTION "list LLVM bitcode and object file’s symbol table" 11 | ) 12 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMObjCopy.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMOBJCOPY_EXECUTABLE NAMES llvm-objcopy llvm-objcopy-10 llvm-objcopy-9 llvm-objcopy-8 llvm-objcopy-7 llvm-objcopy-6.0 llvm-objcopy-5.0 llvm-objcopy-4.0 llvm-objcopy-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMObjCopy 5 | DEFAULT_MSG 6 | LLVMOBJCOPY_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMObjCopy PROPERTIES 9 | DESCRIPTION "llvm objcopy utility" 10 | ) 11 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMObjDump.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMOBJDUMP_EXECUTABLE NAMES llvm-objdump llvm-objdump-10 llvm-objdump-9 llvm-objdump-8 llvm-objdump-7 llvm-objdump-6.0 llvm-objdump-5.0 llvm-objdump-4.0 llvm-objdump-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMObjDump 5 | DEFAULT_MSG 6 | LLVMOBJDUMP_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMObjDump PROPERTIES 9 | DESCRIPTION "llvm object file dumper" 10 | ) 11 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMOptViewer.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMOPTVIEWER_PATH NAMES opt-viewer.py) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMOptViewer 5 | DEFAULT_MSG 6 | LLVMOPTVIEWER_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMOptViewer PROPERTIES 9 | URL https://llvm.org/ 10 | DESCRIPTION "Tool to visualize optimization records" 11 | PURPOSE "Used for rendering *.opt.yaml optimization records into HTML report" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMProfData.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMPROFDATA_PATH NAMES llvm-profdata llvm-profdata-10 llvm-profdata-9 llvm-profdata-8 llvm-profdata-7 llvm-profdata-6.0 llvm-profdata-5.0 llvm-profdata-4.0 llvm-profdata-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMProfData 5 | DEFAULT_MSG 6 | LLVMPROFDATA_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMProfData PROPERTIES 9 | URL https://llvm.org/docs/CommandGuide/llvm-profdata.html 10 | DESCRIPTION "Profile data tool" 11 | PURPOSE "Used for preprocessing *.profraw files into *.profdata" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindLLVMRanLib.cmake: -------------------------------------------------------------------------------- 1 | find_program(LLVMRANLIB_EXECUTABLE NAMES llvm-ranlib llvm-ranlib-10 llvm-ranlib-9 llvm-ranlib-8 llvm-ranlib-7 llvm-ranlib-6.0 llvm-ranlib-5.0 llvm-ranlib-4.0 llvm-ranlib-3.9) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(LLVMRanLib 5 | DEFAULT_MSG 6 | LLVMRANLIB_EXECUTABLE) 7 | 8 | SET_PACKAGE_PROPERTIES(LLVMRanLib PROPERTIES 9 | DESCRIPTION "generate index for LLVM archive" 10 | ) 11 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibFuzzingEngine.cmake: -------------------------------------------------------------------------------- 1 | # - Create LibFuzzingEngine imported target. 2 | 3 | include(LibFindMacros) 4 | 5 | libfind_process(LibFuzzingEngine) 6 | 7 | add_library(LibFuzzingEngine INTERFACE IMPORTED) 8 | 9 | if(LIB_FUZZING_ENGINE) 10 | # If LIB_FUZZING_ENGINE is specified, the compile-time flags were passed via CFLAGS / CXXFLAGS already. 11 | set_property(TARGET LibFuzzingEngine PROPERTY INTERFACE_LINK_LIBRARIES "${LIB_FUZZING_ENGINE}") 12 | else() 13 | set_property(TARGET LibFuzzingEngine PROPERTY INTERFACE_COMPILE_OPTIONS "-fsanitize=fuzzer-no-link") 14 | set_property(TARGET LibFuzzingEngine PROPERTY INTERFACE_LINK_LIBRARIES "-fsanitize=fuzzer") 15 | endif() 16 | 17 | set_package_properties(LibFuzzingEngine PROPERTIES 18 | TYPE REQUIRED 19 | DESCRIPTION "A prebuilt fuzzing engine library (e.g. libFuzzer.a, or -fsanitize=fuzzer) that needs to be linked with all fuzz target" 20 | PURPOSE "Used to actually drive the fuzz targets") 21 | -------------------------------------------------------------------------------- /cmake/Modules/FindPugixml.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Pugixml 2 | # Once done, this will define 3 | # 4 | # Pugixml_FOUND - system has Pugixml 5 | # Pugixml_INCLUDE_DIRS - the Pugixml include directories 6 | # Pugixml_LIBRARIES - link these to use Pugixml 7 | 8 | include(LibFindMacros) 9 | 10 | libfind_pkg_detect(Pugixml pugixml 11 | FIND_PATH pugixml.hpp 12 | FIND_LIBRARY pugixml 13 | ) 14 | 15 | if (Pugixml_PKGCONF_VERSION) 16 | set(Pugixml_VERSION "${Pugixml_PKGCONF_VERSION}") 17 | elseif(Pugixml_INCLUDE_DIR) 18 | # no .pc file, look for version manually. 19 | # yes, libfind_version_header() does not work here. 20 | 21 | file(READ "${Pugixml_INCLUDE_DIR}/pugixml.hpp" Pugixml_VERSION_CONTENT) 22 | string(REGEX MATCH "PUGIXML_VERSION *([0-9])([0-9][0-9])" _dummy "${Pugixml_VERSION_CONTENT}") 23 | set(Pugixml_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") 24 | endif() 25 | 26 | # Set the include dir variables and the libraries and let libfind_process do the rest. 27 | # NOTE: Singular variables for this library, plural for libraries this lib depends on. 28 | set(Pugixml_PROCESS_INCLUDES Pugixml_INCLUDE_DIR) 29 | set(Pugixml_PROCESS_LIBS Pugixml_LIBRARY) 30 | libfind_process(Pugixml) 31 | -------------------------------------------------------------------------------- /cmake/Modules/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | find_program(SPHINX_BUILD_PATH NAMES sphinx-build) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(Sphinx 5 | DEFAULT_MSG 6 | SPHINX_BUILD_PATH) 7 | 8 | SET_PACKAGE_PROPERTIES(Sphinx PROPERTIES 9 | URL http://www.sphinx-doc.org/ 10 | DESCRIPTION "Documentation generator" 11 | PURPOSE "Used for generating the textual documentation, used on web-site" 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/Modules/FindXMLLINT.cmake: -------------------------------------------------------------------------------- 1 | find_program(XMLLINT_EXECUTABLE 2 | NAMES xmllint 3 | DOC "The xmllint executable") 4 | 5 | include(FindPackageHandleStandardArgs) 6 | find_package_handle_standard_args(XMLLINT 7 | DEFAULT_MSG 8 | XMLLINT_EXECUTABLE) 9 | 10 | add_executable(xmllint IMPORTED GLOBAL) 11 | set_property(TARGET xmllint PROPERTY IMPORTED_LOCATION "${XMLLINT_EXECUTABLE}") 12 | 13 | SET_PACKAGE_PROPERTIES(XMLLINT PROPERTIES 14 | URL http://xmlsoft.org/ 15 | DESCRIPTION "command line XML tool" 16 | PURPOSE "Used for validation of data/cameras.xml" 17 | ) 18 | -------------------------------------------------------------------------------- /cmake/Modules/cpu-cache-line-size.cmake: -------------------------------------------------------------------------------- 1 | if(DEFINED RAWSPEED_CACHELINESIZE) 2 | return() 3 | endif() 4 | 5 | message(STATUS "Trying to query CPU L1d cache line size") 6 | 7 | if(BINARY_PACKAGE_BUILD) 8 | message(STATUS "Performing binary package build, using hardcoded value.") 9 | else() 10 | try_run(RAWSPEED_CACHELINESIZE_EXITCODE RAWSPEED_CACHELINESIZE_COMPILED 11 | "${CMAKE_BINARY_DIR}" 12 | "${CMAKE_CURRENT_LIST_DIR}/cpu-cache-line-size.cpp" 13 | COMPILE_OUTPUT_VARIABLE RAWSPEED_CACHELINESIZE_COMPILE_OUTPUT 14 | RUN_OUTPUT_VARIABLE RAWSPEED_CACHELINESIZE_RUN_OUTPUT) 15 | 16 | if(NOT RAWSPEED_CACHELINESIZE_COMPILED OR NOT RAWSPEED_CACHELINESIZE_EXITCODE EQUAL 0) 17 | message(SEND_ERROR "Failed to query CPU L1d cache line size:\n${RAWSPEED_CACHELINESIZE_COMPILE_OUTPUT}\n${RAWSPEED_CACHELINESIZE_RUN_OUTPUT}") 18 | return() 19 | endif() 20 | 21 | string(STRIP "${RAWSPEED_CACHELINESIZE_RUN_OUTPUT}" RAWSPEED_CACHELINESIZE) 22 | 23 | if(RAWSPEED_CACHELINESIZE EQUAL 0) 24 | message(WARNING "Detected CPU L1d cache line size is zero! Falling back to hardcoded value.") 25 | unset(RAWSPEED_CACHELINESIZE) 26 | endif() 27 | endif() 28 | 29 | if(NOT DEFINED RAWSPEED_CACHELINESIZE) 30 | set(RAWSPEED_CACHELINESIZE 64) 31 | endif() 32 | 33 | set(RAWSPEED_CACHELINESIZE ${RAWSPEED_CACHELINESIZE} CACHE INTERNAL "") 34 | message(STATUS "Deciding that the CPU L1d cache line size is ${RAWSPEED_CACHELINESIZE} bytes") 35 | -------------------------------------------------------------------------------- /cmake/Modules/cpu-large-page-size.cmake: -------------------------------------------------------------------------------- 1 | if(NOT DEFINED RAWSPEED_PAGESIZE) 2 | message(FATAL_ERROR "Should first run CPU page size detection") 3 | endif() 4 | 5 | if(DEFINED RAWSPEED_LARGEPAGESIZE) 6 | return() 7 | endif() 8 | 9 | message(STATUS "Trying to query CPU large page size") 10 | 11 | if(BINARY_PACKAGE_BUILD) 12 | message(STATUS "Performing binary package build, using hardcoded value.") 13 | set(RAWSPEED_LARGEPAGESIZE ${RAWSPEED_PAGESIZE}) 14 | else() 15 | try_run(RAWSPEED_LARGEPAGESIZE_EXITCODE RAWSPEED_LARGEPAGESIZE_COMPILED 16 | "${CMAKE_BINARY_DIR}" 17 | "${CMAKE_CURRENT_LIST_DIR}/cpu-large-page-size.cpp" 18 | COMPILE_DEFINITIONS -DRAWSPEED_PAGESIZE=${RAWSPEED_PAGESIZE} 19 | COMPILE_OUTPUT_VARIABLE RAWSPEED_LARGEPAGESIZE_COMPILE_OUTPUT 20 | RUN_OUTPUT_VARIABLE RAWSPEED_LARGEPAGESIZE_RUN_OUTPUT) 21 | 22 | if(NOT RAWSPEED_LARGEPAGESIZE_COMPILED OR NOT RAWSPEED_LARGEPAGESIZE_EXITCODE EQUAL 0) 23 | message(SEND_ERROR "Failed to query CPU large page size:\n${RAWSPEED_LARGEPAGESIZE_COMPILE_OUTPUT}\n${RAWSPEED_LARGEPAGESIZE_RUN_OUTPUT}") 24 | return() 25 | endif() 26 | 27 | string(STRIP "${RAWSPEED_LARGEPAGESIZE_RUN_OUTPUT}" RAWSPEED_LARGEPAGESIZE) 28 | endif() 29 | 30 | message(STATUS "Deciding that the CPU large page size is ${RAWSPEED_LARGEPAGESIZE} bytes") 31 | 32 | if(RAWSPEED_LARGEPAGESIZE EQUAL 0) 33 | unset(RAWSPEED_LARGEPAGESIZE) 34 | message(SEND_ERROR "Detected large page size is zero!") 35 | endif() 36 | 37 | set(RAWSPEED_LARGEPAGESIZE ${RAWSPEED_LARGEPAGESIZE} CACHE INTERNAL "") 38 | -------------------------------------------------------------------------------- /cmake/Modules/cpu-large-page-size.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if defined(__i386__) || defined(__x86_64__) 5 | 6 | #include 7 | 8 | /* Features in %edx for leaf 1 */ 9 | #if !defined(bit_PSE) 10 | #define bit_PSE 0x00000008 11 | #endif 12 | #if !defined(bit_PAE) 13 | #define bit_PAE 0x00000040 14 | #endif 15 | 16 | int main() { 17 | unsigned int eax; 18 | unsigned int ebx; 19 | unsigned int ecx; 20 | unsigned int edx; 21 | 22 | if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) 23 | return 1; // Detection failed. 24 | 25 | size_t val; 26 | if (edx & bit_PAE) 27 | val = 2 * 1024 * 1024; // 2 MiB 28 | else if (edx & bit_PSE) 29 | val = 4 * 1024 * 1024; // 4 MiB 30 | else 31 | val = 4 * 1024; // 4 KiB 32 | 33 | std::cout << val << std::endl; 34 | return 0; 35 | } 36 | 37 | #else 38 | 39 | int main() { 40 | // Don't know how to perform detection. Just fall back to page size. 41 | std::cout << RAWSPEED_PAGESIZE << std::endl; 42 | return 0; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /cmake/Modules/cpu-page-size.cmake: -------------------------------------------------------------------------------- 1 | if(DEFINED RAWSPEED_PAGESIZE) 2 | return() 3 | endif() 4 | 5 | message(STATUS "Trying to query CPU page size") 6 | 7 | if(BINARY_PACKAGE_BUILD) 8 | message(STATUS "Performing binary package build, using hardcoded value.") 9 | set(RAWSPEED_PAGESIZE 4096) 10 | else() 11 | try_run(RAWSPEED_PAGESIZE_EXITCODE RAWSPEED_PAGESIZE_COMPILED 12 | "${CMAKE_BINARY_DIR}" 13 | "${CMAKE_CURRENT_LIST_DIR}/cpu-page-size.cpp" 14 | COMPILE_OUTPUT_VARIABLE RAWSPEED_PAGESIZE_COMPILE_OUTPUT 15 | RUN_OUTPUT_VARIABLE RAWSPEED_PAGESIZE_RUN_OUTPUT) 16 | 17 | if(NOT RAWSPEED_PAGESIZE_COMPILED OR NOT RAWSPEED_PAGESIZE_EXITCODE EQUAL 0) 18 | message(SEND_ERROR "Failed to query CPU page size:\n${RAWSPEED_PAGESIZE_COMPILE_OUTPUT}\n${RAWSPEED_PAGESIZE_RUN_OUTPUT}") 19 | return() 20 | endif() 21 | 22 | string(STRIP "${RAWSPEED_PAGESIZE_RUN_OUTPUT}" RAWSPEED_PAGESIZE) 23 | endif() 24 | 25 | message(STATUS "Deciding that the CPU page size is ${RAWSPEED_PAGESIZE} bytes") 26 | 27 | if(RAWSPEED_PAGESIZE EQUAL 0) 28 | unset(RAWSPEED_PAGESIZE) 29 | message(SEND_ERROR "Detected page size is zero!") 30 | endif() 31 | 32 | set(RAWSPEED_PAGESIZE ${RAWSPEED_PAGESIZE} CACHE INTERNAL "") 33 | -------------------------------------------------------------------------------- /cmake/Modules/cpu-page-size.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(__unix__) || defined(__APPLE__) 4 | #include 5 | #endif 6 | 7 | #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) || defined(__APPLE__) 8 | 9 | int main() { 10 | long val = ::sysconf(_SC_PAGESIZE); 11 | if (val == -1) 12 | return 1; 13 | std::cout << val << std::endl; 14 | return 0; 15 | } 16 | 17 | #elif defined(_WIN32) || defined(_WIN64) 18 | 19 | #include 20 | int main() { 21 | SYSTEM_INFO si; 22 | GetSystemInfo(&si); 23 | std::cout << si.dwPageSize << std::endl; 24 | return 0; 25 | } 26 | 27 | #else 28 | #error Do not know how to query (minimal) CPU page size for this system! 29 | #endif 30 | -------------------------------------------------------------------------------- /cmake/Modules/run-xmllint.cmake: -------------------------------------------------------------------------------- 1 | macro (check_xml XML XSD) 2 | get_filename_component(FILENAME "${XML}" NAME) 3 | 4 | set(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.touch") 5 | 6 | set(TMPNAME "validate-${FILENAME}") 7 | 8 | add_custom_command( 9 | OUTPUT "${TOUCH}" 10 | COMMAND "$" --nonet --valid --noout --schema "${XSD}" "${XML}" 11 | COMMAND "${CMAKE_COMMAND}" -E touch "${TOUCH}" # will be empty! 12 | DEPENDS xmllint "${XML}" "${XSD}" 13 | COMMENT "Checking validity of ${FILENAME}" 14 | VERBATIM 15 | ) 16 | 17 | add_custom_target( 18 | ${TMPNAME} 19 | DEPENDS "${TOUCH}" # will be empty! 20 | DEPENDS "${XML}" 21 | ) 22 | 23 | add_dependencies(check-rawspeed ${TMPNAME}) 24 | add_dependencies(rawspeed ${TMPNAME}) 25 | endmacro (check_xml) 26 | -------------------------------------------------------------------------------- /cmake/Modules/thread-local.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXSourceCompiles) 2 | 3 | CHECK_CXX_SOURCE_COMPILES(" 4 | static thread_local int tls; 5 | int main(void) 6 | { 7 | (void)tls; 8 | return 0; 9 | }" HAVE_CXX_THREAD_LOCAL) 10 | if(HAVE_CXX_THREAD_LOCAL) 11 | return() 12 | endif() 13 | 14 | CHECK_CXX_SOURCE_COMPILES(" 15 | static __thread int tls; 16 | int main(void) 17 | { 18 | (void)tls; 19 | return 0; 20 | }" HAVE_GCC_THREAD_LOCAL) 21 | if(HAVE_GCC_THREAD_LOCAL) 22 | return() 23 | endif() 24 | 25 | MESSAGE(SEND_ERROR "The compiler does not support Thread-local storage.") 26 | -------------------------------------------------------------------------------- /cmake/build-type.cmake: -------------------------------------------------------------------------------- 1 | # Add a sensible build type default and warning because empty means no optimization and no debug info. 2 | if(NOT CMAKE_BUILD_TYPE) 3 | message(WARNING "CMAKE_BUILD_TYPE is not defined!") 4 | 5 | set(default_build_type "ReleaseWithAsserts") 6 | 7 | message("WARNING: Defaulting to CMAKE_BUILD_TYPE=${default_build_type}. Use ccmake to set a proper value.") 8 | 9 | SET(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "" FORCE) 10 | endif(NOT CMAKE_BUILD_TYPE) 11 | 12 | set(RAWSPEED_STANDARD_BUILD_TYPES Debug ReleaseWithAsserts Release) 13 | set(RAWSPEED_SPECIAL_BUILD_TYPES Coverage Sanitize TSan Fuzz) 14 | set(CMAKE_CONFIGURATION_TYPES ${RAWSPEED_STANDARD_BUILD_TYPES} ${RAWSPEED_SPECIAL_BUILD_TYPES} CACHE STRING "All the available build types" FORCE) 15 | 16 | string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPERCASE) 17 | string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" CMAKE_CONFIGURATION_TYPES_UPPERCASE) 18 | string(TOUPPER "${RAWSPEED_SPECIAL_BUILD_TYPES}" RAWSPEED_SPECIAL_BUILD_TYPES_UPPERCASE) 19 | 20 | # is this one of the known build types? 21 | list (FIND CMAKE_CONFIGURATION_TYPES_UPPERCASE ${CMAKE_BUILD_TYPE_UPPERCASE} BUILD_TYPE_IS_KNOWN) 22 | if (${BUILD_TYPE_IS_KNOWN} EQUAL -1) 23 | message(SEND_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE_UPPERCASE}. Please specify one of: ${CMAKE_CONFIGURATION_TYPES}") 24 | endif() 25 | 26 | # is this a special build? 27 | list (FIND RAWSPEED_SPECIAL_BUILD_TYPES_UPPERCASE ${CMAKE_BUILD_TYPE_UPPERCASE} IS_SPECIAL_BUILD) 28 | if (${IS_SPECIAL_BUILD} EQUAL -1) 29 | unset(RAWSPEED_SPECIAL_BUILD) 30 | else() 31 | set(RAWSPEED_SPECIAL_BUILD 1) 32 | endif() 33 | 34 | foreach(CONFIGURATION_TYPE ${CMAKE_CONFIGURATION_TYPES}) 35 | unset(RAWSPEED_${CONFIGURATION_TYPE}_BUILD) 36 | endforeach() 37 | set(RAWSPEED_${CMAKE_BUILD_TYPE_UPPERCASE}_BUILD 1) 38 | -------------------------------------------------------------------------------- /cmake/clang-tidy.cmake: -------------------------------------------------------------------------------- 1 | find_package(LLVMClangTidy REQUIRED) 2 | 3 | unset(plugin) 4 | 5 | if(USE_RAWSPEED_CLANG_TIDY_MODULE) 6 | math(EXPR CLANG_TIDY_VERSION_MAJOR_NEXT "1 + ${CLANG_TIDY_VERSION_MAJOR}") 7 | 8 | find_package(RawSpeedClangTidyModule ${CLANG_TIDY_VERSION_MAJOR}.0.0...<${CLANG_TIDY_VERSION_MAJOR_NEXT}.0.0 REQUIRED CONFIG) 9 | 10 | SET_PACKAGE_PROPERTIES(RawSpeedClangTidyModule PROPERTIES 11 | URL https://github.com/darktable-org/rawspeed-clang-tidy-module 12 | DESCRIPTION "custom clang-tidy module for RawSpeed library" 13 | PURPOSE "RawSpeed-specific clang-tidy checks" 14 | ) 15 | 16 | set(plugin "--load=$") 17 | endif() 18 | 19 | set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY_PATH}") 20 | 21 | if(DEFINED plugin) 22 | set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} ${plugin}) 23 | endif() 24 | 25 | if(NOT RAWSPEED_ENABLE_CLANG_TIDY_WERROR) 26 | set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} -warnings-as-errors=-*) 27 | endif() 28 | 29 | set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} -extra-arg=-Wno-unknown-warning-option) 30 | set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} -extra-arg=-Wno-unknown-pragmas) 31 | -------------------------------------------------------------------------------- /cmake/cmake-command-wrappers.cmake: -------------------------------------------------------------------------------- 1 | # Creates a new executable build target. Use this instead of `add_executable`. 2 | if(NOT COMMAND rawspeed_add_executable) 3 | function(rawspeed_add_executable target) 4 | add_executable(${target} ${ARGN}) 5 | endfunction() 6 | endif() # NOT COMMAND rawspeed_add_executable 7 | 8 | # Creates a new library build target. Use this instead of `add_library`. 9 | if(NOT COMMAND rawspeed_add_library) 10 | function(rawspeed_add_library target) 11 | add_library(${target} ${ARGN}) 12 | endfunction() 13 | endif() # NOT COMMAND rawspeed_add_library 14 | 15 | # Creates test. Use this instead of `add_test`. 16 | # WARNING: do NOT create multiple tests for same COMMAND that only differ in arg 17 | if(NOT COMMAND rawspeed_add_test) 18 | function(rawspeed_add_test) 19 | add_test(${ARGN}) 20 | endfunction() 21 | endif() # NOT COMMAND rawspeed_add_test 22 | -------------------------------------------------------------------------------- /cmake/compiler-warnings-clang.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlagAndEnableIt) 2 | 3 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 4 | return() 5 | endif() 6 | 7 | set (CLANG_WARNING_FLAGS 8 | "all" 9 | "extra" 10 | "everything" 11 | ) 12 | 13 | set (CLANG_DISABLED_WARNING_FLAGS 14 | "c++98-compat" 15 | "c++98-compat-pedantic" 16 | "c++20-extensions" 17 | "padded" 18 | "switch-default" 19 | "switch-enum" 20 | "unused-parameter" 21 | "sign-conversion" # FIXME: should enable this. 22 | "unsafe-buffer-usage-in-libc-call" # FIXME: should probably be enabled 23 | ) 24 | 25 | # Yes, these have to be *re-enabled* after CLANG_DISABLED_WARNING_FLAGS. 26 | set (CLANG_REENABLED_WARNING_FLAGS 27 | "extra-semi" 28 | ) 29 | 30 | if(NOT (UNIX OR APPLE)) 31 | # bogus warnings about std functions... 32 | list(APPEND CLANG_DISABLED_WARNING_FLAGS "used-but-marked-unused") 33 | # just don't care. 34 | list(APPEND CLANG_DISABLED_WARNING_FLAGS "nonportable-system-include-path") 35 | endif() 36 | 37 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) 38 | # Clang 16 used to point at the variable declaration in the diagnostics, 39 | # and not at the pointer arithmetic itself. 40 | list(APPEND CLANG_DISABLED_WARNING_FLAGS "unsafe-buffer-usage") 41 | endif() 42 | 43 | foreach(warning ${CLANG_WARNING_FLAGS}) 44 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-W${warning}) 45 | endforeach() 46 | 47 | foreach(warning ${CLANG_DISABLED_WARNING_FLAGS}) 48 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-${warning}) 49 | endforeach() 50 | 51 | foreach(warning ${CLANG_REENABLED_WARNING_FLAGS}) 52 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-W${warning}) 53 | endforeach() 54 | -------------------------------------------------------------------------------- /cmake/compiler-warnings-gcc.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlagAndEnableIt) 2 | 3 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 4 | return() 5 | endif() 6 | 7 | set (GCC_WARNING_FLAGS 8 | "all" 9 | "extra" 10 | 11 | "cast-qual" 12 | "extra" 13 | "extra-semi" 14 | "format=2" 15 | # "missing-prototypes" 16 | "pointer-arith" 17 | # "strict-prototypes" 18 | # "suggest-attribute=const" 19 | # "suggest-attribute=noreturn" 20 | # "suggest-attribute=pure" 21 | # "suggest-final-methods" 22 | # "suggest-final-types" 23 | # "suggest-override" 24 | # "traditional" 25 | "vla" 26 | # "cast-align" 27 | # "conversion" 28 | ) 29 | 30 | if(UNIX OR APPLE) 31 | list(APPEND GCC_WARNING_FLAGS 32 | "missing-format-attribute" 33 | "suggest-attribute=format" 34 | ) 35 | endif() 36 | 37 | set (GCC_DISABLED_WARNING_FLAGS 38 | "unused-parameter" 39 | "maybe-uninitialized" 40 | "stringop-overflow" # bogus warnings at least as of GCC13 41 | "array-bounds" # bogus warnings at least as of GCC13 42 | "free-nonheap-object" # bogus warnings on armv6l/armv7l at least as of GCC14 43 | ) 44 | 45 | set (GCC_NOERROR_WARNING_FLAGS 46 | # "suggest-attribute=const" 47 | # "suggest-attribute=noreturn" 48 | # "suggest-attribute=pure" 49 | # "suggest-final-methods" 50 | # "suggest-final-types" 51 | # "suggest-override" 52 | ) 53 | 54 | foreach(warning ${GCC_WARNING_FLAGS}) 55 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-W${warning}) 56 | endforeach() 57 | 58 | foreach(warning ${GCC_DISABLED_WARNING_FLAGS}) 59 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-${warning}) 60 | endforeach() 61 | 62 | foreach(warning ${GCC_NOERROR_WARNING_FLAGS}) 63 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-error=${warning}) 64 | endforeach() 65 | -------------------------------------------------------------------------------- /cmake/compiler-warnings.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXCompilerFlagAndEnableIt) 2 | 3 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 4 | include(compiler-warnings-gcc) 5 | endif() 6 | 7 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 8 | include(compiler-warnings-clang) 9 | endif() 10 | 11 | if(NOT (UNIX OR APPLE)) 12 | # on windows, results in bogus false-positive warnings 13 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-format) 14 | endif() 15 | 16 | if(NOT RAWSPEED_SPECIAL_BUILD) 17 | # should be < 64Kb 18 | math(EXPR MAX_MEANINGFUL_SIZE 4*1024) 19 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wstack-usage=${MAX_MEANINGFUL_SIZE}) 20 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wframe-larger-than=${MAX_MEANINGFUL_SIZE}) 21 | 22 | # as small as possible, but 1Mb+ is ok. 23 | math(EXPR MAX_MEANINGFUL_SIZE 32*1024) 24 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wlarger-than=${MAX_MEANINGFUL_SIZE}) 25 | endif() 26 | -------------------------------------------------------------------------------- /cmake/debug-info.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCompilerFlag) 2 | include(CheckLinkerFlag) 3 | 4 | if(RAWSPEED_ENABLE_DEBUG_INFO) 5 | # always debug info 6 | add_definitions(-g3) 7 | add_definitions(-ggdb3) 8 | 9 | check_compiler_flag(CXX -gz COMPILER_SUPPORTS_DEBUG_INFO_COMPRESSION) 10 | check_linker_flag(CXX -gz COMPILER_SUPPORTS_DEBUG_INFO_COMPRESSION_LINK) 11 | if(COMPILER_SUPPORTS_DEBUG_INFO_COMPRESSION AND COMPILER_SUPPORTS_DEBUG_INFO_COMPRESSION_LINK) 12 | add_compile_options(-gz) 13 | add_link_options(-gz) 14 | endif() 15 | 16 | if(NOT (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)) 17 | check_compiler_flag(CXX -gsplit-dwarf COMPILER_SUPPORTS_SPLIT_DEBUG_INFO) 18 | if(COMPILER_SUPPORTS_SPLIT_DEBUG_INFO) 19 | add_compile_options(-gsplit-dwarf) 20 | endif() 21 | 22 | check_linker_flag(CXX -Wl,--gdb-index LINKER_SUPPORTS_GDB_INDEX) 23 | if(LINKER_SUPPORTS_GDB_INDEX) 24 | add_link_options(-Wl,--gdb-index) 25 | endif() 26 | endif() 27 | elseif(NOT RAWSPEED_ENABLE_DEBUG_INFO) 28 | add_definitions(-g0) 29 | else() 30 | message(SEND_ERROR "RAWSPEED_ENABLE_DEBUG_INFO has unknown value: \"${RAWSPEED_ENABLE_DEBUG_INFO}\"") 31 | endif() 32 | -------------------------------------------------------------------------------- /cmake/gcc-coverage.cmake: -------------------------------------------------------------------------------- 1 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) 3 | message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") 4 | endif() 5 | elseif(NOT CMAKE_COMPILER_IS_GNUCXX) 6 | message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") 7 | endif() 8 | 9 | if(NOT RAWSPEED_COVERAGE_BUILD) 10 | message(WARNING "Wrong build type, need COVERAGE.") 11 | endif() 12 | 13 | add_custom_target( 14 | coverage-clean 15 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target genhtml-clean 16 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target lcov-clean 17 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target gcov-clean 18 | ) 19 | 20 | add_custom_target( 21 | coverage 22 | DEPENDS tests 23 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target coverage-clean 24 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target lcov-baseline 25 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target test 26 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target lcov-capture 27 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target lcov-combine 28 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target lcov-postprocess 29 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target genhtml 30 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 31 | COMMENT "Doing everything to generate clean fresh HTML coverage report" 32 | USES_TERMINAL 33 | ) 34 | -------------------------------------------------------------------------------- /cmake/gcc-gcov.cmake: -------------------------------------------------------------------------------- 1 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) 3 | message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") 4 | endif() 5 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 6 | elseif(NOT CMAKE_COMPILER_IS_GNUCXX) 7 | message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") 8 | endif() 9 | 10 | if(NOT RAWSPEED_COVERAGE_BUILD) 11 | message(WARNING "Wrong build type, need COVERAGE.") 12 | endif() 13 | 14 | find_package(GCov REQUIRED) 15 | find_package(Find REQUIRED) 16 | 17 | set(GCOV_OPTS "-pb") 18 | 19 | if(NOT APPLE) 20 | # DON'T elide source prefix. 21 | set(GCOV_OPTS ${GCOV_OPTS} -aflu) 22 | endif() 23 | 24 | # Find all *.gcno files and run gcov on them, but ignore stdout of gcov. 25 | # While you'd normally just "> /dev/null", there are edge cases where that does not work. 26 | file(WRITE "${CMAKE_BINARY_DIR}/run-gcov-wrapper.cmake" 27 | "execute_process( 28 | COMMAND \"${FIND_PATH}\" \"${CMAKE_BINARY_DIR}\" -type f -name *.gcno -exec \"${GCOV_PATH}\" ${GCOV_OPTS} {} + 29 | WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\" 30 | OUTPUT_QUIET 31 | COMMAND_ECHO STDOUT 32 | ) 33 | ") 34 | add_custom_target( 35 | gcov 36 | COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/run-gcov-wrapper.cmake" 37 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 38 | COMMENT "Running gcov tool on all the *.gcno files to produce *.gcov files" 39 | ) 40 | 41 | # DON'T remove *.gcno/*.gcov files here! 42 | add_custom_target( 43 | gcov-clean 44 | COMMAND "${FIND_PATH}" "${CMAKE_BINARY_DIR}" -type f -name '*.gcda' -delete > /dev/null 45 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 46 | COMMENT "Removing all the *.gcda files" 47 | ) 48 | -------------------------------------------------------------------------------- /cmake/gcc-toolchain.cmake: -------------------------------------------------------------------------------- 1 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 2 | return() 3 | endif() 4 | 5 | find_package(GCCAr REQUIRED) 6 | set(CMAKE_AR "${GCCAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) 7 | 8 | find_package(GCCNm REQUIRED) 9 | set(CMAKE_NM "${GCCNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) 10 | 11 | find_package(GCCRanLib REQUIRED) 12 | set(CMAKE_RANLIB "${GCCRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) 13 | -------------------------------------------------------------------------------- /cmake/genhtml.cmake: -------------------------------------------------------------------------------- 1 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) 3 | message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") 4 | endif() 5 | elseif(NOT CMAKE_COMPILER_IS_GNUCXX) 6 | message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") 7 | endif() 8 | 9 | if(NOT RAWSPEED_COVERAGE_BUILD) 10 | message(WARNING "Wrong build type, need COVERAGE.") 11 | endif() 12 | 13 | find_package(GenHtml REQUIRED) 14 | find_package(CppFilt REQUIRED) 15 | 16 | add_custom_target( 17 | genhtml 18 | COMMAND "${GENHTML_PATH}" 19 | --demangle-cpp --precision 2 20 | -o "${CMAKE_BINARY_DIR}/coverage/" 21 | --prefix "${CMAKE_SOURCE_DIR}" 22 | lcov.final.info 23 | COMMAND "${CMAKE_COMMAND}" -E echo "Use $$ sensible-browser \"./coverage/index.html\" to view the coverage report." 24 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 25 | COMMENT "Running genhtml tool to generate HTML coverage report" 26 | USES_TERMINAL 27 | ) 28 | 29 | add_custom_target( 30 | genhtml-clean 31 | COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_BINARY_DIR}/coverage" 32 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 33 | COMMENT "Removing HTML coverage report" 34 | ) 35 | -------------------------------------------------------------------------------- /cmake/libc++.cmake: -------------------------------------------------------------------------------- 1 | if(NOT RAWSPEED_USE_LIBCXX) 2 | return() 3 | endif() 4 | 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 6 | list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES stdc++) 7 | list(APPEND CMAKE_CXX_IMPLICIT_LINK_LIBRARIES c++) 8 | list(REMOVE_DUPLICATES CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) 9 | 10 | # Also remove incorrectly parsed -lto_library flag 11 | # It wasn't present with Xcode 7.2 and appeared before 8.3 release 12 | # cmake 3.7.2 doesn't understand this flag and thinks it's a library 13 | list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES to_library) 14 | -------------------------------------------------------------------------------- /cmake/llvm-cov.cmake: -------------------------------------------------------------------------------- 1 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | message(FATAL_ERROR "Compiler is not clang! Aborting...") 3 | endif() 4 | 5 | if(NOT RAWSPEED_COVERAGE_BUILD) 6 | message(WARNING "Wrong build type, need COVERAGE.") 7 | endif() 8 | 9 | find_package(LLVMCov REQUIRED) 10 | find_package(Demangler REQUIRED) 11 | 12 | # FIXME: all this does not really work because only the rstest coverage is shown 13 | 14 | add_custom_target( 15 | coverage-show 16 | DEPENDS rstest 17 | COMMAND "${LLVMCOV_PATH}" show -Xdemangler=$ -instr-profile "${RAWSPEED_PROFDATA_FILE}" "$" -format html -output-dir "${CMAKE_BINARY_DIR}/coverage" 18 | COMMAND "${CMAKE_COMMAND}" -E echo "Use $$ sensible-browser \"./coverage/index.html\" to view the coverage report." 19 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 20 | COMMENT "Running llvm-cov tool on the *.profdata file to generate HTML coverage report" 21 | VERBATIM 22 | ) 23 | 24 | add_custom_target( 25 | coverage-clean 26 | COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_BINARY_DIR}/coverage" 27 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 28 | COMMENT "Removing HTML coverage report" 29 | ) 30 | 31 | add_custom_target( 32 | coverage 33 | DEPENDS tests rstest 34 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target coverage-clean 35 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target profdata-clean 36 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target test 37 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target profdata 38 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target coverage-show 39 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 40 | COMMENT "Doing everything to generate clean fresh HTML coverage report" 41 | USES_TERMINAL 42 | ) 43 | -------------------------------------------------------------------------------- /cmake/llvm-opt-report.cmake: -------------------------------------------------------------------------------- 1 | if(NOT USE_LLVM_OPT_REPORT OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | return() 3 | endif() 4 | 5 | include(CheckCXXCompilerFlag) 6 | 7 | find_package(LLVMOptViewer REQUIRED) 8 | 9 | message(STATUS "Checking for -fsave-optimization-record support") 10 | CHECK_CXX_COMPILER_FLAG("-fsave-optimization-record" HAVE_CXX_FLAG_FSAVE_OPTIMIZATION_RECORD) 11 | if(NOT HAVE_CXX_FLAG_FSAVE_OPTIMIZATION_RECORD) 12 | message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} does not support saving optimization records.") 13 | else() 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsave-optimization-record") 15 | endif() 16 | 17 | set(REPORT_PATH "${CMAKE_CURRENT_BINARY_DIR}/opt-report") 18 | 19 | add_custom_target(opt-report 20 | COMMAND "${CMAKE_COMMAND}" -E remove_directory "${REPORT_PATH}" 21 | COMMAND "${LLVMOPTVIEWER_PATH}" 22 | --output-dir "${REPORT_PATH}" 23 | -source-dir "${CMAKE_CURRENT_SOURCE_DIR}" 24 | "${CMAKE_CURRENT_BINARY_DIR}" 25 | COMMAND "${CMAKE_COMMAND}" -E echo "Use $$ sensible-browser \"${REPORT_PATH}\" to view the optimizatons report." 26 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 27 | COMMENT "Generating HTML output to visualize optimization records from the YAML files" 28 | VERBATIM 29 | USES_TERMINAL) 30 | -------------------------------------------------------------------------------- /cmake/llvm-profdata.cmake: -------------------------------------------------------------------------------- 1 | if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 2 | message(FATAL_ERROR "Compiler is not clang! Aborting...") 3 | endif() 4 | 5 | if(NOT RAWSPEED_COVERAGE_BUILD) 6 | message(WARNING "Wrong build type, need COVERAGE.") 7 | endif() 8 | 9 | find_package(LLVMProfData REQUIRED) 10 | find_package(Find REQUIRED) 11 | 12 | add_custom_target( 13 | profdata 14 | COMMAND "${FIND_PATH}" "${CMAKE_BINARY_DIR}" -type f -name '*.profraw' -exec "${LLVMPROFDATA_PATH}" merge -o "${RAWSPEED_PROFDATA_FILE}" {} + > /dev/null 15 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 16 | COMMENT "Running llvm-profdata tool on all the *.profraw files" 17 | ) 18 | 19 | add_custom_target( 20 | profdata-clean 21 | COMMAND "${FIND_PATH}" "${CMAKE_BINARY_DIR}" -type f -name '*.profdata' -delete > /dev/null 22 | COMMAND "${FIND_PATH}" "${CMAKE_BINARY_DIR}" -type f -name '*.profraw' -delete > /dev/null 23 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" 24 | COMMENT "Removing all the *.profdata and *.profraw files" 25 | ) 26 | -------------------------------------------------------------------------------- /cmake/llvm-toolchain.cmake: -------------------------------------------------------------------------------- 1 | find_package(LLVMAr REQUIRED) 2 | set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) 3 | 4 | find_package(LLVMNm REQUIRED) 5 | set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) 6 | 7 | find_package(LLVMObjCopy) 8 | if(LLVMObjCopy_FOUND) 9 | set(CMAKE_OBJCOPY "${LLVMOBJCOPY_EXECUTABLE}" CACHE FILEPATH "" FORCE) 10 | endif() 11 | 12 | find_package(LLVMObjDump REQUIRED) 13 | set(CMAKE_OBJDUMP "${LLVMOBJDUMP_EXECUTABLE}" CACHE FILEPATH "" FORCE) 14 | 15 | find_package(LLVMRanLib REQUIRED) 16 | set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) 17 | 18 | find_package(LLVMLLD REQUIRED) 19 | set(CMAKE_LINKER "${LLVMLLD_EXECUTABLE}" CACHE FILEPATH "" FORCE) 20 | -------------------------------------------------------------------------------- /credits.txt: -------------------------------------------------------------------------------- 1 | RawSpeed - a fast RAW file decoder. 2 | Copyright (C) 2009-2014 Klaus Post 3 | 4 | Project github: https://github.com/darktable-org/rawspeed 5 | 6 | Email: klauspost (at) gmail (dot) com 7 | 8 | 9 | RawSpeed contains code from the following projects: 10 | 11 | * libopenraw by Hubert Figuiere, et al. 12 | * http://libopenraw.freedesktop.org 13 | 14 | * dcraw by David Coffin 15 | * http://www.cybercom.net/~dcoffin/ 16 | 17 | Thanks to: 18 | * Pedro Côrte-Real for writing support for Minolta & old Panasonic cameras. 19 | * Pascal de Bruijn for a ton of help with camera definitions 20 | * Alex Tutubalin for bug reports, help and good suggestions 21 | * Laurent Clevy for his excellent CR2 documentation project: 22 | * http://lclevy.free.fr/cr2/index.html 23 | * All who supplied RAW test images to Rawstudio 24 | * Of course all involved with the Rawstudio project 25 | -------------------------------------------------------------------------------- /data/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(USE_XMLLINT) 2 | find_package(XMLLINT) 3 | endif() 4 | 5 | if(USE_XMLLINT AND XMLLINT_FOUND) 6 | include(run-xmllint) 7 | check_xml(${CMAKE_CURRENT_SOURCE_DIR}/cameras.xml ${CMAKE_CURRENT_SOURCE_DIR}/cameras.xsd) 8 | endif() 9 | 10 | if(WITH_PUGIXML) 11 | install(FILES cameras.xml showcameras.xsl DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/rawspeed) 12 | endif() 13 | -------------------------------------------------------------------------------- /docs/Doxygen.rst: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | Doxygen 3 | ================================================================================ 4 | 5 | .. meta:: 6 | :http-equiv=refresh: 0; url=doxygen/index.html 7 | 8 | `The Doxygen-based documentation is available here `_ 9 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. RawSpeed documentation master file, created by 2 | sphinx-quickstart on Mon Aug 14 18:30:09 2017. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to RawSpeed's documentation! 7 | ==================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :hidden: 12 | 13 | self 14 | CameraSupport 15 | ReferenceSampleArchive 16 | IntegrationTesting 17 | Doxygen 18 | lnt/index.rst 19 | 20 | .. include:: ../README.rst 21 | 22 | Indices and tables 23 | ================== 24 | 25 | * :ref:`genindex` 26 | * :ref:`search` 27 | -------------------------------------------------------------------------------- /docs/lnt/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../lnt/README.rst 2 | -------------------------------------------------------------------------------- /docs/sphinx-pyexec.py: -------------------------------------------------------------------------------- 1 | try: 2 | from StringIO import StringIO 3 | except ImportError: 4 | from io import StringIO 5 | 6 | import sys 7 | from docutils.parsers.rst import Directive 8 | from docutils import nodes 9 | from sphinx.util import nested_parse_with_titles 10 | from docutils.statemachine import StringList 11 | 12 | 13 | class ExecDirective(Directive): 14 | has_content = True 15 | required_arguments = 0 16 | 17 | def execute_code(cls, code): 18 | codeOut = StringIO() 19 | codeErr = StringIO() 20 | 21 | sys.stdout = codeOut 22 | sys.stderr = codeErr 23 | 24 | exec(code) 25 | 26 | sys.stdout = sys.__stdout__ 27 | sys.stderr = sys.__stderr__ 28 | 29 | results = list() 30 | results.append(codeOut.getvalue()) 31 | results.append(codeErr.getvalue()) 32 | results = ''.join(results) 33 | 34 | return results 35 | 36 | def run(self): 37 | self.assert_has_content() 38 | 39 | code = '\n'.join(self.content) 40 | code_results = self.execute_code(code) 41 | 42 | sl = StringList(code_results.replace("\r", "").split("\n")) 43 | 44 | node = nodes.paragraph() 45 | nested_parse_with_titles(self.state, sl, node) 46 | 47 | output = [] 48 | output.append(node) 49 | return output 50 | 51 | 52 | def setup(app): 53 | app.add_directive('exec', ExecDirective) 54 | -------------------------------------------------------------------------------- /fuzz/corpora/.gitignore: -------------------------------------------------------------------------------- 1 | # no corpus shall be committed into the repo. 2 | * 3 | -------------------------------------------------------------------------------- /fuzz/corpora/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE CORPORA_ROOTS FOLLOW_SYMLINKS "${CMAKE_CURRENT_SOURCE_DIR}/**/timestamp.txt") 2 | foreach(TOP_CORPORA_DIR ${CORPORA_ROOTS}) 3 | get_filename_component(TOP_CORPORA_DIRS "${TOP_CORPORA_DIR}" DIRECTORY) 4 | file(GLOB CORPORAS FOLLOW_SYMLINKS "${TOP_CORPORA_DIRS}/*") 5 | 6 | foreach(CORPORA ${CORPORAS}) 7 | if(IS_DIRECTORY "${CORPORA}") 8 | get_filename_component(dirname "${CORPORA}" NAME) 9 | list(FIND ALL_FUZZERS "${dirname}" IsFuzzerName) 10 | 11 | if(NOT IsFuzzerName EQUAL -1) 12 | # get all the files 13 | file(GLOB_RECURSE CORPUSES RELATIVE "${CORPORA}" FOLLOW_SYMLINKS "${CORPORA}/*") 14 | 15 | set(test "corpora/${dirname}") 16 | rawspeed_add_test(NAME ${test} 17 | COMMAND ${dirname} ${CORPUSES} 18 | WORKING_DIRECTORY "${CORPORA}") 19 | set_tests_properties(${test} PROPERTIES DEPENDS ${dirname}) 20 | set_tests_properties(${test} PROPERTIES TIMEOUT 300) 21 | endif() 22 | endif() 23 | endforeach() 24 | endforeach() 25 | -------------------------------------------------------------------------------- /fuzz/librawspeed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_include_directories(rawspeed_fuzz PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") 2 | 3 | add_subdirectory(bitstreams) 4 | add_subdirectory(codes) 5 | add_subdirectory(common) 6 | add_subdirectory(decoders) 7 | add_subdirectory(decompressors) 8 | add_subdirectory(fuzz) 9 | add_subdirectory(parsers) 10 | -------------------------------------------------------------------------------- /fuzz/librawspeed/bitstreams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(add_simple_fuzzer name) 2 | set(TheFuzzer "${name}Fuzzer") 3 | rawspeed_add_executable(${TheFuzzer} "${name}.cpp") 4 | 5 | add_fuzz_target(${TheFuzzer}) 6 | 7 | add_dependencies(fuzzers ${TheFuzzer}) 8 | endmacro() 9 | 10 | set(NAMES 11 | "BitVacuumerRoundtrip" 12 | ) 13 | 14 | foreach(name ${NAMES}) 15 | add_simple_fuzzer(${name}) 16 | endforeach() 17 | -------------------------------------------------------------------------------- /fuzz/librawspeed/codes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(PrefixCodeDecoder) 2 | add_subdirectory(PrefixCodeEncoder) 3 | -------------------------------------------------------------------------------- /fuzz/librawspeed/codes/PrefixCodeEncoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(add_simple_fuzzer name) 2 | set(TheFuzzer "${name}Fuzzer") 3 | rawspeed_add_executable(${TheFuzzer} "${name}.cpp") 4 | 5 | add_fuzz_target(${TheFuzzer}) 6 | 7 | add_dependencies(fuzzers ${TheFuzzer}) 8 | endmacro() 9 | 10 | set(NAMES 11 | "PrefixCodeEncoder" 12 | ) 13 | 14 | foreach(name ${NAMES}) 15 | add_simple_fuzzer(${name}) 16 | endforeach() 17 | -------------------------------------------------------------------------------- /fuzz/librawspeed/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(add_simple_fuzzer name) 2 | set(TheFuzzer "${name}Fuzzer") 3 | rawspeed_add_executable(${TheFuzzer} "${name}.cpp") 4 | 5 | add_fuzz_target(${TheFuzzer}) 6 | 7 | add_dependencies(fuzzers ${TheFuzzer}) 8 | endmacro() 9 | 10 | set(NAMES 11 | "DngOpcodes" 12 | ) 13 | 14 | foreach(name ${NAMES}) 15 | add_simple_fuzzer(${name}) 16 | endforeach() 17 | -------------------------------------------------------------------------------- /fuzz/librawspeed/decoders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(TiffDecoders) 2 | -------------------------------------------------------------------------------- /fuzz/librawspeed/decoders/TiffDecoders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(TiffBasedDecoderFuzzers ALL) 2 | add_dependencies(fuzzers TiffBasedDecoderFuzzers) 3 | 4 | function(add_decoder {decoder}) 5 | set(fuzzer "TiffDecoderFuzzer-${decoder}") 6 | 7 | rawspeed_add_executable(${fuzzer} main.cpp) 8 | target_compile_definitions(${fuzzer} 9 | PRIVATE 10 | -DDECODER=${decoder} 11 | ) 12 | 13 | add_fuzz_target(${fuzzer}) 14 | 15 | add_dependencies(TiffBasedDecoderFuzzers ${fuzzer}) 16 | endfunction() 17 | 18 | # see TiffParser::Map[] 19 | set(DECODERS 20 | "ArwDecoder" 21 | "Cr2Decoder" 22 | "DcrDecoder" 23 | "DcsDecoder" 24 | "DngDecoder" 25 | "ErfDecoder" 26 | "IiqDecoder" 27 | "KdcDecoder" 28 | "MefDecoder" 29 | "MosDecoder" 30 | "NefDecoder" 31 | "OrfDecoder" 32 | "PefDecoder" 33 | "Rw2Decoder" 34 | "SrwDecoder" 35 | "StiDecoder" 36 | "ThreefrDecoder" 37 | ) 38 | 39 | foreach(decoder ${DECODERS}) 40 | add_decoder(${decoder}) 41 | endforeach() 42 | -------------------------------------------------------------------------------- /fuzz/librawspeed/decompressors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(add_simple_fuzzer name) 2 | set(TheFuzzer "${name}Fuzzer") 3 | rawspeed_add_executable(${TheFuzzer} "${name}.cpp") 4 | 5 | add_fuzz_target(${TheFuzzer}) 6 | 7 | add_dependencies(fuzzers ${TheFuzzer}) 8 | endmacro() 9 | 10 | set(DECOMPRESSORS 11 | "Cr2LJpegDecoder" 12 | "CrwDecompressor" 13 | "DummyLJpegDecoder" 14 | "FujiDecompressor" 15 | "HasselbladDecompressor" 16 | "HasselbladLJpegDecoder" 17 | "KodakDecompressor" 18 | "LJpegDecoder" 19 | "LJpegDecompressor" 20 | "NikonDecompressor" 21 | "OlympusDecompressor" 22 | "PanasonicV4Decompressor" 23 | "PanasonicV5Decompressor" 24 | "PanasonicV6Decompressor" 25 | "PanasonicV7Decompressor" 26 | "PanasonicV8Decompressor" 27 | "PentaxDecompressor" 28 | "PhaseOneDecompressor" 29 | "SamsungV0Decompressor" 30 | "SamsungV1Decompressor" 31 | "SamsungV2Decompressor" 32 | "SonyArw1Decompressor" 33 | "SonyArw2Decompressor" 34 | "UncompressedDecompressor" 35 | "VC5Decompressor" 36 | ) 37 | 38 | foreach(decompressor ${DECOMPRESSORS}) 39 | add_simple_fuzzer(${decompressor}) 40 | endforeach() 41 | 42 | 43 | macro(add_specialized_fuzzer Name PrefixCodeDecoderImpl) 44 | set(fuzzer "${Name}Fuzzer-${PrefixCodeDecoderImpl}") 45 | 46 | rawspeed_add_executable(${fuzzer} ${Name}.cpp) 47 | target_compile_definitions(${fuzzer} 48 | PRIVATE 49 | -DPrefixCodeDecoderImpl=${PrefixCodeDecoderImpl} 50 | -DWITH_${PrefixCodeDecoderImpl} 51 | ) 52 | 53 | add_fuzz_target(${fuzzer}) 54 | 55 | add_dependencies(PrefixCodeDecoderFuzzers ${fuzzer}) 56 | endmacro() 57 | 58 | add_specialized_fuzzer("Cr2Decompressor" PrefixCodeDecoder) 59 | add_specialized_fuzzer("Cr2Decompressor" DummyPrefixCodeDecoder) 60 | -------------------------------------------------------------------------------- /fuzz/librawspeed/fuzz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_FUZZ_SOURCES 2 | "Common.cpp" 3 | "Common.h" 4 | "RawSpeed.cpp" 5 | ) 6 | 7 | target_sources(rawspeed_fuzz PRIVATE 8 | ${RAWSPEED_FUZZ_SOURCES} 9 | ) 10 | -------------------------------------------------------------------------------- /fuzz/librawspeed/fuzz/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "metadata/ColorFilterArray.h" 25 | 26 | namespace rawspeed { 27 | class ByteStream; 28 | } // namespace rawspeed 29 | 30 | rawspeed::RawImage CreateRawImage(rawspeed::ByteStream& bs); 31 | rawspeed::ColorFilterArray CreateCFA(rawspeed::ByteStream& bs); 32 | -------------------------------------------------------------------------------- /fuzz/librawspeed/fuzz/RawSpeed.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2016-2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "rawspeedconfig.h" 22 | #include "common/Common.h" 23 | 24 | // define this function, it is only declared in rawspeed: 25 | // for fuzzing, do not want any threading. 26 | extern "C" int RAWSPEED_READNONE rawspeed_get_number_of_processor_cores() { 27 | return 1; 28 | } 29 | -------------------------------------------------------------------------------- /fuzz/librawspeed/parsers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(ParserFuzzers ALL) 2 | add_dependencies(fuzzers ParserFuzzers) 3 | 4 | function(add_parser_fuzzer parser variant boolvar boolvar2) 5 | set(fuzzer "${parser}Fuzzer${variant}") 6 | rawspeed_add_executable(${fuzzer} main.cpp) 7 | target_compile_definitions(${fuzzer} 8 | PRIVATE 9 | -DPARSER=${parser} 10 | -DGETDECODER=${boolvar} 11 | -DDECODE=${boolvar2} 12 | ) 13 | 14 | add_fuzz_target(${fuzzer}) 15 | 16 | add_dependencies(ParserFuzzers ${fuzzer}) 17 | endfunction() 18 | 19 | set(PARSERS 20 | "Ciff" 21 | "Fiff" 22 | "Raw" 23 | "Tiff" 24 | ) 25 | 26 | foreach(parser ${PARSERS}) 27 | set(parser "${parser}Parser") 28 | # add_parser_fuzzer(${parser} "" false false) 29 | add_parser_fuzzer(${parser} "-GetDecoder" true false) 30 | add_parser_fuzzer(${parser} "-GetDecoder-Decode" true true) 31 | endforeach() 32 | -------------------------------------------------------------------------------- /fuzz/rawspeed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_executable(RawSpeedFuzzer main.cpp) 2 | 3 | add_fuzz_target(RawSpeedFuzzer) 4 | 5 | add_dependencies(fuzzers RawSpeedFuzzer) 6 | -------------------------------------------------------------------------------- /lnt/RawSpeed.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2019 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | // The goal here is to have an executable that *always* compiles to a different 22 | // binary, *every* compile. This seems counter-productive, but that is needed 23 | // to "fool" LNT into always consider the target changed. 24 | 25 | extern const char* const unique_hash __attribute__((visibility("default"))) = 26 | __TIMESTAMP__; 27 | int main(int argc, char* argv[]) { return 0; } 28 | -------------------------------------------------------------------------------- /lnt/build-lit.local.cfg: -------------------------------------------------------------------------------- 1 | test_modules = config.test_modules 2 | # We have already collected compile/link time, compiler stats globally. 3 | for module in ['compiletime', 'stats']: 4 | if module in test_modules: 5 | test_modules.remove(module) 6 | -------------------------------------------------------------------------------- /lnt/lit.local.cfg: -------------------------------------------------------------------------------- 1 | # Load our custom lit modules 2 | 3 | import site 4 | site.addsitedir(os.path.dirname(__file__)) 5 | 6 | import litsupport_rawspeed 7 | import litsupport_rawspeed.modules 8 | -------------------------------------------------------------------------------- /lnt/litsupport_rawspeed/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/darktable-org/rawspeed/bc4416c6ccad797a71933de2860029f5b7075178/lnt/litsupport_rawspeed/__init__.py -------------------------------------------------------------------------------- /lnt/litsupport_rawspeed/modules/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import logging 3 | import pkgutil 4 | from litsupport.modules import modules 5 | 6 | # Load our custom modules 7 | for importer, modname, ispkg in pkgutil.walk_packages(path=__path__, 8 | prefix=__name__ + '.'): 9 | module = importlib.import_module(modname) 10 | if not hasattr(module, 'mutatePlan'): 11 | logging.error('Skipping %s: No mutatePlan function' % modname) 12 | continue 13 | assert modname.startswith('litsupport_rawspeed.modules.') 14 | shortname = modname[len('litsupport_rawspeed.modules.'):] 15 | modules[shortname] = module 16 | logging.info("Loaded test module %s" % module.__file__) 17 | -------------------------------------------------------------------------------- /lnt/raw-sample-archive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(STRINGS "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/filelist.sha256" _REFERENCE_SAMPLES ENCODING UTF-8) 2 | 3 | set(REFERENCE_SAMPLES) 4 | set(REFERENCE_SAMPLE_HASHES) 5 | 6 | foreach(STR ${_REFERENCE_SAMPLES}) 7 | # There are two schemes: 8 | # <64-char SHA256> <- read in text mode 9 | # <64-char SHA256> <- read in binary mode 10 | # We ignore read mode, so it becomes: 11 | # <64-char SHA256> 12 | string(SUBSTRING "${STR}" 0 64 SAMPLEHASH) 13 | string(SUBSTRING "${STR}" 66 -1 SAMPLENAME) 14 | set(FULLSAMPLENAME "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/${SAMPLENAME}") 15 | 16 | # We have already verified that the entry is valid. 17 | 18 | if(NOT TEST_SUITE_BENCHMARKING_ONLY) 19 | if(NOT EXISTS "${FULLSAMPLENAME}.hash") 20 | message(SEND_ERROR "The reference hash for sample \"${FULLSAMPLENAME}\" does not exist!") 21 | endif() 22 | 23 | llvm_test_run("\"${SAMPLENAME}\"" WORKDIR "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}") 24 | llvm_add_test("${CMAKE_CURRENT_BINARY_DIR}/rstest/${SAMPLENAME}.${SAMPLEHASH}.test" $) 25 | endif() 26 | if(TARGET rsbench) 27 | # WARNING: filename *MUST* be first argument! 28 | llvm_test_run("\"${SAMPLENAME}\"" WORKDIR "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}") 29 | llvm_add_test("${CMAKE_CURRENT_BINARY_DIR}/rsbench/${SAMPLENAME}.${SAMPLEHASH}.test" $) 30 | endif() 31 | endforeach() 32 | 33 | add_subdirectory(rsbench) 34 | 35 | file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") 36 | -------------------------------------------------------------------------------- /lnt/raw-sample-archive/lit.local.cfg: -------------------------------------------------------------------------------- 1 | test_modules = config.test_modules 2 | # Some modules are not interesting for sample-based testing. 3 | for module in ['codesize', 'compiletime', 'stats']: 4 | if module in test_modules: 5 | test_modules.remove(module) 6 | -------------------------------------------------------------------------------- /lnt/raw-sample-archive/rsbench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") 2 | -------------------------------------------------------------------------------- /lnt/raw-sample-archive/rsbench/lit.local.cfg: -------------------------------------------------------------------------------- 1 | test_modules = config.test_modules 2 | if 'run' in test_modules: 3 | # Insert our custom rsbench module behind 'run' 4 | test_modules.insert(test_modules.index('run') + 1, 'rsbench') 5 | # Timeit results are not useful here. 6 | if 'timeit' in test_modules: 7 | test_modules.remove('timeit') 8 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(thread-local) 2 | include(cpu-cache-line-size) 3 | include(cpu-page-size) 4 | include(cpu-large-page-size) 5 | 6 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/rawspeedconfig.h") 7 | target_include_directories(rawspeed PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") 8 | 9 | add_subdirectory(external) 10 | 11 | add_subdirectory(librawspeed) 12 | 13 | if(BUILD_TOOLS) 14 | add_subdirectory(utilities) 15 | endif() 16 | -------------------------------------------------------------------------------- /src/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_include_directories(rawspeed SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") 2 | 3 | FILE(GLOB SOURCES 4 | AddressSanitizer.h 5 | MemorySanitizer.h 6 | ThreadSafetyAnalysis.h 7 | gopro/vc5/table17.inc 8 | ) 9 | 10 | target_sources(rawspeed PRIVATE 11 | ${SOURCES} 12 | ) 13 | -------------------------------------------------------------------------------- /src/librawspeed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(adt) 2 | add_subdirectory(codes) 3 | add_subdirectory(common) 4 | add_subdirectory(metadata) 5 | add_subdirectory(io) 6 | add_subdirectory(tiff) 7 | add_subdirectory(parsers) 8 | add_subdirectory(decompressors) 9 | add_subdirectory(interpolators) 10 | add_subdirectory(decoders) 11 | 12 | target_include_directories(rawspeed PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") 13 | -------------------------------------------------------------------------------- /src/librawspeed/RawSpeed-API.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2011 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | 26 | #include "rawspeedconfig.h" 27 | #include "adt/Mutex.h" 28 | #include "adt/Point.h" 29 | #include "common/Common.h" 30 | #include "common/RawImage.h" 31 | #include "common/RawspeedException.h" 32 | #include "decoders/RawDecoder.h" 33 | #include "io/Buffer.h" 34 | #include "io/Endianness.h" 35 | #include "io/FileReader.h" 36 | #include "metadata/BlackArea.h" 37 | #include "metadata/Camera.h" 38 | #include "metadata/CameraMetaData.h" 39 | #include "metadata/ColorFilterArray.h" 40 | #include "parsers/RawParser.h" 41 | 42 | // IWYU pragma: end_exports 43 | -------------------------------------------------------------------------------- /src/librawspeed/adt/Array1DRefExtras.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2025 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "adt/Array1DRef.h" 24 | #include "adt/Casts.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | template 30 | [[nodiscard]] Array1DRef getAsArray1DRef(const std::vector& vec) { 31 | return {vec.data(), implicit_cast(vec.size())}; 32 | } 33 | 34 | } // namespace rawspeed 35 | -------------------------------------------------------------------------------- /src/librawspeed/adt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_adt OBJECT) 2 | set_target_properties(rawspeed_adt PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "AlignedAllocator.h" 6 | "Array1DRef.h" 7 | "Array2DRef.h" 8 | "Bit.h" 9 | "BitIterator.h" 10 | "Casts.h" 11 | "CoalescingOutputIterator.h" 12 | "CroppedArray1DRef.h" 13 | "CroppedArray2DRef.h" 14 | "DefaultInitAllocatorAdaptor.h" 15 | "Invariant.h" 16 | "Mutex.h" 17 | "NORangesSet.h" 18 | "NotARational.h" 19 | "PartitioningOutputIterator.h" 20 | "Point.h" 21 | "Range.h" 22 | "TiledArray2DRef.h" 23 | "VariableLengthLoad.h" 24 | "iterator_range.h" 25 | ) 26 | 27 | target_sources(rawspeed_adt PRIVATE 28 | ${SOURCES} 29 | ) 30 | 31 | target_link_libraries(rawspeed PRIVATE rawspeed_adt) 32 | -------------------------------------------------------------------------------- /src/librawspeed/adt/Invariant.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #ifndef NDEBUG 24 | 25 | #include 26 | 27 | #define invariant(expr) assert(expr) 28 | 29 | #else // NDEBUG 30 | 31 | #ifndef __has_builtin // Optional of course. 32 | #define __has_builtin(x) 0 // Compatibility with non-clang compilers. 33 | #endif 34 | 35 | #if __has_builtin(__builtin_assume) 36 | 37 | #define invariant(expr) __builtin_assume(expr) 38 | 39 | #else // __has_builtin(__builtin_assume) 40 | 41 | namespace rawspeed { 42 | 43 | __attribute__((always_inline)) constexpr inline void invariant(bool precond) { 44 | if (!precond) 45 | __builtin_unreachable(); 46 | } 47 | 48 | } // namespace rawspeed 49 | 50 | #endif // __has_builtin(__builtin_assume) 51 | 52 | #endif // NDEBUG 53 | -------------------------------------------------------------------------------- /src/librawspeed/adt/NotARational.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2022 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace rawspeed { 26 | 27 | template struct NotARational final { 28 | public: 29 | using value_type = T; 30 | 31 | T num; 32 | T den; 33 | 34 | NotARational() = default; 35 | NotARational(T num_, T den_) : num(num_), den(den_) {} 36 | 37 | template 38 | requires std::is_floating_point_v 39 | explicit operator T2() const { 40 | return T2(num) / T2(den); 41 | } 42 | }; 43 | 44 | } // namespace rawspeed 45 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamJPEG.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | Copyright (C) 2017-2021 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "bitstreams/BitStream.h" 26 | #include "io/Endianness.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | template <> struct BitStreamTraits final { 32 | static constexpr BitOrder Tag = BitOrder::JPEG; 33 | 34 | using StreamFlow = BitStreamCacheRightInLeftOut; 35 | 36 | static constexpr bool FixedSizeChunks = false; // Stuffing byte... 37 | 38 | using ChunkType = uint32_t; 39 | 40 | static constexpr Endianness ChunkEndianness = Endianness::big; 41 | 42 | static constexpr int MinLoadStepByteMultiple = 1; 43 | }; 44 | 45 | } // namespace rawspeed 46 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamLSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | Copyright (C) 2017-2021 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "bitstreams/BitStream.h" 26 | #include "io/Endianness.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | template <> struct BitStreamTraits final { 32 | static constexpr BitOrder Tag = BitOrder::LSB; 33 | 34 | using StreamFlow = BitStreamCacheLeftInRightOut; 35 | 36 | static constexpr bool FixedSizeChunks = true; 37 | 38 | using ChunkType = uint32_t; 39 | 40 | static constexpr Endianness ChunkEndianness = Endianness::little; 41 | 42 | static constexpr int MinLoadStepByteMultiple = 1; 43 | }; 44 | 45 | } // namespace rawspeed 46 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamMSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | Copyright (C) 2017-2021 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "bitstreams/BitStream.h" 26 | #include "io/Endianness.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | template <> struct BitStreamTraits final { 32 | static constexpr BitOrder Tag = BitOrder::MSB; 33 | 34 | using StreamFlow = BitStreamCacheRightInLeftOut; 35 | 36 | static constexpr bool FixedSizeChunks = true; 37 | 38 | using ChunkType = uint32_t; 39 | 40 | static constexpr Endianness ChunkEndianness = Endianness::big; 41 | 42 | static constexpr int MinLoadStepByteMultiple = 1; 43 | }; 44 | 45 | } // namespace rawspeed 46 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamMSB16.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | Copyright (C) 2017-2021 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "bitstreams/BitStream.h" 26 | #include "io/Endianness.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | template <> struct BitStreamTraits final { 32 | static constexpr BitOrder Tag = BitOrder::MSB16; 33 | 34 | using StreamFlow = BitStreamCacheRightInLeftOut; 35 | 36 | static constexpr bool FixedSizeChunks = true; 37 | 38 | using ChunkType = uint16_t; 39 | 40 | static constexpr Endianness ChunkEndianness = Endianness::little; 41 | 42 | static constexpr int MinLoadStepByteMultiple = 2; 43 | }; 44 | 45 | } // namespace rawspeed 46 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamMSB32.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | Copyright (C) 2017-2021 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "bitstreams/BitStream.h" 26 | #include "io/Endianness.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | template <> struct BitStreamTraits final { 32 | static constexpr BitOrder Tag = BitOrder::MSB32; 33 | 34 | using StreamFlow = BitStreamCacheRightInLeftOut; 35 | 36 | static constexpr bool FixedSizeChunks = true; 37 | 38 | using ChunkType = uint32_t; 39 | 40 | static constexpr Endianness ChunkEndianness = Endianness::little; 41 | 42 | static constexpr int MinLoadStepByteMultiple = 4; 43 | }; 44 | 45 | } // namespace rawspeed 46 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2019 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamerLSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Axel Waggershauser 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamLSB.h" 24 | #include "bitstreams/BitStreamer.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | class BitStreamerLSB; 30 | 31 | template <> struct BitStreamerTraits final { 32 | static constexpr BitOrder Tag = BitOrder::LSB; 33 | 34 | // How many bytes can we read from the input per each fillCache(), at most? 35 | static constexpr int MaxProcessBytes = 4; 36 | static_assert(MaxProcessBytes == sizeof(uint32_t)); 37 | }; 38 | 39 | // The LSBPump is ordered in LSB bit order, 40 | // i.e. we push into the cache from the left and read it from the right 41 | 42 | class BitStreamerLSB final : public BitStreamer { 43 | using Base = BitStreamer; 44 | 45 | public: 46 | using Base::Base; 47 | }; 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreamerMSB16.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Axel Waggershauser 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamMSB16.h" 24 | #include "bitstreams/BitStreamer.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | class BitStreamerMSB16; 30 | 31 | template <> struct BitStreamerTraits final { 32 | static constexpr BitOrder Tag = BitOrder::MSB16; 33 | 34 | // How many bytes can we read from the input per each fillCache(), at most? 35 | static constexpr int MaxProcessBytes = 4; 36 | static_assert(MaxProcessBytes == 2 * sizeof(uint16_t)); 37 | }; 38 | 39 | // The MSB data is ordered in MSB bit order, 40 | // i.e. we push into the cache from the right and read it from the left 41 | 42 | class BitStreamerMSB16 final : public BitStreamer { 43 | using Base = BitStreamer; 44 | 45 | public: 46 | using Base::Base; 47 | }; 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitStreams.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2024 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | namespace rawspeed { 27 | 28 | enum class BitOrder : uint8_t { 29 | LSB, /* Memory order */ 30 | MSB, /* Input is added to stack byte by byte, and output is lifted 31 | from top */ 32 | MSB16, /* Same as above, but 16 bits at the time */ 33 | MSB32, /* Same as above, but 32 bits at the time */ 34 | JPEG, /* Same as MSB, but 0xFF byte is followed by an 0x00 stuffing byte */ 35 | }; 36 | 37 | } // namespace rawspeed 38 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitVacuumerLSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2024 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamLSB.h" 24 | #include "bitstreams/BitVacuumer.h" 25 | 26 | namespace rawspeed { 27 | 28 | template class BitVacuumerLSB; 29 | 30 | template 31 | struct BitVacuumerTraits> final { 32 | static constexpr BitOrder Tag = BitOrder::LSB; 33 | }; 34 | 35 | template 36 | class BitVacuumerLSB final 37 | : public BitVacuumer, OutputIterator> { 38 | using Base = BitVacuumer, OutputIterator>; 39 | 40 | public: 41 | using Base::Base; 42 | }; 43 | 44 | } // namespace rawspeed 45 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitVacuumerMSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2024 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamMSB.h" 24 | #include "bitstreams/BitVacuumer.h" 25 | 26 | namespace rawspeed { 27 | 28 | template class BitVacuumerMSB; 29 | 30 | template 31 | struct BitVacuumerTraits> final { 32 | static constexpr BitOrder Tag = BitOrder::MSB; 33 | 34 | static constexpr bool canUseWithPrefixCodeEncoder = true; 35 | }; 36 | 37 | template 38 | class BitVacuumerMSB final 39 | : public BitVacuumer, OutputIterator> { 40 | using Base = BitVacuumer, OutputIterator>; 41 | 42 | public: 43 | using Base::Base; 44 | }; 45 | 46 | } // namespace rawspeed 47 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitVacuumerMSB16.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2024 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamMSB16.h" 24 | #include "bitstreams/BitVacuumer.h" 25 | 26 | namespace rawspeed { 27 | 28 | template class BitVacuumerMSB16; 29 | 30 | template 31 | struct BitVacuumerTraits> final { 32 | static constexpr BitOrder Tag = BitOrder::MSB16; 33 | }; 34 | 35 | template 36 | class BitVacuumerMSB16 final 37 | : public BitVacuumer, OutputIterator> { 38 | using Base = BitVacuumer, OutputIterator>; 39 | 40 | public: 41 | using Base::Base; 42 | }; 43 | 44 | } // namespace rawspeed 45 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/BitVacuumerMSB32.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2024 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamMSB32.h" 24 | #include "bitstreams/BitVacuumer.h" 25 | 26 | namespace rawspeed { 27 | 28 | template class BitVacuumerMSB32; 29 | 30 | template 31 | struct BitVacuumerTraits> final { 32 | static constexpr BitOrder Tag = BitOrder::MSB32; 33 | 34 | static constexpr bool canUseWithPrefixCodeEncoder = true; 35 | }; 36 | 37 | template 38 | class BitVacuumerMSB32 final 39 | : public BitVacuumer, OutputIterator> { 40 | using Base = BitVacuumer, OutputIterator>; 41 | 42 | public: 43 | using Base::Base; 44 | }; 45 | 46 | } // namespace rawspeed 47 | -------------------------------------------------------------------------------- /src/librawspeed/bitstreams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_bitstreams OBJECT) 2 | set_target_properties(rawspeed_bitstreams PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "BitStream.h" 6 | "BitStreamJPEG.h" 7 | "BitStreamLSB.h" 8 | "BitStreamMSB.h" 9 | "BitStreamMSB16.h" 10 | "BitStreamMSB32.h" 11 | "BitStreamPosition.h" 12 | "BitStreamer.cpp" 13 | "BitStreamer.h" 14 | "BitStreamerJPEG.h" 15 | "BitStreamerLSB.h" 16 | "BitStreamerMSB.h" 17 | "BitStreamerMSB16.h" 18 | "BitStreamerMSB32.h" 19 | "BitStreams.h" 20 | "BitVacuumer.h" 21 | "BitVacuumerJPEG.h" 22 | "BitVacuumerLSB.h" 23 | "BitVacuumerMSB.h" 24 | "BitVacuumerMSB16.h" 25 | "BitVacuumerMSB32.h" 26 | ) 27 | 28 | target_sources(rawspeed_bitstreams PRIVATE 29 | ${SOURCES} 30 | ) 31 | 32 | target_include_directories(rawspeed_bitstreams PUBLIC "${RAWSPEED_BINARY_DIR}/src") 33 | target_include_directories(rawspeed_bitstreams SYSTEM PUBLIC "${RAWSPEED_SOURCE_DIR}/src/external") 34 | target_include_directories(rawspeed_bitstreams PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 35 | 36 | target_link_libraries(rawspeed PRIVATE rawspeed_bitstreams) 37 | -------------------------------------------------------------------------------- /src/librawspeed/codes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_codes OBJECT) 2 | set_target_properties(rawspeed_codes PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "AbstractPrefixCode.h" 6 | "AbstractPrefixCodeDecoder.h" 7 | "AbstractPrefixCodeEncoder.h" 8 | "AbstractPrefixCodeTranscoder.h" 9 | "BinaryPrefixTree.h" 10 | "DummyPrefixCodeDecoder.h" 11 | "HuffmanCode.h" 12 | "PrefixCode.h" 13 | "PrefixCodeDecoder.h" 14 | "PrefixCodeLUTDecoder.h" 15 | "PrefixCodeLookupDecoder.h" 16 | "PrefixCodeTreeDecoder.h" 17 | "PrefixCodeVectorDecoder.h" 18 | "PrefixCodeVectorEncoder.h" 19 | ) 20 | 21 | target_sources(rawspeed_codes PRIVATE 22 | ${SOURCES} 23 | ) 24 | 25 | target_link_libraries(rawspeed PRIVATE rawspeed_codes) 26 | -------------------------------------------------------------------------------- /src/librawspeed/common/ChecksumFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2018 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | namespace rawspeed { 27 | 28 | struct ChecksumFileEntry final { 29 | std::string FullFileName; 30 | std::string RelFileName; 31 | }; 32 | 33 | std::vector 34 | ParseChecksumFileContent(const std::string& ChecksumFileContent, 35 | const std::string& RootDir); 36 | 37 | std::vector 38 | ReadChecksumFile(const std::string& RootDir, 39 | const std::string& ChecksumFileBasename = "filelist.sha256"); 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/common/CpuFeatures.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "common/CpuFeatures.h" 22 | 23 | #if defined(__i386__) || defined(__x86_64__) 24 | #include 25 | #endif 26 | 27 | namespace rawspeed { 28 | 29 | #if defined(__i386__) || defined(__x86_64__) 30 | 31 | bool Cpuid::SSE2() { 32 | unsigned int eax; 33 | unsigned int ebx; 34 | unsigned int ecx; 35 | unsigned int edx; 36 | 37 | if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) 38 | return false; 39 | 40 | return edx & bit_SSE2; 41 | } 42 | 43 | #else 44 | 45 | bool Cpuid::SSE2() { return false; } 46 | 47 | #endif 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/librawspeed/common/CpuFeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "rawspeedconfig.h" 24 | 25 | namespace rawspeed { 26 | 27 | class Cpuid final { 28 | public: 29 | static bool RAWSPEED_READNONE SSE2(); 30 | }; 31 | 32 | } // namespace rawspeed 33 | -------------------------------------------------------------------------------- /src/librawspeed/common/ErrorLog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "ErrorLog.h" 22 | #include "adt/Mutex.h" 23 | #include 24 | #include 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | void ErrorLog::setError(const std::string& err) { 30 | MutexLocker guard(&mutex); 31 | errors.push_back(err); 32 | } 33 | 34 | bool ErrorLog::isTooManyErrors(unsigned many, std::string* firstErr) { 35 | MutexLocker guard(&mutex); 36 | 37 | if (errors.size() < many) 38 | return false; 39 | 40 | if (!firstErr) 41 | return true; 42 | 43 | *firstErr = errors[0]; 44 | return true; 45 | } 46 | 47 | std::vector&& ErrorLog::getErrors() { 48 | MutexLocker guard(&mutex); 49 | return std::move(errors); 50 | } 51 | 52 | } // namespace rawspeed 53 | -------------------------------------------------------------------------------- /src/librawspeed/common/ErrorLog.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "ThreadSafetyAnalysis.h" 24 | #include "adt/Mutex.h" 25 | #include 26 | #include 27 | 28 | namespace rawspeed { 29 | 30 | class ErrorLog { 31 | Mutex mutex; 32 | std::vector errors GUARDED_BY(mutex); 33 | 34 | public: 35 | void setError(const std::string& err) REQUIRES(!mutex); 36 | bool isTooManyErrors(unsigned many, std::string* firstErr = nullptr) 37 | REQUIRES(!mutex); 38 | std::vector&& getErrors() REQUIRES(!mutex); 39 | }; 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/common/GetNumberOfProcessorCores.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2016-2019 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "rawspeedconfig.h" 22 | #include "common/Common.h" 23 | 24 | #ifdef HAVE_OPENMP 25 | #include 26 | #endif 27 | 28 | // define this function, it is only declared in rawspeed: 29 | #ifdef HAVE_OPENMP 30 | extern "C" int __attribute__((visibility("default"))) 31 | rawspeed_get_number_of_processor_cores() { 32 | return omp_get_max_threads(); 33 | } 34 | #else 35 | extern "C" int RAWSPEED_READNONE __attribute__((visibility("default"))) 36 | rawspeed_get_number_of_processor_cores() { 37 | return 1; 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/librawspeed/common/RawspeedException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "common/RawspeedException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void RawspeedException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/common/TableLookUp.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "adt/Array1DRef.h" 25 | #include 26 | #include 27 | 28 | namespace rawspeed { 29 | 30 | class TableLookUp final { 31 | public: 32 | TableLookUp(int ntables, bool dither); 33 | 34 | void setTable(int ntable, const std::vector& table); 35 | Array1DRef getTable(int n); 36 | const int ntables; 37 | std::vector tables; 38 | const bool dither; 39 | }; 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/CrwDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "common/RawImage.h" 25 | #include "decoders/RawDecoder.h" 26 | #include "tiff/CiffIFD.h" 27 | #include 28 | #include 29 | 30 | namespace rawspeed { 31 | 32 | class Buffer; 33 | class CameraMetaData; 34 | 35 | class CrwDecoder final : public RawDecoder { 36 | std::unique_ptr mRootIFD; 37 | 38 | public: 39 | CrwDecoder(std::unique_ptr rootIFD, Buffer file); 40 | RawImage decodeRawInternal() override; 41 | void checkSupportInternal(const CameraMetaData* meta) override; 42 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 43 | static bool isCRW(Buffer input); 44 | 45 | private: 46 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 47 | static float canonEv(int64_t in); 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/DcrDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "common/RawImage.h" 25 | #include "decoders/SimpleTiffDecoder.h" 26 | #include "io/Buffer.h" 27 | #include "tiff/TiffIFD.h" 28 | #include 29 | 30 | namespace rawspeed { 31 | 32 | class Buffer; 33 | class CameraMetaData; 34 | 35 | class DcrDecoder final : public SimpleTiffDecoder { 36 | void checkImageDimensions() override; 37 | 38 | public: 39 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 40 | DcrDecoder(TiffRootIFDOwner&& root, Buffer file) 41 | : SimpleTiffDecoder(std::move(root), file) {} 42 | 43 | RawImage decodeRawInternal() override; 44 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 45 | 46 | private: 47 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/ErfDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "common/RawImage.h" 25 | #include "decoders/SimpleTiffDecoder.h" 26 | #include "io/Buffer.h" 27 | #include "tiff/TiffIFD.h" 28 | #include 29 | 30 | namespace rawspeed { 31 | 32 | class Buffer; 33 | class CameraMetaData; 34 | 35 | class ErfDecoder final : public SimpleTiffDecoder { 36 | void checkImageDimensions() override; 37 | 38 | public: 39 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 40 | ErfDecoder(TiffRootIFDOwner&& root, Buffer file) 41 | : SimpleTiffDecoder(std::move(root), file) {} 42 | 43 | RawImage decodeRawInternal() override; 44 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 45 | 46 | private: 47 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/KdcDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "common/RawImage.h" 25 | #include "decoders/AbstractTiffDecoder.h" 26 | #include "io/Buffer.h" 27 | #include "tiff/TiffIFD.h" 28 | #include 29 | 30 | namespace rawspeed { 31 | 32 | class CameraMetaData; 33 | 34 | class KdcDecoder final : public AbstractTiffDecoder { 35 | [[nodiscard]] Buffer getInputBuffer() const; 36 | 37 | public: 38 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 39 | KdcDecoder(TiffRootIFDOwner&& root, Buffer file) 40 | : AbstractTiffDecoder(std::move(root), file) {} 41 | 42 | RawImage decodeRawInternal() override; 43 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 44 | 45 | private: 46 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 47 | }; 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/MefDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "common/RawImage.h" 25 | #include "decoders/SimpleTiffDecoder.h" 26 | #include "io/Buffer.h" 27 | #include "tiff/TiffIFD.h" 28 | #include 29 | 30 | namespace rawspeed { 31 | 32 | class Buffer; 33 | class CameraMetaData; 34 | 35 | class MefDecoder final : public SimpleTiffDecoder { 36 | void checkImageDimensions() override; 37 | 38 | public: 39 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 40 | MefDecoder(TiffRootIFDOwner&& root, Buffer file) 41 | : SimpleTiffDecoder(std::move(root), file) {} 42 | 43 | RawImage decodeRawInternal() override; 44 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 45 | 46 | private: 47 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/PefDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "decoders/AbstractTiffDecoder.h" 25 | #include "io/Buffer.h" 26 | #include "tiff/TiffIFD.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | class Buffer; 32 | class CameraMetaData; 33 | 34 | class PefDecoder final : public AbstractTiffDecoder { 35 | public: 36 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 37 | PefDecoder(TiffRootIFDOwner&& root, Buffer file) 38 | : AbstractTiffDecoder(std::move(root), file) {} 39 | 40 | RawImage decodeRawInternal() override; 41 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 42 | 43 | private: 44 | [[nodiscard]] int getDecoderVersion() const override { return 3; } 45 | }; 46 | 47 | } // namespace rawspeed 48 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/RawDecoderException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "decoders/RawDecoderException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void RawDecoderException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/RawDecoderException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | #include "common/RawspeedException.h" 26 | // IWYU pragma: end_exports 27 | 28 | namespace rawspeed { 29 | 30 | class RawDecoderException : public RawspeedException { 31 | void anchor() const override; 32 | 33 | public: 34 | using RawspeedException::RawspeedException; 35 | }; 36 | 37 | #define ThrowRDE(...) \ 38 | ThrowExceptionHelper(rawspeed::RawDecoderException, __VA_ARGS__) 39 | 40 | } // namespace rawspeed 41 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/SimpleTiffDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | Copyright (C) 2017 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "decoders/AbstractTiffDecoder.h" 26 | #include "io/Buffer.h" 27 | #include "tiff/TiffIFD.h" 28 | #include 29 | #include 30 | 31 | namespace rawspeed { 32 | 33 | class Buffer; 34 | 35 | class SimpleTiffDecoder : public AbstractTiffDecoder { 36 | void anchor() const final; 37 | 38 | virtual void checkImageDimensions() = 0; 39 | 40 | public: 41 | SimpleTiffDecoder(TiffRootIFDOwner&& root, Buffer file) 42 | : AbstractTiffDecoder(std::move(root), file) {} 43 | 44 | void prepareForRawDecoding(); 45 | 46 | protected: 47 | const TiffIFD* raw; 48 | uint32_t width; 49 | uint32_t height; 50 | uint32_t off; 51 | uint32_t c2; 52 | }; 53 | 54 | } // namespace rawspeed 55 | -------------------------------------------------------------------------------- /src/librawspeed/decoders/StiDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "decoders/AbstractTiffDecoder.h" 25 | #include "io/Buffer.h" 26 | #include "tiff/TiffIFD.h" 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | class Buffer; 32 | class CameraMetaData; 33 | 34 | class StiDecoder final : public AbstractTiffDecoder { 35 | public: 36 | static bool isAppropriateDecoder(const TiffRootIFD* rootIFD, Buffer file); 37 | StiDecoder(TiffRootIFDOwner&& root, Buffer file) 38 | : AbstractTiffDecoder(std::move(root), file) {} 39 | 40 | RawImage decodeRawInternal() override; 41 | void decodeMetaDataInternal(const CameraMetaData* meta) override; 42 | 43 | private: 44 | [[nodiscard]] int getDecoderVersion() const override { return 0; } 45 | void DecodeUncompressed(const TiffIFD* raw) const; 46 | }; 47 | 48 | } // namespace rawspeed 49 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/AbstractDecompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | namespace rawspeed { 24 | 25 | class AbstractDecompressor {}; 26 | 27 | } // namespace rawspeed 28 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/AbstractSamsungDecompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "decompressors/AbstractDecompressor.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | class AbstractSamsungDecompressor : public AbstractDecompressor { 30 | protected: 31 | RawImage mRaw; 32 | 33 | public: 34 | explicit AbstractSamsungDecompressor(RawImage raw) : mRaw(std::move(raw)) {} 35 | }; 36 | 37 | } // namespace rawspeed 38 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/Cr2Decompressor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2022 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "decompressors/Cr2Decompressor.h" 22 | #include "codes/PrefixCodeDecoder.h" 23 | #include "decompressors/Cr2DecompressorImpl.h" // IWYU pragma: keep 24 | 25 | namespace rawspeed { 26 | 27 | template class Cr2Decompressor>; 28 | 29 | } // namespace rawspeed 30 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/Cr2LJpegDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Axel Waggershauser 5 | Copyright (C) 2018 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "decompressors/AbstractLJpegDecoder.h" 25 | #include "decompressors/Cr2Decompressor.h" 26 | 27 | namespace rawspeed { 28 | 29 | class ByteStream; 30 | class RawImage; 31 | 32 | class Cr2LJpegDecoder final : public AbstractLJpegDecoder { 33 | Cr2SliceWidths slicing; 34 | 35 | [[nodiscard]] ByteStream::size_type decodeScan() override; 36 | 37 | public: 38 | Cr2LJpegDecoder(ByteStream bs, const RawImage& img); 39 | void decode(const Cr2SliceWidths& slicing); 40 | }; 41 | 42 | } // namespace rawspeed 43 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/HasselbladLJpegDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Axel Waggershauser 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "decompressors/AbstractLJpegDecoder.h" 25 | 26 | namespace rawspeed { 27 | 28 | class ByteStream; 29 | class RawImage; 30 | 31 | class HasselbladLJpegDecoder final : public AbstractLJpegDecoder { 32 | // Old Hasselblad cameras don't end their LJpeg stream with an EOI. 33 | // After fully decoding (first) Scan, just stop. 34 | [[nodiscard]] bool erratumImplicitEOIMarkerAfterScan() const override { 35 | return true; 36 | } 37 | 38 | [[nodiscard]] ByteStream::size_type decodeScan() override; 39 | 40 | public: 41 | HasselbladLJpegDecoder(ByteStream bs, const RawImage& img); 42 | 43 | void decode(); 44 | }; 45 | 46 | } // namespace rawspeed 47 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/JpegDecompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "rawspeedconfig.h" 24 | 25 | #ifdef HAVE_JPEG 26 | 27 | #include "common/RawImage.h" 28 | #include "decompressors/AbstractDecompressor.h" 29 | #include "io/Buffer.h" 30 | #include 31 | #include 32 | 33 | namespace rawspeed { 34 | 35 | class JpegDecompressor final : public AbstractDecompressor { 36 | struct JpegDecompressStruct; 37 | 38 | Buffer input; 39 | RawImage mRaw; 40 | 41 | public: 42 | JpegDecompressor(Buffer bs, RawImage img) : input(bs), mRaw(std::move(img)) {} 43 | 44 | void decode(uint32_t offsetX, uint32_t offsetY); 45 | }; 46 | 47 | } // namespace rawspeed 48 | 49 | #else 50 | 51 | #pragma message \ 52 | "JPEG is not present! Lossy JPEG compression will not be supported!" 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/KodakDecompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | Copyright (C) 2017 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "common/RawImage.h" 26 | #include "decompressors/AbstractDecompressor.h" 27 | #include "io/ByteStream.h" 28 | #include 29 | #include 30 | 31 | namespace rawspeed { 32 | 33 | class KodakDecompressor final : public AbstractDecompressor { 34 | RawImage mRaw; 35 | ByteStream input; 36 | int bps; 37 | bool uncorrectedRawValues; 38 | 39 | static constexpr int segment_size = 256; // pixels 40 | using segment = std::array; 41 | 42 | segment decodeSegment(uint32_t bsize); 43 | 44 | public: 45 | KodakDecompressor(RawImage img, ByteStream bs, int bps, 46 | bool uncorrectedRawValues_); 47 | 48 | void decompress(); 49 | }; 50 | 51 | } // namespace rawspeed 52 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/LJpegDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Axel Waggershauser 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "adt/Point.h" 24 | #include "decompressors/AbstractLJpegDecoder.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | class ByteStream; 30 | class RawImage; 31 | 32 | // Decompresses Lossless JPEGs, with 2-4 components 33 | 34 | class LJpegDecoder final : public AbstractLJpegDecoder { 35 | [[nodiscard]] ByteStream::size_type decodeScan() override; 36 | 37 | uint32_t offX = 0; 38 | uint32_t offY = 0; 39 | uint32_t w = 0; 40 | uint32_t h = 0; 41 | 42 | iPoint2D maxDim; 43 | 44 | public: 45 | LJpegDecoder(ByteStream bs, const RawImage& img); 46 | 47 | void decode(uint32_t offsetX, uint32_t offsetY, uint32_t width, 48 | uint32_t height, iPoint2D maxDim, bool fixDng16Bug_); 49 | }; 50 | 51 | } // namespace rawspeed 52 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/OlympusDecompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "decompressors/AbstractDecompressor.h" 25 | 26 | namespace rawspeed { 27 | 28 | class ByteStream; 29 | 30 | class OlympusDecompressor final : public AbstractDecompressor { 31 | RawImage mRaw; 32 | 33 | public: 34 | explicit OlympusDecompressor(RawImage img); 35 | void decompress(const ByteStream& input) const; 36 | }; 37 | 38 | } // namespace rawspeed 39 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/SamsungV0Decompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamerMSB32.h" 24 | #include "decompressors/AbstractSamsungDecompressor.h" 25 | #include "io/ByteStream.h" 26 | #include 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | class RawImage; 32 | 33 | // Decoder for compressed srw files (NX300 and later) 34 | class SamsungV0Decompressor final : public AbstractSamsungDecompressor { 35 | std::vector stripes; 36 | 37 | void computeStripes(ByteStream bso, ByteStream bsr); 38 | 39 | void decompressStrip(int row, ByteStream bs) const; 40 | 41 | static int32_t calcAdj(BitStreamerMSB32& bits, int b); 42 | 43 | public: 44 | SamsungV0Decompressor(const RawImage& image, ByteStream bso, ByteStream bsr); 45 | 46 | void decompress() const; 47 | }; 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/SamsungV1Decompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamerMSB.h" 24 | #include "decompressors/AbstractSamsungDecompressor.h" 25 | #include "io/ByteStream.h" 26 | #include 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | class ByteStream; 32 | class RawImage; 33 | 34 | // Decoder for compressed srw files (NX3000 and later) 35 | class SamsungV1Decompressor final : public AbstractSamsungDecompressor { 36 | struct encTableItem; 37 | 38 | static inline int32_t samsungDiff(BitStreamerMSB& pump, 39 | const std::vector& tbl); 40 | 41 | ByteStream bs; 42 | static constexpr int bits = 12; 43 | 44 | public: 45 | SamsungV1Decompressor(const RawImage& image, ByteStream bs_, int bit); 46 | 47 | void decompress() const; 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/SonyArw1Decompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "bitstreams/BitStreamerMSB.h" 24 | #include "common/RawImage.h" 25 | #include "decompressors/AbstractDecompressor.h" 26 | #include 27 | 28 | namespace rawspeed { 29 | 30 | class ByteStream; 31 | 32 | class SonyArw1Decompressor final : public AbstractDecompressor { 33 | RawImage mRaw; 34 | 35 | inline static int getDiff(BitStreamerMSB& bs, uint32_t len); 36 | 37 | public: 38 | explicit SonyArw1Decompressor(RawImage img); 39 | void decompress(ByteStream input) const; 40 | }; 41 | 42 | } // namespace rawspeed 43 | -------------------------------------------------------------------------------- /src/librawspeed/decompressors/SonyArw2Decompressor.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017-2019 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "common/RawImage.h" 24 | #include "decompressors/AbstractDecompressor.h" 25 | #include "io/ByteStream.h" 26 | 27 | namespace rawspeed { 28 | 29 | class SonyArw2Decompressor final : public AbstractDecompressor { 30 | void decompressRow(int row) const; 31 | void decompressThread() const noexcept; 32 | 33 | RawImage mRaw; 34 | ByteStream input; 35 | 36 | public: 37 | SonyArw2Decompressor(RawImage img, ByteStream input); 38 | void decompress() const; 39 | }; 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/interpolators/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_interpolators OBJECT) 2 | set_target_properties(rawspeed_interpolators PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "Cr2sRawInterpolator.cpp" 6 | "Cr2sRawInterpolator.h" 7 | ) 8 | 9 | target_sources(rawspeed_interpolators PRIVATE 10 | ${SOURCES} 11 | ) 12 | 13 | target_include_directories(rawspeed_interpolators PUBLIC "${RAWSPEED_BINARY_DIR}/src") 14 | target_include_directories(rawspeed_interpolators SYSTEM PUBLIC "${RAWSPEED_SOURCE_DIR}/src/external") 15 | target_include_directories(rawspeed_interpolators PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 16 | 17 | if(TARGET RawSpeed::OpenMP_CXX) 18 | target_link_libraries(rawspeed_interpolators PUBLIC RawSpeed::OpenMP_CXX) 19 | endif() 20 | 21 | target_link_libraries(rawspeed PRIVATE rawspeed_interpolators) 22 | -------------------------------------------------------------------------------- /src/librawspeed/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_io OBJECT) 2 | set_target_properties(rawspeed_io PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "Buffer.h" 6 | "ByteStream.h" 7 | "Endianness.h" 8 | "FileIO.h" 9 | "FileIOException.cpp" 10 | "FileIOException.h" 11 | "FileReader.cpp" 12 | "FileReader.h" 13 | "FileWriter.cpp" 14 | "FileWriter.h" 15 | "IOException.cpp" 16 | "IOException.h" 17 | "MMapReader.cpp" 18 | "MMapReader.h" 19 | ) 20 | 21 | target_sources(rawspeed_io PRIVATE 22 | ${SOURCES} 23 | ) 24 | 25 | target_include_directories(rawspeed_io PUBLIC "${RAWSPEED_BINARY_DIR}/src") 26 | target_include_directories(rawspeed_io SYSTEM PUBLIC "${RAWSPEED_SOURCE_DIR}/src/external") 27 | target_include_directories(rawspeed_io PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 28 | 29 | target_link_libraries(rawspeed PRIVATE rawspeed_io) 30 | -------------------------------------------------------------------------------- /src/librawspeed/io/FileIOException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "io/FileIOException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void FileIOException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/io/FileIOException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | #include "common/RawspeedException.h" 26 | #include "decoders/RawDecoderException.h" 27 | // IWYU pragma: end_exports 28 | 29 | namespace rawspeed { 30 | 31 | class FileIOException final : public RawDecoderException { 32 | void anchor() const override; 33 | 34 | public: 35 | using RawDecoderException::RawDecoderException; 36 | }; 37 | 38 | #define ThrowFIE(...) \ 39 | ThrowExceptionHelper(rawspeed::FileIOException, __VA_ARGS__) 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/io/FileReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "adt/AlignedAllocator.h" 24 | #include "adt/DefaultInitAllocatorAdaptor.h" 25 | #include "io/Buffer.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace rawspeed { 32 | 33 | class Buffer; 34 | template class AlignedAllocator; 35 | 36 | class FileReader final { 37 | const char* fileName; 38 | 39 | public: 40 | explicit FileReader(const char* fileName_) : fileName(fileName_) {} 41 | 42 | [[nodiscard]] std::pair< 43 | std::unique_ptr>>>, 46 | Buffer> 47 | readFile() const; 48 | }; 49 | 50 | } // namespace rawspeed 51 | -------------------------------------------------------------------------------- /src/librawspeed/io/FileWriter.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace rawspeed { 26 | 27 | class Buffer; 28 | 29 | class FileWriter final { 30 | public: 31 | explicit FileWriter(const char* filename); 32 | 33 | void writeFile(Buffer fileMap, uint32_t size = 0) const; 34 | [[nodiscard]] const char* Filename() const { return mFilename; } 35 | // void Filename(const char * val) { mFilename = val; } 36 | 37 | private: 38 | const char* mFilename; 39 | }; 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/io/IOException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "io/IOException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void IOException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/io/IOException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | #include "common/RawspeedException.h" 26 | // IWYU pragma: end_exports 27 | 28 | namespace rawspeed { 29 | 30 | class IOException final : public RawspeedException { 31 | void anchor() const override; 32 | 33 | public: 34 | using RawspeedException::RawspeedException; 35 | }; 36 | 37 | #define ThrowIOE(...) ThrowExceptionHelper(rawspeed::IOException, __VA_ARGS__) 38 | 39 | } // namespace rawspeed 40 | -------------------------------------------------------------------------------- /src/librawspeed/io/MMapReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2025 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #if !defined(_WIN32) 24 | 25 | #include "io/Buffer.h" 26 | #include 27 | #include 28 | 29 | namespace rawspeed { 30 | 31 | class MMapReader final { 32 | int fd; 33 | void* addr; 34 | size_t length; 35 | 36 | public: 37 | explicit MMapReader(const std::string& fname); 38 | 39 | [[nodiscard]] Buffer getAsBuffer() const; 40 | 41 | ~MMapReader(); 42 | }; 43 | 44 | } // namespace rawspeed 45 | 46 | #endif // !defined(_WIN32) 47 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/BlackArea.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace rawspeed { 26 | 27 | class BlackArea final { 28 | public: 29 | BlackArea(int offset_, int size_, bool isVertical_) 30 | : offset(offset_), size(size_), isVertical(isVertical_) {} 31 | uint32_t offset; // Offset in bayer pixels. 32 | uint32_t size; // Size in bayer pixels. 33 | bool isVertical; // Otherwise horizontal 34 | }; 35 | 36 | } // namespace rawspeed 37 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_metadata OBJECT) 2 | set_target_properties(rawspeed_metadata PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "BlackArea.h" 6 | "Camera.cpp" 7 | "Camera.h" 8 | "CameraMetaData.cpp" 9 | "CameraMetaData.h" 10 | "CameraMetadataException.cpp" 11 | "CameraMetadataException.h" 12 | "CameraSensorInfo.cpp" 13 | "CameraSensorInfo.h" 14 | "ColorFilterArray.cpp" 15 | "ColorFilterArray.h" 16 | ) 17 | 18 | target_sources(rawspeed_metadata PRIVATE 19 | ${SOURCES} 20 | ) 21 | 22 | target_include_directories(rawspeed_metadata PUBLIC "${RAWSPEED_BINARY_DIR}/src") 23 | target_include_directories(rawspeed_metadata PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 24 | 25 | if(WITH_PUGIXML AND TARGET Pugixml::Pugixml) 26 | target_link_libraries(rawspeed_metadata PUBLIC Pugixml::Pugixml) 27 | endif() 28 | 29 | target_link_libraries(rawspeed PRIVATE rawspeed_metadata) 30 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/CameraMetadataException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "metadata/CameraMetadataException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void CameraMetadataException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/CameraMetadataException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | #include "common/RawspeedException.h" 26 | // IWYU pragma: end_exports 27 | 28 | namespace rawspeed { 29 | 30 | class CameraMetadataException final : public RawspeedException { 31 | void anchor() const override; 32 | 33 | public: 34 | using RawspeedException::RawspeedException; 35 | }; 36 | 37 | #define ThrowCME(...) \ 38 | ThrowExceptionHelper(rawspeed::CameraMetadataException, __VA_ARGS__) 39 | 40 | } // namespace rawspeed 41 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/CameraSensorInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2011 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "rawspeedconfig.h" 22 | #include "metadata/CameraSensorInfo.h" 23 | #include 24 | #include 25 | 26 | using std::vector; 27 | 28 | namespace rawspeed { 29 | 30 | CameraSensorInfo::CameraSensorInfo(int black_level, int white_level, 31 | int min_iso, int max_iso, 32 | vector black_separate) 33 | : mBlackLevel(black_level), mWhiteLevel(white_level), mMinIso(min_iso), 34 | mMaxIso(max_iso), mBlackLevelSeparate(std::move(black_separate)) {} 35 | 36 | bool RAWSPEED_READONLY CameraSensorInfo::isIsoWithin(int iso) const { 37 | return (iso >= mMinIso && iso <= mMaxIso) || (iso >= mMinIso && 0 == mMaxIso); 38 | } 39 | 40 | bool RAWSPEED_READONLY CameraSensorInfo::isDefault() const { 41 | return (0 == mMinIso && 0 == mMaxIso); 42 | } 43 | 44 | } // namespace rawspeed 45 | -------------------------------------------------------------------------------- /src/librawspeed/metadata/CameraSensorInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2011 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "rawspeedconfig.h" 24 | #include 25 | 26 | namespace rawspeed { 27 | 28 | class CameraSensorInfo final { 29 | public: 30 | CameraSensorInfo(int black_level, int white_level, int min_iso, int max_iso, 31 | std::vector black_separate); 32 | [[nodiscard]] bool RAWSPEED_READONLY isIsoWithin(int iso) const; 33 | [[nodiscard]] bool RAWSPEED_READONLY isDefault() const; 34 | int mBlackLevel; 35 | int mWhiteLevel; 36 | int mMinIso; 37 | int mMaxIso; 38 | std::vector mBlackLevelSeparate; 39 | }; 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_parsers OBJECT) 2 | set_target_properties(rawspeed_parsers PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "CiffParser.cpp" 6 | "CiffParser.h" 7 | "CiffParserException.cpp" 8 | "CiffParserException.h" 9 | "FiffParser.cpp" 10 | "FiffParser.h" 11 | "FiffParserException.cpp" 12 | "FiffParserException.h" 13 | "RawParser.cpp" 14 | "RawParser.h" 15 | "RawParserException.cpp" 16 | "RawParserException.h" 17 | "TiffParser.cpp" 18 | "TiffParser.h" 19 | "TiffParserException.cpp" 20 | "TiffParserException.h" 21 | ) 22 | 23 | target_sources(rawspeed_parsers PRIVATE 24 | ${SOURCES} 25 | ) 26 | 27 | target_include_directories(rawspeed_parsers PUBLIC "${RAWSPEED_BINARY_DIR}/src") 28 | target_include_directories(rawspeed_parsers SYSTEM PUBLIC "${RAWSPEED_SOURCE_DIR}/src/external") 29 | target_include_directories(rawspeed_parsers PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 30 | 31 | if(TARGET RawSpeed::OpenMP_CXX) 32 | target_link_libraries(rawspeed_parsers PUBLIC RawSpeed::OpenMP_CXX) 33 | endif() 34 | 35 | target_link_libraries(rawspeed PRIVATE rawspeed_parsers) 36 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/CiffParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "parsers/RawParser.h" 25 | #include "tiff/CiffIFD.h" 26 | #include 27 | 28 | namespace rawspeed { 29 | 30 | class Buffer; 31 | class CameraMetaData; 32 | class RawDecoder; 33 | 34 | class CiffParser final : public RawParser { 35 | std::unique_ptr mRootIFD; 36 | 37 | public: 38 | explicit CiffParser(Buffer input); 39 | 40 | void parseData(); 41 | 42 | std::unique_ptr 43 | getDecoder(const CameraMetaData* meta = nullptr) override; 44 | }; 45 | 46 | } // namespace rawspeed 47 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/CiffParserException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "parsers/CiffParserException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void CiffParserException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/CiffParserException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | Copyright (C) 2017 Roman Lebedev 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | // IWYU pragma: begin_exports 26 | #include "common/RawspeedException.h" 27 | #include "parsers/RawParserException.h" 28 | // IWYU pragma: end_exports 29 | 30 | namespace rawspeed { 31 | 32 | class CiffParserException final : public RawParserException { 33 | void anchor() const override; 34 | 35 | public: 36 | using RawParserException::RawParserException; 37 | }; 38 | 39 | #define ThrowCPE(...) \ 40 | ThrowExceptionHelper(rawspeed::CiffParserException, __VA_ARGS__) 41 | 42 | } // namespace rawspeed 43 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/FiffParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "parsers/RawParser.h" 24 | #include "tiff/TiffIFD.h" 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | class Buffer; 30 | class CameraMetaData; 31 | class RawDecoder; 32 | 33 | class FiffParser final : public RawParser { 34 | TiffRootIFDOwner rootIFD; 35 | 36 | public: 37 | explicit FiffParser(Buffer input); 38 | 39 | void parseData(); 40 | std::unique_ptr 41 | getDecoder(const CameraMetaData* meta = nullptr) override; 42 | }; 43 | 44 | } // namespace rawspeed 45 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/FiffParserException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "parsers/FiffParserException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void FiffParserException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/FiffParserException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | // IWYU pragma: begin_exports 24 | #include "common/RawspeedException.h" 25 | #include "parsers/RawParserException.h" 26 | // IWYU pragma: end_exports 27 | 28 | namespace rawspeed { 29 | 30 | class FiffParserException final : public RawParserException { 31 | void anchor() const override; 32 | 33 | public: 34 | using RawParserException::RawParserException; 35 | }; 36 | 37 | #define ThrowFPE(...) \ 38 | ThrowExceptionHelper(rawspeed::FiffParserException, __VA_ARGS__) 39 | 40 | } // namespace rawspeed 41 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/RawParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "io/Buffer.h" 24 | #include 25 | 26 | namespace rawspeed { 27 | 28 | class CameraMetaData; 29 | class RawDecoder; 30 | 31 | class RawParser { 32 | public: 33 | explicit RawParser(Buffer inputData) : mInput(inputData) {} 34 | virtual ~RawParser() = default; 35 | 36 | virtual std::unique_ptr 37 | getDecoder(const CameraMetaData* meta = nullptr); 38 | 39 | protected: 40 | Buffer mInput; 41 | }; 42 | 43 | } // namespace rawspeed 44 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/RawParserException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "parsers/RawParserException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void RawParserException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/RawParserException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | // IWYU pragma: begin_exports 24 | #include "common/RawspeedException.h" 25 | // IWYU pragma: end_exports 26 | 27 | namespace rawspeed { 28 | 29 | class RawParserException : public RawspeedException { 30 | void anchor() const override; 31 | 32 | public: 33 | using RawspeedException::RawspeedException; 34 | }; 35 | 36 | #define ThrowRPE(...) \ 37 | ThrowExceptionHelper(rawspeed::RawParserException, __VA_ARGS__) 38 | 39 | } // namespace rawspeed 40 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/TiffParserException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2023 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "parsers/TiffParserException.h" 22 | 23 | namespace rawspeed { 24 | 25 | void TiffParserException::anchor() const { 26 | // Empty out-of-line definition for the purpose of anchoring 27 | // the class's vtable to this Translational Unit. 28 | } 29 | 30 | } // namespace rawspeed 31 | -------------------------------------------------------------------------------- /src/librawspeed/parsers/TiffParserException.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2017 Roman Lebedev 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | // IWYU pragma: begin_exports 25 | #include "common/RawspeedException.h" 26 | #include "parsers/RawParserException.h" 27 | // IWYU pragma: end_exports 28 | 29 | namespace rawspeed { 30 | 31 | class TiffParserException final : public RawParserException { 32 | void anchor() const override; 33 | 34 | public: 35 | using RawParserException::RawParserException; 36 | }; 37 | 38 | #define ThrowTPE(...) \ 39 | ThrowExceptionHelper(rawspeed::TiffParserException, __VA_ARGS__) 40 | 41 | } // namespace rawspeed 42 | -------------------------------------------------------------------------------- /src/librawspeed/tiff/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_library(rawspeed_tiff OBJECT) 2 | set_target_properties(rawspeed_tiff PROPERTIES LINKER_LANGUAGE CXX) 3 | 4 | FILE(GLOB SOURCES 5 | "TiffEntry.cpp" 6 | "TiffEntry.h" 7 | "TiffIFD.cpp" 8 | "TiffIFD.h" 9 | "TiffTag.h" 10 | "CiffEntry.cpp" 11 | "CiffEntry.h" 12 | "CiffIFD.cpp" 13 | "CiffIFD.h" 14 | "CiffTag.h" 15 | ) 16 | 17 | target_sources(rawspeed_tiff PRIVATE 18 | ${SOURCES} 19 | ) 20 | 21 | target_include_directories(rawspeed_tiff PUBLIC "${RAWSPEED_BINARY_DIR}/src") 22 | target_include_directories(rawspeed_tiff SYSTEM PUBLIC "${RAWSPEED_SOURCE_DIR}/src/external") 23 | target_include_directories(rawspeed_tiff PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 24 | 25 | target_link_libraries(rawspeed PRIVATE rawspeed_tiff) 26 | -------------------------------------------------------------------------------- /src/librawspeed/tiff/CiffTag.h: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2009-2014 Klaus Post 5 | Copyright (C) 2014 Pedro Côrte-Real 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | #include 26 | 27 | namespace rawspeed { 28 | 29 | enum class CiffTag : uint16_t { 30 | NULL_TAG = 0x0000, 31 | MAKEMODEL = 0x080a, 32 | SHOTINFO = 0x102a, 33 | WHITEBALANCE = 0x10a9, 34 | SENSORINFO = 0x1031, 35 | IMAGEINFO = 0x1810, 36 | DECODERTABLE = 0x1835, 37 | RAWDATA = 0x2005, 38 | SUBIFD = 0x300a, 39 | EXIF = 0x300b, 40 | }; 41 | 42 | static constexpr std::initializer_list CiffTagsWeCareAbout = { 43 | CiffTag::DECODERTABLE, CiffTag::MAKEMODEL, CiffTag::RAWDATA, 44 | CiffTag::SENSORINFO, CiffTag::SHOTINFO, CiffTag::WHITEBALANCE, 45 | static_cast(0x0032), // ??? 46 | static_cast(0x102c), // ??? 47 | }; 48 | 49 | } // namespace rawspeed 50 | -------------------------------------------------------------------------------- /src/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (DISABLED_WARNING_FLAGS 2 | "global-constructors" 3 | "exit-time-destructors" 4 | ) 5 | 6 | foreach(warning ${DISABLED_WARNING_FLAGS}) 7 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-${warning}) 8 | endforeach() 9 | 10 | add_subdirectory(identify) 11 | 12 | add_subdirectory(rstest) 13 | 14 | if(BUILD_BENCHMARKING) 15 | add_subdirectory(rsbench) 16 | endif() 17 | -------------------------------------------------------------------------------- /src/utilities/identify/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(rsidentify "rs-identify") 2 | if(DEFINED RAWSPEED_BINARY_PREFIX) 3 | set(rsidentify "${RAWSPEED_BINARY_PREFIX}-${rsidentify}") 4 | endif() 5 | 6 | rawspeed_add_executable(${rsidentify} rawspeed-identify.cpp) 7 | target_compile_definitions(${rsidentify} 8 | PRIVATE -DRS_CAMERAS_XML_PATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/rawspeed/cameras.xml" 9 | ) 10 | 11 | target_link_libraries(${rsidentify} rawspeed) 12 | 13 | target_link_libraries(${rsidentify} rawspeed_get_number_of_processor_cores) 14 | 15 | if(BUILD_TESTING) 16 | rawspeed_add_test(NAME utilities/${rsidentify} COMMAND ${rsidentify} 17 | WORKING_DIRECTORY "$") 18 | set_tests_properties(utilities/${rsidentify} PROPERTIES LABELS "dummy") 19 | endif() 20 | 21 | install(TARGETS ${rsidentify} DESTINATION ${CMAKE_INSTALL_BINDIR}) 22 | -------------------------------------------------------------------------------- /src/utilities/rsbench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | rawspeed_add_executable(rsbench main.cpp) 2 | 3 | target_link_libraries(rsbench rawspeed) 4 | target_link_libraries(rsbench rawspeed_bench) 5 | 6 | rawspeed_add_test(NAME utilities/rsbench COMMAND rsbench --help) 7 | set_tests_properties(utilities/rsbench PROPERTIES LABELS "benchmark;dummy") 8 | if(WIN32) 9 | set_tests_properties(utilities/rsbench PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") 10 | endif() 11 | 12 | add_dependencies(benchmarks rsbench) 13 | -------------------------------------------------------------------------------- /test/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: > 3 | -bugprone-macro-parentheses, 4 | -bugprone-suspicious-memory-comparison, 5 | -cert-msc51-cpp, 6 | -concurrency-mt-unsafe, 7 | -cppcoreguidelines-macro-usage, 8 | -cppcoreguidelines-rvalue-reference-param-not-moved, 9 | -google-global-names-in-headers, 10 | -misc-definitions-in-headers, 11 | -misc-use-anonymous-namespace, 12 | -modernize-avoid-c-arrays, 13 | -modernize-type-traits, 14 | -modernize-use-nodiscard, 15 | -modernize-use-override, 16 | -performance-avoid-endl, 17 | -performance-move-const-arg, 18 | -performance-unnecessary-copy-initialization, 19 | -readability-convert-member-functions-to-static, 20 | -readability-function-cognitive-complexity, 21 | -readability-function-size, 22 | -readability-isolate-declaration, 23 | -readability-make-member-function-const, 24 | -readability-suspicious-call-argument, 25 | -readability-uppercase-literal-suffix, 26 | InheritParentConfig: true 27 | ... 28 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (DISABLED_WARNING_FLAGS 2 | "missing-prototypes" 3 | "missing-variable-declarations" 4 | "suggest-attribute=const" 5 | "suggest-override" 6 | "used-but-marked-unused" 7 | "global-constructors" 8 | "exit-time-destructors" 9 | "weak-vtables" 10 | ) 11 | 12 | foreach(warning ${DISABLED_WARNING_FLAGS}) 13 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wno-${warning}) 14 | endforeach() 15 | 16 | if(NOT RAWSPEED_SPECIAL_BUILD) 17 | # should be < 64Kb 18 | math(EXPR MAX_MEANINGFUL_SIZE 4*1024) 19 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wstack-usage=${MAX_MEANINGFUL_SIZE}) 20 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wframe-larger-than=${MAX_MEANINGFUL_SIZE}) 21 | 22 | # as small as possible, but 1Mb+ is ok. 23 | math(EXPR MAX_MEANINGFUL_SIZE 32*1024) 24 | CHECK_CXX_COMPILER_FLAG_AND_ENABLE_IT(-Wlarger-than=${MAX_MEANINGFUL_SIZE}) 25 | endif() 26 | 27 | add_subdirectory(librawspeed) 28 | -------------------------------------------------------------------------------- /test/librawspeed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(RAWSPEED_COVERAGE_BUILD) 2 | # want all the symbols. 3 | rawspeed_add_library(rawspeed_test SHARED) 4 | else() 5 | rawspeed_add_library(rawspeed_test STATIC) 6 | endif() 7 | 8 | target_link_libraries(rawspeed_test PUBLIC rawspeed) 9 | target_link_libraries(rawspeed_test PUBLIC gtest gmock_main) 10 | target_include_directories(rawspeed_test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") 11 | 12 | function(add_rs_test src) 13 | get_filename_component(TESTNAME ${src} NAME_WE) 14 | rawspeed_add_executable(${TESTNAME} ${src}) 15 | target_link_libraries(${TESTNAME} rawspeed) 16 | target_link_libraries(${TESTNAME} rawspeed_test) 17 | rawspeed_add_test(NAME ${TESTNAME} 18 | COMMAND ${TESTNAME} 19 | WORKING_DIRECTORY "$") 20 | set_tests_properties(${TESTNAME} PROPERTIES LABELS "unittest") 21 | add_dependencies(tests ${TESTNAME}) 22 | endfunction() 23 | 24 | add_subdirectory(adt) 25 | add_subdirectory(bitstreams) 26 | add_subdirectory(codes) 27 | add_subdirectory(common) 28 | add_subdirectory(io) 29 | add_subdirectory(metadata) 30 | add_subdirectory(test) 31 | -------------------------------------------------------------------------------- /test/librawspeed/adt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "BitTest.cpp" 3 | "CoalescingOutputIteratorTest.cpp" 4 | "NORangesSetTest.cpp" 5 | "PartitioningOutputIteratorTest.cpp" 6 | "PointTest.cpp" 7 | "RangeTest.cpp" 8 | "VariableLengthLoadTest.cpp" 9 | ) 10 | 11 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 12 | add_rs_test("${SRC}") 13 | endforeach() 14 | -------------------------------------------------------------------------------- /test/librawspeed/bitstreams/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "BitStreamerJPEGTest.cpp" 3 | "BitStreamerLSBTest.cpp" 4 | "BitStreamerMSB16Test.cpp" 5 | "BitStreamerMSB32Test.cpp" 6 | "BitStreamerMSBTest.cpp" 7 | "BitVacuumerJPEGTest.cpp" 8 | "BitVacuumerLSBTest.cpp" 9 | "BitVacuumerMSB16Test.cpp" 10 | "BitVacuumerMSB32Test.cpp" 11 | "BitVacuumerMSBTest.cpp" 12 | ) 13 | 14 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 15 | add_rs_test("${SRC}") 16 | endforeach() 17 | -------------------------------------------------------------------------------- /test/librawspeed/codes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "HuffmanCodeTest.cpp" 3 | "PrefixCodeDecoderTest.cpp" 4 | ) 5 | 6 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 7 | add_rs_test("${SRC}") 8 | endforeach() 9 | -------------------------------------------------------------------------------- /test/librawspeed/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "BayerPhaseTest.cpp" 3 | "ChecksumFileTest.cpp" 4 | "CommonTest.cpp" 5 | "CpuidTest.cpp" 6 | "SplineTest.cpp" 7 | ) 8 | 9 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 10 | add_rs_test("${SRC}") 11 | endforeach() 12 | -------------------------------------------------------------------------------- /test/librawspeed/common/CpuidTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2017 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; withexpected even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "rawspeedconfig.h" // IWYU pragma: keep 22 | #include "common/CpuFeatures.h" 23 | #include 24 | #include 25 | 26 | using rawspeed::Cpuid; 27 | 28 | namespace rawspeed_test { 29 | 30 | namespace { 31 | 32 | // do not care about WITH_SSE2 here. 33 | TEST(CpuidDeathTest, SSE2Test) { 34 | #if defined(__SSE2__) 35 | ASSERT_EXIT( 36 | { 37 | ASSERT_TRUE(Cpuid::SSE2()); 38 | exit(0); 39 | }, 40 | ::testing::ExitedWithCode(0), ""); 41 | #else 42 | ASSERT_EXIT( 43 | { 44 | ASSERT_FALSE(Cpuid::SSE2()); 45 | exit(0); 46 | }, 47 | ::testing::ExitedWithCode(0), ""); 48 | #endif 49 | } 50 | 51 | } // namespace 52 | 53 | } // namespace rawspeed_test 54 | -------------------------------------------------------------------------------- /test/librawspeed/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "EndiannessTest.cpp" 3 | ) 4 | 5 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 6 | add_rs_test("${SRC}") 7 | endforeach() 8 | -------------------------------------------------------------------------------- /test/librawspeed/metadata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "BlackAreaTest.cpp" 3 | "CameraMetaDataTest.cpp" 4 | "CameraSensorInfoTest.cpp" 5 | "CameraTest.cpp" 6 | "ColorFilterArrayTest.cpp" 7 | ) 8 | 9 | foreach(SRC ${RAWSPEED_TEST_SOURCES}) 10 | add_rs_test("${SRC}") 11 | endforeach() 12 | -------------------------------------------------------------------------------- /test/librawspeed/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB RAWSPEED_TEST_SOURCES 2 | "RawSpeed.cpp" 3 | ) 4 | 5 | target_sources(rawspeed_test PRIVATE 6 | ${RAWSPEED_TEST_SOURCES} 7 | ) 8 | 9 | FILE(GLOB RAWSPEED_TESTS_SOURCES 10 | "ExceptionsTest.cpp" 11 | ) 12 | 13 | foreach(SRC ${RAWSPEED_TESTS_SOURCES}) 14 | add_rs_test("${SRC}") 15 | endforeach() 16 | -------------------------------------------------------------------------------- /test/librawspeed/test/RawSpeed.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | RawSpeed - RAW file decoder. 3 | 4 | Copyright (C) 2016-2019 Roman Lebedev 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | // Just a dummy source file so that librawspeed_test lib is not empty. 22 | --------------------------------------------------------------------------------