| 42 | } |
| 43 | |
| 44 | void LutLoader::loadLutFile(Logger* _log, PixelFormat color, const QList<QString>& files) |
| 45 | { |
| 46 | bool is_yuv = (color == PixelFormat::YUYV); |
| 47 | |
| 48 | _lutBufferInit = false; |
| 49 | |
| 50 | if (color != PixelFormat::RGB24 && color != PixelFormat::YUYV) |
| 51 | { |
| 52 | if (_log) Error(_log, "Unsupported mode for loading LUT table: %s", QSTRING_CSTR(pixelFormatToString(color))); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | if (_hdrToneMappingEnabled || is_yuv) |
| 57 | { |
| 58 | for (QString fileName3d : files) |
| 59 | { |
| 60 | QFile file(fileName3d); |
| 61 | bool compressed = false; |
| 62 | |
| 63 | if (file.open(QIODevice::ReadOnly) |
| 64 | #ifdef ENABLE_ZSTD |
| 65 | || [&]() {file.setFileName(fileName3d + ".zst"); compressed = true; return file.open(QIODevice::ReadOnly); } () |
| 66 | #endif |
| 67 | ) |
| 68 | { |
| 69 | int length; |
| 70 | |
| 71 | if (_log) |
| 72 | { |
| 73 | Debug(_log, "LUT file found: %s (%s)", QSTRING_CSTR(file.fileName()), (compressed) ? "compressed" : "uncompressed"); |
| 74 | } |
| 75 | |
| 76 | length = file.size(); |
| 77 | |
| 78 | if ((length == LUT_FILE_SIZE * 3) || compressed) |
| 79 | { |
| 80 | int index = 0; |
| 81 | |
| 82 | if (is_yuv && _hdrToneMappingEnabled) |
| 83 | { |
| 84 | if (_log) Debug(_log, "Index 1 for HDR YUV"); |
| 85 | index = LUT_FILE_SIZE; |
| 86 | } |
| 87 | else if (is_yuv) |
| 88 | { |
| 89 | if (_log) Debug(_log, "Index 2 for YUV"); |
| 90 | index = LUT_FILE_SIZE * 2; |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | if (_log) Debug(_log, "Index 0 for HDR RGB"); |
| 95 | } |
| 96 | |
| 97 | _lut.resize(LUT_FILE_SIZE + LUT_MEMORY_ALIGN); |
| 98 | |
| 99 | if (!compressed) |
| 100 | { |
| 101 | file.seek(index); |