| Index: third_party/libwebp/dsp/alpha_processing.c
|
| diff --git a/third_party/libwebp/dsp/alpha_processing.c b/third_party/libwebp/dsp/alpha_processing.c
|
| index c8e0b4bccf6264a79771785387fe66beb819b5d8..1716cace8d558993187b56202512ac6b549fa55d 100644
|
| --- a/third_party/libwebp/dsp/alpha_processing.c
|
| +++ b/third_party/libwebp/dsp/alpha_processing.c
|
| @@ -134,7 +134,7 @@ static WEBP_INLINE uint32_t GetScale(uint32_t a, int inverse) {
|
|
|
| #endif // USE_TABLES_FOR_ALPHA_MULT
|
|
|
| -static void MultARGBRow(uint32_t* const ptr, int width, int inverse) {
|
| +void WebPMultARGBRowC(uint32_t* const ptr, int width, int inverse) {
|
| int x;
|
| for (x = 0; x < width; ++x) {
|
| const uint32_t argb = ptr[x];
|
| @@ -154,8 +154,8 @@ static void MultARGBRow(uint32_t* const ptr, int width, int inverse) {
|
| }
|
| }
|
|
|
| -static void MultRow(uint8_t* const ptr, const uint8_t* const alpha,
|
| - int width, int inverse) {
|
| +void WebPMultRowC(uint8_t* const ptr, const uint8_t* const alpha,
|
| + int width, int inverse) {
|
| int x;
|
| for (x = 0; x < width; ++x) {
|
| const uint32_t a = alpha[x];
|
| @@ -284,6 +284,38 @@ static void ApplyAlphaMultiply_16b(uint8_t* rgba4444,
|
| #endif
|
| }
|
|
|
| +static int DispatchAlpha(const uint8_t* alpha, int alpha_stride,
|
| + int width, int height,
|
| + uint8_t* dst, int dst_stride) {
|
| + uint32_t alpha_mask = 0xff;
|
| + int i, j;
|
| +
|
| + for (j = 0; j < height; ++j) {
|
| + for (i = 0; i < width; ++i) {
|
| + const uint32_t alpha_value = alpha[i];
|
| + dst[4 * i] = alpha_value;
|
| + alpha_mask &= alpha_value;
|
| + }
|
| + alpha += alpha_stride;
|
| + dst += dst_stride;
|
| + }
|
| +
|
| + return (alpha_mask != 0xff);
|
| +}
|
| +
|
| +static void DispatchAlphaToGreen(const uint8_t* alpha, int alpha_stride,
|
| + int width, int height,
|
| + uint32_t* dst, int dst_stride) {
|
| + int i, j;
|
| + for (j = 0; j < height; ++j) {
|
| + for (i = 0; i < width; ++i) {
|
| + dst[i] = alpha[i] << 8; // leave A/R/B channels zero'd.
|
| + }
|
| + alpha += alpha_stride;
|
| + dst += dst_stride;
|
| + }
|
| +}
|
| +
|
| static int ExtractAlpha(const uint8_t* argb, int argb_stride,
|
| int width, int height,
|
| uint8_t* alpha, int alpha_stride) {
|
| @@ -304,23 +336,29 @@ static int ExtractAlpha(const uint8_t* argb, int argb_stride,
|
|
|
| void (*WebPApplyAlphaMultiply)(uint8_t*, int, int, int, int);
|
| void (*WebPApplyAlphaMultiply4444)(uint8_t*, int, int, int);
|
| +int (*WebPDispatchAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
|
| +void (*WebPDispatchAlphaToGreen)(const uint8_t*, int, int, int, uint32_t*, int);
|
| int (*WebPExtractAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
|
|
|
| //------------------------------------------------------------------------------
|
| // Init function
|
|
|
| +extern void WebPInitAlphaProcessingMIPSdspR2(void);
|
| extern void WebPInitAlphaProcessingSSE2(void);
|
| +extern void WebPInitAlphaProcessingSSE41(void);
|
|
|
| static volatile VP8CPUInfo alpha_processing_last_cpuinfo_used =
|
| (VP8CPUInfo)&alpha_processing_last_cpuinfo_used;
|
|
|
| -void WebPInitAlphaProcessing(void) {
|
| +WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void) {
|
| if (alpha_processing_last_cpuinfo_used == VP8GetCPUInfo) return;
|
|
|
| - WebPMultARGBRow = MultARGBRow;
|
| - WebPMultRow = MultRow;
|
| + WebPMultARGBRow = WebPMultARGBRowC;
|
| + WebPMultRow = WebPMultRowC;
|
| WebPApplyAlphaMultiply = ApplyAlphaMultiply;
|
| WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply_16b;
|
| + WebPDispatchAlpha = DispatchAlpha;
|
| + WebPDispatchAlphaToGreen = DispatchAlphaToGreen;
|
| WebPExtractAlpha = ExtractAlpha;
|
|
|
| // If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
| @@ -328,6 +366,16 @@ void WebPInitAlphaProcessing(void) {
|
| #if defined(WEBP_USE_SSE2)
|
| if (VP8GetCPUInfo(kSSE2)) {
|
| WebPInitAlphaProcessingSSE2();
|
| +#if defined(WEBP_USE_SSE41)
|
| + if (VP8GetCPUInfo(kSSE4_1)) {
|
| + WebPInitAlphaProcessingSSE41();
|
| + }
|
| +#endif
|
| + }
|
| +#endif
|
| +#if defined(WEBP_USE_MIPS_DSP_R2)
|
| + if (VP8GetCPUInfo(kMIPSdspR2)) {
|
| + WebPInitAlphaProcessingMIPSdspR2();
|
| }
|
| #endif
|
| }
|
|
|