@@ -375,17 +375,10 @@ void ImageResampler::processQImage(
375375
376376
377377
378- #define LUT () \
379- {\
380- *((uint32_t *)&buffer) = *((uint32_t *)startSource);\
381- uint32_t ind_lutd = LUT_INDEX (buffer[0 ],buffer[1 ],buffer[2 ]);\
382- *((uint16_t *)startSource) = *((uint16_t *)(&(lutBuffer[ind_lutd])));\
383- startSource += 3 ;\
384- }
385378
386379void ImageResampler::applyLUT (uint8_t * _source, unsigned int width, unsigned int height, const uint8_t * lutBuffer, const int _hdrToneMappingEnabled)
387- {
388- uint8_t buffer[4 ];
380+ {
381+ uint8_t buffer[8 ];
389382
390383 if (lutBuffer != NULL && _hdrToneMappingEnabled)
391384 {
@@ -400,17 +393,26 @@ void ImageResampler::applyLUT(uint8_t* _source, unsigned int width, unsigned int
400393 if (_hdrToneMappingEnabled != 2 || y < sizeY || y > height - sizeY)
401394 {
402395 while (startSource < endSource)
403- LUT ();
396+ {
397+ *((uint32_t *)&buffer) = *((uint32_t *)startSource);
398+ uint32_t ind_lutd = LUT_INDEX (buffer[0 ], buffer[1 ], buffer[2 ]);
399+ memcpy (startSource, &(lutBuffer[ind_lutd]), 3 );
400+ startSource += 3 ;
401+ }
404402 }
405403 else
406404 {
407- for (unsigned int x = 0 ; x < sizeX; x++)
408- LUT ();
409-
410- startSource += (width - 2 * static_cast <size_t >(sizeX)) * 3 ;
411-
405+ unsigned int x = 0 ;
412406 while (startSource < endSource)
413- LUT ();
407+ {
408+ if (x++ == sizeX)
409+ startSource += (width - 2 * static_cast <size_t >(sizeX)) * 3 ;
410+
411+ *((uint32_t *)&buffer) = *((uint32_t *)startSource);
412+ uint32_t ind_lutd = LUT_INDEX (buffer[0 ], buffer[1 ], buffer[2 ]);
413+ memcpy (startSource, &(lutBuffer[ind_lutd]), 3 );
414+ startSource += 3 ;
415+ }
414416 }
415417 }
416418 }
0 commit comments