diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-01-03 14:34:48 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-01-03 14:34:48 +0000 |
commit | eb680766d56e815086397361b286fd8055fb5377 (patch) | |
tree | 7994cdb0d9077f645ba7fd06bdd2cde32cf599d4 /plugins/AdvaImg/src/Metadata | |
parent | ec61686c3d96f49eb7f40a4208690a0781d63e29 (diff) |
FreeImage updated to 3.15.4
removed not used formats
git-svn-id: http://svn.miranda-ng.org/main/trunk@2926 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AdvaImg/src/Metadata')
-rw-r--r-- | plugins/AdvaImg/src/Metadata/Exif.cpp | 26 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/FreeImageTag.cpp | 14 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/FreeImageTag.h | 26 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/IPTC.cpp | 23 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/TagConversion.cpp | 12 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/TagLib.cpp | 7 | ||||
-rw-r--r-- | plugins/AdvaImg/src/Metadata/XTIFF.cpp | 22 |
7 files changed, 81 insertions, 49 deletions
diff --git a/plugins/AdvaImg/src/Metadata/Exif.cpp b/plugins/AdvaImg/src/Metadata/Exif.cpp index 7d0955c5db..ed667b0974 100644 --- a/plugins/AdvaImg/src/Metadata/Exif.cpp +++ b/plugins/AdvaImg/src/Metadata/Exif.cpp @@ -69,7 +69,7 @@ static int FreeImage_strnicmp(const char *s1, const char *s2, size_t len) { unsigned char c1, c2; - if (!s1 || !s2) return -1; + if(!s1 || !s2) return -1; c1 = 0; c2 = 0; if(len) { @@ -182,7 +182,7 @@ processMakerNote(FIBITMAP *dib, char *pval, BOOL msb_order, DWORD *subdirOffset, FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Make", &tagMake); const char *Maker = (char*)FreeImage_GetTagValue(tagMake); - if ((memcmp("OLYMP\x00\x01", pval, 7) == 0) || (memcmp("OLYMP\x00\x02", pval, 7) == 0) || (memcmp("EPSON", pval, 5) == 0) || (memcmp("AGFA", pval, 4) == 0)) { + if((memcmp("OLYMP\x00\x01", pval, 7) == 0) || (memcmp("OLYMP\x00\x02", pval, 7) == 0) || (memcmp("EPSON", pval, 5) == 0) || (memcmp("AGFA", pval, 4) == 0)) { // Olympus Type 1 Makernote // Epson and Agfa use Olympus maker note standard, // see: http://www.ozhiker.com/electronics/pjmt/jpeg_info/ @@ -280,11 +280,11 @@ processMakerNote(FIBITMAP *dib, char *pval, BOOL msb_order, DWORD *subdirOffset, *subdirOffset = 0; } } - else if ((memcmp("SONY CAM\x20\x00\x00\x00", pval, 12) == 0) || (memcmp("SONY DSC\x20\x00\x00\x00", pval, 12) == 0)) { + else if((memcmp("SONY CAM\x20\x00\x00\x00", pval, 12) == 0) || (memcmp("SONY DSC\x20\x00\x00\x00", pval, 12) == 0)) { *md_model = TagLib::EXIF_MAKERNOTE_SONY; *subdirOffset = 12; } - else if ((memcmp("SIGMA\x00\x00\x00", pval, 8) == 0) || (memcmp("FOVEON\x00\x00", pval, 8) == 0)) { + else if((memcmp("SIGMA\x00\x00\x00", pval, 8) == 0) || (memcmp("FOVEON\x00\x00", pval, 8) == 0)) { FITAG *tagModel = NULL; FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Model", &tagModel); const char *Model = (char*)FreeImage_GetTagValue(tagModel); @@ -365,7 +365,7 @@ processCanonMakerNoteTag(FIBITMAP *dib, FITAG *tag) { // create a tag FITAG *canonTag = FreeImage_CreateTag(); - if (!canonTag) return FALSE; + if(!canonTag) return FALSE; // we intentionally skip the first array member (if needed) for (DWORD i = startIndex; i < FreeImage_GetTagCount(tag); i++) { @@ -560,7 +560,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig do { // if there is anything on the stack then pop it off - if (!destack.empty()) { + if(!destack.empty()) { ifdp = ifdstack.top(); ifdstack.pop(); de = destack.top(); destack.pop(); md_model = modelstack.top(); modelstack.pop(); @@ -577,13 +577,13 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig // determine how many entries there are in the current IFD nde = ReadUint16(msb_order, ifdp); - for (; de < nde; de++) { + for(; de < nde; de++) { char *pde = NULL; // pointer to the directory entry char *pval = NULL; // pointer to the tag value // create a tag FITAG *tag = FreeImage_CreateTag(); - if (!tag) return FALSE; + if(!tag) return FALSE; // point to the directory entry pde = (char*) DIR_ENTRY_ADDR(ifdp, de); @@ -592,7 +592,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig FreeImage_SetTagID(tag, ReadUint16(msb_order, pde)); // get the tag type WORD tag_type = (WORD)ReadUint16(msb_order, pde + 2); - if ((tag_type - 1) >= EXIF_NUM_FORMATS) { + if((tag_type - 1) >= EXIF_NUM_FORMATS) { // a problem occured : delete the tag (not free'd after) FreeImage_DeleteTag(tag); // break out of the for loop @@ -658,7 +658,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig next_ifd = (BYTE*)tiffp + sub_offset; } - if ((sub_offset < (DWORD) length) && (next_mdmodel != TagLib::UNKNOWN)) { + if((sub_offset < (DWORD) length) && (next_mdmodel != TagLib::UNKNOWN)) { // push our current directory state onto the stack ifdstack.push(ifdp); // bump to the next entry @@ -675,7 +675,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig // select a new metadata model modelstack.push(next_mdmodel); - // delete the tag as it won't be stored nor deleted in the for () loop + // delete the tag as it won't be stored nor deleted in the for() loop FreeImage_DeleteTag(tag); break; // break out of the for loop @@ -707,7 +707,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig const WORD entriesCount0th = ReadUint16(msb_order, ifd0th); DWORD next_offset = ReadUint32(msb_order, DIR_ENTRY_ADDR(ifd0th, entriesCount0th)); - if ((next_offset == 0) || (next_offset >= length)) { + if((next_offset == 0) || (next_offset >= length)) { return TRUE; //< no thumbnail } @@ -763,7 +763,7 @@ jpeg_read_exif_dir(FIBITMAP *dib, const BYTE *tiffp, unsigned long offset, unsig } } - if (/*thCompression != 6 ||*/ thOffset == 0 || thSize == 0) { + if(/*thCompression != 6 ||*/ thOffset == 0 || thSize == 0) { return TRUE; } diff --git a/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp b/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp index 84e15d0822..5d9f3034ec 100644 --- a/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp +++ b/plugins/AdvaImg/src/Metadata/FreeImageTag.cpp @@ -81,11 +81,11 @@ FreeImage_DeleteTag(FITAG *tag) { FITAG * DLL_CALLCONV FreeImage_CloneTag(FITAG *tag) { - if (!tag) return NULL; + if(!tag) return NULL; // allocate a new tag FITAG *clone = FreeImage_CreateTag(); - if (!clone) return NULL; + if(!clone) return NULL; try { // copy the tag @@ -97,7 +97,7 @@ FreeImage_CloneTag(FITAG *tag) { // tag key if(src_tag->key) { dst_tag->key = (char*)malloc((strlen(src_tag->key) + 1) * sizeof(char)); - if (!dst_tag->key) { + if(!dst_tag->key) { throw FI_MSG_ERROR_MEMORY; } strcpy(dst_tag->key, src_tag->key); @@ -105,7 +105,7 @@ FreeImage_CloneTag(FITAG *tag) { // tag description if(src_tag->description) { dst_tag->description = (char*)malloc((strlen(src_tag->description) + 1) * sizeof(char)); - if (!dst_tag->description) { + if(!dst_tag->description) { throw FI_MSG_ERROR_MEMORY; } strcpy(dst_tag->description, src_tag->description); @@ -118,7 +118,7 @@ FreeImage_CloneTag(FITAG *tag) { dst_tag->length = src_tag->length; // tag value dst_tag->value = (BYTE*)malloc(src_tag->length * sizeof(BYTE)); - if (!dst_tag->value) { + if(!dst_tag->value) { throw FI_MSG_ERROR_MEMORY; } memcpy(dst_tag->value, src_tag->value, src_tag->length); @@ -253,7 +253,7 @@ FreeImage_SetTagValue(FITAG *tag, const void *value) { case FIDT_ASCII: { tag_header->value = (char*)malloc((tag_header->length + 1) * sizeof(char)); - if (!tag_header->value) { + if(!tag_header->value) { return FALSE; } char *src_data = (char*)value; @@ -267,7 +267,7 @@ FreeImage_SetTagValue(FITAG *tag, const void *value) { default: tag_header->value = malloc(tag_header->length * sizeof(BYTE)); - if (!tag_header->value) { + if(!tag_header->value) { return FALSE; } memcpy(tag_header->value, value, tag_header->length); diff --git a/plugins/AdvaImg/src/Metadata/FreeImageTag.h b/plugins/AdvaImg/src/Metadata/FreeImageTag.h index f412603e8d..4f3bffa1ce 100644 --- a/plugins/AdvaImg/src/Metadata/FreeImageTag.h +++ b/plugins/AdvaImg/src/Metadata/FreeImageTag.h @@ -312,14 +312,24 @@ typedef struct tagTagInfo { /** - Class to hold tag information (based on Meyers’ Singleton).<br> - - Sample usage :<br> - <code> - TagLib& s = TagLib::instance(); - TagInfo *tag_info = s.getTagInfo(EXIF_MAIN, 0x0100); - </code> - +Class to hold tag information (based on Meyers’ Singleton).<br> + +Sample usage :<br> +<code> +TagLib& s = TagLib::instance(); +TagInfo *tag_info = s.getTagInfo(EXIF_MAIN, 0x0100); +</code> + +Note on multi-threaded applications : +
+The singleton pattern must be carefully constructed in multi-threaded applications.
+If two threads are to execute the creation method at the same time when a singleton
+does not yet exist, they both must check for an instance of the singleton and then
+only one should create the new one.
+The classic solution to this problem is to use mutual exclusion on the class that
+indicates that the object is being instantiated.
+The FreeImage solution is to instantiate the singleton before any other thread is launched,
+i.e. inside the FreeImage_Initialise function (see Plugin.cpp).
*/ class TagLib { diff --git a/plugins/AdvaImg/src/Metadata/IPTC.cpp b/plugins/AdvaImg/src/Metadata/IPTC.cpp index 817beddf98..bde718c986 100644 --- a/plugins/AdvaImg/src/Metadata/IPTC.cpp +++ b/plugins/AdvaImg/src/Metadata/IPTC.cpp @@ -41,15 +41,27 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { size_t length = datalen; BYTE *profile = (BYTE*)dataptr; + const char *JPEG_AdobeCM_Tag = "Adobe_CM"; + std::string Keywords; std::string SupplementalCategory; WORD tag_id; - if (!dataptr || (datalen == 0)) { + if(!dataptr || (datalen == 0)) { return FALSE; } + if(datalen > 8) { + if(memcmp(JPEG_AdobeCM_Tag, dataptr, 8) == 0) { + // the "Adobe_CM" APP13 segment presumably contains color management information, + // but the meaning of the data is currently unknown. + // If anyone has an idea about what this means, please let me know. + return FALSE; + } + } + + // create a tag FITAG *tag = FreeImage_CreateTag(); @@ -59,7 +71,7 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { // find start of the BIM portion of the binary data size_t offset = 0; while(offset < length - 1) { - if ((profile[offset] == 0x1C) && (profile[offset+1] == 0x02)) + if((profile[offset] == 0x1C) && (profile[offset+1] == 0x02)) break; offset++; } @@ -88,6 +100,11 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) { break; } + if(tagByteCount == 0) { + // go to next tag + continue; + } + // process the tag tag_id = (WORD)(tagType | (directoryType << 8)); @@ -211,7 +228,7 @@ append_iptc_tag(BYTE *profile, unsigned *profile_size, WORD id, DWORD length, co // calculate the new buffer size size_t buffer_size = (5 + *profile_size + length) * sizeof(BYTE); buffer = (BYTE*)malloc(buffer_size); - if (!buffer) + if(!buffer) return NULL; // add the header diff --git a/plugins/AdvaImg/src/Metadata/TagConversion.cpp b/plugins/AdvaImg/src/Metadata/TagConversion.cpp index 7b91598014..06a1970cd8 100644 --- a/plugins/AdvaImg/src/Metadata/TagConversion.cpp +++ b/plugins/AdvaImg/src/Metadata/TagConversion.cpp @@ -39,7 +39,7 @@ ConvertAnyTag(FITAG *tag) { static std::string buffer;
DWORD i;
- if (!tag)
+ if(!tag)
return NULL;
buffer.erase();
@@ -197,7 +197,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_LONG8: // N x 64-bit unsigned integer
{
- FIUINT64 *pvalue = (FIUINT64 *)FreeImage_GetTagValue(tag);
+ UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag);
sprintf(format, "%ld", pvalue[0]);
buffer += format;
@@ -210,7 +210,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_IFD8: // N x 64-bit unsigned integer (offset)
{
- FIUINT64 *pvalue = (FIUINT64 *)FreeImage_GetTagValue(tag);
+ UINT64 *pvalue = (UINT64 *)FreeImage_GetTagValue(tag);
sprintf(format, "%X", pvalue[0]);
buffer += format;
@@ -223,7 +223,7 @@ ConvertAnyTag(FITAG *tag) { case FIDT_SLONG8: // N x 64-bit signed integer
{
- FIINT64 *pvalue = (FIINT64 *)FreeImage_GetTagValue(tag);
+ INT64 *pvalue = (INT64 *)FreeImage_GetTagValue(tag);
sprintf(format, "%ld", pvalue[0]);
buffer += format;
@@ -259,7 +259,7 @@ ConvertExifTag(FITAG *tag) { char format[MAX_TEXT_EXTENT];
static std::string buffer;
- if (!tag)
+ if(!tag)
return NULL;
buffer.erase();
@@ -993,7 +993,7 @@ ConvertExifGPSTag(FITAG *tag) { char format[MAX_TEXT_EXTENT];
static std::string buffer;
- if (!tag)
+ if(!tag)
return NULL;
buffer.erase();
diff --git a/plugins/AdvaImg/src/Metadata/TagLib.cpp b/plugins/AdvaImg/src/Metadata/TagLib.cpp index eff291beab..580ad6faac 100644 --- a/plugins/AdvaImg/src/Metadata/TagLib.cpp +++ b/plugins/AdvaImg/src/Metadata/TagLib.cpp @@ -537,6 +537,7 @@ static TagInfo { 0x3015, (char *) "ColorMode", (char *) NULL}, { 0x3016, (char *) "Enhancement", (char *) NULL}, { 0x3017, (char *) "ColorFilter", (char *) NULL}, + { 0x301B, (char *) "ArtMode", (char *) NULL}, { 0x301C, (char *) "SequenceNumber", (char *) NULL}, { 0x301D, (char *) "BracketSequence", (char *) NULL}, { 0x3020, (char *) "ImageStabilization", (char *) NULL}, @@ -1478,14 +1479,14 @@ TagLib::TagLib() { BOOL TagLib::addMetadataModel(MDMODEL md_model, TagInfo *tag_table) { // check that the model doesn't already exist - if ((_table_map.find(md_model) == _table_map.end()) && (tag_table != NULL)) { + if((_table_map.find(md_model) == _table_map.end()) && (tag_table != NULL)) { // add the tag description table TAGINFO *info_map = new(std::nothrow) TAGINFO(); - if (!info_map) return FALSE; + if(!info_map) return FALSE; for(int i = 0; ; i++) { - if ((tag_table[i].tag == 0) && (tag_table[i].fieldname == NULL)) + if((tag_table[i].tag == 0) && (tag_table[i].fieldname == NULL)) break; (*info_map)[tag_table[i].tag] = &tag_table[i]; } diff --git a/plugins/AdvaImg/src/Metadata/XTIFF.cpp b/plugins/AdvaImg/src/Metadata/XTIFF.cpp index bc63cf38b2..e6f6bdd0d9 100644 --- a/plugins/AdvaImg/src/Metadata/XTIFF.cpp +++ b/plugins/AdvaImg/src/Metadata/XTIFF.cpp @@ -123,7 +123,7 @@ tiff_read_geotiff_profile(TIFF *tif, FIBITMAP *dib) { if(TIFFGetField(tif, fieldInfo->field_tag, ¶ms)) {
// create a tag
FITAG *tag = FreeImage_CreateTag();
- if (!tag)
+ if(!tag)
return;
WORD tag_id = (WORD)fieldInfo->field_tag;
@@ -147,7 +147,7 @@ tiff_read_geotiff_profile(TIFF *tif, FIBITMAP *dib) { if(TIFFGetField(tif, fieldInfo->field_tag, &tag_count, &data)) {
// create a tag
FITAG *tag = FreeImage_CreateTag();
- if (!tag)
+ if(!tag)
return;
WORD tag_id = (WORD)fieldInfo->field_tag;
@@ -315,7 +315,7 @@ tiff_read_exif_tag(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib, TagLib& t // build FreeImage tag from Tiff Tag data we collected
FITAG *fitag = FreeImage_CreateTag();
- if (!fitag) {
+ if(!fitag) {
if(mem_alloc) {
_TIFFfree(raw_data);
}
@@ -452,7 +452,9 @@ tiff_read_exif_tag(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib, TagLib& t break;
default: {
- size_t length = strlen((char*)raw_data) + 1;
+ // remember that raw_data = _TIFFmalloc(value_size * value_count);
+ const int value_size = _TIFFDataSize(fip->field_type);
+ size_t length = value_size * value_count;
FreeImage_SetTagType(fitag, FIDT_ASCII);
FreeImage_SetTagLength(fitag, (DWORD)length);
FreeImage_SetTagCount(fitag, (DWORD)length);
@@ -514,18 +516,18 @@ tiff_read_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { // test if tag value is set
// (lifted directly form LibTiff _TIFFWriteDirectory)
- if ( fld->field_bit == FIELD_CUSTOM ) {
+ if( fld->field_bit == FIELD_CUSTOM ) {
int ci, is_set = FALSE;
- for ( ci = 0; ci < td->td_customValueCount; ci++ ) {
+ for( ci = 0; ci < td->td_customValueCount; ci++ ) {
is_set |= (td->td_customValues[ci].info == fld);
}
- if ( !is_set ) {
+ if( !is_set ) {
continue;
}
- } else if (!TIFFFieldSet(tif, fld->field_bit)) {
+ } else if(!TIFFFieldSet(tif, fld->field_bit)) {
continue;
}
@@ -558,6 +560,8 @@ skip_write_field(TIFF* tif, uint32 tag) { case TIFFTAG_PHOTOMETRIC:
case TIFFTAG_PLANARCONFIG:
case TIFFTAG_ROWSPERSTRIP:
+ case TIFFTAG_STRIPBYTECOUNTS:
+ case TIFFTAG_STRIPOFFSETS:
case TIFFTAG_RESOLUTIONUNIT:
case TIFFTAG_XRESOLUTION:
case TIFFTAG_YRESOLUTION:
@@ -639,7 +643,7 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { // check for identical formats
// (enum value are the sames between FREE_IMAGE_MDTYPE and TIFFDataType types)
- if ((int)tif_tag_type != (int)tag_type) {
+ if((int)tif_tag_type != (int)tag_type) {
// skip tag or _TIFFmemcpy will fail
continue;
}
|