22 |
22 |
File: pentaxmn.cpp
|
23 |
23 |
Version: $Rev$
|
24 |
24 |
Author(s): Michal Cihar <michal@cihar.com>
|
|
25 |
Alexey Serbin <aserbin at gmail dot com>
|
25 |
26 |
Based on fujimn.cpp by:
|
26 |
27 |
Andreas Huggel (ahu) <ahuggel@gmx.net>
|
27 |
28 |
Gilles Caulier (gc) <caulier dot gilles at gmail dot com>
|
28 |
29 |
History: 27-Sep-07 created
|
|
30 |
08-Sep-16 (aserbin) added decoding for the ShutterCount tag
|
29 |
31 |
Credits: See header file.
|
30 |
32 |
*/
|
31 |
33 |
// *****************************************************************************
|
... | ... | |
44 |
46 |
#include "i18n.h" // NLS support.
|
45 |
47 |
|
46 |
48 |
// + standard includes
|
|
49 |
#include <cstdint>
|
|
50 |
#include <iomanip>
|
47 |
51 |
#include <string>
|
48 |
|
#include <sstream>
|
49 |
|
#include <iomanip>
|
50 |
|
#include <cassert>
|
51 |
|
#include <cstring>
|
52 |
52 |
|
53 |
53 |
// *****************************************************************************
|
54 |
54 |
// class member definitions
|
... | ... | |
1013 |
1013 |
{ 4, N_("Custom") },
|
1014 |
1014 |
};
|
1015 |
1015 |
|
1016 |
|
std::ostream& PentaxMakerNote::printPentaxVersion(std::ostream& os, const Value& value, const ExifData*)
|
|
1016 |
std::ostream& PentaxMakerNote::printVersion(std::ostream& os, const Value& value, const ExifData*)
|
1017 |
1017 |
{
|
1018 |
1018 |
std::string val = value.toString();
|
1019 |
1019 |
size_t i;
|
... | ... | |
1024 |
1024 |
return os;
|
1025 |
1025 |
}
|
1026 |
1026 |
|
1027 |
|
std::ostream& PentaxMakerNote::printPentaxResolution(std::ostream& os, const Value& value, const ExifData*)
|
|
1027 |
std::ostream& PentaxMakerNote::printResolution(std::ostream& os, const Value& value, const ExifData*)
|
1028 |
1028 |
{
|
1029 |
1029 |
std::string val = value.toString();
|
1030 |
1030 |
size_t i;
|
... | ... | |
1035 |
1035 |
return os;
|
1036 |
1036 |
}
|
1037 |
1037 |
|
1038 |
|
std::ostream& PentaxMakerNote::printPentaxDate(std::ostream& os, const Value& value, const ExifData*)
|
|
1038 |
std::ostream& PentaxMakerNote::printDate(std::ostream& os, const Value& value, const ExifData*)
|
1039 |
1039 |
{
|
1040 |
1040 |
/* I choose same format as is used inside EXIF itself */
|
1041 |
1041 |
os << ((value.toLong(0) << 8) + value.toLong(1));
|
... | ... | |
1046 |
1046 |
return os;
|
1047 |
1047 |
}
|
1048 |
1048 |
|
1049 |
|
std::ostream& PentaxMakerNote::printPentaxTime(std::ostream& os, const Value& value, const ExifData*)
|
|
1049 |
std::ostream& PentaxMakerNote::printTime(std::ostream& os, const Value& value, const ExifData*)
|
1050 |
1050 |
{
|
1051 |
1051 |
std::ios::fmtflags f( os.flags() );
|
1052 |
1052 |
os << std::setw(2) << std::setfill('0') << value.toLong(0);
|
... | ... | |
1058 |
1058 |
return os;
|
1059 |
1059 |
}
|
1060 |
1060 |
|
1061 |
|
std::ostream& PentaxMakerNote::printPentaxExposure(std::ostream& os, const Value& value, const ExifData*)
|
|
1061 |
std::ostream& PentaxMakerNote::printExposure(std::ostream& os, const Value& value, const ExifData*)
|
1062 |
1062 |
{
|
1063 |
1063 |
os << static_cast<float>(value.toLong()) / 100 << " ms";
|
1064 |
1064 |
return os;
|
1065 |
1065 |
}
|
1066 |
1066 |
|
1067 |
|
std::ostream& PentaxMakerNote::printPentaxFValue(std::ostream& os, const Value& value, const ExifData*)
|
|
1067 |
std::ostream& PentaxMakerNote::printFValue(std::ostream& os, const Value& value, const ExifData*)
|
1068 |
1068 |
{
|
1069 |
1069 |
std::ios::fmtflags f( os.flags() );
|
1070 |
1070 |
os << "F" << std::setprecision(2)
|
... | ... | |
1073 |
1073 |
return os;
|
1074 |
1074 |
}
|
1075 |
1075 |
|
1076 |
|
std::ostream& PentaxMakerNote::printPentaxFocalLength(std::ostream& os, const Value& value, const ExifData*)
|
|
1076 |
std::ostream& PentaxMakerNote::printFocalLength(std::ostream& os, const Value& value, const ExifData*)
|
1077 |
1077 |
{
|
1078 |
1078 |
std::ios::fmtflags f( os.flags() );
|
1079 |
1079 |
os << std::fixed << std::setprecision(1)
|
... | ... | |
1083 |
1083 |
return os;
|
1084 |
1084 |
}
|
1085 |
1085 |
|
1086 |
|
std::ostream& PentaxMakerNote::printPentaxCompensation(std::ostream& os, const Value& value, const ExifData*)
|
|
1086 |
std::ostream& PentaxMakerNote::printCompensation(std::ostream& os, const Value& value, const ExifData*)
|
1087 |
1087 |
{
|
1088 |
1088 |
std::ios::fmtflags f( os.flags() );
|
1089 |
1089 |
os << std::setprecision(2)
|
... | ... | |
1093 |
1093 |
return os;
|
1094 |
1094 |
}
|
1095 |
1095 |
|
1096 |
|
std::ostream& PentaxMakerNote::printPentaxTemperature(std::ostream& os, const Value& value, const ExifData*)
|
|
1096 |
std::ostream& PentaxMakerNote::printTemperature(std::ostream& os, const Value& value, const ExifData*)
|
1097 |
1097 |
{
|
1098 |
1098 |
os << value.toLong() << " C";
|
1099 |
1099 |
return os;
|
1100 |
1100 |
}
|
1101 |
1101 |
|
1102 |
|
std::ostream& PentaxMakerNote::printPentaxFlashCompensation(std::ostream& os, const Value& value, const ExifData*)
|
|
1102 |
std::ostream& PentaxMakerNote::printFlashCompensation(std::ostream& os, const Value& value, const ExifData*)
|
1103 |
1103 |
{
|
1104 |
1104 |
std::ios::fmtflags f( os.flags() );
|
1105 |
1105 |
os << std::setprecision(2)
|
... | ... | |
1109 |
1109 |
return os;
|
1110 |
1110 |
}
|
1111 |
1111 |
|
1112 |
|
std::ostream& PentaxMakerNote::printPentaxBracketing(std::ostream& os, const Value& value, const ExifData*)
|
|
1112 |
std::ostream& PentaxMakerNote::printBracketing(std::ostream& os, const Value& value, const ExifData*)
|
1113 |
1113 |
{
|
1114 |
1114 |
long l0 = value.toLong(0);
|
1115 |
1115 |
|
... | ... | |
1160 |
1160 |
return os;
|
1161 |
1161 |
}
|
1162 |
1162 |
|
|
1163 |
std::ostream& PentaxMakerNote::printShutterCount(std::ostream& os, const Value& value, const ExifData* metadata)
|
|
1164 |
{
|
|
1165 |
ExifData::const_iterator dateIt = metadata->findKey(
|
|
1166 |
ExifKey("Exif.PentaxDng.Date"));
|
|
1167 |
if (dateIt == metadata->end()) {
|
|
1168 |
dateIt = metadata->findKey(ExifKey("Exif.Pentax.Date"));
|
|
1169 |
}
|
|
1170 |
ExifData::const_iterator timeIt = metadata->findKey(
|
|
1171 |
ExifKey("Exif.PentaxDng.Time"));
|
|
1172 |
if (timeIt == metadata->end()) {
|
|
1173 |
timeIt = metadata->findKey(ExifKey("Exif.Pentax.Time"));
|
|
1174 |
}
|
|
1175 |
if ( dateIt == metadata->end() || dateIt->size() != 4 ||
|
|
1176 |
timeIt == metadata->end() || timeIt->size() != 3 ||
|
|
1177 |
value.size() != 4) {
|
|
1178 |
os << "undefined";
|
|
1179 |
return os;
|
|
1180 |
}
|
|
1181 |
const uint32_t date =
|
|
1182 |
(dateIt->toLong(0) << 24) + (dateIt->toLong(1) << 16) +
|
|
1183 |
(dateIt->toLong(2) << 8) + (dateIt->toLong(3) << 0);
|
|
1184 |
const uint32_t time =
|
|
1185 |
(timeIt->toLong(0) << 24) + (timeIt->toLong(1) << 16) +
|
|
1186 |
(timeIt->toLong(2) << 8);
|
|
1187 |
const uint32_t countEnc =
|
|
1188 |
(value.toLong(0) << 24) + (value.toLong(1) << 16) +
|
|
1189 |
(value.toLong(2) << 8) + (value.toLong(3) << 0);
|
|
1190 |
// The shutter count is encoded using date and time values stored
|
|
1191 |
// in Pentax-specific tags. The prototype for the encoding/decoding
|
|
1192 |
// function is taken from Phil Harvey's ExifTool: Pentax.pm file,
|
|
1193 |
// CryptShutterCount() routine.
|
|
1194 |
const uint32_t count = countEnc ^ date ^ (~time);
|
|
1195 |
os << count;
|
|
1196 |
return os;
|
|
1197 |
}
|
|
1198 |
|
1163 |
1199 |
// #1144 begin
|
1164 |
1200 |
static std::string getKeyString(const std::string& key,const ExifData* metadata)
|
1165 |
1201 |
{
|
... | ... | |
1389 |
1425 |
const TagInfo PentaxMakerNote::tagInfo_[] = {
|
1390 |
1426 |
TagInfo(0x0000, "Version", N_("Version"),
|
1391 |
1427 |
N_("Pentax Makernote version"),
|
1392 |
|
pentaxId, makerTags, undefined, -1, printPentaxVersion),
|
|
1428 |
pentaxId, makerTags, undefined, -1, printVersion),
|
1393 |
1429 |
TagInfo(0x0001, "Mode", N_("Shooting mode"),
|
1394 |
1430 |
N_("Camera shooting mode"),
|
1395 |
1431 |
pentaxId, makerTags, unsignedShort, -1, EXV_PRINT_TAG(pentaxShootingMode)),
|
1396 |
1432 |
TagInfo(0x0002, "PreviewResolution", N_("Resolution of a preview image"),
|
1397 |
1433 |
N_("Resolution of a preview image"),
|
1398 |
|
pentaxId, makerTags, undefined, -1, printPentaxResolution),
|
|
1434 |
pentaxId, makerTags, undefined, -1, printResolution),
|
1399 |
1435 |
TagInfo(0x0003, "PreviewLength", N_("Length of a preview image"),
|
1400 |
1436 |
N_("Size of an IFD containing a preview image"),
|
1401 |
1437 |
pentaxId, makerTags, undefined, -1, printValue),
|
... | ... | |
1407 |
1443 |
pentaxId, makerTags, unsignedShort, -1, EXV_PRINT_TAG(pentaxModel)),
|
1408 |
1444 |
TagInfo(0x0006, "Date", N_("Date"),
|
1409 |
1445 |
N_("Date"),
|
1410 |
|
pentaxId, makerTags, undefined, -1, printPentaxDate),
|
|
1446 |
pentaxId, makerTags, undefined, -1, printDate),
|
1411 |
1447 |
TagInfo(0x0007, "Time", N_("Time"),
|
1412 |
1448 |
N_("Time"),
|
1413 |
|
pentaxId, makerTags, undefined, -1, printPentaxTime),
|
|
1449 |
pentaxId, makerTags, undefined, -1, printTime),
|
1414 |
1450 |
TagInfo(0x0008, "Quality", N_("Image quality"),
|
1415 |
1451 |
N_("Image quality settings"),
|
1416 |
1452 |
pentaxId, makerTags, unsignedShort, -1, EXV_PRINT_TAG(pentaxQuality)),
|
... | ... | |
1433 |
1469 |
/* Some missing ! */
|
1434 |
1470 |
TagInfo(0x0012, "ExposureTime", N_("Exposure time"),
|
1435 |
1471 |
N_("Exposure time"),
|
1436 |
|
pentaxId, makerTags, unsignedLong, -1, printPentaxExposure),
|
|
1472 |
pentaxId, makerTags, unsignedLong, -1, printExposure),
|
1437 |
1473 |
TagInfo(0x0013, "FNumber", N_("F-Number"),
|
1438 |
1474 |
N_("F-Number"),
|
1439 |
|
pentaxId, makerTags, unsignedLong, -1, printPentaxFValue),
|
|
1475 |
pentaxId, makerTags, unsignedLong, -1, printFValue),
|
1440 |
1476 |
TagInfo(0x0014, "ISO", N_("ISO sensitivity"),
|
1441 |
1477 |
N_("ISO sensitivity settings"),
|
1442 |
1478 |
pentaxId, makerTags, unsignedLong, -1, EXV_PRINT_TAG(pentaxISO)),
|
1443 |
1479 |
/* Some missing ! */
|
1444 |
1480 |
TagInfo(0x0016, "ExposureCompensation", N_("Exposure compensation"),
|
1445 |
1481 |
N_("Exposure compensation"),
|
1446 |
|
pentaxId, makerTags, unsignedLong, -1, printPentaxCompensation),
|
|
1482 |
pentaxId, makerTags, unsignedLong, -1, printCompensation),
|
1447 |
1483 |
/* Some missing ! */
|
1448 |
1484 |
TagInfo(0x0017, "MeteringMode", N_("MeteringMode"),
|
1449 |
1485 |
N_("MeteringMode"),
|
1450 |
1486 |
pentaxId, makerTags, undefined, -1, EXV_PRINT_TAG(pentaxMeteringMode)),
|
1451 |
1487 |
TagInfo(0x0018, "AutoBracketing", N_("AutoBracketing"),
|
1452 |
1488 |
N_("AutoBracketing"),
|
1453 |
|
pentaxId, makerTags, undefined, -1, printPentaxBracketing),
|
|
1489 |
pentaxId, makerTags, undefined, -1, printBracketing),
|
1454 |
1490 |
TagInfo(0x0019, "WhiteBalance", N_("White balance"),
|
1455 |
1491 |
N_("White balance"),
|
1456 |
1492 |
pentaxId, makerTags, undefined, -1, EXV_PRINT_TAG(pentaxWhiteBalance)),
|
... | ... | |
1465 |
1501 |
pentaxId, makerTags, unsignedLong, -1, printValue),
|
1466 |
1502 |
TagInfo(0x001d, "FocalLength", N_("FocalLength"),
|
1467 |
1503 |
N_("FocalLength"),
|
1468 |
|
pentaxId, makerTags, undefined, -1, printPentaxFocalLength),
|
|
1504 |
pentaxId, makerTags, undefined, -1, printFocalLength),
|
1469 |
1505 |
TagInfo(0x001e, "DigitalZoom", N_("Digital zoom"),
|
1470 |
1506 |
N_("Digital zoom"),
|
1471 |
1507 |
pentaxId, makerTags, unsignedLong, -1, printValue),
|
... | ... | |
1542 |
1578 |
/* Some missing ! */
|
1543 |
1579 |
TagInfo(0x0047, "Temperature", N_("Temperature"),
|
1544 |
1580 |
N_("Camera temperature"),
|
1545 |
|
pentaxId, makerTags, signedByte, -1, printPentaxTemperature),
|
|
1581 |
pentaxId, makerTags, signedByte, -1, printTemperature),
|
1546 |
1582 |
TagInfo(0x0048, "AELock", N_("AE lock"),
|
1547 |
1583 |
N_("AE lock"),
|
1548 |
1584 |
pentaxId, makerTags, unsignedShort, -1, EXV_PRINT_TAG(pentaxOffOn)),
|
... | ... | |
1552 |
1588 |
/* Some missing ! */
|
1553 |
1589 |
TagInfo(0x004d, "FlashExposureCompensation", N_("Flash exposure compensation"),
|
1554 |
1590 |
N_("Flash exposure compensation"),
|
1555 |
|
pentaxId, makerTags, signedLong, -1, printPentaxFlashCompensation),
|
|
1591 |
pentaxId, makerTags, signedLong, -1, printFlashCompensation),
|
1556 |
1592 |
/* Some missing ! */
|
1557 |
1593 |
TagInfo(0x004f, "ImageTone", N_("Image tone"),
|
1558 |
1594 |
N_("Image tone"),
|
... | ... | |
1566 |
1602 |
pentaxId, makerTags, undefined, -1, printValue),
|
1567 |
1603 |
TagInfo(0x005d, "ShutterCount", N_("Shutter count"),
|
1568 |
1604 |
N_("Shutter count"),
|
1569 |
|
pentaxId, makerTags, undefined, -1, printValue), /* TODO: This has some encryption by date (see exiftool) */
|
|
1605 |
pentaxId, makerTags, undefined, -1, printShutterCount),
|
1570 |
1606 |
TagInfo(0x0069, "DynamicRangeExpansion", N_("Dynamic range expansion"),
|
1571 |
1607 |
N_("Dynamic range expansion"),
|
1572 |
1608 |
pentaxId, makerTags, undefined, -1, EXV_PRINT_COMBITAG(pentaxDynamicRangeExpansion, 4, 0)),
|
... | ... | |
1656 |
1692 |
return tagInfo_;
|
1657 |
1693 |
}
|
1658 |
1694 |
|
1659 |
|
}} // namespace Internal, Exiv2
|
|
1695 |
} // namespace Internal
|
|
1696 |
} // namespace Exiv2
|