Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CubeFile Class Reference
+ Collaboration diagram for CubeFile:

Public Member Functions

void close ()
 
 CubeFile (const char *szFilename)
 
std::string getCopyright ()
 
std::string getDescription ()
 
icFloatNumbergetMaxInput ()
 
icFloatNumbergetMinInput ()
 
bool isCustomInputRange ()
 
bool parse3DTable (icFloatNumber *toLut, icUInt32Number nSizeLut)
 
bool parseHeader ()
 
int sizeLut3D ()
 
 ~CubeFile ()
 

Protected Member Functions

const char * getNext (const char *str)
 
std::string getNextLine ()
 
std::string getTitle (const char *str)
 
bool isEOF ()
 
bool open ()
 
std::string toEnd (const char *str)
 

Protected Attributes

bool m_bLutInVideoRange = false
 
bool m_bLutOutVideoRange = false
 
std::string m_comments
 
FILE * m_f =nullptr
 
icFloatNumber m_fMaxInput [3] = { 1.0f, 1.0f, 1.0f }
 
icFloatNumber m_fMinInput [3] = { 0.0f, 0.0f, 0.0f }
 
std::string m_sFilename
 
int m_sizeLut3D = 0
 
std::string m_title
 

Detailed Description

Definition at line 81 of file iccFromCube.cpp.

Constructor & Destructor Documentation

◆ CubeFile()

CubeFile::CubeFile ( const char * szFilename)
inline

Definition at line 84 of file iccFromCube.cpp.

85 {
86 m_sFilename = szFilename;
87 }
std::string m_sFilename

References m_sFilename.

◆ ~CubeFile()

CubeFile::~CubeFile ( )
inline

Definition at line 88 of file iccFromCube.cpp.

88{ close(); }
void close()

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void CubeFile::close ( )
inline

Definition at line 90 of file iccFromCube.cpp.

91 {
92 if (m_f)
93 fclose(m_f);
94 m_f = nullptr;
95 }

References m_f.

Referenced by main(), and ~CubeFile().

+ Here is the caller graph for this function:

◆ getCopyright()

std::string CubeFile::getCopyright ( )
inline

Definition at line 202 of file iccFromCube.cpp.

202{ return m_comments; }
std::string m_comments

References m_comments.

Referenced by main().

+ Here is the caller graph for this function:

◆ getDescription()

std::string CubeFile::getDescription ( )
inline

Definition at line 201 of file iccFromCube.cpp.

201{ return m_title; }
std::string m_title

References m_title.

Referenced by main().

+ Here is the caller graph for this function:

◆ getMaxInput()

icFloatNumber * CubeFile::getMaxInput ( )
inline

Definition at line 205 of file iccFromCube.cpp.

205{ return m_fMaxInput; }
icFloatNumber m_fMaxInput[3]

References m_fMaxInput.

Referenced by main().

+ Here is the caller graph for this function:

◆ getMinInput()

icFloatNumber * CubeFile::getMinInput ( )
inline

Definition at line 204 of file iccFromCube.cpp.

204{ return m_fMinInput; }
icFloatNumber m_fMinInput[3]

References m_fMinInput.

Referenced by main().

+ Here is the caller graph for this function:

◆ getNext()

const char * CubeFile::getNext ( const char * str)
inlineprotected

Definition at line 279 of file iccFromCube.cpp.

280 {
281 while (*str && *str == ' ') str++;
282 while (*str && *str != ' ') str++;
283 while (*str && *str == ' ') str++;
284
285 return str;
286 }

Referenced by parse3DTable(), and parseHeader().

+ Here is the caller graph for this function:

◆ getNextLine()

std::string CubeFile::getNextLine ( )
inlineprotected

Definition at line 302 of file iccFromCube.cpp.

303 {
304 std::string rv;
305 for (int n=0; n<MAX_LINE_LEN && !isEOF(); n++) {
306 char c = fgetc(m_f);
307
308 if ((c < 0 && feof(m_f)) || c == '\n')
309 break;
310
311 if (c == '\r') //skip unsupported carriage returns
312 continue;
313
314 rv += (unsigned char)c;
315 }
316
317 return rv;
318 }
bool isEOF()
#define MAX_LINE_LEN

References isEOF(), m_f, and MAX_LINE_LEN.

Referenced by parse3DTable(), and parseHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

std::string CubeFile::getTitle ( const char * str)
inlineprotected

Definition at line 264 of file iccFromCube.cpp.

265 {
266 std::string rv;
267 bool bNeedQuote = false;
268 if (*str == '\"') {
269 bNeedQuote = true;
270 str++;
271 }
272 while (*str && (!bNeedQuote || *str != '\"')) {
273 rv += *str++;
274 }
275
276 return rv;
277 }

Referenced by parseHeader().

+ Here is the caller graph for this function:

