mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 23:42:53 +01:00
De-VP8L-ize GetEntropUnrefinedHelper.
Having it architecture dependent resulted in an extra function call of an extern function, hence no inlining and a 5-10% impact on performance. Change-Id: I0ff40d2d881edc76d3594213a64ee53097d42450
This commit is contained in:
parent
a7be73280b
commit
64577de8ae
@ -167,26 +167,20 @@ void VP8LBitEntropyInit(VP8LBitEntropy* const entropy);
|
||||
// Get the combined symbol bit entropy and Huffman cost stats for the
|
||||
// distributions 'X' and 'Y'. Those results can then be refined according to
|
||||
// codec specific heuristics.
|
||||
void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
|
||||
const uint32_t* const Y, int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats);
|
||||
typedef void (*VP8LGetCombinedEntropyUnrefinedFunc)(
|
||||
const uint32_t X[], const uint32_t Y[], int length,
|
||||
VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats);
|
||||
extern VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
|
||||
|
||||
// Get the entropy for the distribution 'X'.
|
||||
void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats);
|
||||
typedef void (*VP8LGetEntropyUnrefinedFunc)(const uint32_t X[], int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats);
|
||||
extern VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
|
||||
|
||||
void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,
|
||||
VP8LBitEntropy* const entropy);
|
||||
|
||||
typedef void (*GetEntropyUnrefinedHelperFunc)(uint32_t val, int i,
|
||||
uint32_t* const val_prev,
|
||||
int* const i_prev,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats);
|
||||
// Internal function used by VP8LGet*EntropyUnrefined.
|
||||
extern GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper;
|
||||
|
||||
typedef void (*VP8LHistogramAddFunc)(const VP8LHistogram* const a,
|
||||
const VP8LHistogram* const b,
|
||||
VP8LHistogram* const out);
|
||||
|
@ -453,9 +453,9 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
|
||||
*i_prev = i;
|
||||
}
|
||||
|
||||
void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
static void GetEntropyUnrefined(const uint32_t X[], int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
int i;
|
||||
int i_prev = 0;
|
||||
uint32_t x_prev = X[0];
|
||||
@ -466,18 +466,18 @@ void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
|
||||
for (i = 1; i < length; ++i) {
|
||||
const uint32_t x = X[i];
|
||||
if (x != x_prev) {
|
||||
VP8LGetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
}
|
||||
}
|
||||
VP8LGetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
|
||||
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
|
||||
}
|
||||
|
||||
void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
|
||||
const uint32_t* const Y, int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
static void GetCombinedEntropyUnrefined(const uint32_t X[], const uint32_t Y[],
|
||||
int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
int i = 1;
|
||||
int i_prev = 0;
|
||||
uint32_t xy_prev = X[0] + Y[0];
|
||||
@ -488,11 +488,10 @@ void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
|
||||
for (i = 1; i < length; ++i) {
|
||||
const uint32_t xy = X[i] + Y[i];
|
||||
if (xy != xy_prev) {
|
||||
VP8LGetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy,
|
||||
stats);
|
||||
GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
|
||||
}
|
||||
}
|
||||
VP8LGetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
|
||||
GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
|
||||
|
||||
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
|
||||
}
|
||||
@ -680,7 +679,8 @@ VP8LCostFunc VP8LExtraCost;
|
||||
VP8LCostCombinedFunc VP8LExtraCostCombined;
|
||||
VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;
|
||||
|
||||
GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper;
|
||||
VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
|
||||
VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
|
||||
|
||||
VP8LHistogramAddFunc VP8LHistogramAdd;
|
||||
|
||||
@ -715,7 +715,8 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) {
|
||||
VP8LExtraCostCombined = ExtraCostCombined;
|
||||
VP8LCombinedShannonEntropy = CombinedShannonEntropy;
|
||||
|
||||
VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper;
|
||||
VP8LGetEntropyUnrefined = GetEntropyUnrefined;
|
||||
VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
|
||||
|
||||
VP8LHistogramAdd = HistogramAdd;
|
||||
|
||||
|
@ -241,6 +241,49 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
|
||||
*i_prev = i;
|
||||
}
|
||||
|
||||
static void GetEntropyUnrefined(const uint32_t X[], int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
int i;
|
||||
int i_prev = 0;
|
||||
uint32_t x_prev = X[0];
|
||||
|
||||
memset(stats, 0, sizeof(*stats));
|
||||
VP8LBitEntropyInit(bit_entropy);
|
||||
|
||||
for (i = 1; i < length; ++i) {
|
||||
const uint32_t x = X[i];
|
||||
if (x != x_prev) {
|
||||
GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
}
|
||||
}
|
||||
GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
|
||||
|
||||
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
|
||||
}
|
||||
|
||||
static void GetCombinedEntropyUnrefined(const uint32_t X[], const uint32_t Y[],
|
||||
int length,
|
||||
VP8LBitEntropy* const bit_entropy,
|
||||
VP8LStreaks* const stats) {
|
||||
int i = 1;
|
||||
int i_prev = 0;
|
||||
uint32_t xy_prev = X[0] + Y[0];
|
||||
|
||||
memset(stats, 0, sizeof(*stats));
|
||||
VP8LBitEntropyInit(bit_entropy);
|
||||
|
||||
for (i = 1; i < length; ++i) {
|
||||
const uint32_t xy = X[i] + Y[i];
|
||||
if (xy != xy_prev) {
|
||||
GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
|
||||
}
|
||||
}
|
||||
GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
|
||||
|
||||
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
|
||||
}
|
||||
|
||||
#define ASM_START \
|
||||
__asm__ volatile( \
|
||||
".set push \n\t" \
|
||||
@ -376,7 +419,8 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPS32(void) {
|
||||
VP8LFastLog2Slow = FastLog2Slow;
|
||||
VP8LExtraCost = ExtraCost;
|
||||
VP8LExtraCostCombined = ExtraCostCombined;
|
||||
VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper;
|
||||
VP8LGetEntropyUnrefined = GetEntropyUnrefined;
|
||||
VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
|
||||
VP8LHistogramAdd = HistogramAdd;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user