| Index: third_party/libwebp/dsp/enc.c
|
| diff --git a/third_party/libwebp/dsp/enc.c b/third_party/libwebp/dsp/enc.c
|
| index fcc6ec8ea259fb6d76004208ac29b2e778c6516f..e4ea8cb8a8c5ef7cf2163fa850c25e44da1ea377 100644
|
| --- a/third_party/libwebp/dsp/enc.c
|
| +++ b/third_party/libwebp/dsp/enc.c
|
| @@ -159,33 +159,6 @@ static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) {
|
| }
|
| }
|
|
|
| -static void ITransformWHT(const int16_t* in, int16_t* out) {
|
| - int tmp[16];
|
| - int i;
|
| - for (i = 0; i < 4; ++i) {
|
| - const int a0 = in[0 + i] + in[12 + i];
|
| - const int a1 = in[4 + i] + in[ 8 + i];
|
| - const int a2 = in[4 + i] - in[ 8 + i];
|
| - const int a3 = in[0 + i] - in[12 + i];
|
| - tmp[0 + i] = a0 + a1;
|
| - tmp[8 + i] = a0 - a1;
|
| - tmp[4 + i] = a3 + a2;
|
| - tmp[12 + i] = a3 - a2;
|
| - }
|
| - for (i = 0; i < 4; ++i) {
|
| - const int dc = tmp[0 + i * 4] + 3; // w/ rounder
|
| - const int a0 = dc + tmp[3 + i * 4];
|
| - const int a1 = tmp[1 + i * 4] + tmp[2 + i * 4];
|
| - const int a2 = tmp[1 + i * 4] - tmp[2 + i * 4];
|
| - const int a3 = dc - tmp[3 + i * 4];
|
| - out[ 0] = (a0 + a1) >> 3;
|
| - out[16] = (a3 + a2) >> 3;
|
| - out[32] = (a0 - a1) >> 3;
|
| - out[48] = (a3 - a2) >> 3;
|
| - out += 64;
|
| - }
|
| -}
|
| -
|
| static void FTransformWHT(const int16_t* in, int16_t* out) {
|
| // input is 12b signed
|
| int32_t tmp[16];
|
| @@ -627,21 +600,23 @@ static const uint8_t kZigzag[16] = {
|
|
|
| // Simple quantization
|
| static int QuantizeBlock(int16_t in[16], int16_t out[16],
|
| - int n, const VP8Matrix* const mtx) {
|
| + const VP8Matrix* const mtx) {
|
| int last = -1;
|
| - for (; n < 16; ++n) {
|
| + int n;
|
| + for (n = 0; n < 16; ++n) {
|
| const int j = kZigzag[n];
|
| const int sign = (in[j] < 0);
|
| - const int coeff = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
|
| + const uint32_t coeff = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
|
| if (coeff > mtx->zthresh_[j]) {
|
| - const int Q = mtx->q_[j];
|
| - const int iQ = mtx->iq_[j];
|
| - const int B = mtx->bias_[j];
|
| - out[n] = QUANTDIV(coeff, iQ, B);
|
| - if (out[n] > MAX_LEVEL) out[n] = MAX_LEVEL;
|
| - if (sign) out[n] = -out[n];
|
| - in[j] = out[n] * Q;
|
| - if (out[n]) last = n;
|
| + const uint32_t Q = mtx->q_[j];
|
| + const uint32_t iQ = mtx->iq_[j];
|
| + const uint32_t B = mtx->bias_[j];
|
| + int level = QUANTDIV(coeff, iQ, B);
|
| + if (level > MAX_LEVEL) level = MAX_LEVEL;
|
| + if (sign) level = -level;
|
| + in[j] = level * Q;
|
| + out[n] = level;
|
| + if (level) last = n;
|
| } else {
|
| out[n] = 0;
|
| in[j] = 0;
|
| @@ -656,17 +631,18 @@ static int QuantizeBlockWHT(int16_t in[16], int16_t out[16],
|
| for (n = 0; n < 16; ++n) {
|
| const int j = kZigzag[n];
|
| const int sign = (in[j] < 0);
|
| - const int coeff = sign ? -in[j] : in[j];
|
| + const uint32_t coeff = sign ? -in[j] : in[j];
|
| assert(mtx->sharpen_[j] == 0);
|
| if (coeff > mtx->zthresh_[j]) {
|
| - const int Q = mtx->q_[j];
|
| - const int iQ = mtx->iq_[j];
|
| - const int B = mtx->bias_[j];
|
| - out[n] = QUANTDIV(coeff, iQ, B);
|
| - if (out[n] > MAX_LEVEL) out[n] = MAX_LEVEL;
|
| - if (sign) out[n] = -out[n];
|
| - in[j] = out[n] * Q;
|
| - if (out[n]) last = n;
|
| + const uint32_t Q = mtx->q_[j];
|
| + const uint32_t iQ = mtx->iq_[j];
|
| + const uint32_t B = mtx->bias_[j];
|
| + int level = QUANTDIV(coeff, iQ, B);
|
| + if (level > MAX_LEVEL) level = MAX_LEVEL;
|
| + if (sign) level = -level;
|
| + in[j] = level * Q;
|
| + out[n] = level;
|
| + if (level) last = n;
|
| } else {
|
| out[n] = 0;
|
| in[j] = 0;
|
| @@ -697,7 +673,6 @@ static void Copy4x4(const uint8_t* src, uint8_t* dst) { Copy(src, dst, 4); }
|
| VP8CHisto VP8CollectHistogram;
|
| VP8Idct VP8ITransform;
|
| VP8Fdct VP8FTransform;
|
| -VP8WHT VP8ITransformWHT;
|
| VP8WHT VP8FTransformWHT;
|
| VP8Intra4Preds VP8EncPredLuma4;
|
| VP8IntraPreds VP8EncPredLuma16;
|
| @@ -713,16 +688,18 @@ VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT;
|
| VP8BlockCopy VP8Copy4x4;
|
|
|
| extern void VP8EncDspInitSSE2(void);
|
| +extern void VP8EncDspInitAVX2(void);
|
| extern void VP8EncDspInitNEON(void);
|
| +extern void VP8EncDspInitMIPS32(void);
|
|
|
| void VP8EncDspInit(void) {
|
| + VP8DspInit(); // common inverse transforms
|
| InitTables();
|
|
|
| // default C implementations
|
| VP8CollectHistogram = CollectHistogram;
|
| VP8ITransform = ITransform;
|
| VP8FTransform = FTransform;
|
| - VP8ITransformWHT = ITransformWHT;
|
| VP8FTransformWHT = FTransformWHT;
|
| VP8EncPredLuma4 = Intra4Preds;
|
| VP8EncPredLuma16 = Intra16Preds;
|
| @@ -738,16 +715,27 @@ void VP8EncDspInit(void) {
|
| VP8Copy4x4 = Copy4x4;
|
|
|
| // If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
| - if (VP8GetCPUInfo) {
|
| + if (VP8GetCPUInfo != NULL) {
|
| #if defined(WEBP_USE_SSE2)
|
| if (VP8GetCPUInfo(kSSE2)) {
|
| VP8EncDspInitSSE2();
|
| }
|
| -#elif defined(WEBP_USE_NEON)
|
| +#endif
|
| +#if defined(WEBP_USE_AVX2)
|
| + if (VP8GetCPUInfo(kAVX2)) {
|
| + VP8EncDspInitAVX2();
|
| + }
|
| +#endif
|
| +#if defined(WEBP_USE_NEON)
|
| if (VP8GetCPUInfo(kNEON)) {
|
| VP8EncDspInitNEON();
|
| }
|
| #endif
|
| +#if defined(WEBP_USE_MIPS32)
|
| + if (VP8GetCPUInfo(kMIPS32)) {
|
| + VP8EncDspInitMIPS32();
|
| + }
|
| +#endif
|
| }
|
| }
|
|
|
|
|