◆ isCustomInputRange()

bool CubeFile::isCustomInputRange ( )
inline

Definition at line 207 of file iccFromCube.cpp.

208 {
209 if (!icIsNear(m_fMinInput[0], 0.0) || !icIsNear(m_fMinInput[1], 0.0) || !icIsNear(m_fMinInput[2], 0.0) ||
210 !icIsNear(m_fMaxInput[0], 1.0) || !icIsNear(m_fMaxInput[1], 1.0) || !icIsNear(m_fMaxInput[2], 1.0))
211 return true;
212 return false;
213 }
bool icIsNear(icFloatNumber v1, icFloatNumber v2, icFloatNumber nearRange)
Name: icIsNear.
Definition IccUtil.cpp:142

References icIsNear(), m_fMaxInput, and m_fMinInput.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEOF()

bool CubeFile::isEOF ( )
inlineprotected

Definition at line 298 of file iccFromCube.cpp.

298{ return m_f ? feof(m_f)!=0 : true; }

References m_f.

Referenced by getNextLine(), parse3DTable(), and parseHeader().

+ Here is the caller graph for this function:

◆ open()

bool CubeFile::open ( )
inlineprotected

Definition at line 253 of file iccFromCube.cpp.

254 {
255 if (!m_f) {
256 m_f = fopen(m_sFilename.c_str(), "rb");
257 }
258 else {
259 fseek(m_f, 0, SEEK_SET);
260 }
261 return m_f != nullptr;
262 }

References m_f, and m_sFilename.

Referenced by parseHeader().

+ Here is the caller graph for this function:

◆ parse3DTable()

bool CubeFile::parse3DTable ( icFloatNumber * toLut,
icUInt32Number nSizeLut )
inline

Definition at line 216 of file iccFromCube.cpp.

217 {
219
220 //
221 if (!m_sizeLut3D || nSizeLut != num*3)
222 return false;
223
224 const char* next;
225 for (auto n = 0u; n < num && !isEOF();) {
226 std::string line = getNextLine();
227
228 //Skip empty and commented lines
229 if (line[0] == '#' || line.size() == 0)
230 continue;
231 *toLut++ = (icFloatNumber)atof(line.c_str());
232 next = getNext(line.c_str());
233 if (!next) {
234 printf("Invalid 3DLUT entry\n");
235 return false;
236 }
237 *toLut++ = (icFloatNumber)atof(next);
238 next = getNext(next);
239 if (!next) {
240 printf("Invalid 3DLUT entry\n");
241 return false;
242 }
243 *toLut++ = (icFloatNumber)atof(next);
244
245 n++;
246 }
247 return true;
248 }
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
unsigned int icUInt32Number
const char * getNext(const char *str)
std::string getNextLine()

References getNext(), getNextLine(), isEOF(), and m_sizeLut3D.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseHeader()

bool CubeFile::parseHeader ( )
inline

Definition at line 97 of file iccFromCube.cpp.

