| 3312 | } |
| 3313 | |
| 3314 | CGU_FLOAT EncodePattern(BC6H_Encode_local* BC6H_data, CGU_FLOAT error) |
| 3315 | { |
| 3316 | CGU_INT8 max_subsets = BC6H_data->region; |
| 3317 | |
| 3318 | // now we have input colors (in), output colors (outB) mapped to a line of ends (EndPoints) |
| 3319 | // and a set of colors on the line equally spaced (indexedcolors) |
| 3320 | // Lets assign indices |
| 3321 | |
| 3322 | //CGU_FLOAT SrcEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations |
| 3323 | |
| 3324 | // Quantize the EndPoints |
| 3325 | CGU_INT F16EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations |
| 3326 | CGU_INT quantEndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // endpoints to save for a given mode |
| 3327 | |
| 3328 | // ModePartition[] starts from 1 to 14 |
| 3329 | // If we have a shape pattern set the loop to check modes from 1 to 10 else from 11 to 14 |
| 3330 | // of the ModePartition table |
| 3331 | CGU_INT min_mode = (BC6H_data->region == 2) ? 1 : 11; |
| 3332 | CGU_INT max_mode = (BC6H_data->region == 2) ? MAX_TWOREGION_MODES : MAX_BC6H_MODES; |
| 3333 | |
| 3334 | CGU_BOOL fits[15]; |
| 3335 | memset((CGU_UINT8*)fits, 0, sizeof(fits)); |
| 3336 | |
| 3337 | CGU_INT bestFit = 0; |
| 3338 | CGU_INT bestEndpointMode = 0; |
| 3339 | CGU_FLOAT bestError = CMP_FLOAT_MAX; |
| 3340 | CGU_FLOAT bestEndpointsErr = CMP_FLOAT_MAX; |
| 3341 | CGU_FLOAT endPointErr = 0; |
| 3342 | |
| 3343 | // Try Optimization for the Mode |
| 3344 | CGU_FLOAT best_EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; |
| 3345 | CGU_INT best_Indices[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_SUBSET_SIZE]; |
| 3346 | CGU_FLOAT opt_toterr[MAX_BC6H_MODES + 1] = {0}; |
| 3347 | |
| 3348 | memset((CGU_UINT8*)opt_toterr, 0, sizeof(opt_toterr)); |
| 3349 | |
| 3350 | CGU_INT numfits = 0; |
| 3351 | // |
| 3352 | // Notes; Only the endpoints are varying; the indices stay fixed in values! |
| 3353 | // so to optimize which mode we need only check the endpoints error against our original to pick the mode to save |
| 3354 | // |
| 3355 | for (CGU_INT modes = min_mode; modes <= max_mode; ++modes) |
| 3356 | { |
| 3357 | memcpy((CGU_UINT8*)best_EndPoints[modes], (CGU_UINT8*)BC6H_data->fEndPoints, sizeof(BC6H_data->fEndPoints)); |
| 3358 | memcpy((CGU_UINT8*)best_Indices[modes], (CGU_UINT8*)BC6H_data->shape_indices, sizeof(BC6H_data->shape_indices)); |
| 3359 | |
| 3360 | { |
| 3361 | QuantizeEndPointToF16Prec(best_EndPoints[modes], F16EndPoints[modes], max_subsets, ModePartition[ModeFitOrder[modes]].nbits, BC6H_data->issigned); |
| 3362 | } |
| 3363 | |
| 3364 | // Indices data to save for given mode |
| 3365 | SwapIndices(F16EndPoints[modes], best_Indices[modes], BC6H_data->entryCount, max_subsets, ModeFitOrder[modes], BC6H_data->d_shape_index); |
| 3366 | CGU_BOOL transformfit = TransformEndPoints(BC6H_data, F16EndPoints[modes], quantEndPoints[modes], max_subsets, ModeFitOrder[modes]); |
| 3367 | fits[modes] = endpts_fit(F16EndPoints[modes], quantEndPoints[modes], ModeFitOrder[modes], max_subsets, BC6H_data->issigned); |
| 3368 | |
| 3369 | if (fits[modes] && transformfit) |
| 3370 | { |
| 3371 | numfits++; |
no test coverage detected