summaryrefslogtreecommitdiff
path: root/drivers/webp/dsp/lossless_enc_mips32.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/webp/dsp/lossless_enc_mips32.c')
-rw-r--r--drivers/webp/dsp/lossless_enc_mips32.c73
1 files changed, 21 insertions, 52 deletions
diff --git a/drivers/webp/dsp/lossless_enc_mips32.c b/drivers/webp/dsp/lossless_enc_mips32.c
index 0468a5aac2..49c666d4fd 100644
--- a/drivers/webp/dsp/lossless_enc_mips32.c
+++ b/drivers/webp/dsp/lossless_enc_mips32.c
@@ -22,10 +22,6 @@
#include <stdlib.h>
#include <string.h>
-#define APPROX_LOG_WITH_CORRECTION_MAX 65536
-#define APPROX_LOG_MAX 4096
-#define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
-
static float FastSLog2Slow(uint32_t v) {
assert(v >= LOG_LOOKUP_IDX_MAX);
if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
@@ -217,51 +213,31 @@ static double ExtraCostCombined(const uint32_t* const X,
);
// Returns the various RLE counts
-static VP8LStreaks HuffmanCostCount(const uint32_t* population, int length) {
- int i;
- int streak = 0;
- VP8LStreaks stats;
- int* const pstreaks = &stats.streaks[0][0];
- int* const pcnts = &stats.counts[0];
+static WEBP_INLINE void GetEntropyUnrefinedHelper(
+ uint32_t val, int i, uint32_t* const val_prev, int* const i_prev,
+ VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats) {
+ int* const pstreaks = &stats->streaks[0][0];
+ int* const pcnts = &stats->counts[0];
int temp0, temp1, temp2, temp3;
- memset(&stats, 0, sizeof(stats));
- for (i = 0; i < length - 1; ++i) {
- ++streak;
- if (population[i] == population[i + 1]) {
- continue;
+ const int streak = i - *i_prev;
+
+ // Gather info for the bit entropy.
+ if (*val_prev != 0) {
+ bit_entropy->sum += (*val_prev) * streak;
+ bit_entropy->nonzeros += streak;
+ bit_entropy->nonzero_code = *i_prev;
+ bit_entropy->entropy -= VP8LFastSLog2(*val_prev) * streak;
+ if (bit_entropy->max_val < *val_prev) {
+ bit_entropy->max_val = *val_prev;
}
- temp0 = (population[i] != 0);
- HUFFMAN_COST_PASS
- streak = 0;
}
- ++streak;
- temp0 = (population[i] != 0);
- HUFFMAN_COST_PASS
- return stats;
-}
+ // Gather info for the Huffman cost.
+ temp0 = (*val_prev != 0);
+ HUFFMAN_COST_PASS
-static VP8LStreaks HuffmanCostCombinedCount(const uint32_t* X,
- const uint32_t* Y, int length) {
- int i;
- int streak = 0;
- uint32_t xy_prev = 0xffffffff;
- VP8LStreaks stats;
- int* const pstreaks = &stats.streaks[0][0];
- int* const pcnts = &stats.counts[0];
- int temp0, temp1, temp2, temp3;
- memset(&stats, 0, sizeof(stats));
- for (i = 0; i < length; ++i) {
- const uint32_t xy = X[i] + Y[i];
- ++streak;
- if (xy != xy_prev) {
- temp0 = (xy != 0);
- HUFFMAN_COST_PASS
- streak = 0;
- xy_prev = xy;
- }
- }
- return stats;
+ *val_prev = val;
+ *i_prev = i;
}
#define ASM_START \
@@ -399,14 +375,7 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPS32(void) {
VP8LFastLog2Slow = FastLog2Slow;
VP8LExtraCost = ExtraCost;
VP8LExtraCostCombined = ExtraCostCombined;
- VP8LHuffmanCostCount = HuffmanCostCount;
-// TODO(mips team): rewrite VP8LGetCombinedEntropy (which used to use
-// HuffmanCostCombinedCount) with MIPS optimizations
-#if 0
- VP8LHuffmanCostCombinedCount = HuffmanCostCombinedCount;
-#else
- (void)HuffmanCostCombinedCount;
-#endif
+ VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper;
VP8LHistogramAdd = HistogramAdd;
}