mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
Optimize VP8SetResidualCoeffs.
Brings down WebP lossy encoding timings by 5% Change-Id: Ia4a2fab0a887aaaf7841ce6d9ee16270d3e15489
This commit is contained in:
@ -13,6 +13,12 @@
|
||||
|
||||
#include "./cost.h"
|
||||
|
||||
#if defined(WEBP_USE_SSE2)
|
||||
#include <emmintrin.h>
|
||||
#endif // WEBP_USE_SSE2
|
||||
|
||||
#include "../utils/utils.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Boolean-cost cost table
|
||||
|
||||
@ -536,15 +542,13 @@ extern int VP8GetResidualCostMIPS32(int ctx0, const VP8Residual* const res);
|
||||
VP8GetResidualCostFunc VP8GetResidualCost;
|
||||
|
||||
void VP8GetResidualCostInit(void) {
|
||||
if (VP8GetResidualCost == NULL) {
|
||||
VP8GetResidualCost = GetResidualCost;
|
||||
if (VP8GetCPUInfo != NULL) {
|
||||
VP8GetResidualCost = GetResidualCost;
|
||||
if (VP8GetCPUInfo != NULL) {
|
||||
#if defined(WEBP_USE_MIPS32)
|
||||
if (VP8GetCPUInfo(kMIPS32)) {
|
||||
VP8GetResidualCost = VP8GetResidualCostMIPS32;
|
||||
}
|
||||
#endif
|
||||
if (VP8GetCPUInfo(kMIPS32)) {
|
||||
VP8GetResidualCost = VP8GetResidualCostMIPS32;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,7 +564,8 @@ void VP8InitResidual(int first, int coeff_type,
|
||||
res->first = first;
|
||||
}
|
||||
|
||||
void VP8SetResidualCoeffs(const int16_t* const coeffs, VP8Residual* const res) {
|
||||
static void SetResidualCoeffs(const int16_t* const coeffs,
|
||||
VP8Residual* const res) {
|
||||
int n;
|
||||
res->last = -1;
|
||||
for (n = 15; n >= res->first; --n) {
|
||||
@ -572,6 +577,27 @@ void VP8SetResidualCoeffs(const int16_t* const coeffs, VP8Residual* const res) {
|
||||
res->coeffs = coeffs;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// init function
|
||||
|
||||
#if defined(WEBP_USE_SSE2)
|
||||
extern void VP8SetResidualCoeffsSSE2(const int16_t* const coeffs,
|
||||
VP8Residual* const res);
|
||||
#endif // WEBP_USE_SSE2
|
||||
|
||||
VP8SetResidualCoeffsFunc VP8SetResidualCoeffs;
|
||||
|
||||
void VP8SetResidualCoeffsInit(void) {
|
||||
VP8SetResidualCoeffs = SetResidualCoeffs;
|
||||
if (VP8GetCPUInfo != NULL) {
|
||||
#if defined(WEBP_USE_SSE2)
|
||||
if (VP8GetCPUInfo(kSSE2)) {
|
||||
VP8SetResidualCoeffs = VP8SetResidualCoeffsSSE2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Mode costs
|
||||
|
||||
|
@ -37,7 +37,13 @@ typedef struct {
|
||||
|
||||
void VP8InitResidual(int first, int coeff_type,
|
||||
VP8Encoder* const enc, VP8Residual* const res);
|
||||
void VP8SetResidualCoeffs(const int16_t* const coeffs, VP8Residual* const res);
|
||||
|
||||
typedef void (*VP8SetResidualCoeffsFunc)(const int16_t* const coeffs,
|
||||
VP8Residual* const res);
|
||||
extern VP8SetResidualCoeffsFunc VP8SetResidualCoeffs;
|
||||
|
||||
extern void VP8SetResidualCoeffsInit(void); // must be called first
|
||||
|
||||
int VP8RecordCoeffs(int ctx, const VP8Residual* const res);
|
||||
|
||||
// approximate cost per level:
|
||||
|
@ -253,6 +253,7 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config,
|
||||
ResetFilterHeader(enc);
|
||||
ResetBoundaryPredictions(enc);
|
||||
VP8GetResidualCostInit();
|
||||
VP8SetResidualCoeffsInit();
|
||||
VP8EncInitAlpha(enc);
|
||||
|
||||
// lower quality means smaller output -> we modulate a little the page
|
||||
|
Reference in New Issue
Block a user