Differential D9642 Diff 31357 extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h.
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | struct Error { | ||||
| // Primary metric: number of bits required to store the data as a result of | // Primary metric: number of bits required to store the data as a result of | ||||
| // the selected prediction configuration. | // the selected prediction configuration. | ||||
| int num_bits; | int num_bits; | ||||
| // Secondary metric: absolute difference of residuals for the given | // Secondary metric: absolute difference of residuals for the given | ||||
| // configuration. | // configuration. | ||||
| int residual_error; | int residual_error; | ||||
| bool operator<(const Error &e) const { | bool operator<(const Error &e) const { | ||||
| if (num_bits < e.num_bits) | if (num_bits < e.num_bits) { | ||||
| return true; | return true; | ||||
| if (num_bits > e.num_bits) | } | ||||
| if (num_bits > e.num_bits) { | |||||
| return false; | return false; | ||||
| } | |||||
| return residual_error < e.residual_error; | return residual_error < e.residual_error; | ||||
| } | } | ||||
| }; | }; | ||||
| // Computes error for predicting |predicted_val| instead of |actual_val|. | // Computes error for predicting |predicted_val| instead of |actual_val|. | ||||
| // Error is computed as the number of bits needed to encode the difference | // Error is computed as the number of bits needed to encode the difference | ||||
| // between the values. | // between the values. | ||||
| Error ComputeError(const DataTypeT *predicted_val, | Error ComputeError(const DataTypeT *predicted_val, | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | while (corner_id != kInvalidCornerIndex) { | ||||
| if (ComputeParallelogramPrediction( | if (ComputeParallelogramPrediction( | ||||
| p, corner_id, table, *vertex_to_data_map, in_data, num_components, | p, corner_id, table, *vertex_to_data_map, in_data, num_components, | ||||
| &(pred_vals[num_parallelograms][0]))) { | &(pred_vals[num_parallelograms][0]))) { | ||||
| // Parallelogram prediction applied and stored in | // Parallelogram prediction applied and stored in | ||||
| // |pred_vals[num_parallelograms]| | // |pred_vals[num_parallelograms]| | ||||
| ++num_parallelograms; | ++num_parallelograms; | ||||
| // Stop processing when we reach the maximum number of allowed | // Stop processing when we reach the maximum number of allowed | ||||
| // parallelograms. | // parallelograms. | ||||
| if (num_parallelograms == kMaxNumParallelograms) | if (num_parallelograms == kMaxNumParallelograms) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | |||||
| // Proceed to the next corner attached to the vertex. First swing left | // Proceed to the next corner attached to the vertex. First swing left | ||||
| // and if we reach a boundary, swing right from the start corner. | // and if we reach a boundary, swing right from the start corner. | ||||
| if (first_pass) { | if (first_pass) { | ||||
| corner_id = table->SwingLeft(corner_id); | corner_id = table->SwingLeft(corner_id); | ||||
| } else { | } else { | ||||
| corner_id = table->SwingRight(corner_id); | corner_id = table->SwingRight(corner_id); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | for (int num_used_parallelograms = 1; | ||||
| // configuration (permutation of excluded parallelograms). | // configuration (permutation of excluded parallelograms). | ||||
| do { | do { | ||||
| // Reset the multi-parallelogram predicted values. | // Reset the multi-parallelogram predicted values. | ||||
| for (int j = 0; j < num_components; ++j) { | for (int j = 0; j < num_components; ++j) { | ||||
| multi_pred_vals[j] = 0; | multi_pred_vals[j] = 0; | ||||
| } | } | ||||
| uint8_t configuration = 0; | uint8_t configuration = 0; | ||||
| for (int j = 0; j < num_parallelograms; ++j) { | for (int j = 0; j < num_parallelograms; ++j) { | ||||
| if (exluded_parallelograms[j]) | if (exluded_parallelograms[j]) { | ||||
| continue; | continue; | ||||
| } | |||||
| for (int c = 0; c < num_components; ++c) { | for (int c = 0; c < num_components; ++c) { | ||||
| multi_pred_vals[c] += pred_vals[j][c]; | multi_pred_vals[c] += pred_vals[j][c]; | ||||
| } | } | ||||
| // Set jth bit of the configuration. | // Set jth bit of the configuration. | ||||
| configuration |= (1 << j); | configuration |= (1 << j); | ||||
| } | } | ||||
| for (int j = 0; j < num_components; ++j) { | for (int j = 0; j < num_components; ++j) { | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||