Skip to content

Commit

Permalink
Fix: Color management on blocks > 4Gb fail
Browse files Browse the repository at this point in the history
Fix an error on huge memory blocks. size_t is part of C99
  • Loading branch information
mm2 committed Mar 11, 2024
1 parent 2e7d174 commit c429e37
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_16_tethra.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void PerformanceEval16(struct _cmstransform_struct *CMMcargo,

int in16, out16; // Used by macros!

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;

cmsUInt32Number dwInFormat = cmsGetTransformInputFormat((cmsHTRANSFORM)CMMcargo);
cmsUInt32Number dwOutFormat = cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_8_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static void FastEvaluateGrayCurves8(struct _cmstransform_struct *CMMcargo,
cmsUInt8Number* gout;
cmsUInt8Number* aout = NULL;

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;

Curves8Data* Data = (Curves8Data*)_cmsGetTransformUserData(CMMcargo);

Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_8_matsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void MatShaperXform8(struct _cmstransform_struct *CMMcargo,
cmsUInt8Number* bout;
cmsUInt8Number* aout = NULL;

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;

_cmsComputeComponentIncrements(cmsGetTransformInputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneIn, NULL, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneOut, NULL, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_8_matsh_sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void MatShaperXform8SSE(struct _cmstransform_struct *CMMcargo,
cmsUInt8Number* bout;
cmsUInt8Number* aout = NULL;

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;


__m128 mat0 = _mm_load_ps(p->Mat[0]);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_8_tethra.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void PerformanceEval8(struct _cmstransform_struct *CMMcargo,
const cmsUInt8Number* bin;
const cmsUInt8Number* ain = NULL;

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;

_cmsComputeComponentIncrements(cmsGetTransformInputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneIn, NULL, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneOut, NULL, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_15mats.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void MatShaperXform(struct _cmstransform_struct *CMMcargo,
cmsUInt8Number* bout;
cmsUInt8Number* aout = NULL;

cmsUInt32Number nalpha, strideIn, strideOut;
size_t nalpha, strideIn, strideOut;

_cmsComputeComponentIncrements(cmsGetTransformInputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneIn, NULL, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneOut, NULL, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_cmyk.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void FloatCMYKCLUTEval(struct _cmstransform_struct *CMMcargo,
cmsUInt32Number OutputFormat = cmsGetTransformOutputFormat((cmsHTRANSFORM) CMMcargo);

cmsUInt32Number nchans, nalpha;
cmsUInt32Number strideIn, strideOut;
size_t strideIn, strideOut;

_cmsComputeComponentIncrements(InputFormat, Stride->BytesPerPlaneIn, &nchans, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(OutputFormat, Stride->BytesPerPlaneOut, &nchans, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void FastEvaluateFloatRGBCurves(struct _cmstransform_struct *CMMcargo,
CurvesFloatData* Data = (CurvesFloatData*) _cmsGetTransformUserData(CMMcargo);

cmsUInt32Number nchans, nalpha;
cmsUInt32Number strideIn, strideOut;
size_t strideIn, strideOut;

_cmsComputeComponentIncrements(InputFormat, Stride->BytesPerPlaneIn, &nchans, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(OutputFormat, Stride->BytesPerPlaneOut, &nchans, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_lab.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void LabCLUTEval(struct _cmstransform_struct* CMMcargo,
cmsUInt32Number OutputFormat = cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo);

cmsUInt32Number nchans, nalpha;
cmsUInt32Number strideIn, strideOut;
size_t strideIn, strideOut;

_cmsComputeComponentIncrements(InputFormat, Stride->BytesPerPlaneIn, &nchans, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(OutputFormat, Stride->BytesPerPlaneOut, &nchans, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_matsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MatShaperFloat(struct _cmstransform_struct* CMMcargo,
cmsUInt8Number* aout = NULL;

cmsUInt32Number nchans, nalpha;
cmsUInt32Number strideIn, strideOut;
size_t strideIn, strideOut;

_cmsComputeComponentIncrements(cmsGetTransformInputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneIn, &nchans, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo), Stride->BytesPerPlaneOut, &nchans, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fast_float/src/fast_float_tethra.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void FloatCLUTEval(struct _cmstransform_struct* CMMcargo,
cmsUInt32Number OutputFormat = cmsGetTransformOutputFormat((cmsHTRANSFORM)CMMcargo);

cmsUInt32Number nchans, nalpha;
cmsUInt32Number strideIn, strideOut;
size_t strideIn, strideOut;

_cmsComputeComponentIncrements(InputFormat, Stride->BytesPerPlaneIn, &nchans, &nalpha, SourceStartingOrder, SourceIncrements);
_cmsComputeComponentIncrements(OutputFormat, Stride->BytesPerPlaneOut, &nchans, &nalpha, DestStartingOrder, DestIncrements);
Expand Down
8 changes: 4 additions & 4 deletions src/cmsalpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
cmsUInt8Number* SourcePtr;
cmsUInt8Number* DestPtr;

cmsUInt32Number SourceStrideIncrement = 0;
cmsUInt32Number DestStrideIncrement = 0;
size_t SourceStrideIncrement = 0;
size_t DestStrideIncrement = 0;

// The loop itself
for (i = 0; i < LineCount; i++) {
Expand All @@ -611,8 +611,8 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];

cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];
size_t SourceStrideIncrements[cmsMAXCHANNELS];
size_t DestStrideIncrements[cmsMAXCHANNELS];

memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
Expand Down
50 changes: 25 additions & 25 deletions src/cmsxform.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void FloatXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS], fOut[cmsMAXCHANNELS];
cmsFloat32Number OutOfGamut;
cmsUInt32Number i, j, c, strideIn, strideOut;
size_t i, j, c, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand Down Expand Up @@ -332,7 +332,7 @@ void NullFloatXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsFloat32Number fIn[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand Down Expand Up @@ -370,7 +370,7 @@ void NullXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand All @@ -380,17 +380,17 @@ void NullXFORM(_cmsTRANSFORM* p,

for (i = 0; i < LineCount; i++) {

accum = (cmsUInt8Number*)in + strideIn;
output = (cmsUInt8Number*)out + strideOut;
accum = (cmsUInt8Number*)in + strideIn;
output = (cmsUInt8Number*)out + strideOut;

for (j = 0; j < PixelsPerLine; j++) {
for (j = 0; j < PixelsPerLine; j++) {

accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
output = p->ToOutput(p, wIn, output, Stride->BytesPerPlaneOut);
}
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
output = p->ToOutput(p, wIn, output, Stride->BytesPerPlaneOut);
}

strideIn += Stride->BytesPerLineIn;
strideOut += Stride->BytesPerLineOut;
strideIn += Stride->BytesPerLineIn;
strideOut += Stride->BytesPerLineOut;
}

}
Expand All @@ -408,7 +408,7 @@ void PrecalculatedXFORM(_cmsTRANSFORM* p,
CMSREGISTER cmsUInt8Number* accum;
CMSREGISTER cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand Down Expand Up @@ -471,7 +471,7 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
cmsUInt8Number* accum;
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand All @@ -482,18 +482,18 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,

for (i = 0; i < LineCount; i++) {

accum = (cmsUInt8Number*)in + strideIn;
output = (cmsUInt8Number*)out + strideOut;
accum = (cmsUInt8Number*)in + strideIn;
output = (cmsUInt8Number*)out + strideOut;

for (j = 0; j < PixelsPerLine; j++) {
for (j = 0; j < PixelsPerLine; j++) {

accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
TransformOnePixelWithGamutCheck(p, wIn, wOut);
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
}
accum = p->FromInput(p, wIn, accum, Stride->BytesPerPlaneIn);
TransformOnePixelWithGamutCheck(p, wIn, wOut);
output = p->ToOutput(p, wOut, output, Stride->BytesPerPlaneOut);
}

strideIn += Stride->BytesPerLineIn;
strideOut += Stride->BytesPerLineOut;
strideIn += Stride->BytesPerLineIn;
strideOut += Stride->BytesPerLineOut;
}
}

Expand All @@ -511,7 +511,7 @@ void CachedXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
_cmsCACHE Cache;
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand Down Expand Up @@ -566,7 +566,7 @@ void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
_cmsCACHE Cache;
cmsUInt32Number i, j, strideIn, strideOut;
size_t i, j, strideIn, strideOut;

_cmsHandleExtraChannels(p, in, out, PixelsPerLine, LineCount, Stride);

Expand Down Expand Up @@ -683,7 +683,7 @@ void _cmsTransform2toTransformAdaptor(struct _cmstransform_struct *CMMcargo,
const cmsStride* Stride)
{

cmsUInt32Number i, strideIn, strideOut;
size_t i, strideIn, strideOut;

_cmsHandleExtraChannels(CMMcargo, InputBuffer, OutputBuffer, PixelsPerLine, LineCount, Stride);

Expand Down
Binary file modified testbed/new.icc
Binary file not shown.

0 comments on commit c429e37

Please sign in to comment.