Skip to content

Commit 6e22b3f

Browse files
committed
Fix critical issue #63
1 parent fcca7de commit 6e22b3f

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

libsrc/utils/ImageResampler.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -405,17 +405,9 @@ void ImageResampler::processQImage(
405405

406406

407407

408-
#define LUT() \
409-
{\
410-
*((uint32_t*)&buffer) = *((uint32_t*)startSource);\
411-
uint32_t ind_lutd = LUT_INDEX(buffer[0],buffer[1],buffer[2]);\
412-
*((uint16_t*)startSource) = *((uint16_t*)(&(lutBuffer[ind_lutd])));\
413-
startSource += 3;\
414-
}
415-
416-
void ImageResampler::applyLUT(unsigned char* _source, unsigned int width, unsigned int height, const uint8_t* lutBuffer, const int _hdrToneMappingEnabled)
417-
{
418-
uint8_t buffer[4];
408+
void ImageResampler::applyLUT(uint8_t* _source, unsigned int width, unsigned int height, const uint8_t* lutBuffer, const int _hdrToneMappingEnabled)
409+
{
410+
uint8_t buffer[8];
419411

420412
if (lutBuffer != NULL && _hdrToneMappingEnabled)
421413
{
@@ -430,17 +422,26 @@ void ImageResampler::applyLUT(unsigned char* _source, unsigned int width, unsign
430422
if (_hdrToneMappingEnabled != 2 || y < sizeY || y > height - sizeY)
431423
{
432424
while (startSource < endSource)
433-
LUT();
425+
{
426+
*((uint32_t*)&buffer) = *((uint32_t*)startSource);
427+
uint32_t ind_lutd = LUT_INDEX(buffer[0], buffer[1], buffer[2]);
428+
memcpy(startSource, &(lutBuffer[ind_lutd]), 3);
429+
startSource += 3;
430+
}
434431
}
435432
else
436433
{
437-
for (unsigned int x = 0; x < sizeX; x++)
438-
LUT();
439-
440-
startSource += (width - 2 * static_cast<size_t>(sizeX)) * 3;
441-
434+
unsigned int x = 0;
442435
while (startSource < endSource)
443-
LUT();
436+
{
437+
if (x++ == sizeX)
438+
startSource += (width - 2 * static_cast<size_t>(sizeX)) * 3;
439+
440+
*((uint32_t*)&buffer) = *((uint32_t*)startSource);
441+
uint32_t ind_lutd = LUT_INDEX(buffer[0], buffer[1], buffer[2]);
442+
memcpy(startSource, &(lutBuffer[ind_lutd]), 3);
443+
startSource += 3;
444+
}
444445
}
445446
}
446447
}

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.0.0.0
1+
16.0.0.1

0 commit comments

Comments
 (0)