98 {
99 if (!open())
100 return false;
101
102 m_title.clear();
103 m_comments.clear();
104 m_sizeLut3D = 0;
105 m_fMinInput[0] = m_fMinInput[1] = m_fMinInput[2] = 0.0f;
106 m_fMaxInput[0] = m_fMaxInput[1] = m_fMaxInput[2] = 1.0f;
107
108 bool bAddBlankLine = false;
109 while (!isEOF()) {
110 long pos = ftell(m_f);
111 std::string line = getNextLine();
112
113 if (line[0] == '-' || line[0] == '.' || (line[0] >= '0' && line[0] <= '9')) {
114 //undo getNextLine so it can be 3D table can be parsed
115 fseek(m_f, pos, SEEK_SET);
116 break;
117 }
118
119 if (!line.size()) {
120 if (m_comments.size()) {
121 bAddBlankLine = true;
122 }
123 }
124 else if (line.substr(0, 6) == "TITLE ") {
125 if (m_title.size()) {
126 m_title += "\n";
127 }
128 m_title += getTitle(line.c_str() + 6);
129 }
130 else if (line[0] == '#') {
131 if (bAddBlankLine) {
132 m_comments += "\n";
133 }
134 if (line[1]==' ')
135 m_comments += line.c_str() + 2;
136 else
137 m_comments += line.c_str() + 1;
138 m_comments += '\n';
139
140 bAddBlankLine = false;
141 }
142 else if (line.substr(0, 12) == "LUT_1D_SiZE ") {
143 printf("1DLUTs are not supported\n");
144 return false;
145 }
146 else if (line.substr(0, 12) == "LUT_3D_SIZE ") {
147 m_sizeLut3D = atoi(line.c_str() + 12);
148 }
149 else if (line.substr(0, 19) == "LUT_3D_INPUT_RANGE ") {
150 m_fMinInput[0] = m_fMinInput[1] = m_fMinInput[2] = (icFloatNumber)atof(line.c_str() + 19);
151 const char* next = getNext(line.c_str() + 19);
152 if (next) {
153 m_fMaxInput[0] = m_fMaxInput[1] = m_fMaxInput[2] = (icFloatNumber)atof(next);
154 }
155 }
156 else if (line.substr(0, 11) == "DOMAIN_MIN ") {
157 m_fMinInput[0] = (icFloatNumber)atof(line.c_str() + 11);
158 const char* next = getNext(line.c_str());
159 if (next) {
160 m_fMinInput[1] = (icFloatNumber)atof(next);
161 next = getNext(next);
162 if (next) {
163 m_fMinInput[2] = (icFloatNumber)atof(next);
164 }
165 else
166 m_fMinInput[2] = m_fMinInput[1];
167 }
168 else {
170 }
171 }
172 else if (line.substr(0, 11) == "DOMAIN_MAX ") {
173 m_fMaxInput[0] = (icFloatNumber)atof(line.c_str() + 11);
174 const char* next = getNext(line.c_str());
175 if (next) {
176 m_fMaxInput[1] = (icFloatNumber)atof(next);
177 next = getNext(next);
178 if (next) {
179 m_fMaxInput[2] = (icFloatNumber)atof(next);
180 }
181 else
182 m_fMaxInput[2] = m_fMaxInput[1];
183 }
184 else {
186 }
187 }
188 else if (line.substr(0, 18) == "LUT_IN_VIDEO_RANGE")
189 m_bLutInVideoRange = true;
190 else if (line.substr(0, 19) == "LUT_OUT_VIDEO_RANGE")
191 m_bLutOutVideoRange = true;
192 else {
193 printf("Unknown keyword '%s'\n", line.c_str());
194 return false;
195 }
196 }
197
198 return !isEOF();
199 }
bool open()
std::string getTitle(const char *str)
bool m_bLutInVideoRange
bool m_bLutOutVideoRange

References getNext(), getNextLine(), getTitle(), isEOF(), m_bLutInVideoRange, m_bLutOutVideoRange, m_comments, m_f, m_fMaxInput, m_fMinInput, m_sizeLut3D, m_title, and open().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeLut3D()

int CubeFile::sizeLut3D ( )
inline

Definition at line 215 of file iccFromCube.cpp.

215{ return m_sizeLut3D; }

References m_sizeLut3D.

Referenced by main().

+ Here is the caller graph for this function:

◆ toEnd()

std::string CubeFile::toEnd ( const char * str)
inlineprotected

Definition at line 288 of file iccFromCube.cpp.

289 {
290 std::string rv;
291 while (*str && *str != '\"') {
292 rv += *str++;
293 }
294
295 return rv;
296 }

Member Data Documentation

◆ m_bLutInVideoRange

bool CubeFile::m_bLutInVideoRange = false
protected

Definition at line 329 of file iccFromCube.cpp.

Referenced by parseHeader().

◆ m_bLutOutVideoRange

bool CubeFile::m_bLutOutVideoRange = false
protected

Definition at line 330 of file iccFromCube.cpp.

Referenced by parseHeader().

◆ m_comments

std::string CubeFile::m_comments
protected

Definition at line 327 of file iccFromCube.cpp.

Referenced by getCopyright(), and parseHeader().

◆ m_f

FILE* CubeFile::m_f =nullptr
protected

Definition at line 320 of file iccFromCube.cpp.

Referenced by close(), getNextLine(), isEOF(), open(), and parseHeader().

◆ m_fMaxInput

icFloatNumber CubeFile::m_fMaxInput[3] = { 1.0f, 1.0f, 1.0f }
protected

Definition at line 324 of file iccFromCube.cpp.

324{ 1.0f, 1.0f, 1.0f };

Referenced by getMaxInput(), isCustomInputRange(), and parseHeader().

◆ m_fMinInput

icFloatNumber CubeFile::m_fMinInput[3] = { 0.0f, 0.0f, 0.0f }
protected

Definition at line 323 of file iccFromCube.cpp.

323{ 0.0f, 0.0f, 0.0f };

Referenced by getMinInput(), isCustomInputRange(), and parseHeader().

◆ m_sFilename

std::string CubeFile::m_sFilename
protected

Definition at line 251 of file iccFromCube.cpp.

Referenced by CubeFile(), and open().

◆ m_sizeLut3D

int CubeFile::m_sizeLut3D = 0
protected

Definition at line 322 of file iccFromCube.cpp.

Referenced by parse3DTable(), parseHeader(), and sizeLut3D().

◆ m_title

std::string CubeFile::m_title
protected

Definition at line 326 of file iccFromCube.cpp.

Referenced by getDescription(), and parseHeader().


The documentation for this class was generated from the following file: