169 DataTypeT, TransformT, MeshDataT>::
170 ComputeCorrectionValues(
const DataTypeT *in_data,
CorrType *out_corr,
171 int size,
int num_components,
175 const std::vector<int32_t> *
const vertex_to_data_map =
180 std::vector<DataTypeT> pred_vals[kMaxNumParallelograms];
181 for (
int i = 0; i < kMaxNumParallelograms; ++i) {
182 pred_vals[i].resize(num_components);
186 std::vector<DataTypeT> multi_pred_vals(num_components);
187 entropy_symbols_.resize(num_components);
191 struct PredictionConfiguration {
192 PredictionConfiguration()
193 :
error(), configuration(0), num_used_parallelograms(0) {}
195 uint8_t configuration;
196 int num_used_parallelograms;
197 std::vector<DataTypeT> predicted_value;
198 std::vector<int32_t> residuals;
203 bool exluded_parallelograms[kMaxNumParallelograms];
208 int64_t total_used_parallelograms[kMaxNumParallelograms] = {0};
209 int64_t total_parallelograms[kMaxNumParallelograms] = {0};
211 std::vector<int> current_residuals(num_components);
217 static_cast<int>(this->
mesh_data().data_to_corner_map()->
size()) - 1;
220 this->
mesh_data().data_to_corner_map()->at(p);
225 int num_parallelograms = 0;
226 bool first_pass =
true;
227 while (corner_id != kInvalidCornerIndex) {
229 p, corner_id, table, *vertex_to_data_map, in_data, num_components,
230 &(pred_vals[num_parallelograms][0]))) {
233 ++num_parallelograms;
236 if (num_parallelograms == kMaxNumParallelograms) {
244 corner_id = table->SwingLeft(corner_id);
246 corner_id = table->SwingRight(corner_id);
248 if (corner_id == start_corner_id) {
251 if (corner_id == kInvalidCornerIndex && first_pass) {
253 corner_id = table->SwingRight(start_corner_id);
258 const int dst_offset = p * num_components;
265 PredictionConfiguration best_prediction;
269 const int src_offset = (p - 1) * num_components;
270 error = ComputeError(in_data + src_offset, in_data + dst_offset,
271 ¤t_residuals[0], num_components);
273 if (num_parallelograms > 0) {
274 total_parallelograms[num_parallelograms - 1] += num_parallelograms;
275 const int64_t new_overhead_bits =
276 ComputeOverheadBits(total_used_parallelograms[num_parallelograms - 1],
277 total_parallelograms[num_parallelograms - 1]);
278 error.num_bits += new_overhead_bits;
281 best_prediction.error =
error;
282 best_prediction.configuration = 0;
283 best_prediction.num_used_parallelograms = 0;
284 best_prediction.predicted_value.assign(
285 in_data + src_offset, in_data + src_offset + num_components);
286 best_prediction.residuals.assign(current_residuals.begin(),
287 current_residuals.end());
290 for (
int num_used_parallelograms = 1;
291 num_used_parallelograms <= num_parallelograms;
292 ++num_used_parallelograms) {
294 std::fill(exluded_parallelograms,
295 exluded_parallelograms + num_parallelograms,
true);
298 for (
int j = 0; j < num_used_parallelograms; ++j) {
299 exluded_parallelograms[j] =
false;
305 for (
int j = 0; j < num_components; ++j) {
306 multi_pred_vals[j] = 0;
308 uint8_t configuration = 0;
309 for (
int j = 0; j < num_parallelograms; ++j) {
310 if (exluded_parallelograms[j]) {
313 for (
int c = 0; c < num_components; ++c) {
314 multi_pred_vals[c] += pred_vals[j][c];
317 configuration |= (1 << j);
320 for (
int j = 0; j < num_components; ++j) {
321 multi_pred_vals[j] /= num_used_parallelograms;
323 error = ComputeError(multi_pred_vals.data(), in_data + dst_offset,
324 ¤t_residuals[0], num_components);
325 if (num_parallelograms > 0) {
326 const int64_t new_overhead_bits = ComputeOverheadBits(
327 total_used_parallelograms[num_parallelograms - 1] +
328 num_used_parallelograms,
329 total_parallelograms[num_parallelograms - 1]);
332 error.num_bits += new_overhead_bits;
334 if (
error < best_prediction.error) {
335 best_prediction.error =
error;
336 best_prediction.configuration = configuration;
337 best_prediction.num_used_parallelograms = num_used_parallelograms;
338 best_prediction.predicted_value.assign(multi_pred_vals.begin(),
339 multi_pred_vals.end());
340 best_prediction.residuals.assign(current_residuals.begin(),
341 current_residuals.end());
343 }
while (std::next_permutation(
344 exluded_parallelograms, exluded_parallelograms + num_parallelograms));
346 if (num_parallelograms > 0) {
347 total_used_parallelograms[num_parallelograms - 1] +=
348 best_prediction.num_used_parallelograms;
353 for (
int i = 0; i < num_components; ++i) {
354 entropy_symbols_[i] =
357 entropy_tracker_.Push(entropy_symbols_.data(), num_components);
359 for (
int i = 0; i < num_parallelograms; ++i) {
360 if ((best_prediction.configuration & (1 << i)) == 0) {
362 is_crease_edge_[num_parallelograms - 1].push_back(
true);
366 is_crease_edge_[num_parallelograms - 1].push_back(
false);
369 this->
transform().ComputeCorrection(in_data + dst_offset,
370 best_prediction.predicted_value.data(),
371 out_corr + dst_offset);
374 for (
int i = 0; i < num_components; ++i) {
375 pred_vals[0][i] =
static_cast<DataTypeT
>(0);
377 this->
transform().ComputeCorrection(in_data, pred_vals[0].
data(), out_corr);
lazy data
Definition meshpage.php:1583
n< br > font size
Definition meshpage.php:3536