corrections in exif for multithreading issue
This commit is contained in:
@@ -33,6 +33,7 @@ class NAISOInterpreter : public Interpreter {
|
||||
public:
|
||||
NAISOInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%d", t->toInt(2));
|
||||
return buffer;
|
||||
}
|
||||
|
@@ -232,6 +232,7 @@ class PAFNumberInterpreter: public Interpreter {
|
||||
public:
|
||||
PAFNumberInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble()/10);
|
||||
return buffer;
|
||||
}
|
||||
@@ -389,6 +390,7 @@ public:
|
||||
s << "\n1/3 EV steps";
|
||||
return s.str();
|
||||
}else {
|
||||
char buffer[1024];
|
||||
t->toString (buffer);
|
||||
return std::string (buffer);
|
||||
}
|
||||
@@ -694,6 +696,7 @@ class PAMaxApertureInterpreter: public Interpreter {
|
||||
int a = t->toInt(0,BYTE);
|
||||
a &= 0x7F;
|
||||
if(a>1){
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", pow(2.0, (a-1)/32.0));
|
||||
return buffer;
|
||||
}else
|
||||
@@ -706,6 +709,7 @@ class PANominalMinMaxApertureInterpreter: public Interpreter {
|
||||
public:
|
||||
PANominalMinMaxApertureInterpreter(){}
|
||||
virtual std::string toString (Tag* t){
|
||||
char buffer[1024];
|
||||
int a = t->toInt(0,BYTE);
|
||||
int mina = a & 0x0F;
|
||||
int maxa = (a & 0xF0)>>4;
|
||||
@@ -804,6 +808,7 @@ class PAExternalFlashGNInterpreter: public Interpreter {
|
||||
public:
|
||||
PAExternalFlashGNInterpreter(){}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
int b = t->toInt(0,BYTE) & 0x1F;
|
||||
sprintf (buffer, "%0.0f", pow(2.,b/16.+4) );
|
||||
return buffer;
|
||||
@@ -871,10 +876,10 @@ public:
|
||||
if (r!=choices.end())
|
||||
return r->second;
|
||||
else {
|
||||
char buffer[1024];
|
||||
t->toString (buffer);
|
||||
return std::string (buffer);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
PAFlashOptionInterpreter paFlashOptionInterpreter;
|
||||
|
@@ -1263,7 +1263,7 @@ void ExifManager::parseCIFF (FILE* f, int base, int length, TagDirectory* root)
|
||||
}
|
||||
|
||||
TagDirectory* ExifManager::parse (FILE* f, int base) {
|
||||
|
||||
setlocale(LC_NUMERIC, "C"); // to set decimal point in sscanf
|
||||
// read tiff header
|
||||
fseek (f, base, SEEK_SET);
|
||||
unsigned short bo;
|
||||
@@ -1562,37 +1562,22 @@ bool extractLensInfo(std::string &fullname,double &minFocal, double &maxFocal, d
|
||||
maxFocal=0.0;
|
||||
maxApertureAtMinFocal=0.0;
|
||||
maxApertureAtMaxFocal=0.0;
|
||||
|
||||
int iAperture = fullname.find("f/");
|
||||
if( iAperture != std::string::npos ){
|
||||
char meno;
|
||||
std::istringstream apertures( std::string(fullname,iAperture+2) );
|
||||
apertures >> maxApertureAtMinFocal;
|
||||
if( !apertures.eof())
|
||||
apertures >> meno;
|
||||
if( !apertures.eof())
|
||||
apertures >> maxApertureAtMaxFocal;
|
||||
char buffer[1024];
|
||||
strcpy(buffer,fullname.c_str());
|
||||
char *pF = strstr(buffer,"f/" );
|
||||
if( pF ){
|
||||
sscanf(pF+2,"%lf-%lf",&maxApertureAtMinFocal,&maxApertureAtMaxFocal);
|
||||
if(maxApertureAtMinFocal >0. && maxApertureAtMaxFocal==0.)
|
||||
maxApertureAtMaxFocal= maxApertureAtMinFocal;
|
||||
|
||||
int eFocal = fullname.rfind("mm",iAperture);
|
||||
if( eFocal != -1 ){
|
||||
int iFocal = fullname.rfind(' ',eFocal); // find first space leading focal length
|
||||
if( iFocal == std::string::npos )
|
||||
iFocal = 0;
|
||||
|
||||
std::istringstream focals( std::string(fullname,iFocal,eFocal-iFocal) );
|
||||
focals >> minFocal;
|
||||
if( !focals.eof())
|
||||
focals >> meno;
|
||||
if( !focals.eof())
|
||||
focals >> maxFocal;
|
||||
if(minFocal >0. && maxFocal==0.0)
|
||||
maxFocal=minFocal;
|
||||
|
||||
return true;
|
||||
char *pMM = pF-3;
|
||||
while( pMM[0]!= 'm' && pMM[1]!= 'm' && pMM>buffer) pMM--;
|
||||
if( pMM[0]== 'm' && pMM[1]== 'm' ){
|
||||
char *sp=pMM;
|
||||
while( *sp != ' ' && sp > buffer )sp--;
|
||||
sscanf(sp+1,"%lf-%lf",&minFocal,&maxFocal);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -204,8 +204,6 @@ class ExifManager {
|
||||
};
|
||||
|
||||
class Interpreter {
|
||||
protected:
|
||||
char buffer[1024];
|
||||
public:
|
||||
Interpreter () {}
|
||||
virtual std::string toString (Tag* t) { return ""; }
|
||||
@@ -216,6 +214,7 @@ class StdInterpreter : public Interpreter {
|
||||
public:
|
||||
StdInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[1024];
|
||||
t->toString (buffer);
|
||||
std::string s(buffer);
|
||||
std::string::size_type p1 = s.find_first_not_of(' ');
|
||||
@@ -242,6 +241,7 @@ class ChoiceInterpreter : public Interpreter {
|
||||
if (r!=choices.end())
|
||||
return r->second;
|
||||
else {
|
||||
char buffer[1024];
|
||||
t->toString (buffer);
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
@@ -243,6 +243,7 @@ class FNumberInterpreter : public Interpreter {
|
||||
public:
|
||||
FNumberInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble());
|
||||
return buffer;
|
||||
}
|
||||
@@ -253,6 +254,7 @@ class ApertureInterpreter : public Interpreter {
|
||||
public:
|
||||
ApertureInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", pow(2.0, t->toDouble()/2.0));
|
||||
return buffer;
|
||||
}
|
||||
@@ -263,6 +265,7 @@ class ExposureBiasInterpreter : public Interpreter {
|
||||
public:
|
||||
ExposureBiasInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%+0.2f", t->toDouble());
|
||||
return buffer;
|
||||
}
|
||||
@@ -273,6 +276,7 @@ class ShutterSpeedInterpreter : public Interpreter {
|
||||
public:
|
||||
ShutterSpeedInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
double d = pow (2.0, -t->toDouble());
|
||||
if (d > 0.0 && d < 0.9)
|
||||
sprintf (buffer, "1/%0.0f", 1.0 / d);
|
||||
@@ -287,6 +291,7 @@ class ExposureTimeInterpreter : public Interpreter {
|
||||
public:
|
||||
ExposureTimeInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
double d = t->toDouble();
|
||||
if (d > 0.0 && d < 0.9)
|
||||
sprintf (buffer, "1/%0.0f", 1.0 / d);
|
||||
@@ -301,6 +306,7 @@ class FocalLengthInterpreter : public Interpreter {
|
||||
public:
|
||||
FocalLengthInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble());
|
||||
return buffer;
|
||||
}
|
||||
@@ -311,6 +317,7 @@ class UserCommentInterpreter : public Interpreter {
|
||||
public:
|
||||
UserCommentInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[1024];
|
||||
if (!strncmp((char*)t->getValue(), "ASCII\0\0\0",8))
|
||||
strncpy (buffer, (char*)t->getValue()+8, t->getCount()-8);
|
||||
else
|
||||
@@ -318,6 +325,7 @@ class UserCommentInterpreter : public Interpreter {
|
||||
return buffer;
|
||||
}
|
||||
virtual void fromString (Tag* t, const std::string& value) {
|
||||
char buffer[1024];
|
||||
memcpy (buffer, "ASCII\0\0\0", 8);
|
||||
strcpy (buffer+8, value.c_str());
|
||||
t->fromString (buffer, value.size() + 9);
|
||||
@@ -330,6 +338,7 @@ public:
|
||||
CFAInterpreter(){}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char colors[]="RGB";
|
||||
char buffer[1024];
|
||||
for( int i=0; i< t->getCount();i++){
|
||||
unsigned char c = t->toInt(i,BYTE);
|
||||
buffer[i]= c<3 ?colors[c]:' ';
|
||||
|
Reference in New Issue
Block a user