mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-29 15:08:20 +01:00
Code cleanup for HistogramRemap.
Avoid call to HistogramAddThresh when there's only one Histogram image. Change-Id: I43b09e8e2d218c95969567034224777dcce37ab9
This commit is contained in:
parent
f5c04d64b7
commit
f4059d0c7d
@ -640,12 +640,15 @@ static void HistogramRemap(const VP8LHistogramSet* const orig_histo,
|
|||||||
int i;
|
int i;
|
||||||
VP8LHistogram** const orig_histograms = orig_histo->histograms;
|
VP8LHistogram** const orig_histograms = orig_histo->histograms;
|
||||||
VP8LHistogram** const histograms = image_histo->histograms;
|
VP8LHistogram** const histograms = image_histo->histograms;
|
||||||
for (i = 0; i < orig_histo->size; ++i) {
|
const int orig_histo_size = orig_histo->size;
|
||||||
|
const int image_histo_size = image_histo->size;
|
||||||
|
if (image_histo_size > 1) {
|
||||||
|
for (i = 0; i < orig_histo_size; ++i) {
|
||||||
int best_out = 0;
|
int best_out = 0;
|
||||||
double best_bits =
|
double best_bits =
|
||||||
HistogramAddThresh(histograms[0], orig_histograms[i], MAX_COST);
|
HistogramAddThresh(histograms[0], orig_histograms[i], MAX_COST);
|
||||||
int k;
|
int k;
|
||||||
for (k = 1; k < image_histo->size; ++k) {
|
for (k = 1; k < image_histo_size; ++k) {
|
||||||
const double cur_bits =
|
const double cur_bits =
|
||||||
HistogramAddThresh(histograms[k], orig_histograms[i], best_bits);
|
HistogramAddThresh(histograms[k], orig_histograms[i], best_bits);
|
||||||
if (cur_bits < best_bits) {
|
if (cur_bits < best_bits) {
|
||||||
@ -655,13 +658,19 @@ static void HistogramRemap(const VP8LHistogramSet* const orig_histo,
|
|||||||
}
|
}
|
||||||
symbols[i] = best_out;
|
symbols[i] = best_out;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
assert(image_histo_size == 1);
|
||||||
|
for (i = 0; i < orig_histo_size; ++i) {
|
||||||
|
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 < image_histo_size; ++i) {
|
||||||
HistogramClear(histograms[i]);
|
HistogramClear(histograms[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < orig_histo->size; ++i) {
|
for (i = 0; i < orig_histo_size; ++i) {
|
||||||
const int idx = symbols[i];
|
const int idx = symbols[i];
|
||||||
VP8LHistogramAdd(orig_histograms[i], histograms[idx], histograms[idx]);
|
VP8LHistogramAdd(orig_histograms[i], histograms[idx], histograms[idx]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user