clang -cc1 -cc1 -triple x86_64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name IccEval.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -target-sdk-version=14.0 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 1015.7 -fprofile-instrument=clang -fcoverage-mapping -fcoverage-compilation-dir=/Users/xss/DemoIccMAX-hoyt-master/build/IccProfLib -resource-dir /usr/local/Cellar/llvm/17.0.3/lib/clang/17 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -D IccProfLib2_EXPORTS -I /Users/xss/DemoIccMAX-hoyt-master/build/Cmake/../../IccProfLib -I /Developer/Headers/FlatCarbon -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks -internal-isystem /usr/local/Cellar/llvm/17.0.3/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/include -internal-isystem /usr/local/Cellar/llvm/17.0.3/lib/clang/17/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/Users/xss/DemoIccMAX-hoyt-master/build/IccProfLib -ferror-limit 19 -fsanitize=address -fsanitize-system-ignorelist=/usr/local/Cellar/llvm/17.0.3/lib/clang/17/share/asan_ignorelist.txt -fno-sanitize-memory-param-retval -fsanitize-address-use-after-scope -fsanitize-address-globals-dead-stripping -fno-assume-sane-operator-new -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -analyzer-output=html -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/l9/sd9kj1px4yq2wc5_lkwhlt6w0000gn/T/scan-build-2023-10-28-102616-57860-1 -x c++ /Users/xss/DemoIccMAX-hoyt-master/IccProfLib/IccEval.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | #include <math.h> |
| 72 | #include "IccEval.h" |
| 73 | #include "IccTag.h" |
| 74 | #include <iostream> |
| 75 | #include <typeinfo> |
| 76 | #include <cassert> |
| 77 | |
| 78 | #ifdef USEREFICCMAXNAMESPACE |
| 79 | namespace refIccMAX { |
| 80 | #endif |
| 81 | |
| 82 | static const icFloatNumber SMALLNUM = (icFloatNumber)0.0001; |
| 83 | static const icFloatNumber LESSTHANONE = (icFloatNumber)(1.0 - SMALLNUM); |
| 84 | |
| 85 | icStatusCMM CIccEvalCompare::EvaluateProfile(CIccProfile *pProfile, icUInt8Number nGran, |
| 86 | icRenderingIntent nIntent, icXformInterp nInterp, |
| 87 | bool buseMpeTags) |
| 88 | { |
| 89 | if (!pProfile) |
| 90 | { |
| 91 | return icCmmStatCantOpenProfile; |
| 92 | } |
| 93 | |
| 94 | if (pProfile->m_Header.deviceClass!=icSigInputClass && |
| 4 | | Assuming field 'deviceClass' is equal to icSigInputClass | |
|
| 95 | pProfile->m_Header.deviceClass!=icSigDisplayClass && |
| 96 | pProfile->m_Header.deviceClass!=icSigOutputClass && |
| 97 | pProfile->m_Header.deviceClass!=icSigColorSpaceClass) |
| 98 | { |
| 99 | return icCmmStatInvalidProfile; |
| 100 | } |
| 101 | |
| 102 | CIccCmm dev2Lab(icSigUnknownData, icSigLabData); |
| 103 | CIccCmm Lab2Dev2Lab(icSigLabData, icSigLabData, false); |
| 104 | |
| 105 | icStatusCMM result; |
| 106 | |
| 107 | result = dev2Lab.AddXform(*pProfile, nIntent, nInterp, NULL, icXformLutColorimetric, buseMpeTags); |
| 108 | |
| 109 | if (result!=icCmmStatOk) { |
| 5 | | Assuming 'result' is equal to icCmmStatOk | |
|
| |
| 110 | return result; |
| 111 | } |
| 112 | |
| 113 | result = dev2Lab.Begin(); |
| 114 | if (result != icCmmStatOk) { |
| 7 | | Assuming 'result' is equal to icCmmStatOk | |
|
| |
| 115 | return result; |
| 116 | } |
| 117 | |
| 118 | result = Lab2Dev2Lab.AddXform(*pProfile, nIntent, nInterp, NULL, icXformLutColorimetric, buseMpeTags); |
| 119 | if (result != icCmmStatOk) { |
| 9 | | Assuming 'result' is equal to icCmmStatOk | |
|
| |
| 120 | return result; |
| 121 | } |
| 122 | |
| 123 | result = Lab2Dev2Lab.AddXform(*pProfile, nIntent, nInterp, NULL, icXformLutColorimetric, buseMpeTags); |
| 124 | if (result != icCmmStatOk) { |
| 11 | | Assuming 'result' is equal to icCmmStatOk | |
|
| |
| 125 | return result; |
| 126 | } |
| 127 | |
| 128 | result = Lab2Dev2Lab.Begin(); |
| 129 | if (result != icCmmStatOk) { |
| 13 | | Assuming 'result' is equal to icCmmStatOk | |
|
| |
| 130 | return result; |
| 131 | } |
| 132 | |
| 133 | icFloatNumber sPixel[15]; |
| 134 | icFloatNumber devPcs[15], roundPcs1[15], roundPcs2[15]; |
| 135 | |
| 136 | int ndim = icGetSpaceSamples(pProfile->m_Header.colorSpace); |
| 137 | int ndim1 = ndim+1; |
| 138 | |
| 139 | |
| 140 | if (!nGran) { |
| 15 | | Assuming 'nGran' is not equal to 0 | |
|
| |
| 141 | CIccTag* tag = pProfile->FindTag(icSigAToB0Tag + (nIntent == icAbsoluteColorimetric ? icRelativeColorimetric : nIntent)); |
| 142 | |
| 143 | if (!tag) { |
| 144 | std::cerr << "Tag is nullptr!" << std::endl; |
| 145 | return icCmmStatColorNotFound; |
| 146 | } |
| 147 | |
| 148 | try { |
| 149 | if (dynamic_cast<CIccTagLut16*>(tag) != nullptr) { |
| 150 | std::cerr << "Unexpected object type detected!" << std::endl; |
| 151 | |
| 152 | |
| 153 | std::cerr << "Actual object type: " << typeid(*tag).name() << std::endl; |
| 154 | } else { |
| 155 | std::cerr << "Tag is not of expected type!" << std::endl; |
| 156 | std::cerr << "Actual object type: " << typeid(*tag).name() << std::endl; |
| 157 | } |
| 158 | } catch (const std::bad_typeid& e) { |
| 159 | std::cerr << "Caught bad_typeid exception: " << e.what() << std::endl; |
| 160 | return icCmmStatBadLutType; |
| 161 | } |
| 162 | |
| 163 | CIccTagLutAtoB* pTag = dynamic_cast<CIccTagLutAtoB*>(tag); |
| 164 | |
| 165 | |
| 166 | if (!pTag || ndim == 3) { |
| 167 | nGran = 33; |
| 168 | } else { |
| 169 | CIccCLUT* pClut = pTag->GetCLUT(); |
| 170 | nGran = pClut ? (pClut->GridPoints() + 2) : 33; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | int i, j; |
| 175 | icFloatNumber stepsize = (icFloatNumber)(1.0/(icFloatNumber)(nGran-1)); |
| 176 | icFloatNumber* steps = new icFloatNumber[ndim1]; |
| |
| 177 | icFloatNumber nstart = 0.0; |
| 178 | icFloatNumber nEnd = (icFloatNumber)(1.0+stepsize/2.0); |
| 179 | for(j=0; j<ndim1; j++) { |
| 18 | | Assuming 'j' is < 'ndim1' | |
|
| 19 | | Loop condition is true. Entering loop body | |
|
| 20 | | Assuming 'j' is >= 'ndim1' | |
|
| 21 | | Loop condition is false. Execution continues on line 183 | |
|
| 180 | steps[j] = nstart; |
| 181 | } |
| 182 | |
| 183 | while(steps[0]==nstart) { |
| 22 | | Loop condition is false. Execution continues on line 207 | |
|
| 184 | for(j=0; j<ndim; j++) { |
| 185 | sPixel[j] = icMin(steps[j+1],1.0); |
| 186 | } |
| 187 | steps[ndim] = (steps[ndim]+stepsize); |
| 188 | for(i=ndim; i>=0; i--) { |
| 189 | if(steps[i]>nEnd) { |
| 190 | steps[i] = nstart; |
| 191 | steps[i-1] = (steps[i-1]+stepsize); |
| 192 | } |
| 193 | else break; |
| 194 | } |
| 195 | |
| 196 | dev2Lab.Apply(devPcs, sPixel); |
| 197 | Lab2Dev2Lab.Apply(roundPcs1, devPcs); |
| 198 | Lab2Dev2Lab.Apply(roundPcs2, roundPcs1); |
| 199 | |
| 200 | icLabFromPcs(devPcs); |
| 201 | icLabFromPcs(roundPcs1); |
| 202 | icLabFromPcs(roundPcs2); |
| 203 | |
| 204 | Compare(sPixel, devPcs, roundPcs1, roundPcs2); |
| 205 | } |
| 206 | |
| 207 | return icCmmStatOk; |
| 23 | | Potential leak of memory pointed to by 'steps' |
|
| 208 | } |
| 209 | |
| 210 | icStatusCMM CIccEvalCompare::EvaluateProfile(const icChar *szProfilePath, icUInt8Number nGrid, icRenderingIntent nIntent, |
| 211 | icXformInterp nInterp, bool buseMpeTags) |
| 212 | { |
| 213 | CIccProfile *pProfile = ReadIccProfile(szProfilePath); |
| 214 | |
| 215 | if (!pProfile) |
| 1 | Assuming 'pProfile' is non-null | |
|
| |
| 216 | return icCmmStatCantOpenProfile; |
| 217 | |
| 218 | icStatusCMM result = EvaluateProfile(pProfile, nGrid, nIntent, nInterp, buseMpeTags); |
| 3 | | Calling 'CIccEvalCompare::EvaluateProfile' | |
|
| 219 | |
| 220 | delete pProfile; |
| 221 | |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | #ifdef USEREFICCMAXNAMESPACE |
| 226 | } |
| 227 | #endif |