36,7 → 36,7 |
#define BUFSIZE 4L<<10 |
#define MAXLINE 0x200 |
|
FFLoadingResult readparams_afs_pff(Handle h){ |
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder){ |
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
char linebuf[MAXLINE] = { 0 }; |
char curexpr[MAXEXPR] = { 0 }; |
67,8 → 67,7 |
/* process complete line */ |
if(linecnt==0){ |
if(strcmp(linebuf,"%RGB-1.0") != 0){ |
// Note: We don't set res to an error message, because we cannot be sure if it is a valid file in regards to a different data type |
// We only set res to an error message, if we are sure that it is an AFS file which is indeed wrong. |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
break; |
} |
}else if(linecnt<=8){ |
88,7 → 87,15 |
}else{ |
/* it's an empty line: we've completed the expr string */ |
*q = '\0'; |
if (premiereOrder) { |
// Premiere has the order BGRA , while Photoshop (and our internal order) is RGBA |
if (exprcnt == 0) strcpy(gdata->parm.szFormula[2], curexpr); |
else if (exprcnt == 2) strcpy(gdata->parm.szFormula[0], curexpr); |
else strcpy(gdata->parm.szFormula[exprcnt], curexpr); |
} |
else { |
strcpy(gdata->parm.szFormula[exprcnt], curexpr); |
} |
|
if(++exprcnt == 4){ |
res = 0; |
854,23 → 861,15 |
if ((h = readfileintohandle(refnum))) { |
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h); |
char* q = PILOCKHANDLE(h, false); |
char protocol[256]; |
|
char out[256]; |
if (_gufReadProperty(q, count, "GUF", "Protocol", out, sizeof(out))) { |
if (strcmp(out, "1") != 0) { |
PIUNLOCKHANDLE(h); |
PIDISPOSEHANDLE(h); |
FSClose(refnum); |
return MSG_INCOMPATIBLE_GUF_FILE_ID; |
if (!_gufReadProperty(q, count, "GUF", "Protocol", protocol, sizeof(protocol))) { |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
} |
else if (strcmp(protocol, "1") != 0) { |
res = MSG_INCOMPATIBLE_GUF_FILE_ID; |
} |
else { |
PIUNLOCKHANDLE(h); |
PIDISPOSEHANDLE(h); |
FSClose(refnum); |
return MSG_INCOMPATIBLE_GUF_FILE_ID; |
} |
if (_gufReadProperty(q, count, "Info", "Title", out, sizeof(out))) { |
int i; |
char tmp[256]; |
char* tmp2; |
946,14 → 945,12 |
|
if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){ |
if( (h = readfileintohandle(r)) ){ |
if( 0 == (res = readparams_afs_pff(h)) ) { |
if (fileHasExtension(sfr, TEXT(".pff"))) { |
// If it is a Premiere settings file, we need to swap the channels red and blue |
// We just swap the pointers! |
char tmp[MAXEXPR]; |
strcpy(tmp, gdata->parm.szFormula[0]); |
strcpy(gdata->parm.szFormula[0], gdata->parm.szFormula[2]); |
strcpy(gdata->parm.szFormula[2], tmp); |
if( 0 != (res = readparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff")))) ) { |
// If .afs and .pff files are not recognized, then it is a hard error. |
// If a .txt file has no "%RGB1.0" signature, then it is OK and |
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID to inform the caller that they shall continue trying formats. |
if (!fileHasExtension(sfr, TEXT(".afs")) && !fileHasExtension(sfr, TEXT(".pff"))) { |
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
} |
} |
|
970,12 → 967,14 |
FFLoadingResult readfile_ffl(StandardFileReply* sfr) { |
FILEREF rTmp, refnum; |
Handle h, hTmp; |
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
FFLoadingResult res = 0; |
StandardFileReply sfrTmp; |
OSErr e; |
char* p, * start; |
size_t est; |
int foundFilters = 0; |
|
// TODO: sollte von außerhalb gesteuert werden [auch bei anderen] |
if (!fileHasExtension(sfr, TEXT(".ffl"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID; |
|
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) { |
990,11 → 989,9 |
// This is required to make strtok work, because q is not zero-terminated... |
q2 = (char*)malloc(count + 1/*NUL byte*/); |
if (q2 == NULL) { |
PIUNLOCKHANDLE(h); |
PIDISPOSEHANDLE(h); |
FSClose(refnum); |
return MSG_OUT_OF_MEMORY_ID; |
res = MSG_OUT_OF_MEMORY_ID; |
} |
else { |
memcpy(q2, q, count); |
q2[count] = '\0'; |
|
1007,11 → 1004,8 |
} |
if (lineNumber == 0) { |
if (strcmp(token2,"FFL1.0") != 0) { |
free(q2); |
PIUNLOCKHANDLE(h); |
PIDISPOSEHANDLE(h); |
FSClose(refnum); |
return MSG_INVALID_FILE_SIGNATURE_ID; |
res = MSG_INVALID_FILE_SIGNATURE_ID; |
break; |
} |
} |
else if (lineNumber == 1) { |
1150,6 → 1144,7 |
lineNumber++; |
token = strtok(NULL, "\n"); |
} |
} |
|
free(q2); |
|
1159,6 → 1154,8 |
FSClose(refnum); |
} |
|
// TODO: show a different message when no filters were processed for some reason... |
return MSG_FFL_CONVERTED_ID; |
if (res == 0) { |
res = foundFilters == 0 ? MSG_FFL_NO_FILTERS_DETECTED_ID : MSG_FFL_CONVERTED_ID; |
} |
return res; |
} |