| 1318 | }; |
| 1319 | |
| 1320 | float BC6HBlockEncoder::EncodePattern(AMD_BC6H_Format& BC6H_data, float error) |
| 1321 | { |
| 1322 | int max_subsets = BC6H_data.region; |
| 1323 | |
| 1324 | // now we have input colors (in), output colors (outB) mapped to a line of ends (EndPoints) |
| 1325 | // and a set of colors on the line equally spaced (indexedcolors) |
| 1326 | // Lets assign indices |
| 1327 | |
| 1328 | //float SrcEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations |
| 1329 | |
| 1330 | // Quantize the EndPoints |
| 1331 | int F16EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations |
| 1332 | int quantEndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // endpoints to save for a given mode |
| 1333 | |
| 1334 | // ModePartition[] starts from 1 to 14 |
| 1335 | // If we have a shape pattern set the loop to check modes from 1 to 10 else from 11 to 14 |
| 1336 | // of the ModePartition table |
| 1337 | int min_mode = (BC6H_data.region == 2) ? 1 : 11; |
| 1338 | int max_mode = (BC6H_data.region == 2) ? MAX_TWOREGION_MODES : MAX_BC6H_MODES; |
| 1339 | |
| 1340 | bool fits[15]; |
| 1341 | memset(fits, 0, sizeof(fits)); |
| 1342 | |
| 1343 | int bestFit = 0; |
| 1344 | int bestEndpointMode = 0; |
| 1345 | float bestError = FLT_MAX; |
| 1346 | float bestEndpointsErr = FLT_MAX; |
| 1347 | float endPointErr = 0; |
| 1348 | |
| 1349 | // Try Optimization for the Mode |
| 1350 | float best_EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; |
| 1351 | int best_Indices[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_SUBSET_SIZE]; |
| 1352 | float opt_toterr[MAX_BC6H_MODES + 1]; |
| 1353 | |
| 1354 | // for debugging |
| 1355 | memset(opt_toterr, 0, sizeof(opt_toterr)); |
| 1356 | |
| 1357 | int numfits = 0; |
| 1358 | // |
| 1359 | // Notes; Only the endpoints are varying; the indices stay fixed in values! |
| 1360 | // so to optimize which mode we need only check the endpoints error against our original to pick the mode to save |
| 1361 | // |
| 1362 | for (int modes = min_mode; modes <= max_mode; ++modes) |
| 1363 | { |
| 1364 | memcpy(best_EndPoints[modes], BC6H_data.fEndPoints, sizeof(BC6H_data.fEndPoints)); |
| 1365 | memcpy(best_Indices[modes], BC6H_data.shape_indices, sizeof(BC6H_data.shape_indices)); |
| 1366 | |
| 1367 | // For some modes the differances between channels can be quite small |
| 1368 | // typically for 6 bits 0..32 an increment of 1 in a channel can cause |
| 1369 | // unwanted color artifacts. |
| 1370 | // Check if computed channel endpoint have a wide spread between channels if not |
| 1371 | // scale all the channels to a avarage so that the variance is not noticed at lower bit values |
| 1372 | //if (m_bAverageEndPoint) |
| 1373 | //{ |
| 1374 | // AverageEndPoint(best_EndPoints[modes], SrcEndPoints, max_subsets, ModeFitOrder[modes]); |
| 1375 | // QuantizeEndPointToF16Prec(SrcEndPoints, F16EndPoints[modes], max_subsets, ModePartition[ModeFitOrder[modes]].nbits); |
| 1376 | //} |
| 1377 | //else |
nothing calls this directly
no test coverage detected