Dataset Viewer
Auto-converted to Parquet
commit_id
stringlengths
40
40
owner
stringclasses
14 values
repo
stringclasses
14 values
commit_message
stringlengths
0
22.6k
diff
stringlengths
132
21.9M
label
int64
0
1
afb1e830848a8cd66e29e23accc0b412560a260c
Exiv2
exiv2
Merge pull request #1373 from lbschenkel/sigma_18_35 Fix_1368 Sigma 18-35mm f/1.8 DC HSM (0.27 only)
commit afb1e830848a8cd66e29e23accc0b412560a260c Merge: cfd7c09f2 0f6fef750 Author: Robin Mills <[email protected]> Date: Mon Oct 19 12:56:11 2020 +0100 Merge pull request #1373 from lbschenkel/sigma_18_35 Fix_1368 Sigma 18-35mm f/1.8 DC HSM (0.27 only)
0
09ca3ca1f2fb271ab350d1104f661064c930d3ec
Exiv2
exiv2
manual namespace concatenations Signed-off-by: Rosen Penev <[email protected]>
commit 09ca3ca1f2fb271ab350d1104f661064c930d3ec Author: Rosen Penev <[email protected]> Date: Mon Mar 7 14:16:55 2022 -0800 manual namespace concatenations Signed-off-by: Rosen Penev <[email protected]> diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 48975252b..a8fbbbd08 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -10,13 +10,9 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - class ExifData; - - namespace Internal { - -// ***************************************************************************** -// class definitions +namespace Exiv2::Internal { + // ***************************************************************************** + // class definitions //! Type to specify the IFD to which a metadata belongs enum IfdId { @@ -501,6 +497,6 @@ namespace Exiv2 { //! Calculate the exposure time from an APEX shutter speed value URational exposureTime(float shutterSpeedValue); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef TAGS_INT_HPP_
0
63e41c3aeb47638738fb4d2774744f90a0c7c26c
Exiv2
exiv2
clang-tidy: simplify bool Signed-off-by: Rosen Penev <[email protected]>
commit 63e41c3aeb47638738fb4d2774744f90a0c7c26c Author: Rosen Penev <[email protected]> Date: Sat Mar 5 02:35:14 2022 -0800 clang-tidy: simplify bool Signed-off-by: Rosen Penev <[email protected]> diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index ab6c47532..7d9274ceb 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -345,11 +345,10 @@ namespace Exiv2::Internal { append(blob, reinterpret_cast<const byte*>(signature_), 8); o += 8; // Pad as needed - if (pPadding_.empty() == false) { + if (!pPadding_.empty()) { assert(padded_ == offset_ - o); append(blob, pPadding_.data(), padded_); - } - else { + } else { for (uint32_t i = o; i < offset_; ++i) { blob.push_back(0); ++o; diff --git a/src/pngimage.cpp b/src/pngimage.cpp index d2f2f36cd..b82e6beea 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -681,22 +681,17 @@ namespace Exiv2 { } else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") || !strcmp(szChunk, "iCCP")) { DataBuf key = PngChunk::keyTXTChunk(chunkBuf, true); - if (key.empty() == false && ( - compare("Raw profile type exif", key, 21) || - compare("Raw profile type APP1", key, 21) || - compare("Raw profile type iptc", key, 21) || - compare("Raw profile type xmp", key, 20) || - compare("XML:com.adobe.xmp", key, 17) || - compare("icc", key, 3) || // see test/data/imagemagick.png - compare("ICC", key, 3) || - compare("Description", key, 11))) - { + if (!key.empty() && + (compare("Raw profile type exif", key, 21) || compare("Raw profile type APP1", key, 21) || + compare("Raw profile type iptc", key, 21) || compare("Raw profile type xmp", key, 20) || + compare("XML:com.adobe.xmp", key, 17) || + compare("icc", key, 3) || // see test/data/imagemagick.png + compare("ICC", key, 3) || compare("Description", key, 11))) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl; #endif - } else - { + } else { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::doWriteMetadata: write " << szChunk << " chunk (length: " << dataOffset << ")" << std::endl;
0
5882c177aa1227c4a01aec57b9a3484fed56116f
Exiv2
exiv2
Fixed typo.
commit 5882c177aa1227c4a01aec57b9a3484fed56116f Author: clanmills <[email protected]> Date: Thu Apr 16 13:40:21 2020 +0100 Fixed typo. diff --git a/README.md b/README.md index d439e4961..1c0035be4 100644 --- a/README.md +++ b/README.md @@ -981,7 +981,7 @@ For all platforms you will need the following components to build: 4. sudo 5. gettext -To run the test suite, you neeed: +To run the test suite, you need: 1. python3 2. chksum
0
b3d0d5cf826de635a126c02c80f8ba48dd3864d5
Exiv2
exiv2
#542: Use the first Exif APP1 segment (not the last) if more than one are present.
commit b3d0d5cf826de635a126c02c80f8ba48dd3864d5 Author: Andreas Huggel <[email protected]> Date: Wed Dec 10 16:37:55 2008 +0000 #542: Use the first Exif APP1 segment (not the last) if more than one are present. diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 570be2c2e..a2c449b39 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -283,6 +283,7 @@ namespace Exiv2 { DataBuf buf(bufMinSize); Blob iptcBlob; bool foundPsData = false; + bool foundExifData = false; // Read section marker int marker = advanceToMarker(); @@ -305,7 +306,8 @@ namespace Exiv2 { if (--search == 0) break; } - if (marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) { + if ( !foundExifData + && marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) { if (size < 8) { rc = 1; break; @@ -324,6 +326,7 @@ namespace Exiv2 { exifData_.clear(); } --search; + foundExifData = true; } else if (marker == app1_ && memcmp(buf.pData_ + 2, xmpId_, 29) == 0) { if (size < 31) { @@ -511,7 +514,8 @@ namespace Exiv2 { insertPos = count + 1; if (io_->seek(size-bufRead, BasicIo::cur)) throw Error(22); } - else if (marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) { + else if ( skipApp1Exif == -1 + && marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) { if (size < 8) throw Error(22); skipApp1Exif = count; ++search;
0
240a72468e3fdefda94b99457cb68dbda9d6e95c
Exiv2
exiv2
Clang-format in pngchunk_int.cpp
commit 240a72468e3fdefda94b99457cb68dbda9d6e95c Author: Luis Díaz Más <[email protected]> Date: Fri Jan 7 08:18:59 2022 +0100 Clang-format in pngchunk_int.cpp diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 621cdd327..4068da86f 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -22,28 +22,28 @@ #include "config.h" #ifdef EXV_HAVE_LIBZ -#include "pngchunk_int.hpp" -#include "tiffimage.hpp" -#include "jpgimage.hpp" -#include "exif.hpp" -#include "iptc.hpp" -#include "image.hpp" -#include "error.hpp" #include "enforce.hpp" +#include "error.hpp" +#include "exif.hpp" #include "helper_functions.hpp" +#include "image.hpp" +#include "iptc.hpp" +#include "jpgimage.hpp" +#include "pngchunk_int.hpp" #include "safe_op.hpp" +#include "tiffimage.hpp" -// + standard includes -#include <sstream> -#include <iomanip> -#include <string> -#include <cstring> -#include <iostream> +#include <zlib.h> // To uncompress or compress text chunk + +// standard includes +#include <algorithm> #include <cassert> #include <cstdio> -#include <algorithm> - -#include <zlib.h> // To uncompress or compress text chunk +#include <cstring> +#include <iomanip> +#include <iostream> +#include <sstream> +#include <string> /* @@ -54,687 +54,612 @@ iTXt chunk : http://www.vias.org/pngguide/chapter11_05.html PNG tags : http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html#TextualData */ -namespace { -constexpr int nullSeparators = 2; +namespace +{ + constexpr int nullSeparators = 2; } // ***************************************************************************** // class member definitions -namespace Exiv2 { - namespace Internal { - - void PngChunk::decodeIHDRChunk(const DataBuf& data, - int* outWidth, - int* outHeight) +namespace Exiv2 +{ + namespace Internal { - assert(data.size() >= 8); - - // Extract image width and height from IHDR chunk. + void PngChunk::decodeIHDRChunk(const DataBuf& data, int* outWidth, int* outHeight) + { + assert(data.size() >= 8); - *outWidth = data.read_uint32(0, bigEndian); - *outHeight = data.read_uint32(4, bigEndian); + // Extract image width and height from IHDR chunk. - } + *outWidth = data.read_uint32(0, bigEndian); + *outHeight = data.read_uint32(4, bigEndian); + } - void PngChunk::decodeTXTChunk(Image* pImage, - const DataBuf& data, - TxtChunkType type) - { - DataBuf key = keyTXTChunk(data); - DataBuf arr = parseTXTChunk(data, key.size(), type); + void PngChunk::decodeTXTChunk(Image* pImage, const DataBuf& data, TxtChunkType type) + { + DataBuf key = keyTXTChunk(data); + DataBuf arr = parseTXTChunk(data, key.size(), type); #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk data: " - << std::string(arr.c_str(), arr.size()) << std::endl; + std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk data: " << std::string(arr.c_str(), arr.size()) + << std::endl; #endif - parseChunkContent(pImage, key.c_data(), key.size(), arr); - - } + parseChunkContent(pImage, key.c_data(), key.size(), arr); + } - DataBuf PngChunk::decodeTXTChunk(const DataBuf& data, - TxtChunkType type) - { - DataBuf key = keyTXTChunk(data); + DataBuf PngChunk::decodeTXTChunk(const DataBuf& data, TxtChunkType type) + { + DataBuf key = keyTXTChunk(data); #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk key: " - << std::string(key.c_str(), key.size()) << std::endl; + std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk key: " << std::string(key.c_str(), key.size()) + << std::endl; #endif - return parseTXTChunk(data, key.size(), type); - - } - - DataBuf PngChunk::keyTXTChunk(const DataBuf& data, bool stripHeader) - { - // From a tEXt, zTXt, or iTXt chunk, we get the keyword which is null terminated. - const int offset = stripHeader ? 8 : 0; - if (data.size() <= offset) - throw Error(kerFailedToReadImageData); - - // Search for null char until the end of the DataBuf - const byte* dataPtr = data.c_data(); - int keysize=offset; - while (dataPtr[keysize] != 0 && keysize < data.size()) { - keysize++; + return parseTXTChunk(data, key.size(), type); } - if (keysize == data.size()) - throw Error(kerFailedToReadImageData); + DataBuf PngChunk::keyTXTChunk(const DataBuf& data, bool stripHeader) + { + // From a tEXt, zTXt, or iTXt chunk, we get the keyword which is null terminated. + const int offset = stripHeader ? 8 : 0; + if (data.size() <= offset) + throw Error(kerFailedToReadImageData); - return DataBuf(dataPtr+offset, keysize-offset); - } + // Search for null char until the end of the DataBuf + const byte* dataPtr = data.c_data(); + int keysize = offset; + while (dataPtr[keysize] != 0 && keysize < data.size()) { + keysize++; + } - DataBuf PngChunk::parseTXTChunk(const DataBuf& data, - int keysize, - TxtChunkType type) - { - DataBuf arr; + if (keysize == data.size()) + throw Error(kerFailedToReadImageData); - if(type == zTXt_Chunk) + return DataBuf(dataPtr + offset, keysize - offset); + } + + DataBuf PngChunk::parseTXTChunk(const DataBuf& data, int keysize, TxtChunkType type) { - enforce(data.size() >= Safe::add(keysize, nullSeparators), Exiv2::kerCorruptedMetadata); + DataBuf arr; + + if (type == zTXt_Chunk) { + enforce(data.size() >= Safe::add(keysize, nullSeparators), Exiv2::kerCorruptedMetadata); - // Extract a deflate compressed Latin-1 text chunk + // Extract a deflate compressed Latin-1 text chunk - // we get the compression method after the key - const byte* compressionMethod = data.c_data(keysize + 1); - if ( *compressionMethod != 0x00 ) - { - // then it isn't zlib compressed and we are sunk + // we get the compression method after the key + const byte* compressionMethod = data.c_data(keysize + 1); + if (*compressionMethod != 0x00) { + // then it isn't zlib compressed and we are sunk #ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard zTXt compression method.\n"; + std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard zTXt compression method.\n"; #endif - throw Error(kerFailedToReadImageData); - } + throw Error(kerFailedToReadImageData); + } - // compressed string after the compression technique spec - const byte* compressedText = data.c_data(keysize + nullSeparators); - long compressedTextSize = data.size() - keysize - nullSeparators; - enforce(compressedTextSize < data.size(), kerCorruptedMetadata); + // compressed string after the compression technique spec + const byte* compressedText = data.c_data(keysize + nullSeparators); + long compressedTextSize = data.size() - keysize - nullSeparators; + enforce(compressedTextSize < data.size(), kerCorruptedMetadata); - zlibUncompress(compressedText, compressedTextSize, arr); - } - else if(type == tEXt_Chunk) - { - enforce(data.size() >= Safe::add(keysize, 1), Exiv2::kerCorruptedMetadata); - // Extract a non-compressed Latin-1 text chunk + zlibUncompress(compressedText, compressedTextSize, arr); + } else if (type == tEXt_Chunk) { + enforce(data.size() >= Safe::add(keysize, 1), Exiv2::kerCorruptedMetadata); + // Extract a non-compressed Latin-1 text chunk - // the text comes after the key, but isn't null terminated - const byte* text = data.c_data(keysize + 1); - long textsize = data.size() - keysize - 1; + // the text comes after the key, but isn't null terminated + const byte* text = data.c_data(keysize + 1); + long textsize = data.size() - keysize - 1; - arr = DataBuf(text, textsize); - } - else if(type == iTXt_Chunk) - { - enforce(data.size() >= Safe::add(keysize, 3), Exiv2::kerCorruptedMetadata); - const size_t nullCount = std::count(data.c_data(keysize+3), data.c_data(data.size()), '\0'); - enforce(nullCount >= nullSeparators, Exiv2::kerCorruptedMetadata); - - // Extract a deflate compressed or uncompressed UTF-8 text chunk - - // we get the compression flag after the key - const byte compressionFlag = data.read_uint8(keysize + 1); - // we get the compression method after the compression flag - const byte compressionMethod = data.read_uint8(keysize + 2); - - enforce(compressionFlag == 0x00 || compressionFlag == 0x01, Exiv2::kerCorruptedMetadata); - enforce(compressionMethod == 0x00, Exiv2::kerCorruptedMetadata); - - // language description string after the compression technique spec - const size_t languageTextMaxSize = data.size() - keysize - 3; - std::string languageText = string_from_unterminated( - data.c_str(Safe::add(keysize, 3)), languageTextMaxSize); - const size_t languageTextSize = languageText.size(); - - enforce(static_cast<unsigned long>(data.size()) >= - Safe::add(static_cast<size_t>(Safe::add(keysize, 4)), languageTextSize), - Exiv2::kerCorruptedMetadata); - // translated keyword string after the language description - std::string translatedKeyText = string_from_unterminated( - data.c_str(keysize + 3 + languageTextSize + 1), - data.size() - (keysize + 3 + languageTextSize + 1)); - const auto translatedKeyTextSize = static_cast<unsigned int>(translatedKeyText.size()); - - if ((compressionFlag == 0x00) || (compressionFlag == 0x01 && compressionMethod == 0x00)) { - enforce(Safe::add(static_cast<unsigned int>(keysize + 3 + languageTextSize + 1), - Safe::add(translatedKeyTextSize, 1U)) <= static_cast<size_t>(data.size()), - Exiv2::kerCorruptedMetadata); + arr = DataBuf(text, textsize); + } else if (type == iTXt_Chunk) { + enforce(data.size() >= Safe::add(keysize, 3), Exiv2::kerCorruptedMetadata); + const size_t nullCount = std::count(data.c_data(keysize + 3), data.c_data(data.size()), '\0'); + enforce(nullCount >= nullSeparators, Exiv2::kerCorruptedMetadata); + + // Extract a deflate compressed or uncompressed UTF-8 text chunk + + // we get the compression flag after the key + const byte compressionFlag = data.read_uint8(keysize + 1); + // we get the compression method after the compression flag + const byte compressionMethod = data.read_uint8(keysize + 2); - const byte* text = data.c_data(keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1); - const long textsize = static_cast<long>(data.size() - (keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1)); + enforce(compressionFlag == 0x00 || compressionFlag == 0x01, Exiv2::kerCorruptedMetadata); + enforce(compressionMethod == 0x00, Exiv2::kerCorruptedMetadata); - if (compressionFlag == 0x00) { - // then it's an uncompressed iTXt chunk + // language description string after the compression technique spec + const size_t languageTextMaxSize = data.size() - keysize - 3; + std::string languageText = + string_from_unterminated(data.c_str(Safe::add(keysize, 3)), languageTextMaxSize); + const size_t languageTextSize = languageText.size(); + + enforce(static_cast<unsigned long>(data.size()) >= + Safe::add(static_cast<size_t>(Safe::add(keysize, 4)), languageTextSize), + Exiv2::kerCorruptedMetadata); + // translated keyword string after the language description + std::string translatedKeyText = string_from_unterminated( + data.c_str(keysize + 3 + languageTextSize + 1), data.size() - (keysize + 3 + languageTextSize + 1)); + const auto translatedKeyTextSize = static_cast<unsigned int>(translatedKeyText.size()); + + if ((compressionFlag == 0x00) || (compressionFlag == 0x01 && compressionMethod == 0x00)) { + enforce(Safe::add(static_cast<unsigned int>(keysize + 3 + languageTextSize + 1), + Safe::add(translatedKeyTextSize, 1U)) <= static_cast<size_t>(data.size()), + Exiv2::kerCorruptedMetadata); + + const byte* text = data.c_data(keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1); + const long textsize = static_cast<long>( + data.size() - (keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1)); + + if (compressionFlag == 0x00) { + // then it's an uncompressed iTXt chunk #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::parseTXTChunk: We found an uncompressed iTXt field\n"; + std::cout << "Exiv2::PngChunk::parseTXTChunk: We found an uncompressed iTXt field\n"; #endif - arr.alloc(textsize); - arr = DataBuf(text, textsize); - } else if (compressionFlag == 0x01 && compressionMethod == 0x00) { - // then it's a zlib compressed iTXt chunk + arr.alloc(textsize); + arr = DataBuf(text, textsize); + } else if (compressionFlag == 0x01 && compressionMethod == 0x00) { + // then it's a zlib compressed iTXt chunk #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::parseTXTChunk: We found a zlib compressed iTXt field\n"; + std::cout << "Exiv2::PngChunk::parseTXTChunk: We found a zlib compressed iTXt field\n"; #endif - // the compressed text comes after the translated keyword, but isn't null terminated - zlibUncompress(text, textsize, arr); + // the compressed text comes after the translated keyword, but isn't null terminated + zlibUncompress(text, textsize, arr); + } + } else { + // then it isn't zlib compressed and we are sunk +#ifdef EXIV2_DEBUG_MESSAGES + std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard iTXt compression method.\n"; +#endif + throw Error(kerFailedToReadImageData); } } else { - // then it isn't zlib compressed and we are sunk -#ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard iTXt compression method.\n"; +#ifdef DEBUG + std::cerr << "Exiv2::PngChunk::parseTXTChunk: We found a field, not expected though\n"; #endif throw Error(kerFailedToReadImageData); } - } - else - { -#ifdef DEBUG - std::cerr << "Exiv2::PngChunk::parseTXTChunk: We found a field, not expected though\n"; -#endif - throw Error(kerFailedToReadImageData); - } - - return arr; - } - void PngChunk::parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr) - { - // We look if an ImageMagick EXIF raw profile exist. + return arr; + } - if ( keySize >= 21 - && ( memcmp("Raw profile type exif", key, 21) == 0 - || memcmp("Raw profile type APP1", key, 21) == 0) - && pImage->exifData().empty()) + void PngChunk::parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr) { - DataBuf exifData = readRawProfile(arr,false); - long length = exifData.size(); + // We look if an ImageMagick EXIF raw profile exist. - if (length > 0) - { - // Find the position of Exif header in bytes array. + if (keySize >= 21 && + (memcmp("Raw profile type exif", key, 21) == 0 || memcmp("Raw profile type APP1", key, 21) == 0) && + pImage->exifData().empty()) { + DataBuf exifData = readRawProfile(arr, false); + long length = exifData.size(); - const byte exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; - long pos = -1; + if (length > 0) { + // Find the position of Exif header in bytes array. - for (long i = 0; i < length - static_cast<long>(sizeof(exifHeader)); i++) { - if (exifData.cmpBytes(i, exifHeader, sizeof(exifHeader)) == 0) - { - pos = i; - break; + const byte exifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; + long pos = -1; + + for (long i = 0; i < length - static_cast<long>(sizeof(exifHeader)); i++) { + if (exifData.cmpBytes(i, exifHeader, sizeof(exifHeader)) == 0) { + pos = i; + break; + } } - } - // If found it, store only these data at from this place. + // If found it, store only these data at from this place. - if (pos !=-1) - { + if (pos != -1) { #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::parseChunkContent: Exif header found at position " << pos << "\n"; + std::cout << "Exiv2::PngChunk::parseChunkContent: Exif header found at position " << pos + << "\n"; #endif - pos = pos + sizeof(exifHeader); - ByteOrder bo = TiffParser::decode(pImage->exifData(), - pImage->iptcData(), - pImage->xmpData(), - exifData.c_data(pos), - length - pos); - pImage->setByteOrder(bo); - } - else - { + pos = pos + sizeof(exifHeader); + ByteOrder bo = TiffParser::decode(pImage->exifData(), pImage->iptcData(), pImage->xmpData(), + exifData.c_data(pos), length - pos); + pImage->setByteOrder(bo); + } else { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode Exif metadata.\n"; + EXV_WARNING << "Failed to decode Exif metadata.\n"; #endif - pImage->exifData().clear(); + pImage->exifData().clear(); + } } } - } - // We look if an ImageMagick IPTC raw profile exist. - - if ( keySize >= 21 - && memcmp("Raw profile type iptc", key, 21) == 0 - && pImage->iptcData().empty()) { - DataBuf psData = readRawProfile(arr,false); - if (psData.size() > 0) { - Blob iptcBlob; - const byte* record = nullptr; - uint32_t sizeIptc = 0; - uint32_t sizeHdr = 0; - - const byte* pEnd = psData.c_data(psData.size()); - const byte* pCur = psData.c_data(); - while ( pCur < pEnd - && 0 == Photoshop::locateIptcIrb(pCur, - static_cast<long>(pEnd - pCur), - &record, - &sizeHdr, - &sizeIptc)) { - if (sizeIptc) { + // We look if an ImageMagick IPTC raw profile exist. + + if (keySize >= 21 && memcmp("Raw profile type iptc", key, 21) == 0 && pImage->iptcData().empty()) { + DataBuf psData = readRawProfile(arr, false); + if (psData.size() > 0) { + Blob iptcBlob; + const byte* record = nullptr; + uint32_t sizeIptc = 0; + uint32_t sizeHdr = 0; + + const byte* pEnd = psData.c_data(psData.size()); + const byte* pCur = psData.c_data(); + while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, static_cast<long>(pEnd - pCur), &record, + &sizeHdr, &sizeIptc)) { + if (sizeIptc) { #ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n"; + std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n"; #endif - append(iptcBlob, record + sizeHdr, sizeIptc); + append(iptcBlob, record + sizeHdr, sizeIptc); + } + pCur = record + sizeHdr + sizeIptc; + pCur += (sizeIptc & 1); } - pCur = record + sizeHdr + sizeIptc; - pCur += (sizeIptc & 1); - } - if (!iptcBlob.empty() && - IptcParser::decode(pImage->iptcData(), &iptcBlob[0], static_cast<uint32_t>(iptcBlob.size()))) { + if (!iptcBlob.empty() && + IptcParser::decode(pImage->iptcData(), &iptcBlob[0], static_cast<uint32_t>(iptcBlob.size()))) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode IPTC metadata.\n"; + EXV_WARNING << "Failed to decode IPTC metadata.\n"; #endif - pImage->clearIptcData(); - } - // If there is no IRB, try to decode the complete chunk data - if ( iptcBlob.empty() - && IptcParser::decode(pImage->iptcData(), - psData.c_data(), - psData.size())) { + pImage->clearIptcData(); + } + // If there is no IRB, try to decode the complete chunk data + if (iptcBlob.empty() && IptcParser::decode(pImage->iptcData(), psData.c_data(), psData.size())) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode IPTC metadata.\n"; + EXV_WARNING << "Failed to decode IPTC metadata.\n"; #endif - pImage->clearIptcData(); - } - } // if (psData.size() > 0) - } + pImage->clearIptcData(); + } + } // if (psData.size() > 0) + } - // We look if an ImageMagick XMP raw profile exist. + // We look if an ImageMagick XMP raw profile exist. - if ( keySize >= 20 - && memcmp("Raw profile type xmp", key, 20) == 0 - && pImage->xmpData().empty()) - { - DataBuf xmpBuf = readRawProfile(arr,false); - long length = xmpBuf.size(); - - if (length > 0) - { - std::string& xmpPacket = pImage->xmpPacket(); - xmpPacket.assign(xmpBuf.c_str(), length); - std::string::size_type idx = xmpPacket.find_first_of('<'); - if (idx != std::string::npos && idx > 0) - { + if (keySize >= 20 && memcmp("Raw profile type xmp", key, 20) == 0 && pImage->xmpData().empty()) { + DataBuf xmpBuf = readRawProfile(arr, false); + long length = xmpBuf.size(); + + if (length > 0) { + std::string& xmpPacket = pImage->xmpPacket(); + xmpPacket.assign(xmpBuf.c_str(), length); + std::string::size_type idx = xmpPacket.find_first_of('<'); + if (idx != std::string::npos && idx > 0) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Removing " << idx - << " characters from the beginning of the XMP packet\n"; + EXV_WARNING << "Removing " << idx << " characters from the beginning of the XMP packet\n"; #endif - xmpPacket = xmpPacket.substr(idx); - } - if (XmpParser::decode(pImage->xmpData(), xmpPacket)) - { + xmpPacket = xmpPacket.substr(idx); + } + if (XmpParser::decode(pImage->xmpData(), xmpPacket)) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode XMP metadata.\n"; + EXV_WARNING << "Failed to decode XMP metadata.\n"; #endif + } } } - } - // We look if an Adobe XMP string exist. + // We look if an Adobe XMP string exist. - if ( keySize >= 17 - && memcmp("XML:com.adobe.xmp", key, 17) == 0 - && pImage->xmpData().empty()) - { - if (arr.size() > 0) - { - std::string& xmpPacket = pImage->xmpPacket(); - xmpPacket.assign(arr.c_str(), arr.size()); - std::string::size_type idx = xmpPacket.find_first_of('<'); - if (idx != std::string::npos && idx > 0) - { + if (keySize >= 17 && memcmp("XML:com.adobe.xmp", key, 17) == 0 && pImage->xmpData().empty()) { + if (arr.size() > 0) { + std::string& xmpPacket = pImage->xmpPacket(); + xmpPacket.assign(arr.c_str(), arr.size()); + std::string::size_type idx = xmpPacket.find_first_of('<'); + if (idx != std::string::npos && idx > 0) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Removing " << idx << " characters " - << "from the beginning of the XMP packet\n"; + EXV_WARNING << "Removing " << idx << " characters " + << "from the beginning of the XMP packet\n"; #endif - xmpPacket = xmpPacket.substr(idx); - } - if (XmpParser::decode(pImage->xmpData(), xmpPacket)) - { + xmpPacket = xmpPacket.substr(idx); + } + if (XmpParser::decode(pImage->xmpData(), xmpPacket)) { #ifndef SUPPRESS_WARNINGS - EXV_WARNING << "Failed to decode XMP metadata.\n"; + EXV_WARNING << "Failed to decode XMP metadata.\n"; #endif + } } } - } - // We look if a comments string exist. Note than we use only 'Description' keyword which - // is dedicaced to store long comments. 'Comment' keyword is ignored. + // We look if a comments string exist. Note than we use only 'Description' keyword which + // is dedicaced to store long comments. 'Comment' keyword is ignored. - if ( keySize >= 11 - && memcmp("Description", key, 11) == 0 - && pImage->comment().empty()) - { - pImage->setComment(std::string(arr.c_str(), arr.size())); - } + if (keySize >= 11 && memcmp("Description", key, 11) == 0 && pImage->comment().empty()) { + pImage->setComment(std::string(arr.c_str(), arr.size())); + } - } // PngChunk::parseChunkContent + } // PngChunk::parseChunkContent - std::string PngChunk::makeMetadataChunk(const std::string& metadata, - MetadataId type) - { - std::string chunk; - std::string rawProfile; - - switch (type) { - case mdComment: - chunk = makeUtf8TxtChunk("Description", metadata, true); - break; - case mdExif: - rawProfile = writeRawProfile(metadata, "exif"); - chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true); - break; - case mdIptc: - rawProfile = writeRawProfile(metadata, "iptc"); - chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true); - break; - case mdXmp: - chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false); - break; - case mdIccProfile: - break; - case mdNone: - assert(false); - } - - return chunk; - - } // PngChunk::makeMetadataChunk - - void PngChunk::zlibUncompress(const byte* compressedText, - unsigned int compressedTextSize, - DataBuf& arr) - { - uLongf uncompressedLen = compressedTextSize * 2; // just a starting point - int zlibResult; - int dos = 0; - - do { - arr.alloc(uncompressedLen); - zlibResult = uncompress(arr.data(), - &uncompressedLen, - compressedText, - compressedTextSize); - if (zlibResult == Z_OK) { - assert((uLongf)arr.size() >= uncompressedLen); - arr.resize(uncompressedLen); + std::string PngChunk::makeMetadataChunk(const std::string& metadata, MetadataId type) + { + std::string chunk; + std::string rawProfile; + + switch (type) { + case mdComment: + chunk = makeUtf8TxtChunk("Description", metadata, true); + break; + case mdExif: + rawProfile = writeRawProfile(metadata, "exif"); + chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true); + break; + case mdIptc: + rawProfile = writeRawProfile(metadata, "iptc"); + chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true); + break; + case mdXmp: + chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false); + break; + case mdIccProfile: + break; + case mdNone: + assert(false); } - else if (zlibResult == Z_BUF_ERROR) { - // the uncompressedArray needs to be larger - uncompressedLen *= 2; - // DoS protection. can't be bigger than 64k - if (uncompressedLen > 131072) { - if (++dos > 1) break; - uncompressedLen = 131072; + + return chunk; + + } // PngChunk::makeMetadataChunk + + void PngChunk::zlibUncompress(const byte* compressedText, unsigned int compressedTextSize, DataBuf& arr) + { + uLongf uncompressedLen = compressedTextSize * 2; // just a starting point + int zlibResult; + int dos = 0; + + do { + arr.alloc(uncompressedLen); + zlibResult = uncompress(arr.data(), &uncompressedLen, compressedText, compressedTextSize); + if (zlibResult == Z_OK) { + assert((uLongf)arr.size() >= uncompressedLen); + arr.resize(uncompressedLen); + } else if (zlibResult == Z_BUF_ERROR) { + // the uncompressedArray needs to be larger + uncompressedLen *= 2; + // DoS protection. can't be bigger than 64k + if (uncompressedLen > 131072) { + if (++dos > 1) + break; + uncompressedLen = 131072; + } + } else { + // something bad happened + throw Error(kerFailedToReadImageData); } - } - else { - // something bad happened + } while (zlibResult == Z_BUF_ERROR); + + if (zlibResult != Z_OK) { throw Error(kerFailedToReadImageData); } - } - while (zlibResult == Z_BUF_ERROR); + } // PngChunk::zlibUncompress - if (zlibResult != Z_OK) { - throw Error(kerFailedToReadImageData); - } - } // PngChunk::zlibUncompress + std::string PngChunk::zlibCompress(const std::string& text) + { + auto compressedLen = static_cast<uLongf>(text.size() * 2); // just a starting point + int zlibResult; - std::string PngChunk::zlibCompress(const std::string& text) - { - auto compressedLen = static_cast<uLongf>(text.size() * 2); // just a starting point - int zlibResult; - - DataBuf arr; - do { - arr.resize(compressedLen); - zlibResult = compress2(arr.data(), &compressedLen, reinterpret_cast<const Bytef*>(text.data()), - static_cast<uLong>(text.size()), Z_BEST_COMPRESSION); - - switch (zlibResult) { - case Z_OK: - assert((uLongf)arr.size() >= compressedLen); + DataBuf arr; + do { arr.resize(compressedLen); - break; - case Z_BUF_ERROR: - // The compressed array needs to be larger + zlibResult = compress2(arr.data(), &compressedLen, reinterpret_cast<const Bytef*>(text.data()), + static_cast<uLong>(text.size()), Z_BEST_COMPRESSION); + + switch (zlibResult) { + case Z_OK: + assert((uLongf)arr.size() >= compressedLen); + arr.resize(compressedLen); + break; + case Z_BUF_ERROR: + // The compressed array needs to be larger #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Exiv2::PngChunk::parsePngChunk: doubling size for compression.\n"; + std::cout << "Exiv2::PngChunk::parsePngChunk: doubling size for compression.\n"; #endif - compressedLen *= 2; - // DoS protection. Cap max compressed size - if ( compressedLen > 131072 ) throw Error(kerFailedToReadImageData); - break; - default: - // Something bad happened - throw Error(kerFailedToReadImageData); - } - } while (zlibResult == Z_BUF_ERROR); + compressedLen *= 2; + // DoS protection. Cap max compressed size + if (compressedLen > 131072) + throw Error(kerFailedToReadImageData); + break; + default: + // Something bad happened + throw Error(kerFailedToReadImageData); + } + } while (zlibResult == Z_BUF_ERROR); - return std::string(arr.c_str(), arr.size()); + return std::string(arr.c_str(), arr.size()); - } // PngChunk::zlibCompress + } // PngChunk::zlibCompress - std::string PngChunk::makeAsciiTxtChunk(const std::string& keyword, - const std::string& text, - bool compress) - { - // Chunk structure: length (4 bytes) + chunk type + chunk data + CRC (4 bytes) - // Length is the size of the chunk data - // CRC is calculated on chunk type + chunk data - - // Compressed text chunk using zlib. - // Chunk data format : keyword + 0x00 + compression method (0x00) + compressed text - - // Not Compressed text chunk. - // Chunk data format : keyword + 0x00 + text - - // Build chunk data, determine chunk type - std::string chunkData = keyword + '\0'; - std::string chunkType; - if (compress) { - chunkData += '\0' + zlibCompress(text); - chunkType = "zTXt"; - } - else { - chunkData += text; - chunkType = "tEXt"; - } - // Determine length of the chunk data - byte length[4]; - ul2Data(length, static_cast<uint32_t>(chunkData.size()), bigEndian); - // Calculate CRC on chunk type and chunk data - std::string crcData = chunkType + chunkData; - uLong tmp = crc32(0L, Z_NULL, 0); - tmp = crc32(tmp, reinterpret_cast<const Bytef*>(crcData.data()), static_cast<uInt>(crcData.size())); - byte crc[4]; - ul2Data(crc, tmp, bigEndian); - // Assemble the chunk - return std::string(reinterpret_cast<const char*>(length), 4) + chunkType + chunkData + - std::string(reinterpret_cast<const char*>(crc), 4); - - } // PngChunk::makeAsciiTxtChunk - - std::string PngChunk::makeUtf8TxtChunk(const std::string& keyword, - const std::string& text, - bool compress) - { - // Chunk structure: length (4 bytes) + chunk type + chunk data + CRC (4 bytes) - // Length is the size of the chunk data - // CRC is calculated on chunk type + chunk data - - // Chunk data format : keyword + 0x00 + compression flag (0x00: uncompressed - 0x01: compressed) - // + compression method (0x00: zlib format) + language tag (null) + 0x00 - // + translated keyword (null) + 0x00 + text (compressed or not) - - // Build chunk data, determine chunk type - std::string chunkData = keyword; - if (compress) { - static const char flags[] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; - chunkData += std::string(flags, 5) + zlibCompress(text); - } - else { - static const char flags[] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; - chunkData += std::string(flags, 5) + text; - } - // Determine length of the chunk data - byte length[4]; - ul2Data(length, static_cast<uint32_t>(chunkData.size()), bigEndian); - // Calculate CRC on chunk type and chunk data - std::string chunkType = "iTXt"; - std::string crcData = chunkType + chunkData; - uLong tmp = crc32(0L, Z_NULL, 0); - tmp = crc32(tmp, reinterpret_cast<const Bytef*>(crcData.data()), static_cast<uInt>(crcData.size())); - byte crc[4]; - ul2Data(crc, tmp, bigEndian); - // Assemble the chunk - return std::string(reinterpret_cast<const char*>(length), 4) + chunkType + chunkData + - std::string(reinterpret_cast<const char*>(crc), 4); - - } // PngChunk::makeUtf8TxtChunk - - DataBuf PngChunk::readRawProfile(const DataBuf& text,bool iTXt) - { - DataBuf info; - unsigned char unhex[103]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,1, 2,3,4,5,6,7,8,9,0,0, - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,10,11,12, - 13,14,15}; - if (text.size() == 0) { - return DataBuf(); - } - - if ( iTXt ) { - info.alloc(text.size()); - info.copyBytes(0, text.c_data(), text.size()); - return info; - } + std::string PngChunk::makeAsciiTxtChunk(const std::string& keyword, const std::string& text, bool compress) + { + // Chunk structure: length (4 bytes) + chunk type + chunk data + CRC (4 bytes) + // Length is the size of the chunk data + // CRC is calculated on chunk type + chunk data + + // Compressed text chunk using zlib. + // Chunk data format : keyword + 0x00 + compression method (0x00) + compressed text + + // Not Compressed text chunk. + // Chunk data format : keyword + 0x00 + text + + // Build chunk data, determine chunk type + std::string chunkData = keyword + '\0'; + std::string chunkType; + if (compress) { + chunkData += '\0' + zlibCompress(text); + chunkType = "zTXt"; + } else { + chunkData += text; + chunkType = "tEXt"; + } + // Determine length of the chunk data + byte length[4]; + ul2Data(length, static_cast<uint32_t>(chunkData.size()), bigEndian); + // Calculate CRC on chunk type and chunk data + std::string crcData = chunkType + chunkData; + uLong tmp = crc32(0L, Z_NULL, 0); + tmp = crc32(tmp, reinterpret_cast<const Bytef*>(crcData.data()), static_cast<uInt>(crcData.size())); + byte crc[4]; + ul2Data(crc, tmp, bigEndian); + // Assemble the chunk + return std::string(reinterpret_cast<const char*>(length), 4) + chunkType + chunkData + + std::string(reinterpret_cast<const char*>(crc), 4); + + } // PngChunk::makeAsciiTxtChunk + + std::string PngChunk::makeUtf8TxtChunk(const std::string& keyword, const std::string& text, bool compress) + { + // Chunk structure: length (4 bytes) + chunk type + chunk data + CRC (4 bytes) + // Length is the size of the chunk data + // CRC is calculated on chunk type + chunk data + + // Chunk data format : keyword + 0x00 + compression flag (0x00: uncompressed - 0x01: compressed) + // + compression method (0x00: zlib format) + language tag (null) + 0x00 + // + translated keyword (null) + 0x00 + text (compressed or not) + + // Build chunk data, determine chunk type + std::string chunkData = keyword; + if (compress) { + static const char flags[] = {0x00, 0x01, 0x00, 0x00, 0x00}; + chunkData += std::string(flags, 5) + zlibCompress(text); + } else { + static const char flags[] = {0x00, 0x00, 0x00, 0x00, 0x00}; + chunkData += std::string(flags, 5) + text; + } + // Determine length of the chunk data + byte length[4]; + ul2Data(length, static_cast<uint32_t>(chunkData.size()), bigEndian); + // Calculate CRC on chunk type and chunk data + std::string chunkType = "iTXt"; + std::string crcData = chunkType + chunkData; + uLong tmp = crc32(0L, Z_NULL, 0); + tmp = crc32(tmp, reinterpret_cast<const Bytef*>(crcData.data()), static_cast<uInt>(crcData.size())); + byte crc[4]; + ul2Data(crc, tmp, bigEndian); + // Assemble the chunk + return std::string(reinterpret_cast<const char*>(length), 4) + chunkType + chunkData + + std::string(reinterpret_cast<const char*>(crc), 4); + + } // PngChunk::makeUtf8TxtChunk + + DataBuf PngChunk::readRawProfile(const DataBuf& text, bool iTXt) + { + DataBuf info; + unsigned char unhex[103] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; + if (text.size() == 0) { + return DataBuf(); + } - const char* sp = text.c_str(1); // current byte (space pointer) - const char* eot = text.c_str(text.size()); // end of text + if (iTXt) { + info.alloc(text.size()); + info.copyBytes(0, text.c_data(), text.size()); + return info; + } - if (sp >= eot) { - return DataBuf(); - } + const char* sp = text.c_str(1); // current byte (space pointer) + const char* eot = text.c_str(text.size()); // end of text - // Look for newline - while (*sp != '\n') - { - sp++; - if ( sp == eot ) - { + if (sp >= eot) { return DataBuf(); } - } - sp++ ; // step over '\n' - if (sp == eot) { - return DataBuf(); - } - // Look for length - while (*sp == '\0' || *sp == ' ' || *sp == '\n') - { - sp++; - if (sp == eot ) - { + // Look for newline + while (*sp != '\n') { + sp++; + if (sp == eot) { + return DataBuf(); + } + } + sp++; // step over '\n' + if (sp == eot) { return DataBuf(); } - } - // Parse the length. - long length = 0; - while ('0' <= *sp && *sp <= '9') - { - // Compute the new length using unsigned long, so that we can - // check for overflow. - const unsigned long newlength = (10 * static_cast<unsigned long>(length)) + (*sp - '0'); - if (newlength > static_cast<unsigned long>(std::numeric_limits<long>::max())) { - return DataBuf(); // Integer overflow. + // Look for length + while (*sp == '\0' || *sp == ' ' || *sp == '\n') { + sp++; + if (sp == eot) { + return DataBuf(); + } + } + + // Parse the length. + long length = 0; + while ('0' <= *sp && *sp <= '9') { + // Compute the new length using unsigned long, so that we can + // check for overflow. + const unsigned long newlength = (10 * static_cast<unsigned long>(length)) + (*sp - '0'); + if (newlength > static_cast<unsigned long>(std::numeric_limits<long>::max())) { + return DataBuf(); // Integer overflow. + } + length = static_cast<long>(newlength); + sp++; + if (sp == eot) { + return DataBuf(); + } } - length = static_cast<long>(newlength); - sp++; - if (sp == eot ) - { + sp++; // step over '\n' + if (sp == eot) { return DataBuf(); } - } - sp++ ; // step over '\n' - if (sp == eot) { - return DataBuf(); - } - enforce(length <= (eot - sp)/2, Exiv2::kerCorruptedMetadata); + enforce(length <= (eot - sp) / 2, Exiv2::kerCorruptedMetadata); - // Allocate space - if (length == 0) - { + // Allocate space + if (length == 0) { #ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: invalid profile length\n"; + std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: invalid profile length\n"; #endif - } - info.alloc(length); - if (info.size() != length) - { + } + info.alloc(length); + if (info.size() != length) { #ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: cannot allocate memory\n"; + std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: cannot allocate memory\n"; #endif - return DataBuf(); - } + return DataBuf(); + } - // Copy profile, skipping white space and column 1 "=" signs + // Copy profile, skipping white space and column 1 "=" signs - unsigned char *dp = info.data(); // decode pointer - unsigned int nibbles = length * 2; + unsigned char* dp = info.data(); // decode pointer + unsigned int nibbles = length * 2; - for (long i = 0; i < static_cast<long>(nibbles); i++) { - enforce(sp < eot, Exiv2::kerCorruptedMetadata); - while (*sp < '0' || (*sp > '9' && *sp < 'a') || *sp > 'f') - { - if (*sp == '\0') - { + for (long i = 0; i < static_cast<long>(nibbles); i++) { + enforce(sp < eot, Exiv2::kerCorruptedMetadata); + while (*sp < '0' || (*sp > '9' && *sp < 'a') || *sp > 'f') { + if (*sp == '\0') { #ifdef EXIV2_DEBUG_MESSAGES - std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: ran out of data\n"; + std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: ran out of data\n"; #endif - return DataBuf(); + return DataBuf(); + } + + sp++; + enforce(sp < eot, Exiv2::kerCorruptedMetadata); } - sp++; - enforce(sp < eot, Exiv2::kerCorruptedMetadata); + if (i % 2 == 0) + *dp = static_cast<unsigned char>(16 * unhex[static_cast<int>(*sp++)]); + else + (*dp++) += unhex[static_cast<int>(*sp++)]; } - if (i%2 == 0) - *dp = static_cast<unsigned char>(16 * unhex[static_cast<int>(*sp++)]); - else - (*dp++) += unhex[static_cast<int>(*sp++)]; - } - - return info; + return info; - } // PngChunk::readRawProfile + } // PngChunk::readRawProfile - std::string PngChunk::writeRawProfile(const std::string& profileData, - const char* profileType) - { - static byte hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - - std::ostringstream oss; - oss << '\n' << profileType << '\n' << std::setw(8) << profileData.size(); - const char* sp = profileData.data(); - for (std::string::size_type i = 0; i < profileData.size(); ++i) { - if (i % 36 == 0) oss << '\n'; - oss << hex[((*sp >> 4) & 0x0f)]; - oss << hex[((*sp++) & 0x0f)]; - } - oss << '\n'; - return oss.str(); + std::string PngChunk::writeRawProfile(const std::string& profileData, const char* profileType) + { + static byte hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + std::ostringstream oss; + oss << '\n' << profileType << '\n' << std::setw(8) << profileData.size(); + const char* sp = profileData.data(); + for (std::string::size_type i = 0; i < profileData.size(); ++i) { + if (i % 36 == 0) + oss << '\n'; + oss << hex[((*sp >> 4) & 0x0f)]; + oss << hex[((*sp++) & 0x0f)]; + } + oss << '\n'; + return oss.str(); - } // PngChunk::writeRawProfile + } // PngChunk::writeRawProfile } // namespace Internal } // namespace Exiv2 -#endif // ifdef EXV_HAVE_LIBZ - +#endif // ifdef EXV_HAVE_LIBZ
0
8a756ffd66492dec4e165bf8b0f56f3bacc34633
Exiv2
exiv2
Updated Spanish translation. (Pablo Valdes)
commit 8a756ffd66492dec4e165bf8b0f56f3bacc34633 Author: Andreas Huggel <[email protected]> Date: Mon Nov 22 10:22:26 2010 +0000 Updated Spanish translation. (Pablo Valdes) diff --git a/po/es.po b/po/es.po index 6f4f43008..78c55c940 100644 --- a/po/es.po +++ b/po/es.po @@ -243,7 +243,7 @@ msgstr "normal" #: src/actions.cpp:837 #, fuzzy msgid "found in the file" -msgstr "encontrado en el archivo" +msgid "encontrado en el archivo" #: src/actions.cpp:842 msgid "Image file creation timestamp not set in the file" @@ -476,7 +476,7 @@ msgstr "Renombrando archivo a" #: src/actions.cpp:2024 msgid "updating timestamp" -msgstr "actualizando fecha y hora" +msgid "actualizando fecha y hora" #: src/actions.cpp:2033 msgid "Failed to rename" @@ -943,6 +943,7 @@ msgstr "" #: src/canonmn.cpp:160 msgid "EOS Digital Rebel XTi / 400D / Kiss Digital X" msgstr "" +---------------------------------------- #: src/canonmn.cpp:165 src/canonmn.cpp:168 src/canonmn.cpp:176 #: src/canonmn.cpp:181 src/canonmn.cpp:182 src/canonmn.cpp:183 @@ -2308,7 +2309,7 @@ msgstr "de derecha a izquiera" #: src/canonmn.cpp:794 src/olympusmn.cpp:1082 #, fuzzy msgid "Bottom to top" -msgstr "de abajo a arriba" +msgstr "de abajo a arriba'' #: src/canonmn.cpp:795 src/olympusmn.cpp:1083 #, fuzzy @@ -2870,7 +2871,7 @@ msgstr "Id del Servicio" #: src/datasets.cpp:106 #, fuzzy msgid "Identifies the provider and product" -msgstr "Identifica al proveedor y el producto" +msgstr "Identifica al proveedor y el producto #: src/datasets.cpp:108 #, fuzzy @@ -2964,11 +2965,15 @@ msgid "" "functions follow the ISO 2022 standard and may consist of the escape control " "character and one or more graphic characters." msgstr "" +"Esta etiqueta consiste en una o mas funciones de control utilizadas para el anuncio, " +"invocación o designio de juegos de caracteres codificados. Las funciones de control " +"siguen el estándar ISO 2022 y pueden consistir en el caracter de control escape " +"y uno o más caracteres gráficos." #: src/datasets.cpp:145 #, fuzzy msgid "Unique Name Object" -msgstr "Retrato" +msgstr "Nombre único de Objeto" #: src/datasets.cpp:146 msgid "" @@ -2976,6 +2981,10 @@ msgid "" "in the IIM, independent of provider and for any media form. The provider " "must ensure the UNO is unique. Objects with the same UNO are identical." msgstr "" +"Esta etiqueta proporciona un identificador único globalmente para objetos, " +"independiente del proveedor y para cualquier tipo de medio, tal y como está " +"especificado en el IIM. El proveedor debe garantizar que el UNO es único. " +"Los objetos con el mismo UNO son idénticos." #: src/datasets.cpp:151 #, fuzzy @@ -2988,22 +2997,29 @@ msgid "" "which is described in a document registered by the originator of the ARM " "with the IPTC and NAA organizations." msgstr "" +"El DataSet identifica al Abstract Relationship Method identifier (ARM) " +"que es descrito en un documento registrado por el creador del ARM " +"con las organizaciones IPTC y NAA." +### can be improved probably #: src/datasets.cpp:156 #, fuzzy msgid "ARM Version" -msgstr "Versión Exif" +msgstr "Versión ARM" #: src/datasets.cpp:157 msgid "" "This tag consisting of a binary number representing the particular version " "of the ARM specified by tag <ARMId>." msgstr "" +"Consiste en un número binario representando la versión particular " +"del ARM especificado por la etiqueta <ARMId>." #: src/datasets.cpp:170 #, fuzzy msgid "Record Version" msgstr "Versión Exif" +### ? not translated #: src/datasets.cpp:171 msgid "" @@ -3011,11 +3027,14 @@ msgid "" "Model, Part II, utilised by the provider. Version numbers are assigned by " "IPTC and NAA organizations." msgstr "" +"Número binario, asignado por las organizaciones IPTC y NAA, que identifica " +"la versión del Modelo de Intercambio de Información, Parte II, utilizado por " +"el proveedor." #: src/datasets.cpp:175 #, fuzzy msgid "Object Type" -msgstr "Área del sujeto" +msgstr "Tipo de Objeto" #: src/datasets.cpp:176 msgid "" @@ -3026,11 +3045,17 @@ msgid "" "Type Number consisting of graphic characters plus spaces either in English " "or in the language of the service as indicated in tag <LanguageIdentifier>" msgstr "" +"Tipo de Objeto; se utiliza para distinguir entre diferentes tipos de objetos " +"dentro del IIM. Consta de dos partes separadas por un signo de dos puntos, siendo " +"la segunda parte opcional. La primera es un número de referencia internacional e " +"independiente del lenguaje para un tipo de objeto; La segunda una representación " +"textual del Object Type Number mediante caracteres gráficos y espacios, bien en " +"Inglés o en el lenguaje del servicio indicado en la etiqueta <LanguageIdentifier>." #: src/datasets.cpp:184 #, fuzzy msgid "Object Attribute" -msgstr "Área del sujeto" +msgstr "Atributos del objeto" #: src/datasets.cpp:185 msgid "" @@ -3042,6 +3067,12 @@ msgid "" "English, or in the language of the service as indicated in tag " "<LanguageIdentifier>" msgstr "" +"El Object Attribute define la naturaleza del objeto independientemente del tema que trate. " +"Consta de dos partes separadas por un signo de dos puntos, siendo la segunda parte opcional." +"La primera es un número de referencia internacional (independiente del lenguaje) para un " +"atributo del objeto; La segunda una representación textual del Object Attribute Number mediante " +"caracteres gráficos y espacios, bien en Inglés o en el lenguaje del servicio indicado en " +"la etiqueta <LanguageIdentifier>. #: src/datasets.cpp:193 #, fuzzy @@ -3054,6 +3085,9 @@ msgid "" "such as updated stories or new crops on photos, should be identified in tag " "<EditStatus>." msgstr "" +"Utilizado como referencia rápida (taquigráfica) para el objeto. Los cambios " +"a datos existentes, como historias actualizadas o nuevos recortes en fotos, " +"deben estar identificados en la etiqueta <EditStatus>." #: src/datasets.cpp:198 #, fuzzy @@ -3063,15 +3097,16 @@ msgstr "Título del documento" #: src/datasets.cpp:199 src/olympusmn.cpp:759 #, fuzzy msgid "Edit Status" -msgstr "Vista distante" +msgstr "Editar Estátus" +#### temptatively, can have several meanings here #: src/datasets.cpp:200 msgid "Status of the object data, according to the practice of the provider." -msgstr "" +msgstr "Estatus de los datos del objeto, de acuerdo con la costumbre del proveedor " #: src/datasets.cpp:202 msgid "Editorial Update" -msgstr "" +msgstr "Actualización Editorial" #: src/datasets.cpp:203 msgid "" @@ -3079,10 +3114,13 @@ msgid "" "The link to the previous object is made using the tags <ARMIdentifier> and " "<ARMVersion>, according to the practices of the provider." msgstr "" +"Indica el tipo de actualización que éste objeto proporciona a un objeto previo. " +"El enlace al objeto previo se hace usando las etiquetas <ARMIdentifier> y " +"<ARMVersion>, de acuerdo a las costumbres del proveedor." #: src/datasets.cpp:207 src/datasets.cpp:212 src/properties.cpp:401 msgid "Urgency" -msgstr "" +msgstr "Urgencia (de edición)" #: src/datasets.cpp:208 msgid "" @@ -3090,20 +3128,23 @@ msgid "" "handling priority (see tag <EnvelopePriority>). The \"1\" is most urgent, \"5" "\" normal and \"8\" denotes the least-urgent copy." msgstr "" +"Especifica la urgencia editorial del contenido y no equivale necesariamente a " +"la prioridad de manejo del sobre (véase <EnvelopePriority>). El \"1\" es el más +" urgente, \"5""\" indica normal y \"8\" denota a la copia menos prioritaria." #: src/datasets.cpp:213 src/properties.cpp:155 #, fuzzy msgid "Subject" -msgstr "Área del sujeto" +msgstr "Sujeto" #: src/datasets.cpp:214 msgid "The Subject Reference is a structured definition of the subject matter." -msgstr "" +msgstr "La referencia Sujeto es una definición estructurada del contenido" #: src/datasets.cpp:216 src/datasets.cpp:221 src/properties.cpp:387 #, fuzzy msgid "Category" -msgstr "Centímetro" +msgstr "Categoría" #: src/datasets.cpp:217 msgid "" @@ -3111,10 +3152,13 @@ msgid "" "list of categories will be maintained by a regional registry, where " "available, otherwise by the provider." msgstr "" +"Identifica el tema del objeto dato en opinión del proveedor. Donde sea posible " +"una lista de categorías será mantenida por un registro regional, en otro caso sera " +"proporcionada por el proveedor." #: src/datasets.cpp:222 msgid "Supplemental Category" -msgstr "" +msgstr "Categoría suplementaria" #: src/datasets.cpp:223 msgid "" @@ -3123,25 +3167,33 @@ msgid "" "in tag <Category>. Otherwise, selection of supplemental categories are left " "to the provider." msgstr "" +"Las categorías suplementarias permiten refinar el tema de un objeto de datos. " +"Una categoría suplementaria puede incluir cualquiera de las categorías ya reconocidas " +"en la etiqueta <Category>. Por lo demás, la selección de categorías suplementarias " +"se deja al proveedor." #: src/datasets.cpp:228 src/properties.cpp:399 msgid "Supplemental Categories" -msgstr "" +msgstr "Categorías suplementarias" #: src/datasets.cpp:229 #, fuzzy msgid "Fixture Id" -msgstr "Modo de exposición" +msgstr "Id de objetos permanentes" +### only my best effort, can be improved probably #: src/datasets.cpp:230 msgid "" "Identifies object data that recurs often and predictably. Enables users to " "immediately find or recall such an object." msgstr "" +"Identifica objetos de datos que recurren a menudo y de modo predecible, " +"permitiendo a los usuarios encontrarlos inmediatamente o rellamarlos " +"cuando se precise." #: src/datasets.cpp:233 src/datasets.cpp:239 src/properties.cpp:377 msgid "Keywords" -msgstr "" +msgstr "Palabras Clave" #: src/datasets.cpp:234 msgid "" @@ -3150,11 +3202,15 @@ msgid "" "the same keyword, enabling the receiving system or subsystems to search " "across all types of data for related material." msgstr "" +"Utilizado para indicar palabras clave específicas. Se espera que un proveedor de " +"varios tipos de datos ligados a un mismo tema utilice la misma palabra clave, " +"permitiendo al sistema receptor o a los distintos subsistemas encontrar rápidamente " +"todo el material relacionado entre todos los tipos de datos." #: src/datasets.cpp:240 #, fuzzy msgid "Location Code" -msgstr "Nombre del documento" +msgstr "Código de Localidad" #: src/datasets.cpp:241 msgid "" @@ -3165,11 +3221,16 @@ msgid "" "space, IPTC will assign an appropriate three-character code under the " "provisions of ISO 3166 to avoid conflicts." msgstr "" +"Indica el código de País/localización geográfica referenciado por el contenido " +"de un objeto. Allí donde la ISO 3166 haya establecido un código apropiado de país " +"se utilizará ése código. En caso contrario (ej. el espacio o barcos en alta mar, " +"IPTC asignará un código de tres caracteres apropiado bajo las previsiones de +"la ISO 3166 para evitar conflictos." #: src/datasets.cpp:248 #, fuzzy msgid "Location Name" -msgstr "Nombre del documento" +msgstr "Nombre de la localización" #: src/datasets.cpp:249 msgid "" @@ -3177,66 +3238,85 @@ msgid "" "referenced by the content of the object, according to guidelines of the " "provider." msgstr "" +"Proporciona un nombre, publicable y completo, del país o localización geográfica " +"referenciado por el contenido de un objeto, de acuerdo a las directrices del proveedor." #: src/datasets.cpp:253 src/properties.cpp:340 #, fuzzy msgid "Release Date" -msgstr "Tipo de captura de escena" +msgstr "Fecha de publicación" #: src/datasets.cpp:254 msgid "" "Designates in the form CCYYMMDD the earliest date the provider intends the " "object to be used. Follows ISO 8601 standard." msgstr "" +"Designa la fecha inicial (expresada en forma CCYYMMDD) a partir de la cual " +"el proveedor tiene intención de que un objeto concreto pueda ser usado. " +"Sigue el estándar ISO 8601." #: src/datasets.cpp:257 #, fuzzy msgid "Release Time" -msgstr "Ancho de la imagen" +msgstr "Tiempo de Publicación" #: src/datasets.cpp:258 msgid "" "Designates in the form HHMMSS:HHMM the earliest time the provider intends " "the object to be used. Follows ISO 8601 standard." msgstr "" +"Designa la hora inicial (expresada en forma HHMMSS:HHMM) a partir de la cual " +"el proveedor tiene intención de que un objeto concreto pueda ser usado. " +"Sigue el estándar ISO 8601." #: src/datasets.cpp:261 #, fuzzy msgid "Expiration Date" -msgstr "Tipo de captura de escena" +msgstr "Fecha de Caducidad" #: src/datasets.cpp:262 msgid "" "Designates in the form CCYYMMDD the latest date the provider or owner " "intends the object data to be used. Follows ISO 8601 standard." msgstr "" +"Designa la fecha de expiración de la validez de un objeto para su uso " +"(expresada en forma CCYYMMDD) a partir de la cual el proveedor o el usuario consideran " +"que ya no debe utilizarse mas dicho objeto. Sigue el estándar ISO 8601." #: src/datasets.cpp:265 #, fuzzy msgid "ExpirationTime" -msgstr "Fecha y hora" +msgstr "Tiempo de Caducidad" #: src/datasets.cpp:266 msgid "" "Designates in the form HHMMSS:HHMM the latest time the provider or owner " "intends the object data to be used. Follows ISO 8601 standard." msgstr "" +"Designa la hora de expiración de la validez de un objeto para su uso " +"(expresada en forma HHMMSS:HHMM) a partir de la cual el proveedor o el usuario consideran " +"que ya no debe utilizarse mas dicho objeto. Sigue el estándar ISO 8601." #: src/datasets.cpp:269 #, fuzzy msgid "Special Instructions" -msgstr "Proceso personalizado" +msgstr "Instrucciones especiales" #: src/datasets.cpp:270 msgid "" "Other editorial instructions concerning the use of the object data, such as " "embargoes and warnings." msgstr "" +"Instrucciones editoriales adicionales sobre el uso del objeto dato, " +"como embargos y advertencias." #: src/datasets.cpp:273 src/properties.cpp:396 #, fuzzy msgid "Instructions" -msgstr "Proceso personalizado" +msgstr "Instrucciones" + +################################################## stop. rev 18 oct 2010 + #: src/datasets.cpp:274 #, fuzzy @@ -5147,7 +5227,7 @@ msgstr "Tiempo de exposición" #: src/minoltamn.cpp:159 src/sonymn.cpp:325 msgid "Color Compensation Filter: negative is green, positive is magenta" -msgstr "Filtro de compensación del color: el verde es negativo, el magenta es positivo" +msgstr "Filtro de compensación del color: el verde es negativo, el magenta es positivo"" #: src/minoltamn.cpp:161 src/minoltamn.cpp:1425 src/sonymn.cpp:249 #: src/sonymn.cpp:527 src/sonymn.cpp:528 @@ -18326,7 +18406,7 @@ msgstr "Escena nocturna / Crepúsculo" #: src/sonymn.cpp:107 msgid "Hi-Speed Shutter" -msgstr "Obturador alta velocidad" +msgstr "Obturador alta velocidad'' #: src/sonymn.cpp:108 #, fuzzy @@ -22522,7 +22602,7 @@ msgstr "" #, fuzzy #~ msgid "Flash fired, compulsatory flash mode" -#~ msgstr "El flash disparó, modo compulsivo del flash." +#~ msgstr "Flash disparado, modo compulsivo del flash." #, fuzzy #~ msgid "Flash did not fire, compulsatory flash mode."
0
15b0cf42ad8d940a0d49beb255d9c742aca8e77e
Exiv2
exiv2
New TIFF parser: Simplified Makernote design.
commit 15b0cf42ad8d940a0d49beb255d9c742aca8e77e Author: Andreas Huggel <[email protected]> Date: Sat Apr 29 10:10:53 2006 +0000 New TIFF parser: Simplified Makernote design. diff --git a/src/Makefile b/src/Makefile index 6ded735c6..3aadbe7b3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,14 +55,12 @@ CCHDR = exv_conf.h \ # Add library C++ source files to this list CCSRC = basicio.cpp \ canonmn.cpp \ - canonmn2.cpp \ crwimage.cpp \ datasets.cpp \ error.cpp \ exif.cpp \ futils.cpp \ fujimn.cpp \ - fujimn2.cpp \ ifd.cpp \ image.cpp \ imgreg.cpp \ @@ -71,17 +69,11 @@ CCSRC = basicio.cpp \ makernote.cpp \ makernote2.cpp \ metadatum.cpp \ - mnreg.cpp \ nikonmn.cpp \ - nikonmn2.cpp \ olympusmn.cpp \ - olympusmn2.cpp \ panasonicmn.cpp \ - panasonicmn2.cpp \ sigmamn.cpp \ - sigmamn2.cpp \ sonymn.cpp \ - sonymn2.cpp \ tags.cpp \ tiffcomposite.cpp \ tiffimage.cpp \ diff --git a/src/canonmn2.cpp b/src/canonmn2.cpp deleted file mode 100644 index d1b5acf86..000000000 --- a/src/canonmn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: canonmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "canonmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const TiffStructure TiffCanonCreator::tiffStructure_[] = { - // ext. tag group create function new group - //--------- -------------- ------------------- -------------- - { 0x0001, Group::canonmn, newTiffArrayEntry, Group::canoncs }, - { 0x0004, Group::canonmn, newTiffArrayEntry, Group::canonsi }, - { 0x000f, Group::canonmn, newTiffArrayEntry, Group::canoncf }, - { Tag::all, Group::canoncs, newTiffArrayElement, Group::canoncs }, - { Tag::all, Group::canonsi, newTiffArrayElement, Group::canonsi }, - { Tag::all, Group::canoncf, newTiffArrayElement, Group::canoncf } - }; - - TiffComponent::AutoPtr TiffCanonCreator::create(uint32_t extendedTag, - uint16_t group) - { - TiffComponent::AutoPtr tc(0); - uint16_t tag = static_cast<uint16_t>(extendedTag & 0xffff); - const TiffStructure* ts = find(tiffStructure_, - TiffStructure::Key(extendedTag, group)); - if (ts && ts->newTiffCompFct_) { - tc = ts->newTiffCompFct_(tag, ts); - } - if (!ts && extendedTag != Tag::next) { - tc = TiffComponent::AutoPtr(new TiffEntry(tag, group)); - } - return tc; - } // TiffCanonCreator::create - - TiffRwState::AutoPtr TiffCanonMn::doGetState(uint32_t /*mnOffset*/, - ByteOrder byteOrder) const - { - // Byteorder: No change - // Offsets : No change (relative to the start of the TIFF header) - // Creator : Canon TIFF component factory - return TiffRwState::AutoPtr( - new TiffRwState(byteOrder, 0, TiffCanonCreator::create)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newCanonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffCanonMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/canonmn2.hpp b/src/canonmn2.hpp deleted file mode 100644 index 3879d0b46..000000000 --- a/src/canonmn2.hpp +++ /dev/null @@ -1,109 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file canonmn2.hpp - @brief TIFF Canon makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 18-Apr-06, ahu: created - */ -#ifndef CANONMN2_HPP_ -#define CANONMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t canonmn = 259; //!< Canon makernote - const uint16_t canoncs = 260; //!< Canon camera settings - const uint16_t canonsi = 261; //!< Canon shot info - const uint16_t canoncf = 262; //!< Canon customer functions - } - - /*! - @brief Canon Makernote - */ - class TiffCanonMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffCanonMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffCanonMn() {} - //@} - private: - //! @name Accessors - //@{ - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - }; // class TiffCanonMn - - /*! - @brief TIFF component factory for Canon TIFF components. - */ - class TiffCanonCreator { - public: - /*! - @brief Create the TiffComponent for TIFF entry \em extendedTag and - \em group based on the embedded lookup table. - - If a tag and group combination is not found in the table, a TiffEntry - is created. If the pointer that is returned is 0, then the TIFF entry - should be ignored. - */ - static TiffComponent::AutoPtr create(uint32_t extendedTag, - uint16_t group); - - private: - static const TiffStructure tiffStructure_[]; //<! TIFF structure - }; // class TiffCanonCreator - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Canon makernote - TiffComponent* newCanonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef CANONMN2_HPP_ diff --git a/src/fujimn2.cpp b/src/fujimn2.cpp deleted file mode 100644 index 0b795bb1b..000000000 --- a/src/fujimn2.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: fujimn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 15-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "fujimn2.hpp" -#include "tiffcomposite.hpp" -#include "tiffparser.hpp" -#include "types.hpp" - -// + standard includes -#include <cstring> -#include <cassert> - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte FujiMnHeader::signature_[] = { - 'F', 'U', 'J', 'I', 'F', 'I', 'L', 'M', 0x0c, 0x00, 0x00, 0x00 - }; - const uint32_t FujiMnHeader::size_ = 12; - const ByteOrder FujiMnHeader::byteOrder_ = littleEndian; - - FujiMnHeader::FujiMnHeader() - { - read(signature_, size_, byteOrder_); - } - - bool FujiMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - - header_.alloc(size_); - memcpy(header_.pData_, pData, header_.size_); - - // Read offset to the IFD relative to the start of the makernote - // from the header. Note that we ignore the byteOrder argument - start_ = getUShort(header_.pData_ + 8, byteOrder_); - - if ( static_cast<uint32_t>(header_.size_) < size_ - || 0 != memcmp(header_.pData_, signature_, 8)) { - return false; - } - return true; - } // FujiMnHeader::read - - bool TiffFujiMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffFujiMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - TiffRwState::AutoPtr TiffFujiMn::doGetState(uint32_t mnOffset, - ByteOrder /*byteOrder*/) const - { - // Byteorder: from the header (little endian) - // Offsets : relative to the start of the makernote - // Creator : no change - return TiffRwState::AutoPtr( - new TiffRwState(header_.byteOrder(), mnOffset, 0)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newFujiMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffFujiMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/fujimn2.hpp b/src/fujimn2.hpp deleted file mode 100644 index d4ccd8f6f..000000000 --- a/src/fujimn2.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file fujimn2.hpp - @brief TIFF Fujifilm makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 15-Apr-06, ahu: created - */ -#ifndef FUJIMN2_HPP_ -#define FUJIMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t fujimn = 258; //!< Fujifilm makernote - } - - //! Header of a Fujifilm Makernote - class FujiMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - FujiMnHeader(); - //! Virtual destructor. - virtual ~FujiMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return header_.size_; } - virtual uint32_t ifdOffset() const { return start_; } - //! Return the byte order for the header - ByteOrder byteOrder() const { return byteOrder_; } - //@} - - private: - DataBuf header_; //!< Data buffer for the makernote header - static const byte signature_[]; //!< Fujifilm makernote header signature - static const uint32_t size_; //!< Size of the signature - static const ByteOrder byteOrder_; //!< Byteorder for makernote (II) - uint32_t start_; //!< Start of the mn IFD rel. to mn start - - }; // class FujiMnHeader - - /*! - @brief Fujifilm Makernote - */ - class TiffFujiMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffFujiMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffFujiMn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - private: - // DATA - FujiMnHeader header_; //!< Makernote header - - }; // TiffFujiMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Fujifilm makernote - TiffComponent* newFujiMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef FUJIMN2_HPP_ diff --git a/src/makernote2.cpp b/src/makernote2.cpp index e8d9e9118..aae68b985 100644 --- a/src/makernote2.cpp +++ b/src/makernote2.cpp @@ -39,6 +39,7 @@ EXIV2_RCSID("@(#) $Id$"); #include "makernote2.hpp" #include "tiffcomposite.hpp" #include "tiffvisitor.hpp" +#include "tiffimage.hpp" // + standard includes #include <string> @@ -47,38 +48,70 @@ EXIV2_RCSID("@(#) $Id$"); // class member definitions namespace Exiv2 { + const TiffMnRegistry TiffMnCreator::registry_[] = { + { "Canon", newCanonMn, Group::canonmn }, + { "FOVEON", newSigmaMn, Group::sigmamn }, + { "FUJIFILM", newFujiMn, Group::fujimn }, + { "NIKON", newNikonMn, Group::nikonmn }, + { "OLYMPUS", newOlympusMn, Group::olympmn }, + { "Panasonic", newPanasonicMn, Group::panamn }, + { "SIGMA", newSigmaMn, Group::sigmamn }, + { "SONY", newSonyMn, Group::sonymn } + }; + bool TiffMnRegistry::operator==(const TiffMnRegistry::Key& key) const { std::string make(make_); return make == key.make_.substr(0, make.length()); } + TiffComponent* TiffMnCreator::create(uint16_t tag, + uint16_t group, + const std::string& make, + const byte* pData, + uint32_t size, + ByteOrder byteOrder) + { + TiffComponent* tc = 0; + const TiffMnRegistry* tmr = find(registry_, TiffMnRegistry::Key(make)); + if (tmr) tc = tmr->newMnFct_(tag, + group, + tmr->mnGroup_, + pData, + size, + byteOrder); + return tc; + } // TiffMnCreator::create + TiffIfdMakernote::~TiffIfdMakernote() { + delete pHeader_; } - bool TiffIfdMakernote::readHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) + uint32_t TiffIfdMakernote::ifdOffset() const { - return doReadHeader(pData, size, byteOrder); + if (!pHeader_) return 0; + return pHeader_->ifdOffset(); } - uint32_t TiffIfdMakernote::ifdOffset() const + ByteOrder TiffIfdMakernote::byteOrder () const { - return doIfdOffset(); + if (!pHeader_) return invalidByteOrder; + return pHeader_->byteOrder(); } - TiffRwState::AutoPtr TiffIfdMakernote::getState(uint32_t mnOffset, - ByteOrder byteOrder) const + uint32_t TiffIfdMakernote::baseOffset(uint32_t mnOffset) const { - return doGetState(mnOffset, byteOrder); + if (!pHeader_) return 0; + return pHeader_->baseOffset(mnOffset); } - TiffRwState::AutoPtr TiffIfdMakernote::doGetState(uint32_t /*mnOffset*/, - ByteOrder /*byteOrder*/) const + bool TiffIfdMakernote::readHeader(const byte* pData, + uint32_t size, + ByteOrder byteOrder) { - return TiffRwState::AutoPtr(0); + if (!pHeader_) return true; + return pHeader_->read(pData, size, byteOrder); } void TiffIfdMakernote::doAddChild(TiffComponent::AutoPtr tiffComponent) @@ -98,4 +131,285 @@ namespace Exiv2 { if (visitor.go()) visitor.visitIfdMakernoteEnd(this); } + const byte OlympusMnHeader::signature_[] = { + 'O', 'L', 'Y', 'M', 'P', 0x00, 0x01, 0x00 + }; + const uint32_t OlympusMnHeader::size_ = 8; + + OlympusMnHeader::OlympusMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool OlympusMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + + header_.alloc(size_); + memcpy(header_.pData_, pData, header_.size_); + if ( static_cast<uint32_t>(header_.size_) < size_ + || 0 != memcmp(header_.pData_, signature_, 5)) { + return false; + } + return true; + } // OlympusMnHeader::read + + const byte FujiMnHeader::signature_[] = { + 'F', 'U', 'J', 'I', 'F', 'I', 'L', 'M', 0x0c, 0x00, 0x00, 0x00 + }; + const uint32_t FujiMnHeader::size_ = 12; + const ByteOrder FujiMnHeader::byteOrder_ = littleEndian; + + FujiMnHeader::FujiMnHeader() + { + read(signature_, size_, byteOrder_); + } + + bool FujiMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + + header_.alloc(size_); + memcpy(header_.pData_, pData, header_.size_); + + // Read offset to the IFD relative to the start of the makernote + // from the header. Note that we ignore the byteOrder argument + start_ = getUShort(header_.pData_ + 8, byteOrder_); + + if ( static_cast<uint32_t>(header_.size_) < size_ + || 0 != memcmp(header_.pData_, signature_, 8)) { + return false; + } + return true; + } // FujiMnHeader::read + + + const byte Nikon2MnHeader::signature_[] = { + 'N', 'i', 'k', 'o', 'n', '\0', 0x00, 0x01 + }; + const uint32_t Nikon2MnHeader::size_ = 8; + + Nikon2MnHeader::Nikon2MnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool Nikon2MnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 6)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // Nikon2MnHeader::read + + const byte Nikon3MnHeader::signature_[] = { + 'N', 'i', 'k', 'o', 'n', '\0', + 0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08 + }; + const uint32_t Nikon3MnHeader::size_ = 18; + + Nikon3MnHeader::Nikon3MnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool Nikon3MnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 6)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + TiffHeade2 th; + if (!th.read(buf_.pData_ + 10, 8)) return false; + byteOrder_ = th.byteOrder(); + start_ = 10 + th.ifdOffset(); + return true; + + } // Nikon3MnHeader::read + + const byte PanasonicMnHeader::signature_[] = { + 'P', 'a', 'n', 'a', 's', 'o', 'n', 'i', 'c', 0x00, 0x00, 0x00 + }; + const uint32_t PanasonicMnHeader::size_ = 12; + + PanasonicMnHeader::PanasonicMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool PanasonicMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, 9)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // PanasonicMnHeader::read + + const byte SigmaMnHeader::signature1_[] = { + 'S', 'I', 'G', 'M', 'A', '\0', '\0', '\0', 0x01, 0x00 + }; + const byte SigmaMnHeader::signature2_[] = { + 'F', 'O', 'V', 'E', 'O', 'N', '\0', '\0', 0x01, 0x00 + }; + const uint32_t SigmaMnHeader::size_ = 10; + + SigmaMnHeader::SigmaMnHeader() + { + read(signature1_, size_, invalidByteOrder); + } + + bool SigmaMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if ( 0 != memcmp(pData, signature1_, 8) + && 0 != memcmp(pData, signature2_, 8)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // SigmaMnHeader::read + + const byte SonyMnHeader::signature_[] = { + 'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0' + }; + const uint32_t SonyMnHeader::size_ = 12; + + SonyMnHeader::SonyMnHeader() + { + read(signature_, size_, invalidByteOrder); + } + + bool SonyMnHeader::read(const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + assert (pData != 0); + + if (size < size_) return false; + if (0 != memcmp(pData, signature_, size_)) return false; + buf_.alloc(size_); + memcpy(buf_.pData_, pData, buf_.size_); + start_ = size_; + return true; + + } // SonyMnHeader::read + + // ************************************************************************* + // free functions + + TiffComponent* newCanonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, 0); + } + + TiffComponent* newOlympusMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new OlympusMnHeader); + } + + TiffComponent* newFujiMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new FujiMnHeader); + } + + TiffComponent* newNikonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder /*byteOrder*/) + { + // If there is no "Nikon" string it must be Nikon1 format + if (size < 6 || std::string(reinterpret_cast<const char*>(pData), 6) + != std::string("Nikon\0", 6)) { + return new TiffIfdMakernote(tag, group, Group::nikon1mn, 0); + } + // If the "Nikon" string is not followed by a TIFF header, we assume + // Nikon2 format + TiffHeade2 tiffHeader; + if ( size < 18 + || !tiffHeader.read(pData + 10, size - 10) + || tiffHeader.tag() != 0x002a) { + return new TiffIfdMakernote(tag, group, Group::nikon2mn, new Nikon2MnHeader); + } + // Else we have a Nikon3 makernote + return new TiffIfdMakernote(tag, group, Group::nikon3mn, new Nikon3MnHeader); + } + + TiffComponent* newPanasonicMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new PanasonicMnHeader, false); + } + + TiffComponent* newSigmaMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new SigmaMnHeader); + } + + TiffComponent* newSonyMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* /*pData*/, + uint32_t /*size*/, + ByteOrder /*byteOrder*/) + { + return new TiffIfdMakernote(tag, group, mnGroup, new SonyMnHeader); + } + } // namespace Exiv2 diff --git a/src/makernote2.hpp b/src/makernote2.hpp index 8b788b9ef..e51d53b3d 100644 --- a/src/makernote2.hpp +++ b/src/makernote2.hpp @@ -20,7 +20,7 @@ */ /*! @file makernote2.hpp - @brief Makernote base classes, factory and registry + @brief Makernote related classes @version $Rev$ @author Andreas Huggel (ahu) <a href="mailto:[email protected]">[email protected]</a> @@ -42,6 +42,23 @@ // namespace extensions namespace Exiv2 { + namespace Group { + const uint16_t olympmn = 257; //!< Olympus makernote + const uint16_t fujimn = 258; //!< Fujifilm makernote + const uint16_t canonmn = 259; //!< Canon makernote + const uint16_t canoncs = 260; //!< Canon camera settings + const uint16_t canonsi = 261; //!< Canon shot info + const uint16_t canoncf = 262; //!< Canon customer functions + const uint16_t nikonmn = 263; //!< Any Nikon makernote (pseudo group) + const uint16_t nikon1mn = 264; //!< Nikon1 makernote + const uint16_t nikon2mn = 265; //!< Nikon2 makernote + const uint16_t nikon3mn = 266; //!< Nikon3 makernote + const uint16_t panamn = 267; //!< Panasonic makernote + const uint16_t sigmamn = 268; //!< Sigma makernote + const uint16_t sonymn = 269; //!< Sony makernote + + } + // ***************************************************************************** // class definitions @@ -119,25 +136,43 @@ namespace Exiv2 { //! Read the header from a data buffer, return true if ok virtual bool read(const byte* pData, uint32_t size, - ByteOrder byteOrder) =0; + ByteOrder byteOrder) =0; //@} //! @name Accessors //@{ - //! Size of the header + //! Return the size of the header (in bytes). virtual uint32_t size() const =0; /*! - @brief Start of the makernote directory relative to the start of the - header. + @brief Return the offset to the start of the Makernote IFD from + the start of the Makernote (= the start of the header). + */ + virtual uint32_t ifdOffset() const { return 0; } + /*! + @brief Return the byte order for the makernote. If the return value is + invalidByteOrder, this means that the byte order of the the + image should be used for the makernote. + */ + virtual ByteOrder byteOrder() const { return invalidByteOrder; } + /*! + @brief Return the base offset for the makernote IFD entries relative + to the start of the TIFF header. + + @param mnOffset Offset to the makernote from the start of the + TIFF header. */ - virtual uint32_t ifdOffset() const =0; + virtual uint32_t baseOffset(uint32_t mnOffset) const { return 0; } //@} }; // class MnHeader /*! - @brief Tiff IFD Makernote. Defines the interface for all IFD makernotes. - Contains an IFD and implements child mgmt functions to deal with - the IFD entries. + @brief Tiff IFD Makernote. This is a concrete class suitable for all + IFD makernotes. + + Contains a makernote header (which can be 0) and an IFD and + implements child mgmt functions to deal with the IFD entries. The + various makernote weirdnesses are taken care of in the makernote + header. */ class TiffIfdMakernote : public TiffComponent { friend class TiffReader; @@ -145,18 +180,25 @@ namespace Exiv2 { //! @name Creators //@{ //! Default constructor - TiffIfdMakernote(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - bool hasNext =true) - : TiffComponent(tag, group), ifd_(tag, mnGroup, hasNext) {} + TiffIfdMakernote(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + MnHeader* pHeader, + bool hasNext =true) + : TiffComponent(tag, group), + pHeader_(pHeader), + ifd_(tag, mnGroup, hasNext) {} //! Virtual destructor - virtual ~TiffIfdMakernote() =0; + virtual ~TiffIfdMakernote(); //@} //! @name Manipulators //@{ - //! Read the header from a data buffer, return true if successful + /*! + @brief Read the header from a data buffer, return true if successful. + + The default implementation simply returns true. + */ bool readHeader(const byte* pData, uint32_t size, ByteOrder byteOrder); //@} @@ -167,21 +209,21 @@ namespace Exiv2 { the start of the Makernote. */ uint32_t ifdOffset() const; + /*! + @brief Return the byte order for the makernote. Default (if there is + no header) is invalidByteOrder. This means that the byte order + of the the image should be used for the makernote. + */ + ByteOrder byteOrder() const; /*! - @brief Get status information relevant for the makernote. - - State includes byte order, offset and TIFF component factory. - This method allows the TiffReader to change state, i.e., change - these parameters, to parse the Makernote and its sub components - (if any). + @brief Return the base offset for the makernote IFD entries relative + to the start of the TIFF header. The default, if there is no + header, is 0. @param mnOffset Offset to the makernote from the start of the TIFF header. - @param byteOrder Byte order in use at the point where the function - is called. */ - TiffRwState::AutoPtr getState(uint32_t mnOffset, - ByteOrder byteOrder) const; + uint32_t baseOffset (uint32_t mnOffset) const; //@} protected: @@ -190,43 +232,292 @@ namespace Exiv2 { virtual void doAddChild(TiffComponent::AutoPtr tiffComponent); virtual void doAddNext(TiffComponent::AutoPtr tiffComponent); virtual void doAccept(TiffVisitor& visitor); - /*! - @brief Implements readHeader(). + //@} - The default implementation simply returns true. Derived classes for - makernotes which have a header should overwrite this. - */ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) { return true; } + private: + // DATA + MnHeader* pHeader_; //!< Makernote header + TiffDirectory ifd_; //!< Makernote IFD + + }; // class TiffIfdMakernote + + //! Header of an Olympus Makernote + class OlympusMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + OlympusMnHeader(); + //! Virtual destructor. + virtual ~OlympusMnHeader() {} //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return header_.size_; } + virtual uint32_t ifdOffset() const { return size_; } + //@} + + private: + DataBuf header_; //!< Data buffer for the makernote header + static const byte signature_[]; //!< Olympus makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class OlympusMnHeader + //! Header of a Fujifilm Makernote + class FujiMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + FujiMnHeader(); + //! Virtual destructor. + virtual ~FujiMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} //! @name Accessors //@{ - /*! - @brief Implements ifdOffset(). + virtual uint32_t size() const { return header_.size_; } + virtual uint32_t ifdOffset() const { return start_; } + virtual ByteOrder byteOrder() const { return byteOrder_; } + virtual uint32_t baseOffset(uint32_t mnOffset) const { return mnOffset; } + //@} - Default implementation returns 0. Derived classes for makernotes - with an IFD which doesn't start at the beginning of the buffer - should overwrite this. - */ - virtual uint32_t doIfdOffset() const { return 0; } - /*! - @brief Implements getState(). - - Default implementation returns a 0-pointer. Derived classes for - makernotes which need a different byte order, base offset or - TIFF component factory should overwrite this. - */ - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; + private: + DataBuf header_; //!< Data buffer for the makernote header + static const byte signature_[]; //!< Fujifilm makernote header signature + static const uint32_t size_; //!< Size of the signature + static const ByteOrder byteOrder_; //!< Byteorder for makernote (II) + uint32_t start_; //!< Start of the mn IFD rel. to mn start + + }; // class FujiMnHeader + + //! Header of a Nikon 2 Makernote + class Nikon2MnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + Nikon2MnHeader(); + //! Virtual destructor. + virtual ~Nikon2MnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } //@} private: - // DATA - TiffDirectory ifd_; //!< Makernote IFD - - }; // class TiffIfdMakernote + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Nikon 2 makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class Nikon2MnHeader + + //! Header of a Nikon 3 Makernote + class Nikon3MnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + Nikon3MnHeader(); + //! Virtual destructor. + virtual ~Nikon3MnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + virtual ByteOrder byteOrder() const { return byteOrder_; } + virtual uint32_t baseOffset(uint32_t mnOffset) const { return mnOffset + 10; } + //@} + + private: + DataBuf buf_; //!< Raw header data + ByteOrder byteOrder_; //!< Byteorder for makernote + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Nikon 3 makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class Nikon3MnHeader + + //! Header of a Panasonic Makernote + class PanasonicMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + PanasonicMnHeader(); + //! Virtual destructor. + virtual ~PanasonicMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Panasonic makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class PanasonicMnHeader + + //! Header of a Sigma Makernote + class SigmaMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + SigmaMnHeader(); + //! Virtual destructor. + virtual ~SigmaMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature1_[]; //!< Sigma makernote header signature 1 + static const byte signature2_[]; //!< Sigma makernote header signature 2 + static const uint32_t size_; //!< Size of the signature + + }; // class SigmaMnHeader + + //! Header of a Sony Makernote + class SonyMnHeader : public MnHeader { + public: + //! @name Creators + //@{ + //! Default constructor + SonyMnHeader(); + //! Virtual destructor. + virtual ~SonyMnHeader() {} + //@} + //! @name Manipulators + //@{ + virtual bool read(const byte* pData, + uint32_t size, + ByteOrder byteOrder); + //@} + //! @name Accessors + //@{ + virtual uint32_t size() const { return size_; } + virtual uint32_t ifdOffset() const { return start_; } + //@} + + private: + DataBuf buf_; //!< Raw header data + uint32_t start_; //!< Start of the mn IFD rel. to mn start + static const byte signature_[]; //!< Sony makernote header signature + static const uint32_t size_; //!< Size of the signature + + }; // class SonyMnHeader + +// ***************************************************************************** +// template, inline and free functions + + //! Function to create a Canon makernote + TiffComponent* newCanonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create an Olympus makernote + TiffComponent* newOlympusMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Fujifilm makernote + TiffComponent* newFujiMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + /*! + @brief Function to create a Nikon makernote. This will create the + appropriate Nikon 1, 2 or 3 makernote, based on the arguments. + */ + TiffComponent* newNikonMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Panasonic makernote + TiffComponent* newPanasonicMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Sigma makernote + TiffComponent* newSigmaMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); + + //! Function to create a Sony makernote + TiffComponent* newSonyMn(uint16_t tag, + uint16_t group, + uint16_t mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); } // namespace Exiv2 diff --git a/src/mnreg.cpp b/src/mnreg.cpp deleted file mode 100644 index 0cf997d45..000000000 --- a/src/mnreg.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2005, 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: mnreg.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 15-Apr-06, ahu: created - - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "canonmn2.hpp" -#include "fujimn2.hpp" -#include "nikonmn2.hpp" -#include "olympusmn2.hpp" -#include "panasonicmn2.hpp" -#include "sigmamn2.hpp" -#include "sonymn2.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const TiffMnRegistry TiffMnCreator::registry_[] = { - { "Canon", newCanonMn, Group::canonmn }, - { "FOVEON", newSigmaMn, Group::sigmamn }, - { "FUJIFILM", newFujiMn, Group::fujimn }, - { "NIKON", newNikonMn, Group::nikonmn }, - { "OLYMPUS", newOlympusMn, Group::olympmn }, - { "Panasonic", newPanasonicMn, Group::panamn }, - { "SIGMA", newSigmaMn, Group::sigmamn }, - { "SONY", newSonyMn, Group::sonymn } - }; - - - // The find template needs to see the array from where it is called - TiffComponent* TiffMnCreator::create(uint16_t tag, - uint16_t group, - const std::string& make, - const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - TiffComponent* tc = 0; - const TiffMnRegistry* tmr = find(registry_, TiffMnRegistry::Key(make)); - if (tmr) tc = tmr->newMnFct_(tag, - group, - tmr->mnGroup_, - pData, - size, - byteOrder); - return tc; - } // TiffMnCreator::create - -} // namespace Exiv2 diff --git a/src/nikonmn2.cpp b/src/nikonmn2.cpp deleted file mode 100644 index fa8955ce8..000000000 --- a/src/nikonmn2.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: nikonmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "nikonmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte Nikon2MnHeader::signature_[] = { - 'N', 'i', 'k', 'o', 'n', '\0', 0x00, 0x01 - }; - const uint32_t Nikon2MnHeader::size_ = 8; - - Nikon2MnHeader::Nikon2MnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool Nikon2MnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 6)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // Nikon2MnHeader::read - - bool TiffNikon2Mn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffNikon2Mn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - const byte Nikon3MnHeader::signature_[] = { - 'N', 'i', 'k', 'o', 'n', '\0', - 0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08 - }; - const uint32_t Nikon3MnHeader::size_ = 18; - - Nikon3MnHeader::Nikon3MnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool Nikon3MnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 6)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - TiffHeade2 th; - if (!th.read(buf_.pData_ + 10, 8)) return false; - byteOrder_ = th.byteOrder(); - start_ = 10 + th.ifdOffset(); - return true; - - } // Nikon3MnHeader::read - - bool TiffNikon3Mn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffNikon3Mn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - TiffRwState::AutoPtr TiffNikon3Mn::doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const - { - // Byteorder: From header - // Offsets : From header - // Creator : No change - return TiffRwState::AutoPtr( - new TiffRwState(header_.byteOrder(), - mnOffset + header_.baseOffset(), - 0)); - } - - // ************************************************************************* - // free functions - - TiffComponent* newNikonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - // If there is no "Nikon" string it must be Nikon1 format - if (size < 6 || std::string(reinterpret_cast<const char*>(pData), 6) - != std::string("Nikon\0", 6)) { - return new TiffNikon1Mn(tag, group, Group::nikon1mn); - } - // If the "Nikon" string is not followed by a TIFF header, we assume - // Nikon2 format - TiffHeade2 tiffHeader; - if ( size < 18 - || !tiffHeader.read(pData + 10, size - 10) - || tiffHeader.tag() != 0x002a) { - return new TiffNikon2Mn(tag, group, Group::nikon2mn); - } - // Else we have a Nikon3 makernote - return new TiffNikon3Mn(tag, group, Group::nikon3mn); - } - -} // namespace Exiv2 diff --git a/src/nikonmn2.hpp b/src/nikonmn2.hpp deleted file mode 100644 index 5f227c761..000000000 --- a/src/nikonmn2.hpp +++ /dev/null @@ -1,221 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file nikonmn2.hpp - @brief TIFF Nikon makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 18-Apr-06, ahu: created - */ -#ifndef NIKONMN2_HPP_ -#define NIKONMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" -#include "tiffimage.hpp" // for TiffHeade2 - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t nikonmn = 263; //!< Any Nikon makernote - const uint16_t nikon1mn = 264; //!< Nikon1 makernote - const uint16_t nikon2mn = 265; //!< Nikon2 makernote - const uint16_t nikon3mn = 266; //!< Nikon3 makernote - } - - //! Nikon 1 Makernote - class TiffNikon1Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon1Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon1Mn() {} - //@} - - }; // class TiffNikon1Mn - - //! Header of a Nikon 2 Makernote - class Nikon2MnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - Nikon2MnHeader(); - //! Virtual destructor. - virtual ~Nikon2MnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Nikon 2 makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class Nikon2MnHeader - - /*! - @brief Nikon 2 Makernote - */ - class TiffNikon2Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon2Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon2Mn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - Nikon2MnHeader header_; //!< Makernote header - - }; // class TiffNikon2Mn - - //! Header of a Nikon 3 Makernote - class Nikon3MnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - Nikon3MnHeader(); - //! Virtual destructor. - virtual ~Nikon3MnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //! Return the byte order for the header - ByteOrder byteOrder() const { return byteOrder_; } - /*! - @brief Return the base offset for the makernote IFD entries relative - to the start of the makernote. - */ - uint32_t baseOffset() const { return 10; } - //@} - - private: - DataBuf buf_; //!< Raw header data - ByteOrder byteOrder_; //!< Byteorder for makernote - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Nikon 3 makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class Nikon3MnHeader - - /*! - @brief Nikon 3 Makernote - */ - class TiffNikon3Mn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffNikon3Mn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffNikon3Mn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - virtual TiffRwState::AutoPtr doGetState(uint32_t mnOffset, - ByteOrder byteOrder) const; - //@} - - private: - // DATA - Nikon3MnHeader header_; //!< Makernote header - - }; // class TiffNikon3Mn - -// ***************************************************************************** -// template, inline and free functions - - /*! - @brief Function to create a Nikon makernote. This will create the - appropriate Nikon 1, 2 or 3 makernote, based on the arguments. - */ - TiffComponent* newNikonMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef NIKONMN2_HPP_ diff --git a/src/olympusmn2.cpp b/src/olympusmn2.cpp deleted file mode 100644 index ad3178d97..000000000 --- a/src/olympusmn2.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: olympusmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 15-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "olympusmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes -#include <cstring> -#include <cassert> - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte OlympusMnHeader::signature_[] = { - 'O', 'L', 'Y', 'M', 'P', 0x00, 0x01, 0x00 - }; - const uint32_t OlympusMnHeader::size_ = 8; - - OlympusMnHeader::OlympusMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool OlympusMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - - header_.alloc(size_); - memcpy(header_.pData_, pData, header_.size_); - if ( static_cast<uint32_t>(header_.size_) < size_ - || 0 != memcmp(header_.pData_, signature_, 5)) { - return false; - } - return true; - } // OlympusMnHeader::read - - bool TiffOlympusMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffOlympusMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newOlympusMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffOlympusMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/olympusmn2.hpp b/src/olympusmn2.hpp deleted file mode 100644 index 68aba42a1..000000000 --- a/src/olympusmn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file olympusmn2.hpp - @brief TIFF Olympus makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 15-Apr-06, ahu: created - */ -#ifndef OLYMPUSMN2_HPP_ -#define OLYMPUSMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t olympmn = 257; //!< Olympus makernote - } - - //! Header of an Olympus Makernote - class OlympusMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - OlympusMnHeader(); - //! Virtual destructor. - virtual ~OlympusMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return header_.size_; } - virtual uint32_t ifdOffset() const { return size_; } - //@} - - private: - DataBuf header_; //!< Data buffer for the makernote header - static const byte signature_[]; //!< Olympus makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class OlympusMnHeader - - /*! - @brief Olympus Makernote - */ - class TiffOlympusMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor - TiffOlympusMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffOlympusMn() {} - //@} - - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - OlympusMnHeader header_; //!< Makernote header - - }; // TiffOlympusMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create an Olympus makernote - TiffComponent* newOlympusMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef OLYMPUSMN2_HPP_ diff --git a/src/panasonicmn2.cpp b/src/panasonicmn2.cpp deleted file mode 100644 index c512b7b9e..000000000 --- a/src/panasonicmn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: panasonicmn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "panasonicmn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte PanasonicMnHeader::signature_[] = { - 'P', 'a', 'n', 'a', 's', 'o', 'n', 'i', 'c', 0x00, 0x00, 0x00 - }; - const uint32_t PanasonicMnHeader::size_ = 12; - - PanasonicMnHeader::PanasonicMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool PanasonicMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, 9)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // PanasonicMnHeader::read - - bool TiffPanasonicMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffPanasonicMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newPanasonicMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffPanasonicMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/panasonicmn2.hpp b/src/panasonicmn2.hpp deleted file mode 100644 index d6676cf43..000000000 --- a/src/panasonicmn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file panasonicmn2.hpp - @brief TIFF Panasonic makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 18-Apr-06, ahu: created - */ -#ifndef PANASONICMN2_HPP_ -#define PANASONICMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t panamn = 267; //!< Panasonic makernote - } - - //! Header of a Panasonic Makernote - class PanasonicMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - PanasonicMnHeader(); - //! Virtual destructor. - virtual ~PanasonicMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Panasonic makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class PanasonicMnHeader - - /*! - @brief Panasonic Makernote - */ - class TiffPanasonicMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffPanasonicMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup, false) {} - //! Virtual destructor - virtual ~TiffPanasonicMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - PanasonicMnHeader header_; //!< Makernote header - - }; // class TiffPanasonicMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Panasonic makernote - TiffComponent* newPanasonicMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef PANASONICMN2_HPP_ diff --git a/src/sigmamn2.cpp b/src/sigmamn2.cpp deleted file mode 100644 index 5545f4cfb..000000000 --- a/src/sigmamn2.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: sigmamn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "sigmamn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte SigmaMnHeader::signature1_[] = { - 'S', 'I', 'G', 'M', 'A', '\0', '\0', '\0', 0x01, 0x00 - }; - const byte SigmaMnHeader::signature2_[] = { - 'F', 'O', 'V', 'E', 'O', 'N', '\0', '\0', 0x01, 0x00 - }; - const uint32_t SigmaMnHeader::size_ = 10; - - SigmaMnHeader::SigmaMnHeader() - { - read(signature1_, size_, invalidByteOrder); - } - - bool SigmaMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if ( 0 != memcmp(pData, signature1_, 8) - && 0 != memcmp(pData, signature2_, 8)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // SigmaMnHeader::read - - bool TiffSigmaMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffSigmaMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newSigmaMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffSigmaMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/sigmamn2.hpp b/src/sigmamn2.hpp deleted file mode 100644 index 4359536fc..000000000 --- a/src/sigmamn2.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file sigmamn2.hpp - @brief TIFF Sigma makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 18-Apr-06, ahu: created - */ -#ifndef SIGMAMN2_HPP_ -#define SIGMAMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t sigmamn = 268; //!< Sigma makernote - } - - //! Header of a Sigma Makernote - class SigmaMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - SigmaMnHeader(); - //! Virtual destructor. - virtual ~SigmaMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature1_[]; //!< Sigma makernote header signature 1 - static const byte signature2_[]; //!< Sigma makernote header signature 2 - static const uint32_t size_; //!< Size of the signature - - }; // class SigmaMnHeader - - /*! - @brief Sigma Makernote - */ - class TiffSigmaMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffSigmaMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffSigmaMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - SigmaMnHeader header_; //!< Makernote header - - }; // class TiffSigmaMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Sigma makernote - TiffComponent* newSigmaMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef SIGMAMN2_HPP_ diff --git a/src/sonymn2.cpp b/src/sonymn2.cpp deleted file mode 100644 index ecd794cf9..000000000 --- a/src/sonymn2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/* - File: sonymn2.cpp - Version: $Rev$ - Author(s): Andreas Huggel (ahu) <[email protected]> - History: 18-Apr-06, ahu: created - */ -// ***************************************************************************** -#include "rcsid.hpp" -EXIV2_RCSID("@(#) $Id$"); - -// ***************************************************************************** -// included header files -#ifdef _MSC_VER -# include "exv_msvc.h" -#else -# include "exv_conf.h" -#endif - -#include "sonymn2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// class member definitions -namespace Exiv2 { - - const byte SonyMnHeader::signature_[] = { - 'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0' - }; - const uint32_t SonyMnHeader::size_ = 12; - - SonyMnHeader::SonyMnHeader() - { - read(signature_, size_, invalidByteOrder); - } - - bool SonyMnHeader::read(const byte* pData, - uint32_t size, - ByteOrder /*byteOrder*/) - { - assert (pData != 0); - - if (size < size_) return false; - if (0 != memcmp(pData, signature_, size_)) return false; - buf_.alloc(size_); - memcpy(buf_.pData_, pData, buf_.size_); - start_ = size_; - return true; - - } // SonyMnHeader::read - - bool TiffSonyMn::doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder) - { - return header_.read(pData, size, byteOrder); - } - - uint32_t TiffSonyMn::doIfdOffset() const - { - return header_.ifdOffset(); - } - - // ************************************************************************* - // free functions - - TiffComponent* newSonyMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* /*pData*/, - uint32_t /*size*/, - ByteOrder /*byteOrder*/) - { - return new TiffSonyMn(tag, group, mnGroup); - } - -} // namespace Exiv2 diff --git a/src/sonymn2.hpp b/src/sonymn2.hpp deleted file mode 100644 index 6987ad27b..000000000 --- a/src/sonymn2.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2006 Andreas Huggel <[email protected]> - * - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -/*! - @file sonymn2.hpp - @brief TIFF Sony makernote - @version $Rev$ - @author Andreas Huggel (ahu) - <a href="mailto:[email protected]">[email protected]</a> - @date 18-Apr-06, ahu: created - */ -#ifndef SONYMN2_HPP_ -#define SONYMN2_HPP_ - -// ***************************************************************************** -// included header files -#include "makernote2.hpp" -#include "tiffcomposite.hpp" -#include "types.hpp" - -// + standard includes - -// ***************************************************************************** -// namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class definitions - - namespace Group { - const uint16_t sonymn = 269; //!< Sony makernote - } - - //! Header of a Sony Makernote - class SonyMnHeader : public MnHeader { - public: - //! @name Creators - //@{ - //! Default constructor - SonyMnHeader(); - //! Virtual destructor. - virtual ~SonyMnHeader() {} - //@} - //! @name Manipulators - //@{ - virtual bool read(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - //! @name Accessors - //@{ - virtual uint32_t size() const { return size_; } - virtual uint32_t ifdOffset() const { return start_; } - //@} - - private: - DataBuf buf_; //!< Raw header data - uint32_t start_; //!< Start of the mn IFD rel. to mn start - static const byte signature_[]; //!< Sony makernote header signature - static const uint32_t size_; //!< Size of the signature - - }; // class SonyMnHeader - - /*! - @brief Sony Makernote - */ - class TiffSonyMn : public TiffIfdMakernote { - public: - //! @name Creators - //@{ - //! Default constructor. - TiffSonyMn(uint16_t tag, uint16_t group, uint16_t mnGroup) - : TiffIfdMakernote(tag, group, mnGroup) {} - //! Virtual destructor - virtual ~TiffSonyMn() {} - //@} - private: - //! @name Manipulators - //@{ - virtual bool doReadHeader(const byte* pData, - uint32_t size, - ByteOrder byteOrder); - //@} - - //! @name Accessors - //@{ - virtual uint32_t doIfdOffset() const; - //@} - - private: - // DATA - SonyMnHeader header_; //!< Makernote header - - }; // class TiffSonyMn - -// ***************************************************************************** -// template, inline and free functions - - //! Function to create a Sony makernote - TiffComponent* newSonyMn(uint16_t tag, - uint16_t group, - uint16_t mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); - -} // namespace Exiv2 - -#endif // #ifndef SONYMN2_HPP_ diff --git a/src/tiffparser.cpp b/src/tiffparser.cpp index a4cec6970..ba7a3d4dd 100644 --- a/src/tiffparser.cpp +++ b/src/tiffparser.cpp @@ -39,6 +39,7 @@ EXIV2_RCSID("@(#) $Id$"); #include "tiffparser.hpp" #include "tiffcomposite.hpp" +#include "makernote2.hpp" #include "tiffvisitor.hpp" #include "tiffimage.hpp" #include "error.hpp" @@ -62,6 +63,10 @@ EXIV2_RCSID("@(#) $Id$"); + Is it easier (for writing) to combine all creation tables into one? + CR2 Makernotes don't seem to have a next pointer but Canon Jpeg Makernotes do. What a mess. (That'll become an issue when it comes to writing to CR2) + + Sony makernotes in RAW files do not seem to have header like those in Jpegs. + And maybe no next pointer either. + + Filtering of large unknown tags: Should be moved to writing/encoding code + and done only if really needed (i.e., if writing to a Jpeg segment) in crwimage.* : @@ -87,19 +92,26 @@ namespace Exiv2 { new component is. */ const TiffStructure TiffCreator::tiffStructure_[] = { - // ext. tag group create function new group - //--------- ----------- ---------------- ----------- - { Tag::root, Group::none, newTiffDirectory, Group::ifd0 }, - { 0x8769, Group::ifd0, newTiffSubIfd, Group::exif }, - { 0x8825, Group::ifd0, newTiffSubIfd, Group::gps }, - { 0x014a, Group::ifd0, newTiffSubIfd, Group::ignr }, - { 0xa005, Group::exif, newTiffSubIfd, Group::iop }, - { 0x927c, Group::exif, newTiffMnEntry, Group::mn }, - { 0x0201, Group::ifd1, newTiffThumbData, Group::ifd1 }, - { 0x0202, Group::ifd1, newTiffThumbSize, Group::ifd1 }, - { Tag::next, Group::ifd0, newTiffDirectory, Group::ifd1 }, - { Tag::next, Group::ifd1, newTiffDirectory, Group::ignr }, - { Tag::next, Group::ignr, newTiffDirectory, Group::ignr } + // ext. tag group create function new group + //--------- -------------- ------------------- -------------- + { Tag::root, Group::none, newTiffDirectory, Group::ifd0 }, + { 0x8769, Group::ifd0, newTiffSubIfd, Group::exif }, + { 0x8825, Group::ifd0, newTiffSubIfd, Group::gps }, + { 0x014a, Group::ifd0, newTiffSubIfd, Group::ignr }, // todo: better support + { 0xa005, Group::exif, newTiffSubIfd, Group::iop }, + { 0x927c, Group::exif, newTiffMnEntry, Group::mn }, + { 0x0201, Group::ifd1, newTiffThumbData, Group::ifd1 }, + { 0x0202, Group::ifd1, newTiffThumbSize, Group::ifd1 }, + { Tag::next, Group::ifd0, newTiffDirectory, Group::ifd1 }, + { Tag::next, Group::ifd1, newTiffDirectory, Group::ignr }, + { Tag::next, Group::ignr, newTiffDirectory, Group::ignr }, + // Canon makernote structure + { 0x0001, Group::canonmn, newTiffArrayEntry, Group::canoncs }, + { 0x0004, Group::canonmn, newTiffArrayEntry, Group::canonsi }, + { 0x000f, Group::canonmn, newTiffArrayEntry, Group::canoncf }, + { Tag::all, Group::canoncs, newTiffArrayElement, Group::canoncs }, + { Tag::all, Group::canonsi, newTiffArrayElement, Group::canonsi }, + { Tag::all, Group::canoncf, newTiffArrayElement, Group::canoncf } }; TiffComponent::AutoPtr TiffCreator::create(uint32_t extendedTag, diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp index 5e444dd2c..08343455b 100644 --- a/src/tiffvisitor.cpp +++ b/src/tiffvisitor.cpp @@ -284,7 +284,7 @@ namespace Exiv2 { void TiffPrinter::visitIfdMakernote(TiffIfdMakernote* object) { - os_ << prefix() << "Todo: Print IFD makernote header\n"; + // Nothing to do } // TiffPrinter::visitIfdMakernote void TiffPrinter::printTiffEntry(TiffEntryBase* object, @@ -359,6 +359,8 @@ namespace Exiv2 { if (pOrigState_ != pState_) delete pState_; // 0 for create function indicates 'no change' if (state->createFct_ == 0) state->createFct_ = pState_->createFct_; + // invalidByteOrder indicates 'no change' + if (state->byteOrder_ == invalidByteOrder) state->byteOrder_ = pState_->byteOrder_; pState_ = state.release(); } } @@ -589,10 +591,11 @@ namespace Exiv2 { setGo(false); return; } - // Modify reader for Makernote peculiarities, byte order, offset, - // component factory - changeState(object->getState(static_cast<uint32_t>(object->start() - pData_), - byteOrder())); + // Modify reader for Makernote peculiarities, byte order and offset + TiffRwState::AutoPtr state( + new TiffRwState(object->byteOrder(), + object->baseOffset(static_cast<uint32_t>(object->start() - pData_)))); + changeState(state); object->ifd_.setStart(object->start() + object->ifdOffset()); } // TiffReader::visitIfdMakernote diff --git a/src/tiffvisitor.hpp b/src/tiffvisitor.hpp index b05801662..ee301e029 100644 --- a/src/tiffvisitor.hpp +++ b/src/tiffvisitor.hpp @@ -253,37 +253,56 @@ namespace Exiv2 { reader can change state if needed (e.g., to read certain complex makernotes). */ - struct TiffRwState { + class TiffRwState { + friend class TiffReader; + public: //! TiffRWState auto_ptr type typedef std::auto_ptr<TiffRwState> AutoPtr; + + //! @name Creators + //@{ //! Constructor. - explicit TiffRwState(ByteOrder byteOrder, - uint32_t baseOffset, - TiffCompFactoryFct createFct) + TiffRwState(ByteOrder byteOrder, + uint32_t baseOffset, + TiffCompFactoryFct createFct =0) : byteOrder_(byteOrder), baseOffset_(baseOffset), createFct_(createFct) {} + //@} + + //! @name Manipulators + //@{ /*! - Applicable byte order. May be different for the Makernote and the - rest of the TIFF entries. + @brief Return the applicable byte order. May be different for + the Makernote and the rest of the TIFF entries. */ - const ByteOrder byteOrder_; + ByteOrder byteOrder() const { return byteOrder_; } /*! - Base offset. TIFF standard format uses byte offsets which are - always relative to the start of the TIFF file, i.e., relative to the - start of the TIFF image header. In this case, the base offset is 0. - However, some camera vendors encode their makernotes in TIFF IFDs - using offsets relative to (somewhere near) the start of the makernote - data. In this case, base offset added to the start of the TIFF image - header points to the basis for such makernote offsets. + @brief Return the base offset. + + TIFF standard format uses byte offsets which are always relative to + the start of the TIFF file, i.e., relative to the start of the TIFF + image header. In this case, the base offset is 0. However, some + camera vendors encode their makernotes in TIFF IFDs using offsets + relative to (somewhere near) the start of the makernote data. In this + case, base offset added to the start of the TIFF image header points + to the basis for such makernote offsets. */ - const uint32_t baseOffset_; + uint32_t baseOffset() const { return baseOffset_; } /*! - Factory function to create new TIFF components. Different create - functions may use different lookup tables, so that makernotes - can independently use their own factory function and lookup table, - which can be defined together with the makernote implementation. + @brief Return the factory function to create new TIFF components. + + Different create functions may use different lookup tables, so that + makernotes can independently use their own factory function and lookup + table, which can be defined together with the makernote + implementation. */ + TiffCompFactoryFct createFct() const { return createFct_; } + //@} + + private: + ByteOrder byteOrder_; + const uint32_t baseOffset_; TiffCompFactoryFct createFct_; }; // TiffRwState
0
f396a356790c2f933f6796593c12aac52eb520e1
Exiv2
exiv2
webready: change to handling test/data/eps
commit f396a356790c2f933f6796593c12aac52eb520e1 Author: Robin Mills <[email protected]> Date: Thu Dec 25 17:38:00 2014 +0000 webready: change to handling test/data/eps
0
e38d3d99764790a1799692e8479e5b07cf71b5ea
Exiv2
exiv2
"several keys added to easyaccess\n\nsample easyaccess-test enhanced with additional optional argume(...TRUNCATED)
"commit e38d3d99764790a1799692e8479e5b07cf71b5ea\nAuthor: norbertwg <[email protected]>\nDat(...TRUNCATED)
0
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
20