mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
fix the -g/O3 discrepancy for 32bit compile
in debug mode, some float operations see their intermediate values stored in memory rather than staying in the FPU (which is 80bit precision). Several fixes are possible (breaking long calculations into atomic steps for instance), but simpler of all is just about turning the cost[] array into float* instead of double*. The code is a tad faster, and i didn't see any major output size difference. Change-Id: I053e6d340850f02761687e072b0782c6734d4bf8
This commit is contained in:
parent
77aa7d50a4
commit
3de58d7730
@ -459,8 +459,8 @@ static int BackwardReferencesHashChainDistanceOnly(
|
|||||||
const int quality = 100;
|
const int quality = 100;
|
||||||
const int pix_count = xsize * ysize;
|
const int pix_count = xsize * ysize;
|
||||||
const int use_color_cache = (cache_bits > 0);
|
const int use_color_cache = (cache_bits > 0);
|
||||||
double* const cost =
|
float* const cost =
|
||||||
(double*)WebPSafeMalloc((uint64_t)pix_count, sizeof(*cost));
|
(float*)WebPSafeMalloc((uint64_t)pix_count, sizeof(*cost));
|
||||||
CostModel* cost_model = (CostModel*)malloc(sizeof(*cost_model));
|
CostModel* cost_model = (CostModel*)malloc(sizeof(*cost_model));
|
||||||
HashChain* hash_chain = (HashChain*)malloc(sizeof(*hash_chain));
|
HashChain* hash_chain = (HashChain*)malloc(sizeof(*hash_chain));
|
||||||
VP8LColorCache hashers;
|
VP8LColorCache hashers;
|
||||||
@ -481,7 +481,7 @@ static int BackwardReferencesHashChainDistanceOnly(
|
|||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pix_count; ++i) cost[i] = 1e100;
|
for (i = 0; i < pix_count; ++i) cost[i] = 1e38f;
|
||||||
|
|
||||||
// We loop one pixel at a time, but store all currently best points to
|
// We loop one pixel at a time, but store all currently best points to
|
||||||
// non-processed locations from this point.
|
// non-processed locations from this point.
|
||||||
@ -509,10 +509,9 @@ static int BackwardReferencesHashChainDistanceOnly(
|
|||||||
prev_cost + GetDistanceCost(cost_model, code);
|
prev_cost + GetDistanceCost(cost_model, code);
|
||||||
int k;
|
int k;
|
||||||
for (k = 1; k < len; ++k) {
|
for (k = 1; k < len; ++k) {
|
||||||
const double cost_val =
|
const double cost_val = distance_cost + GetLengthCost(cost_model, k);
|
||||||
distance_cost + GetLengthCost(cost_model, k);
|
|
||||||
if (cost[i + k] > cost_val) {
|
if (cost[i + k] > cost_val) {
|
||||||
cost[i + k] = cost_val;
|
cost[i + k] = (float)cost_val;
|
||||||
dist_array[i + k] = k + 1;
|
dist_array[i + k] = k + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user