Skip to content

Commit

Permalink
Integration for December 2023 release (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
suhail95 authored Dec 21, 2023
1 parent e0955b2 commit 5f6fe44
Show file tree
Hide file tree
Showing 67 changed files with 377 additions and 340 deletions.
Binary file modified XMP-Toolkit-SDK-Overview.pdf
100644 → 100755
Binary file not shown.
3 changes: 2 additions & 1 deletion XMPCommon/source/ErrorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ namespace XMP_COMPONENT_INT_NAMESPACE {
UTF8StringStream stm1;
stm1.setf( std::ios::hex );
stm1 << "0x" << addressParameter;
std::string str1 = stm1.str().c_str();
if ( stm1.str().size() > 4 ) {
const char * charPtr = stm1.str().c_str();
const char * charPtr = str1.c_str();
if ( charPtr[ 2 ] == '0' && ( charPtr[ 3 ] == 'x' || charPtr[ 3 ] == 'X' ) ) {
appends0x = true;
}
Expand Down
8 changes: 0 additions & 8 deletions XMPCore/source/XMPUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ class XMPUtils {

#if ENABLE_CPP_DOM_MODEL
static void MapXMPErrorToIError(XMP_Int32 xmpErrorCodes, AdobeXMPCommon::IError::eErrorDomain & domain, AdobeXMPCommon::IError::eErrorCode & code);
static bool SerializeExtensionAsJSON(const AdobeXMPCore::spINode & extensionNode, std::string & key, std::string & value);
static bool IsExtensionValidForBackwardCompatibility(const AdobeXMPCore::spINode & extensionNode);
static bool CreateExtensionNode(const AdobeXMPCore::spIStructureNode & xmpNode, const XMP_VarString & serializedJSON, const XMP_VarString & doubleQuotesStr);


static void
Expand Down Expand Up @@ -295,11 +292,6 @@ class XMPUtils {

#endif

static bool CreateExtensionNode(XMP_Node ** xmpNode, const XMP_VarString & serializedJSON, const XMP_VarString & doubleQuotesString);

static bool GetSerializedJSONForExtensionNode(const XMP_Node * xmpNode, XMP_VarString &extensionAsKey, XMP_VarString & serializedJSON);

static bool IsSuitableForJSONSerialization(const XMP_Node * xmpNode);

}; // XMPUtils

Expand Down
8 changes: 4 additions & 4 deletions XMPFiles/source/FileHandlers/AVCHD_Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ static void AVCCAM_SetXMPStartTimecode ( SXMPMeta& xmpObj, const XMP_Uns8* avcca
if ( dmTimeFormat != NULL ) {
char timecodeBuff [12];

sprintf ( timecodeBuff, "%d%d%c%d%d%c%d%d%c%d%d", hourTens, hourUnits, tcSeparator,
snprintf ( timecodeBuff, sizeof(timecodeBuff), "%d%d%c%d%d%c%d%d%c%d%d", hourTens, hourUnits, tcSeparator,
minuteTens, minuteUnits, tcSeparator, secondTens, secondUnits, tcSeparator, frameTens, frameUnits);

xmpObj.SetProperty( kXMP_NS_DM, "startTimeScale", dmTimeScale, kXMP_DeleteExisting );
Expand Down Expand Up @@ -1638,7 +1638,7 @@ static bool AVCHD_SetXMPMakeAndModel ( SXMPMeta& xmpObj, const AVCHD_blkClipExte
case kMakerIDPanasonic : xmpValue = "Panasonic"; break;
case kMakerIDSony : xmpValue = "Sony"; break;
default :
std::sprintf ( hexMakeNumber, "0x%04x", clipExtData.mClipInfoExt.mMakerID );
snprintf ( hexMakeNumber,sizeof(hexMakeNumber), "0x%04x", clipExtData.mClipInfoExt.mMakerID );
xmpValue = hexMakeNumber;

break;
Expand Down Expand Up @@ -1693,7 +1693,7 @@ static bool AVCHD_SetXMPMakeAndModel ( SXMPMeta& xmpObj, const AVCHD_blkClipExte
// Panasonic has said that if we don't have a string for the model number, they'd like to see the code
// anyway. We'll do the same for every manufacturer except Sony, who have said that they use
// the same model number for multiple cameras.
std::sprintf ( hexModelNumber, "0x%04x", clipExtData.mClipInfoExt.mMakerModelCode );
snprintf ( hexModelNumber,sizeof(hexModelNumber), "0x%04x", clipExtData.mClipInfoExt.mMakerModelCode );
xmpValue = hexModelNumber;
}

Expand Down Expand Up @@ -1800,7 +1800,7 @@ static std::string AVCHD_DateFieldToXMP ( XMP_Uns8 avchdTimeZone, const XMP_Uns8

char dateBuff [26];

sprintf ( dateBuff,
snprintf ( dateBuff, sizeof(dateBuff),
"%01d%01d%01d%01d-%01d%01d-%01d%01dT%01d%01d:%01d%01d:%01d%01d%+02d:%02d",
(avchdDateTime[0] >> 4), (avchdDateTime[0] & 0x0F),
(avchdDateTime[1] >> 4), (avchdDateTime[1] & 0x0F),
Expand Down
4 changes: 2 additions & 2 deletions XMPFiles/source/FileHandlers/P2_Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void P2_MetaHandler::SetGPSPropertyFromLegacyXML ( XML_NodePtr legacyLocationCo
const double minutes = fractionalDegrees * 60.0;
char xmpValue [128];

sprintf ( xmpValue, "%d,%.5lf%c", static_cast<int>(wholeDegrees), minutes, direction );
snprintf ( xmpValue, sizeof(xmpValue), "%d,%.5lf%c", static_cast<int>(wholeDegrees), minutes, direction );
this->xmpObj.SetProperty ( kXMP_NS_EXIF, propName, xmpValue );
this->containsXMP = true;

Expand Down Expand Up @@ -902,7 +902,7 @@ void P2_MetaHandler::SetAltitudeFromLegacyXML ( XML_NodePtr legacyLocationConte

char xmpValue [128];

sprintf ( xmpValue, "%d/1", altitude );
snprintf ( xmpValue, sizeof(xmpValue), "%d/1", altitude );
this->xmpObj.SetProperty ( kXMP_NS_EXIF, "GPSAltitude", xmpValue );
this->containsXMP = true;

Expand Down
1 change: 1 addition & 0 deletions XMPFiles/source/FileHandlers/PostScript_Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ void PostScript_MetaHandler::ParsePSFile()
if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 ))
{
ioBuf.ptr+=4;
if ( !CheckFileSpace( fileRef, &ioBuf, 1 ) ) return;
while ( !IsNewline( *ioBuf.ptr ) )
{
if ( !CheckFileSpace( fileRef, &ioBuf, 1 ) ) return;
Expand Down
21 changes: 11 additions & 10 deletions XMPFiles/source/FileHandlers/SonyHDV_Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================

#define BUFFER_SIZE 255
#define TIMECODE_SIZE 256
#include "public/include/XMP_Environment.h" // ! XMP_Environment.h must be the first included header.

#include "public/include/XMP_Const.h"
Expand Down Expand Up @@ -290,7 +291,7 @@ static bool ReadIDXFile ( const std::string& idxPath,
idxFile.ReadAll ( &hdvFileBlock.mTotalFrame, 4 );

// Compose file name we expect from file contents and break out on match.
sprintf ( filenameBuffer, "%02d-%02d-%02d_%02d%02d%02d",
snprintf ( filenameBuffer, sizeof(filenameBuffer), "%02d-%02d-%02d_%02d%02d%02d",
hdvFileBlock.mFileNameYear + 2000,
hdvFileBlock.mFileNameMonth,
hdvFileBlock.mFileNameDay,
Expand Down Expand Up @@ -377,16 +378,16 @@ static bool ReadIDXFile ( const std::string& idxPath,
// Sample size and scale.
if ( clipSampleScale != 0 ) {

char buffer[255];
char buffer[BUFFER_SIZE];

if ( digestFound || (! xmpObj->DoesPropertyExist ( kXMP_NS_DM, "startTimeScale" )) ) {
sprintf(buffer, "%d", clipSampleScale);
snprintf(buffer,BUFFER_SIZE, "%d", clipSampleScale);
xmpValue = buffer;
xmpObj->SetProperty ( kXMP_NS_DM, "startTimeScale", xmpValue, kXMP_DeleteExisting );
}

if ( digestFound || (! xmpObj->DoesPropertyExist ( kXMP_NS_DM, "startTimeSampleSize" )) ) {
sprintf(buffer, "%d", clipSampleSize);
snprintf(buffer,BUFFER_SIZE, "%d", clipSampleSize);
xmpValue = buffer;
xmpObj->SetProperty ( kXMP_NS_DM, "startTimeSampleSize", xmpValue, kXMP_DeleteExisting );
}
Expand All @@ -396,11 +397,11 @@ static bool ReadIDXFile ( const std::string& idxPath,
const int frameCount = (hdvFileBlock.mTotalFrame[0] << 24) + (hdvFileBlock.mTotalFrame[1] << 16) +
(hdvFileBlock.mTotalFrame[2] << 8) + hdvFileBlock.mTotalFrame[3];

sprintf ( buffer, "%d", frameCount );
snprintf ( buffer,BUFFER_SIZE, "%d", frameCount );
xmpValue = buffer;
xmpObj->SetStructField ( kXMP_NS_DM, "duration", kXMP_NS_DM, "value", xmpValue, 0 );

sprintf ( buffer, "%d/%d", clipSampleSize, clipSampleScale );
snprintf ( buffer,BUFFER_SIZE, "%d/%d", clipSampleSize, clipSampleScale );
xmpValue = buffer;
xmpObj->SetStructField ( kXMP_NS_DM, "duration", kXMP_NS_DM, "scale", xmpValue, 0 );

Expand All @@ -421,8 +422,8 @@ static bool ReadIDXFile ( const std::string& idxPath,
const int tcHours = ExtractTimeCodeByte ( hdvFileBlock.mStartTimeCode[3], 0x30 );

// HH:MM:SS:FF or HH;MM;SS;FF
char timecode[256];
sprintf ( timecode, "%02d%c%02d%c%02d%c%02d", tcHours, chDF, tcMinutes, chDF, tcSeconds, chDF, tcFrames );
char timecode[TIMECODE_SIZE];
snprintf ( timecode,TIMECODE_SIZE, "%02d%c%02d%c%02d%c%02d", tcHours, chDF, tcMinutes, chDF, tcSeconds, chDF, tcFrames );
std::string sonyTimeString = timecode;

xmpObj->GetStructField ( kXMP_NS_DM, "startTimecode", kXMP_NS_DM, "timeValue", &xmpString, 0 );
Expand Down Expand Up @@ -476,7 +477,7 @@ static bool ReadIDXFile ( const std::string& idxPath,

// YYYY-MM-DDThh:mm:ssZ
char date[256];
sprintf ( date, "%4d-%02d-%02dT%02d:%02d:%02dZ",
snprintf ( date,sizeof(date), "%4d-%02d-%02dT%02d:%02d:%02dZ",
hdvFileBlock.mFileNameYear + 2000,
hdvFileBlock.mFileNameMonth,
hdvFileBlock.mFileNameDay,
Expand Down
1 change: 1 addition & 0 deletions XMPFiles/source/FormatSupport/ASF_Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bool ASF_Support::ReadObject ( XMP_IO* fileRef, ObjectState & inOutObjectState,
if ( bytesRead != kASF_ObjectBaseLen ) return false;

*objectLength = GetUns64LE ( &objectBase.size );
if (*objectLength == 0) return false;
inOutPosition += *objectLength;

ObjectData newObject;
Expand Down
8 changes: 7 additions & 1 deletion XMPFiles/source/FormatSupport/MacScriptExtracts.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Script code 28 (smEthiopic) is also used for the Inuit encoding in the Inuktitut
system.
*/
#if !defined(XMP_MacBuild)
enum {
smRoman = 0,
smJapanese = 1,
Expand Down Expand Up @@ -240,5 +241,10 @@ enum {
langAfricaans = 141, /* Use langAfrikaans */
langGreekPoly = 148 /* Use langGreekAncient*/
};

#else
enum {
klangUnspecified = 32767,
klangJapanese = 11
};
#endif
#endif /* __MacScriptExtracts__ */
11 changes: 8 additions & 3 deletions XMPFiles/source/FormatSupport/PNG_Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,14 @@ namespace PNG_Support

if (chunkType == iTXt)
{
ExtractXMPPacket(fileRef, chunkLength, tempBuffer, bufferLimit - tempBuffer, inOutPosition, outXMPPacket, outXmpOffset);
processedXMP = true;
break;
/* There could be multiple iTXt chunks. There should be no more than one
* chunk containing XMP in each PNG file.
*/
if (ExtractXMPPacket(fileRef, chunkLength, tempBuffer, bufferLimit - tempBuffer, inOutPosition, outXMPPacket, outXmpOffset))
{
processedXMP = true;
break;
}
}
else if (chunkType == IEND && isOpenForRead) {
/*signifies end of png file. No need to process further.*/
Expand Down
4 changes: 2 additions & 2 deletions XMPFiles/source/FormatSupport/PostScript_Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,12 +1071,12 @@ std::string PostScript_Support::ConvertToDate(const char* inString)
{
if ( date.containsOffset )
{
sprintf(dtstr,"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",date.year,date.month,date.day,
snprintf(dtstr,sizeof(dtstr),"%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",date.year,date.month,date.day,
date.hours,date.minutes,date.seconds,date.offsetSign,date.offsetHour,date.offsetMin);
}
else
{
sprintf(dtstr,"%04d-%02d-%02dT%02d:%02d:%02dZ",date.year,date.month,date.day,
snprintf(dtstr,sizeof(dtstr),"%04d-%02d-%02dT%02d:%02d:%02dZ",date.year,date.month,date.day,
date.hours,date.minutes,date.seconds);
}
try
Expand Down
Loading

0 comments on commit 5f6fe44

Please sign in to comment.