| Index: third_party/libwebp/dsp/upsampling_mips_dsp_r2.c
|
| diff --git a/third_party/libwebp/dsp/upsampling.c b/third_party/libwebp/dsp/upsampling_mips_dsp_r2.c
|
| similarity index 55%
|
| copy from third_party/libwebp/dsp/upsampling.c
|
| copy to third_party/libwebp/dsp/upsampling_mips_dsp_r2.c
|
| index 53c68d5a8290a833a48aa81eab57b03d4e69f3fa..d4ccbe0adaad8f2da5db53b44acc55c29d648a3b 100644
|
| --- a/third_party/libwebp/dsp/upsampling.c
|
| +++ b/third_party/libwebp/dsp/upsampling_mips_dsp_r2.c
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2011 Google Inc. All Rights Reserved.
|
| +// Copyright 2014 Google Inc. All Rights Reserved.
|
| //
|
| // Use of this source code is governed by a BSD-style license
|
| // that can be found in the COPYING file in the root of the source
|
| @@ -9,21 +9,130 @@
|
| //
|
| // YUV to RGB upsampling functions.
|
| //
|
| -// Author: somnath@google.com (Somnath Banerjee)
|
| +// Author(s): Branimir Vasic (branimir.vasic@imgtec.com)
|
| +// Djordje Pesut (djordje.pesut@imgtec.com)
|
|
|
| #include "./dsp.h"
|
| -#include "./yuv.h"
|
| +
|
| +// Code is disabled for now, in favor of the plain-C version
|
| +// TODO(djordje.pesut): adapt the code to reflect the C-version.
|
| +#if 0 // defined(WEBP_USE_MIPS_DSP_R2)
|
|
|
| #include <assert.h>
|
| +#include "./yuv.h"
|
| +
|
| +#if !defined(WEBP_YUV_USE_TABLE)
|
| +
|
| +#define YUV_TO_RGB(Y, U, V, R, G, B) do { \
|
| + const int t1 = kYScale * Y; \
|
| + const int t2 = kVToG * V; \
|
| + R = kVToR * V; \
|
| + G = kUToG * U; \
|
| + B = kUToB * U; \
|
| + R = t1 + R; \
|
| + G = t1 - G; \
|
| + B = t1 + B; \
|
| + R = R + kRCst; \
|
| + G = G - t2 + kGCst; \
|
| + B = B + kBCst; \
|
| + __asm__ volatile ( \
|
| + "shll_s.w %[" #R "], %[" #R "], 9 \n\t" \
|
| + "shll_s.w %[" #G "], %[" #G "], 9 \n\t" \
|
| + "shll_s.w %[" #B "], %[" #B "], 9 \n\t" \
|
| + "precrqu_s.qb.ph %[" #R "], %[" #R "], $zero \n\t" \
|
| + "precrqu_s.qb.ph %[" #G "], %[" #G "], $zero \n\t" \
|
| + "precrqu_s.qb.ph %[" #B "], %[" #B "], $zero \n\t" \
|
| + "srl %[" #R "], %[" #R "], 24 \n\t" \
|
| + "srl %[" #G "], %[" #G "], 24 \n\t" \
|
| + "srl %[" #B "], %[" #B "], 24 \n\t" \
|
| + : [R]"+r"(R), [G]"+r"(G), [B]"+r"(B) \
|
| + : \
|
| + ); \
|
| + } while (0)
|
| +
|
| +static WEBP_INLINE void YuvToRgb(int y, int u, int v, uint8_t* const rgb) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + rgb[0] = r;
|
| + rgb[1] = g;
|
| + rgb[2] = b;
|
| +}
|
| +static WEBP_INLINE void YuvToBgr(int y, int u, int v, uint8_t* const bgr) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + bgr[0] = b;
|
| + bgr[1] = g;
|
| + bgr[2] = r;
|
| +}
|
| +static WEBP_INLINE void YuvToRgb565(int y, int u, int v, uint8_t* const rgb) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + {
|
| + const int rg = (r & 0xf8) | (g >> 5);
|
| + const int gb = ((g << 3) & 0xe0) | (b >> 3);
|
| +#ifdef WEBP_SWAP_16BIT_CSP
|
| + rgb[0] = gb;
|
| + rgb[1] = rg;
|
| +#else
|
| + rgb[0] = rg;
|
| + rgb[1] = gb;
|
| +#endif
|
| + }
|
| +}
|
| +static WEBP_INLINE void YuvToRgba4444(int y, int u, int v,
|
| + uint8_t* const argb) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + {
|
| + const int rg = (r & 0xf0) | (g >> 4);
|
| + const int ba = (b & 0xf0) | 0x0f; // overwrite the lower 4 bits
|
| +#ifdef WEBP_SWAP_16BIT_CSP
|
| + argb[0] = ba;
|
| + argb[1] = rg;
|
| +#else
|
| + argb[0] = rg;
|
| + argb[1] = ba;
|
| +#endif
|
| + }
|
| +}
|
| +#endif // WEBP_YUV_USE_TABLE
|
| +
|
| +//-----------------------------------------------------------------------------
|
| +// Alpha handling variants
|
| +
|
| +static WEBP_INLINE void YuvToArgb(uint8_t y, uint8_t u, uint8_t v,
|
| + uint8_t* const argb) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + argb[0] = 0xff;
|
| + argb[1] = r;
|
| + argb[2] = g;
|
| + argb[3] = b;
|
| +}
|
| +static WEBP_INLINE void YuvToBgra(uint8_t y, uint8_t u, uint8_t v,
|
| + uint8_t* const bgra) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + bgra[0] = b;
|
| + bgra[1] = g;
|
| + bgra[2] = r;
|
| + bgra[3] = 0xff;
|
| +}
|
| +static WEBP_INLINE void YuvToRgba(uint8_t y, uint8_t u, uint8_t v,
|
| + uint8_t* const rgba) {
|
| + int r, g, b;
|
| + YUV_TO_RGB(y, u, v, r, g, b);
|
| + rgba[0] = r;
|
| + rgba[1] = g;
|
| + rgba[2] = b;
|
| + rgba[3] = 0xff;
|
| +}
|
|
|
| //------------------------------------------------------------------------------
|
| // Fancy upsampler
|
|
|
| #ifdef FANCY_UPSAMPLING
|
|
|
| -// Fancy upsampling functions to convert YUV to RGB
|
| -WebPUpsampleLinePairFunc WebPUpsamplers[MODE_LAST];
|
| -
|
| // Given samples laid out in a square as:
|
| // [a b]
|
| // [c d]
|
| @@ -93,62 +202,38 @@ static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bottom_y, \
|
| }
|
|
|
| // All variants implemented.
|
| -UPSAMPLE_FUNC(UpsampleRgbLinePair, VP8YuvToRgb, 3)
|
| -UPSAMPLE_FUNC(UpsampleBgrLinePair, VP8YuvToBgr, 3)
|
| -UPSAMPLE_FUNC(UpsampleRgbaLinePair, VP8YuvToRgba, 4)
|
| -UPSAMPLE_FUNC(UpsampleBgraLinePair, VP8YuvToBgra, 4)
|
| -UPSAMPLE_FUNC(UpsampleArgbLinePair, VP8YuvToArgb, 4)
|
| -UPSAMPLE_FUNC(UpsampleRgba4444LinePair, VP8YuvToRgba4444, 2)
|
| -UPSAMPLE_FUNC(UpsampleRgb565LinePair, VP8YuvToRgb565, 2)
|
| +UPSAMPLE_FUNC(UpsampleRgbLinePair, YuvToRgb, 3)
|
| +UPSAMPLE_FUNC(UpsampleBgrLinePair, YuvToBgr, 3)
|
| +UPSAMPLE_FUNC(UpsampleRgbaLinePair, YuvToRgba, 4)
|
| +UPSAMPLE_FUNC(UpsampleBgraLinePair, YuvToBgra, 4)
|
| +UPSAMPLE_FUNC(UpsampleArgbLinePair, YuvToArgb, 4)
|
| +UPSAMPLE_FUNC(UpsampleRgba4444LinePair, YuvToRgba4444, 2)
|
| +UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
|
|
|
| #undef LOAD_UV
|
| #undef UPSAMPLE_FUNC
|
|
|
| -#endif // FANCY_UPSAMPLING
|
| -
|
| //------------------------------------------------------------------------------
|
| +// Entry point
|
|
|
| -#if !defined(FANCY_UPSAMPLING)
|
| -#define DUAL_SAMPLE_FUNC(FUNC_NAME, FUNC) \
|
| -static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bot_y, \
|
| - const uint8_t* top_u, const uint8_t* top_v, \
|
| - const uint8_t* bot_u, const uint8_t* bot_v, \
|
| - uint8_t* top_dst, uint8_t* bot_dst, int len) { \
|
| - const int half_len = len >> 1; \
|
| - int x; \
|
| - assert(top_dst != NULL); \
|
| - { \
|
| - for (x = 0; x < half_len; ++x) { \
|
| - FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x + 0); \
|
| - FUNC(top_y[2 * x + 1], top_u[x], top_v[x], top_dst + 8 * x + 4); \
|
| - } \
|
| - if (len & 1) FUNC(top_y[2 * x + 0], top_u[x], top_v[x], top_dst + 8 * x); \
|
| - } \
|
| - if (bot_dst != NULL) { \
|
| - for (x = 0; x < half_len; ++x) { \
|
| - FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x + 0); \
|
| - FUNC(bot_y[2 * x + 1], bot_u[x], bot_v[x], bot_dst + 8 * x + 4); \
|
| - } \
|
| - if (len & 1) FUNC(bot_y[2 * x + 0], bot_u[x], bot_v[x], bot_dst + 8 * x); \
|
| - } \
|
| -}
|
| +extern void WebPInitUpsamplersMIPSdspR2(void);
|
|
|
| -DUAL_SAMPLE_FUNC(DualLineSamplerBGRA, VP8YuvToBgra)
|
| -DUAL_SAMPLE_FUNC(DualLineSamplerARGB, VP8YuvToArgb)
|
| -#undef DUAL_SAMPLE_FUNC
|
| -
|
| -#endif // !FANCY_UPSAMPLING
|
| -
|
| -WebPUpsampleLinePairFunc WebPGetLinePairConverter(int alpha_is_last) {
|
| - WebPInitUpsamplers();
|
| - VP8YUVInit();
|
| -#ifdef FANCY_UPSAMPLING
|
| - return WebPUpsamplers[alpha_is_last ? MODE_BGRA : MODE_ARGB];
|
| -#else
|
| - return (alpha_is_last ? DualLineSamplerBGRA : DualLineSamplerARGB);
|
| -#endif
|
| +WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersMIPSdspR2(void) {
|
| + WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
|
| + WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
|
| + WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
|
| + WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
|
| + WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
|
| + WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
|
| + WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
|
| + WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
|
| + WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
|
| + WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
|
| + WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
|
| }
|
|
|
| +#endif // FANCY_UPSAMPLING
|
| +
|
| //------------------------------------------------------------------------------
|
| // YUV444 converter
|
|
|
| @@ -159,70 +244,41 @@ static void FUNC_NAME(const uint8_t* y, const uint8_t* u, const uint8_t* v, \
|
| for (i = 0; i < len; ++i) FUNC(y[i], u[i], v[i], &dst[i * XSTEP]); \
|
| }
|
|
|
| -YUV444_FUNC(Yuv444ToRgb, VP8YuvToRgb, 3)
|
| -YUV444_FUNC(Yuv444ToBgr, VP8YuvToBgr, 3)
|
| -YUV444_FUNC(Yuv444ToRgba, VP8YuvToRgba, 4)
|
| -YUV444_FUNC(Yuv444ToBgra, VP8YuvToBgra, 4)
|
| -YUV444_FUNC(Yuv444ToArgb, VP8YuvToArgb, 4)
|
| -YUV444_FUNC(Yuv444ToRgba4444, VP8YuvToRgba4444, 2)
|
| -YUV444_FUNC(Yuv444ToRgb565, VP8YuvToRgb565, 2)
|
| +YUV444_FUNC(Yuv444ToRgb, YuvToRgb, 3)
|
| +YUV444_FUNC(Yuv444ToBgr, YuvToBgr, 3)
|
| +YUV444_FUNC(Yuv444ToRgba, YuvToRgba, 4)
|
| +YUV444_FUNC(Yuv444ToBgra, YuvToBgra, 4)
|
| +YUV444_FUNC(Yuv444ToArgb, YuvToArgb, 4)
|
| +YUV444_FUNC(Yuv444ToRgba4444, YuvToRgba4444, 2)
|
| +YUV444_FUNC(Yuv444ToRgb565, YuvToRgb565, 2)
|
|
|
| #undef YUV444_FUNC
|
|
|
| -const WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = {
|
| - Yuv444ToRgb, // MODE_RGB
|
| - Yuv444ToRgba, // MODE_RGBA
|
| - Yuv444ToBgr, // MODE_BGR
|
| - Yuv444ToBgra, // MODE_BGRA
|
| - Yuv444ToArgb, // MODE_ARGB
|
| - Yuv444ToRgba4444, // MODE_RGBA_4444
|
| - Yuv444ToRgb565, // MODE_RGB_565
|
| - Yuv444ToRgba, // MODE_rgbA
|
| - Yuv444ToBgra, // MODE_bgrA
|
| - Yuv444ToArgb, // MODE_Argb
|
| - Yuv444ToRgba4444 // MODE_rgbA_4444
|
| -};
|
| -
|
| //------------------------------------------------------------------------------
|
| -// Main calls
|
| +// Entry point
|
|
|
| -extern void WebPInitUpsamplersSSE2(void);
|
| -extern void WebPInitUpsamplersNEON(void);
|
| +extern void WebPInitYUV444ConvertersMIPSdspR2(void);
|
|
|
| -static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 =
|
| - (VP8CPUInfo)&upsampling_last_cpuinfo_used2;
|
| +WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444ConvertersMIPSdspR2(void) {
|
| + WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
|
| + WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
|
| + WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;
|
| + WebPYUV444Converters[MODE_BGRA] = Yuv444ToBgra;
|
| + WebPYUV444Converters[MODE_ARGB] = Yuv444ToArgb;
|
| + WebPYUV444Converters[MODE_RGBA_4444] = Yuv444ToRgba4444;
|
| + WebPYUV444Converters[MODE_RGB_565] = Yuv444ToRgb565;
|
| + WebPYUV444Converters[MODE_rgbA] = Yuv444ToRgba;
|
| + WebPYUV444Converters[MODE_bgrA] = Yuv444ToBgra;
|
| + WebPYUV444Converters[MODE_Argb] = Yuv444ToArgb;
|
| + WebPYUV444Converters[MODE_rgbA_4444] = Yuv444ToRgba4444;
|
| +}
|
|
|
| -void WebPInitUpsamplers(void) {
|
| - if (upsampling_last_cpuinfo_used2 == VP8GetCPUInfo) return;
|
| +#else // !WEBP_USE_MIPS_DSP_R2
|
|
|
| -#ifdef FANCY_UPSAMPLING
|
| - WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
|
| - WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
|
| - WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
|
| - WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
|
| - WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
|
| - WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
|
| - WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
|
| - WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
|
| - WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
|
| - WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
|
| - WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
|
| +WEBP_DSP_INIT_STUB(WebPInitYUV444ConvertersMIPSdspR2)
|
|
|
| - // 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
|
| - upsampling_last_cpuinfo_used2 = VP8GetCPUInfo;
|
| -}
|
| +#endif // WEBP_USE_MIPS_DSP_R2
|
|
|
| -//------------------------------------------------------------------------------
|
| +#if 1 // !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_MIPS_DSP_R2))
|
| +WEBP_DSP_INIT_STUB(WebPInitUpsamplersMIPSdspR2)
|
| +#endif
|
|
|