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:
Vincent Rabaud 2016-09-14 13:25:59 +02:00
parent a7be73280b
commit 64577de8ae
3 changed files with 69 additions and 30 deletions

View File

@ -167,26 +167,20 @@ void VP8LBitEntropyInit(VP8LBitEntropy* const entropy);
// Get the combined symbol bit entropy and Huffman cost stats for the // Get the combined symbol bit entropy and Huffman cost stats for the
// distributions 'X' and 'Y'. Those results can then be refined according to // distributions 'X' and 'Y'. Those results can then be refined according to
// codec specific heuristics. // codec specific heuristics.
void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X, typedef void (*VP8LGetCombinedEntropyUnrefinedFunc)(
const uint32_t* const Y, int length, const uint32_t X[], const uint32_t Y[], int length,
VP8LBitEntropy* const bit_entropy, VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats);
VP8LStreaks* const stats); extern VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
// Get the entropy for the distribution 'X'. // Get the entropy for the distribution 'X'.
void VP8LGetEntropyUnrefined(const uint32_t* const X, int length, typedef void (*VP8LGetEntropyUnrefinedFunc)(const uint32_t X[], int length,
VP8LBitEntropy* const bit_entropy, VP8LBitEntropy* const bit_entropy,
VP8LStreaks* const stats); VP8LStreaks* const stats);
extern VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n, void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,
VP8LBitEntropy* const entropy); 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, typedef void (*VP8LHistogramAddFunc)(const VP8LHistogram* const a,
const VP8LHistogram* const b, const VP8LHistogram* const b,
VP8LHistogram* const out); VP8LHistogram* const out);

View File

@ -453,7 +453,7 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
*i_prev = i; *i_prev = i;
} }
void VP8LGetEntropyUnrefined(const uint32_t* const X, int length, static void GetEntropyUnrefined(const uint32_t X[], int length,
VP8LBitEntropy* const bit_entropy, VP8LBitEntropy* const bit_entropy,
VP8LStreaks* const stats) { VP8LStreaks* const stats) {
int i; int i;
@ -466,16 +466,16 @@ void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
for (i = 1; i < length; ++i) { for (i = 1; i < length; ++i) {
const uint32_t x = X[i]; const uint32_t x = X[i];
if (x != x_prev) { 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); bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
} }
void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X, static void GetCombinedEntropyUnrefined(const uint32_t X[], const uint32_t Y[],
const uint32_t* const Y, int length, int length,
VP8LBitEntropy* const bit_entropy, VP8LBitEntropy* const bit_entropy,
VP8LStreaks* const stats) { VP8LStreaks* const stats) {
int i = 1; int i = 1;
@ -488,11 +488,10 @@ void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
for (i = 1; i < length; ++i) { for (i = 1; i < length; ++i) {
const uint32_t xy = X[i] + Y[i]; const uint32_t xy = X[i] + Y[i];
if (xy != xy_prev) { if (xy != xy_prev) {
VP8LGetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
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); bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
} }
@ -680,7 +679,8 @@ VP8LCostFunc VP8LExtraCost;
VP8LCostCombinedFunc VP8LExtraCostCombined; VP8LCostCombinedFunc VP8LExtraCostCombined;
VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy; VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;
GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper; VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
VP8LHistogramAddFunc VP8LHistogramAdd; VP8LHistogramAddFunc VP8LHistogramAdd;
@ -715,7 +715,8 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) {
VP8LExtraCostCombined = ExtraCostCombined; VP8LExtraCostCombined = ExtraCostCombined;
VP8LCombinedShannonEntropy = CombinedShannonEntropy; VP8LCombinedShannonEntropy = CombinedShannonEntropy;
VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper; VP8LGetEntropyUnrefined = GetEntropyUnrefined;
VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
VP8LHistogramAdd = HistogramAdd; VP8LHistogramAdd = HistogramAdd;

View File

@ -241,6 +241,49 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
*i_prev = i; *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 \ #define ASM_START \
__asm__ volatile( \ __asm__ volatile( \
".set push \n\t" \ ".set push \n\t" \
@ -376,7 +419,8 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPS32(void) {
VP8LFastLog2Slow = FastLog2Slow; VP8LFastLog2Slow = FastLog2Slow;
VP8LExtraCost = ExtraCost; VP8LExtraCost = ExtraCost;
VP8LExtraCostCombined = ExtraCostCombined; VP8LExtraCostCombined = ExtraCostCombined;
VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper; VP8LGetEntropyUnrefined = GetEntropyUnrefined;
VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
VP8LHistogramAdd = HistogramAdd; VP8LHistogramAdd = HistogramAdd;
} }