diff options
author | mm2 <marti.maria@littlecms.com> | 2022-03-08 21:27:38 +0100 |
---|---|---|
committer | mm2 <marti.maria@littlecms.com> | 2022-03-08 21:27:38 +0100 |
commit | c3d6caa1f332f08ad67e9763a5b4eae82911bde3 (patch) | |
tree | a51fa681a031e26d59d3859b7741c9d1ca2beffe /src/cmsio0.c | |
parent | a2420c5c101dc1f4eba9b39a961f3945c5b38520 (diff) | |
download | lcms2-c3d6caa1f332f08ad67e9763a5b4eae82911bde3.tar.gz |
Update raw tag comments
Thanks to Phil Race to point the comments were not so accurate.
Diffstat (limited to 'src/cmsio0.c')
-rw-r--r-- | src/cmsio0.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cmsio0.c b/src/cmsio0.c index e369e0d..0ef1fa1 100644 --- a/src/cmsio0.c +++ b/src/cmsio0.c @@ -1776,11 +1776,9 @@ Error: } -// Read and write raw data. The only way those function would work and keep consistence with normal read and write -// is to do an additional step of serialization. That means, readRaw would issue a normal read and then convert the obtained -// data to raw bytes by using the "write" serialization logic. And vice-versa. I know this may end in situations where -// raw data written does not exactly correspond with the raw data proposed to cmsWriteRaw data, but this approach allows -// to write a tag as raw data and the read it as handled. +// Read and write raw data. Read/Write Raw/cooked pairs try to maintain consistency within the pair. Some sequences +// raw/cooked would work, but at a cost. Data "cooked" may be converted to "raw" by using the "write" serialization logic. +// In general it is better to avoid mixing pairs. cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* data, cmsUInt32Number BufferSize) { @@ -1797,6 +1795,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0; // Search for given tag in ICC profile directory + i = _cmsSearchTag(Icc, sig, TRUE); if (i < 0) goto Error; // Not found, @@ -1808,6 +1807,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si TagSize = Icc ->TagSizes[i]; // read the data directly, don't keep copy + if (data != NULL) { if (BufferSize < TagSize) @@ -1826,6 +1826,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si // The data has been already read, or written. But wait!, maybe the user chose to save as // raw data. In this case, return the raw data directly + if (Icc ->TagSaveAsRaw[i]) { if (data != NULL) { @@ -1845,8 +1846,8 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si } // Already read, or previously set by cmsWriteTag(). We need to serialize that - // data to raw in order to maintain consistency. - + // data to raw to get something that makes sense + _cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex); Object = cmsReadTag(hProfile, sig); if (!_cmsLockMutex(Icc->ContextID, Icc ->UsrMutex)) return 0; |