mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
shuffle variables in HashChainFindCopy
might lead to observable speed-up on some compiler/arch Change-Id: I6c89ec9cd4f490e7e22b790785f80097a47d27b5
This commit is contained in:
parent
8130c4cc64
commit
cdf885c67c
@ -146,18 +146,20 @@ static int HashChainFindCopy(const HashChain* const p,
|
|||||||
const uint64_t hash_code = GetPixPairHash64(&argb[index]);
|
const uint64_t hash_code = GetPixPairHash64(&argb[index]);
|
||||||
int prev_length = 0;
|
int prev_length = 0;
|
||||||
int64_t best_val = 0;
|
int64_t best_val = 0;
|
||||||
|
int best_length = 0;
|
||||||
|
int best_distance = 0;
|
||||||
|
const uint32_t* const argb_start = argb + index;
|
||||||
const int iter_min_mult = (quality < 50) ? 2 : (quality < 75) ? 4 : 8;
|
const int iter_min_mult = (quality < 50) ? 2 : (quality < 75) ? 4 : 8;
|
||||||
const int iter_min = -quality * iter_min_mult;
|
const int iter_min = -quality * iter_min_mult;
|
||||||
int iter_cnt = 10 + (quality >> 1);
|
int iter_cnt = 10 + (quality >> 1);
|
||||||
const int min_pos = (index > WINDOW_SIZE) ? index - WINDOW_SIZE : 0;
|
const int min_pos = (index > WINDOW_SIZE) ? index - WINDOW_SIZE : 0;
|
||||||
int32_t pos;
|
int pos;
|
||||||
int64_t val;
|
|
||||||
int best_length = 0;
|
|
||||||
int best_distance = 0;
|
|
||||||
assert(xsize > 0);
|
assert(xsize > 0);
|
||||||
for (pos = p->hash_to_first_index_[hash_code];
|
for (pos = p->hash_to_first_index_[hash_code];
|
||||||
pos >= min_pos;
|
pos >= min_pos;
|
||||||
pos = p->chain_[pos]) {
|
pos = p->chain_[pos]) {
|
||||||
|
int64_t val;
|
||||||
int curr_length;
|
int curr_length;
|
||||||
if (iter_cnt < 0) {
|
if (iter_cnt < 0) {
|
||||||
if (iter_cnt < iter_min || best_val >= 0xff0000) {
|
if (iter_cnt < iter_min || best_val >= 0xff0000) {
|
||||||
@ -166,10 +168,10 @@ static int HashChainFindCopy(const HashChain* const p,
|
|||||||
}
|
}
|
||||||
--iter_cnt;
|
--iter_cnt;
|
||||||
if (best_length != 0 &&
|
if (best_length != 0 &&
|
||||||
argb[pos + best_length - 1] != argb[index + best_length - 1]) {
|
argb[pos + best_length - 1] != argb_start[best_length - 1]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curr_length = FindMatchLength(argb + pos, argb + index, maxlen);
|
curr_length = FindMatchLength(argb + pos, argb_start, maxlen);
|
||||||
if (curr_length < prev_length) {
|
if (curr_length < prev_length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user