This baker is based on what was done for ResolveCube and HDL. We enhanced it to use a half-domain Lut1D for the shaper to better represent transforms expecting linear inputs. TODO: The CLF format is more powerful than those older formats and there is no need to be limited to a Lut1D + Lut3D structure -- more ops could be used when necessary for a more accurate bake.
| 1347 | // no need to be limited to a Lut1D + Lut3D structure -- more ops could be used |
| 1348 | // when necessary for a more accurate bake. |
| 1349 | void LocalFileFormat::bake(const Baker & baker, |
| 1350 | const std::string & formatName, |
| 1351 | std::ostream & ostream) const |
| 1352 | { |
| 1353 | static constexpr int DEFAULT_1D_SIZE = 4096; |
| 1354 | static constexpr int DEFAULT_3D_SIZE = 64; |
| 1355 | |
| 1356 | // NB: By default, the shaper uses a half-domain LUT1D, which is always 65536 entries. |
| 1357 | // If the user requests some other size, a typical (non-half-domain) LUT1D will be used. |
| 1358 | if (formatName != FILEFORMAT_CTF && formatName != FILEFORMAT_CLF) |
| 1359 | { |
| 1360 | std::ostringstream os; |
| 1361 | os << "Unknown CLF/CTF file format name, '"; |
| 1362 | os << formatName << "'."; |
| 1363 | throw Exception(os.str().c_str()); |
| 1364 | } |
| 1365 | |
| 1366 | // |
| 1367 | // Initialize config and data. |
| 1368 | // |
| 1369 | |
| 1370 | ConstConfigRcPtr config = baker.getConfig(); |
| 1371 | |
| 1372 | int onedSize = baker.getCubeSize(); |
| 1373 | if (onedSize == -1) |
| 1374 | { |
| 1375 | onedSize = DEFAULT_1D_SIZE; |
| 1376 | } |
| 1377 | |
| 1378 | int cubeSize = baker.getCubeSize(); |
| 1379 | if (cubeSize == -1) |
| 1380 | { |
| 1381 | cubeSize = DEFAULT_3D_SIZE; |
| 1382 | } |
| 1383 | cubeSize = std::max(2, cubeSize); // smallest cube is 2x2x2 |
| 1384 | |
| 1385 | // Get spaces from baker. |
| 1386 | const std::string shaperSpace = baker.getShaperSpace(); |
| 1387 | |
| 1388 | // |
| 1389 | // Determine required LUT type. |
| 1390 | // |
| 1391 | |
| 1392 | constexpr int CTF_1D = 1; // 1D LUT version number |
| 1393 | constexpr int CTF_3D = 2; // 3D LUT version number |
| 1394 | constexpr int CTF_1D_3D = 3; // 3D LUT with 1D prelut |
| 1395 | |
| 1396 | int required_lut = -1; |
| 1397 | |
| 1398 | ConstCPUProcessorRcPtr inputToTarget = GetInputToTargetProcessor(baker); |
| 1399 | |
| 1400 | if (inputToTarget->hasChannelCrosstalk()) |
| 1401 | { |
| 1402 | if (shaperSpace.empty()) |
| 1403 | { |
| 1404 | // Has crosstalk, but no shaper, so need 3D LUT. |
| 1405 | required_lut = CTF_3D; |
| 1406 | } |
nothing calls this directly
no test coverage detected