| Index: third_party/libwebp/dsp/upsampling.c
|
| diff --git a/third_party/libwebp/dsp/upsampling.c b/third_party/libwebp/dsp/upsampling.c
|
| index 978e3ce2509c2adcf90c0d38d48be6dce0789d59..2b1656bf9b5abd41c13f65f18045334c3bff415e 100644
|
| --- a/third_party/libwebp/dsp/upsampling.c
|
| +++ b/third_party/libwebp/dsp/upsampling.c
|
| @@ -107,57 +107,6 @@ UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
|
| #endif // FANCY_UPSAMPLING
|
|
|
| //------------------------------------------------------------------------------
|
| -// simple point-sampling
|
| -
|
| -#define SAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
|
| -static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
|
| - const uint8_t* u, const uint8_t* v, \
|
| - uint8_t* top_dst, uint8_t* bottom_dst, int len) { \
|
| - int i; \
|
| - for (i = 0; i < len - 1; i += 2) { \
|
| - FUNC(top_y[0], u[0], v[0], top_dst); \
|
| - FUNC(top_y[1], u[0], v[0], top_dst + XSTEP); \
|
| - FUNC(bottom_y[0], u[0], v[0], bottom_dst); \
|
| - FUNC(bottom_y[1], u[0], v[0], bottom_dst + XSTEP); \
|
| - top_y += 2; \
|
| - bottom_y += 2; \
|
| - u++; \
|
| - v++; \
|
| - top_dst += 2 * XSTEP; \
|
| - bottom_dst += 2 * XSTEP; \
|
| - } \
|
| - if (i == len - 1) { /* last one */ \
|
| - FUNC(top_y[0], u[0], v[0], top_dst); \
|
| - FUNC(bottom_y[0], u[0], v[0], bottom_dst); \
|
| - } \
|
| -}
|
| -
|
| -// All variants implemented.
|
| -SAMPLE_FUNC(SampleRgbLinePair, VP8YuvToRgb, 3)
|
| -SAMPLE_FUNC(SampleBgrLinePair, VP8YuvToBgr, 3)
|
| -SAMPLE_FUNC(SampleRgbaLinePair, VP8YuvToRgba, 4)
|
| -SAMPLE_FUNC(SampleBgraLinePair, VP8YuvToBgra, 4)
|
| -SAMPLE_FUNC(SampleArgbLinePair, VP8YuvToArgb, 4)
|
| -SAMPLE_FUNC(SampleRgba4444LinePair, VP8YuvToRgba4444, 2)
|
| -SAMPLE_FUNC(SampleRgb565LinePair, VP8YuvToRgb565, 2)
|
| -
|
| -#undef SAMPLE_FUNC
|
| -
|
| -const WebPSampleLinePairFunc WebPSamplers[MODE_LAST] = {
|
| - SampleRgbLinePair, // MODE_RGB
|
| - SampleRgbaLinePair, // MODE_RGBA
|
| - SampleBgrLinePair, // MODE_BGR
|
| - SampleBgraLinePair, // MODE_BGRA
|
| - SampleArgbLinePair, // MODE_ARGB
|
| - SampleRgba4444LinePair, // MODE_RGBA_4444
|
| - SampleRgb565LinePair, // MODE_RGB_565
|
| - SampleRgbaLinePair, // MODE_rgbA
|
| - SampleBgraLinePair, // MODE_bgrA
|
| - SampleArgbLinePair, // MODE_Argb
|
| - SampleRgba4444LinePair // MODE_rgbA_4444
|
| -};
|
| -
|
| -//------------------------------------------------------------------------------
|
|
|
| #if !defined(FANCY_UPSAMPLING)
|
| #define DUAL_SAMPLE_FUNC(FUNC_NAME, FUNC) \
|
| @@ -235,83 +184,10 @@ const WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = {
|
| };
|
|
|
| //------------------------------------------------------------------------------
|
| -// Premultiplied modes
|
| -
|
| -// non dithered-modes
|
| -
|
| -// (x * a * 32897) >> 23 is bit-wise equivalent to (int)(x * a / 255.)
|
| -// for all 8bit x or a. For bit-wise equivalence to (int)(x * a / 255. + .5),
|
| -// one can use instead: (x * a * 65793 + (1 << 23)) >> 24
|
| -#if 1 // (int)(x * a / 255.)
|
| -#define MULTIPLIER(a) ((a) * 32897UL)
|
| -#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
|
| -#else // (int)(x * a / 255. + .5)
|
| -#define MULTIPLIER(a) ((a) * 65793UL)
|
| -#define PREMULTIPLY(x, m) (((x) * (m) + (1UL << 23)) >> 24)
|
| -#endif
|
| -
|
| -static void ApplyAlphaMultiply(uint8_t* rgba, int alpha_first,
|
| - int w, int h, int stride) {
|
| - while (h-- > 0) {
|
| - uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);
|
| - const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);
|
| - int i;
|
| - for (i = 0; i < w; ++i) {
|
| - const uint32_t a = alpha[4 * i];
|
| - if (a != 0xff) {
|
| - const uint32_t mult = MULTIPLIER(a);
|
| - rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);
|
| - rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);
|
| - rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);
|
| - }
|
| - }
|
| - rgba += stride;
|
| - }
|
| -}
|
| -#undef MULTIPLIER
|
| -#undef PREMULTIPLY
|
| -
|
| -// rgbA4444
|
| -
|
| -#define MULTIPLIER(a) ((a) * 0x1111) // 0x1111 ~= (1 << 16) / 15
|
| -
|
| -static WEBP_INLINE uint8_t dither_hi(uint8_t x) {
|
| - return (x & 0xf0) | (x >> 4);
|
| -}
|
| -
|
| -static WEBP_INLINE uint8_t dither_lo(uint8_t x) {
|
| - return (x & 0x0f) | (x << 4);
|
| -}
|
| -
|
| -static WEBP_INLINE uint8_t multiply(uint8_t x, uint32_t m) {
|
| - return (x * m) >> 16;
|
| -}
|
| +// Main calls
|
|
|
| -static void ApplyAlphaMultiply4444(uint8_t* rgba4444,
|
| - int w, int h, int stride) {
|
| - while (h-- > 0) {
|
| - int i;
|
| - for (i = 0; i < w; ++i) {
|
| - const uint8_t a = (rgba4444[2 * i + 1] & 0x0f);
|
| - const uint32_t mult = MULTIPLIER(a);
|
| - const uint8_t r = multiply(dither_hi(rgba4444[2 * i + 0]), mult);
|
| - const uint8_t g = multiply(dither_lo(rgba4444[2 * i + 0]), mult);
|
| - const uint8_t b = multiply(dither_hi(rgba4444[2 * i + 1]), mult);
|
| - rgba4444[2 * i + 0] = (r & 0xf0) | ((g >> 4) & 0x0f);
|
| - rgba4444[2 * i + 1] = (b & 0xf0) | a;
|
| - }
|
| - rgba4444 += stride;
|
| - }
|
| -}
|
| -#undef MULTIPLIER
|
| -
|
| -void (*WebPApplyAlphaMultiply)(uint8_t*, int, int, int, int)
|
| - = ApplyAlphaMultiply;
|
| -void (*WebPApplyAlphaMultiply4444)(uint8_t*, int, int, int)
|
| - = ApplyAlphaMultiply4444;
|
| -
|
| -//------------------------------------------------------------------------------
|
| -// Main call
|
| +extern void WebPInitUpsamplersSSE2(void);
|
| +extern void WebPInitUpsamplersNEON(void);
|
|
|
| void WebPInitUpsamplers(void) {
|
| #ifdef FANCY_UPSAMPLING
|
| @@ -322,45 +198,25 @@ void WebPInitUpsamplers(void) {
|
| WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
|
| WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
|
| WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
|
| -
|
| - // If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
| - if (VP8GetCPUInfo != NULL) {
|
| -#if defined(WEBP_USE_SSE2)
|
| - if (VP8GetCPUInfo(kSSE2)) {
|
| - WebPInitUpsamplersSSE2();
|
| - }
|
| -#endif
|
| -#if defined(WEBP_USE_NEON)
|
| - if (VP8GetCPUInfo(kNEON)) {
|
| - WebPInitUpsamplersNEON();
|
| - }
|
| -#endif
|
| - }
|
| -#endif // FANCY_UPSAMPLING
|
| -}
|
| -
|
| -void WebPInitPremultiply(void) {
|
| - WebPApplyAlphaMultiply = ApplyAlphaMultiply;
|
| - WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply4444;
|
| -
|
| -#ifdef FANCY_UPSAMPLING
|
| WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
|
| WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
|
| WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
|
| WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
|
|
|
| + // If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
| if (VP8GetCPUInfo != NULL) {
|
| #if defined(WEBP_USE_SSE2)
|
| if (VP8GetCPUInfo(kSSE2)) {
|
| - WebPInitPremultiplySSE2();
|
| + WebPInitUpsamplersSSE2();
|
| }
|
| #endif
|
| #if defined(WEBP_USE_NEON)
|
| if (VP8GetCPUInfo(kNEON)) {
|
| - WebPInitPremultiplyNEON();
|
| + WebPInitUpsamplersNEON();
|
| }
|
| #endif
|
| }
|
| #endif // FANCY_UPSAMPLING
|
| }
|
|
|
| +//------------------------------------------------------------------------------
|
|
|