#1178 Thanks to Terence for reporting this an providing confidential test data

This commit is contained in:
Robin Mills 2016-04-19 20:17:20 +00:00
parent a547679a2b
commit 00984afaa2
7 changed files with 46 additions and 33 deletions

View File

@ -427,6 +427,16 @@ namespace Exiv2 {
const NativePreviewList& nativePreviews() const;
//@}
void setTypeSupported(
int imageType,
uint16_t supportedMetadata
) {
imageType_ = imageType;
supportedMetadata_ = supportedMetadata;
}
int imageType() const { return imageType_; }
protected:
// DATA
BasicIo::AutoPtr io_; //!< Image data IO pointer
@ -450,8 +460,8 @@ namespace Exiv2 {
//@}
// DATA
const int imageType_; //!< Image type
const uint16_t supportedMetadata_; //!< Bitmap with all supported metadata types
int imageType_; //!< Image type
uint16_t supportedMetadata_; //!< Bitmap with all supported metadata types
bool writeXmpFromPacket_;//!< Determines the source when writing XMP
ByteOrder byteOrder_; //!< Byte order

View File

@ -32,6 +32,7 @@
// *****************************************************************************
// included header files
#include "image.hpp"
#include "tiffimage.hpp"
#include "basicio.hpp"
#include "types.hpp"
@ -54,7 +55,7 @@ namespace Exiv2 {
@brief Class to access raw Olympus ORF images. Exif metadata is supported
directly, IPTC is read from the Exif data, if present.
*/
class EXIV2API OrfImage : public Image {
class EXIV2API OrfImage : public TiffImage {
public:
//! @name Creators
//@{

View File

@ -93,7 +93,7 @@ namespace Exiv2 {
not valid (does not look like data of the specific image type).
@caution This function is not thread safe and intended for exiv2 -p{S|R} as a file debugging aid
*/
void printStructure(std::ostream& out, PrintStructureOption option,int depth=-1);
virtual void printStructure(std::ostream& out, PrintStructureOption option,int depth=-1);
/*!
@brief Print out the structure of image file.

View File

@ -255,10 +255,10 @@ namespace Exiv2 {
{
if (size < 16) return false;
if (pData[0] == 0x49 && pData[1] == 0x49) {
if (pData[0] == 'I' && pData[0] == pData[1]) {
setByteOrder(littleEndian);
}
else if (pData[0] == 0x4d && pData[1] == 0x4d) {
else if (pData[0] == 'M' && pData[0] == pData[1]) {
setByteOrder(bigEndian);
}
else {
@ -277,17 +277,17 @@ namespace Exiv2 {
DataBuf buf(16);
switch (byteOrder()) {
case littleEndian:
buf.pData_[0] = 0x49;
buf.pData_[1] = 0x49;
buf.pData_[0] = 'I';
break;
case bigEndian:
buf.pData_[0] = 0x4d;
buf.pData_[1] = 0x4d;
buf.pData_[0] = 'M';
break;
case invalidByteOrder:
assert(false);
break;
}
buf.pData_[1] = buf.pData_[0];
us2Data(buf.pData_ + 2, tag(), byteOrder());
ul2Data(buf.pData_ + 4, 0x00000010, byteOrder());
memcpy(buf.pData_ + 8, cr2sig_, 4);

View File

@ -367,10 +367,10 @@ namespace Exiv2 {
{
if (size < 14) throw Error(33);
if (pData[0] == 0x49 && pData[1] == 0x49) {
if (pData[0] == 'I' && pData[0] == pData[1]) {
byteOrder_ = littleEndian;
}
else if (pData[0] == 0x4d && pData[1] == 0x4d) {
else if (pData[0] == 'M' && pData[0] == pData[1]) {
byteOrder_ = bigEndian;
}
else {
@ -500,12 +500,12 @@ namespace Exiv2 {
assert( byteOrder_ == littleEndian
|| byteOrder_ == bigEndian);
if (byteOrder_ == littleEndian) {
blob.push_back(0x49);
blob.push_back(0x49);
blob.push_back('I');
blob.push_back('I');
}
else {
blob.push_back(0x4d);
blob.push_back(0x4d);
blob.push_back('M');
blob.push_back('M');
}
uint32_t o = 2;
byte buf[4];

View File

@ -34,6 +34,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "orfimage.hpp"
#include "orfimage_int.hpp"
#include "tiffimage.hpp"
#include "tiffcomposite_int.hpp"
#include "tiffimage_int.hpp"
#include "image.hpp"
@ -53,9 +54,10 @@ namespace Exiv2 {
using namespace Internal;
OrfImage::OrfImage(BasicIo::AutoPtr io, bool /*create*/)
: Image(ImageType::orf, mdExif | mdIptc | mdXmp, io)
OrfImage::OrfImage(BasicIo::AutoPtr io, bool create)
: TiffImage(/*ImageType::orf, mdExif | mdIptc | mdXmp,*/ io,create)
{
setTypeSupported(ImageType::orf, mdExif | mdIptc | mdXmp);
} // OrfImage::OrfImage
std::string OrfImage::mimeType() const
@ -242,21 +244,20 @@ namespace Exiv2 {
{
if (size < 8) return false;
if (pData[0] == 0x49 && pData[1] == 0x49) {
if (pData[0] == 'I' && pData[0] == pData[1]) {
setByteOrder(littleEndian);
}
else if (pData[0] == 0x4d && pData[1] == 0x4d) {
else if (pData[0] == 'M' && pData[0] == pData[1]) {
setByteOrder(bigEndian);
}
else {
return false;
}
uint16_t sig = getUShort(pData + 2, byteOrder());
if (tag() != sig && 0x5352 != sig) return false; // #658: Added 0x5352 for SP-560UZ
if (tag() != sig && 0x5352 != sig) return false; // #658: Added 0x5352 "SR" for SP-560UZ
sig_ = sig;
setOffset(getULong(pData + 4, byteOrder()));
if (offset() != 0x00000008) return false;
return true;
} // OrfHeader::read
@ -265,17 +266,17 @@ namespace Exiv2 {
DataBuf buf(8);
switch (byteOrder()) {
case littleEndian:
buf.pData_[0] = 0x49;
buf.pData_[1] = 0x49;
buf.pData_[0] = 'I';
break;
case bigEndian:
buf.pData_[0] = 0x4d;
buf.pData_[1] = 0x4d;
buf.pData_[0] = 'M';
break;
case invalidByteOrder:
assert(false);
break;
}
buf.pData_[1] = buf.pData_[0];
us2Data(buf.pData_ + 2, sig_, byteOrder());
ul2Data(buf.pData_ + 4, 0x00000008, byteOrder());
return buf;

View File

@ -36,6 +36,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "tiffimage_int.hpp"
#include "tiffcomposite_int.hpp"
#include "tiffvisitor_int.hpp"
#include "orfimage.hpp"
#include "makernote_int.hpp"
#include "image.hpp"
#include "image_int.hpp"
@ -455,6 +456,7 @@ namespace Exiv2 {
{
if (io_->open() != 0) throw Error(9, io_->path(), strError());
// Ensure that this is the correct image type
if ( imageType() == ImageType::none )
if (!isTiffType(*io_, false)) {
if (io_->error() || io_->eof()) throw Error(14);
throw Error(15);
@ -2326,10 +2328,10 @@ namespace Exiv2 {
{
if (!pData || size < 8) return false;
if (pData[0] == 0x49 && pData[1] == 0x49) {
if (pData[0] == 'I' && pData[0] == pData[1]) {
byteOrder_ = littleEndian;
}
else if (pData[0] == 0x4d && pData[1] == 0x4d) {
else if (pData[0] == 'M' && pData[0] == pData[1]) {
byteOrder_ = bigEndian;
}
else {
@ -2346,17 +2348,16 @@ namespace Exiv2 {
DataBuf buf(8);
switch (byteOrder_) {
case littleEndian:
buf.pData_[0] = 0x49;
buf.pData_[1] = 0x49;
buf.pData_[0] = 'I';
break;
case bigEndian:
buf.pData_[0] = 0x4d;
buf.pData_[1] = 0x4d;
buf.pData_[0] = 'M';
break;
case invalidByteOrder:
assert(false);
break;
}
buf.pData_[1]=buf.pData_[0];
us2Data(buf.pData_ + 2, tag_, byteOrder_);
ul2Data(buf.pData_ + 4, 0x00000008, byteOrder_);
return buf;