Merge "clarify variable names in HistogramRemap()"

This commit is contained in:
Pascal Massimino 2016-06-08 19:48:37 +00:00 committed by Gerrit Code Review
commit 71be9b8c11

View File

@ -803,24 +803,23 @@ static VP8LHistogram* HistogramCombineStochastic(
// Find the best 'out' histogram for each of the 'in' histograms. // Find the best 'out' histogram for each of the 'in' histograms.
// Note: we assume that out[]->bit_cost_ is already up-to-date. // Note: we assume that out[]->bit_cost_ is already up-to-date.
static void HistogramRemap(const VP8LHistogramSet* const orig_histo, static void HistogramRemap(const VP8LHistogramSet* const in,
const VP8LHistogramSet* const image_histo, const VP8LHistogramSet* const out,
uint16_t* const symbols) { uint16_t* const symbols) {
int i; int i;
VP8LHistogram** const orig_histograms = orig_histo->histograms; VP8LHistogram** const in_histo = in->histograms;
VP8LHistogram** const histograms = image_histo->histograms; VP8LHistogram** const out_histo = out->histograms;
const int orig_histo_size = orig_histo->size; const int in_size = in->size;
const int image_histo_size = image_histo->size; const int out_size = out->size;
if (image_histo_size > 1) { if (out_size > 1) {
for (i = 0; i < orig_histo_size; ++i) { for (i = 0; i < in_size; ++i) {
int best_out = 0; int best_out = 0;
double best_bits = double best_bits = MAX_COST;
HistogramAddThresh(histograms[0], orig_histograms[i], MAX_COST);
int k; int k;
for (k = 1; k < image_histo_size; ++k) { for (k = 0; k < out_size; ++k) {
const double cur_bits = const double cur_bits =
HistogramAddThresh(histograms[k], orig_histograms[i], best_bits); HistogramAddThresh(out_histo[k], in_histo[i], best_bits);
if (cur_bits < best_bits) { if (k == 0 || cur_bits < best_bits) {
best_bits = cur_bits; best_bits = cur_bits;
best_out = k; best_out = k;
} }
@ -828,20 +827,20 @@ static void HistogramRemap(const VP8LHistogramSet* const orig_histo,
symbols[i] = best_out; symbols[i] = best_out;
} }
} else { } else {
assert(image_histo_size == 1); assert(out_size == 1);
for (i = 0; i < orig_histo_size; ++i) { for (i = 0; i < in_size; ++i) {
symbols[i] = 0; symbols[i] = 0;
} }
} }
// Recompute each out based on raw and symbols. // Recompute each out based on raw and symbols.
for (i = 0; i < image_histo_size; ++i) { for (i = 0; i < out_size; ++i) {
HistogramClear(histograms[i]); HistogramClear(out_histo[i]);
} }
for (i = 0; i < orig_histo_size; ++i) { for (i = 0; i < in_size; ++i) {
const int idx = symbols[i]; const int idx = symbols[i];
VP8LHistogramAdd(orig_histograms[i], histograms[idx], histograms[idx]); VP8LHistogramAdd(in_histo[i], out_histo[idx], out_histo[idx]);
} }
} }