summaryrefslogtreecommitdiffstats
path: root/third_party/libwebp/dsp
diff options
context:
space:
mode:
authorjzern <jzern@chromium.org>2015-03-05 14:36:54 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-05 22:37:45 +0000
commit10c227ede75651f2c14eeffcb893c6d1cef304b6 (patch)
treee807cd39887c972c8830f4dc4e31f4d7a8fa4100 /third_party/libwebp/dsp
parent5aabb3fb79526ba574f1a0b91273af1d990570e2 (diff)
downloadchromium_src-10c227ede75651f2c14eeffcb893c6d1cef304b6.zip
chromium_src-10c227ede75651f2c14eeffcb893c6d1cef304b6.tar.gz
chromium_src-10c227ede75651f2c14eeffcb893c6d1cef304b6.tar.bz2
libwebp: update to 0.4.3-rc1
rolls up local cherry-picks on 0.4.2 BUG= Review URL: https://codereview.chromium.org/983613002 Cr-Commit-Position: refs/heads/master@{#319347}
Diffstat (limited to 'third_party/libwebp/dsp')
-rw-r--r--third_party/libwebp/dsp/alpha_processing.c6
-rw-r--r--third_party/libwebp/dsp/cpu.c12
-rw-r--r--third_party/libwebp/dsp/dec.c7
-rw-r--r--third_party/libwebp/dsp/enc.c6
-rw-r--r--third_party/libwebp/dsp/enc_neon.c5
-rw-r--r--third_party/libwebp/dsp/lossless.c6
-rw-r--r--third_party/libwebp/dsp/lossless_neon.c49
-rw-r--r--third_party/libwebp/dsp/upsampling.c6
-rw-r--r--third_party/libwebp/dsp/yuv.c6
9 files changed, 84 insertions, 19 deletions
diff --git a/third_party/libwebp/dsp/alpha_processing.c b/third_party/libwebp/dsp/alpha_processing.c
index d0f7a6c..c8e0b4b 100644
--- a/third_party/libwebp/dsp/alpha_processing.c
+++ b/third_party/libwebp/dsp/alpha_processing.c
@@ -311,7 +311,12 @@ int (*WebPExtractAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
extern void WebPInitAlphaProcessingSSE2(void);
+static volatile VP8CPUInfo alpha_processing_last_cpuinfo_used =
+ (VP8CPUInfo)&alpha_processing_last_cpuinfo_used;
+
void WebPInitAlphaProcessing(void) {
+ if (alpha_processing_last_cpuinfo_used == VP8GetCPUInfo) return;
+
WebPMultARGBRow = MultARGBRow;
WebPMultRow = MultRow;
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
@@ -326,4 +331,5 @@ void WebPInitAlphaProcessing(void) {
}
#endif
}
+ alpha_processing_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/third_party/libwebp/dsp/cpu.c b/third_party/libwebp/dsp/cpu.c
index 8754f87..ef04a75 100644
--- a/third_party/libwebp/dsp/cpu.c
+++ b/third_party/libwebp/dsp/cpu.c
@@ -29,16 +29,18 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
"cpuid\n"
"xchg %%edi, %%ebx\n"
: "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type));
+ : "a"(info_type), "c"(0));
}
#elif defined(__i386__) || defined(__x86_64__)
static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
__asm__ volatile (
"cpuid\n"
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type));
+ : "a"(info_type), "c"(0));
}
-#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 // >= VS2008 SP1
+#elif (defined(_M_X64) || defined(_M_IX86)) && \
+ defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 // >= VS2008 SP1
+#include <intrin.h>
#define GetCPUInfo(info, type) __cpuidex(info, type, 0) // set ecx=0
#elif defined(WEBP_MSC_SSE2)
#define GetCPUInfo __cpuid
@@ -55,7 +57,9 @@ static WEBP_INLINE uint64_t xgetbv(void) {
: "=a"(eax), "=d"(edx) : "c" (ecx));
return ((uint64_t)edx << 32) | eax;
}
-#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219 // >= VS2010 SP1
+#elif (defined(_M_X64) || defined(_M_IX86)) && \
+ defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219 // >= VS2010 SP1
+#include <immintrin.h>
#define xgetbv() _xgetbv(0)
#elif defined(_MSC_VER) && defined(_M_IX86)
static WEBP_INLINE uint64_t xgetbv(void) {
diff --git a/third_party/libwebp/dsp/dec.c b/third_party/libwebp/dsp/dec.c
index 65a2a88..3a8dc81 100644
--- a/third_party/libwebp/dsp/dec.c
+++ b/third_party/libwebp/dsp/dec.c
@@ -688,7 +688,12 @@ extern void VP8DspInitSSE2(void);
extern void VP8DspInitNEON(void);
extern void VP8DspInitMIPS32(void);
+static volatile VP8CPUInfo dec_last_cpuinfo_used =
+ (VP8CPUInfo)&dec_last_cpuinfo_used;
+
void VP8DspInit(void) {
+ if (dec_last_cpuinfo_used == VP8GetCPUInfo) return;
+
VP8InitClipTables();
VP8TransformWHT = TransformWHT;
@@ -727,5 +732,5 @@ void VP8DspInit(void) {
}
#endif
}
+ dec_last_cpuinfo_used = VP8GetCPUInfo;
}
-
diff --git a/third_party/libwebp/dsp/enc.c b/third_party/libwebp/dsp/enc.c
index e4ea8cb..f4e72d4 100644
--- a/third_party/libwebp/dsp/enc.c
+++ b/third_party/libwebp/dsp/enc.c
@@ -692,7 +692,12 @@ extern void VP8EncDspInitAVX2(void);
extern void VP8EncDspInitNEON(void);
extern void VP8EncDspInitMIPS32(void);
+static volatile VP8CPUInfo enc_last_cpuinfo_used =
+ (VP8CPUInfo)&enc_last_cpuinfo_used;
+
void VP8EncDspInit(void) {
+ if (enc_last_cpuinfo_used == VP8GetCPUInfo) return;
+
VP8DspInit(); // common inverse transforms
InitTables();
@@ -737,5 +742,6 @@ void VP8EncDspInit(void) {
}
#endif
}
+ enc_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/third_party/libwebp/dsp/enc_neon.c b/third_party/libwebp/dsp/enc_neon.c
index bcab8ff..5814fac 100644
--- a/third_party/libwebp/dsp/enc_neon.c
+++ b/third_party/libwebp/dsp/enc_neon.c
@@ -1012,9 +1012,10 @@ static int QuantizeBlock(int16_t in[16], int16_t out[16],
const int16x8_t out0 = Quantize(in, mtx, 0);
const int16x8_t out1 = Quantize(in, mtx, 8);
uint8x8x4_t shuffles;
- // vtbl4_u8 is marked unavailable for iOS arm64, use wider versions there.
+ // vtbl?_u8 are marked unavailable for iOS arm64 with Xcode < 6.3, use
+ // non-standard versions there.
#if defined(__APPLE__) && defined(__aarch64__) && \
- defined(__apple_build_version__)
+ defined(__apple_build_version__) && (__apple_build_version__< 6020037)
uint8x16x2_t all_out;
INIT_VECTOR2(all_out, vreinterpretq_u8_s16(out0), vreinterpretq_u8_s16(out1));
INIT_VECTOR4(shuffles,
diff --git a/third_party/libwebp/dsp/lossless.c b/third_party/libwebp/dsp/lossless.c
index a1bf358..ee334bc 100644
--- a/third_party/libwebp/dsp/lossless.c
+++ b/third_party/libwebp/dsp/lossless.c
@@ -1590,7 +1590,12 @@ extern void VP8LDspInitSSE2(void);
extern void VP8LDspInitNEON(void);
extern void VP8LDspInitMIPS32(void);
+static volatile VP8CPUInfo lossless_last_cpuinfo_used =
+ (VP8CPUInfo)&lossless_last_cpuinfo_used;
+
void VP8LDspInit(void) {
+ if (lossless_last_cpuinfo_used == VP8GetCPUInfo) return;
+
memcpy(VP8LPredictors, kPredictorsC, sizeof(VP8LPredictors));
VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;
@@ -1634,6 +1639,7 @@ void VP8LDspInit(void) {
}
#endif
}
+ lossless_last_cpuinfo_used = VP8GetCPUInfo;
}
//------------------------------------------------------------------------------
diff --git a/third_party/libwebp/dsp/lossless_neon.c b/third_party/libwebp/dsp/lossless_neon.c
index 987767b..8c82b19 100644
--- a/third_party/libwebp/dsp/lossless_neon.c
+++ b/third_party/libwebp/dsp/lossless_neon.c
@@ -259,20 +259,45 @@ static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
//------------------------------------------------------------------------------
// Subtract-Green Transform
-// vtbl? are unavailable in iOS/arm64 builds.
-#if !defined(__aarch64__)
+// vtbl?_u8 are marked unavailable for iOS arm64 with Xcode < 6.3, use
+// non-standard versions there.
+#if defined(__APPLE__) && defined(__aarch64__) && \
+ defined(__apple_build_version__) && (__apple_build_version__< 6020037)
+#define USE_VTBLQ
+#endif
+
+#ifdef USE_VTBLQ
+// 255 = byte will be zeroed
+static const uint8_t kGreenShuffle[16] = {
+ 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255, 13, 255, 13, 255
+};
-// 255 = byte will be zero'd
+static WEBP_INLINE uint8x16_t DoGreenShuffle(const uint8x16_t argb,
+ const uint8x16_t shuffle) {
+ return vcombine_u8(vtbl1q_u8(argb, vget_low_u8(shuffle)),
+ vtbl1q_u8(argb, vget_high_u8(shuffle)));
+}
+#else // !USE_VTBLQ
+// 255 = byte will be zeroed
static const uint8_t kGreenShuffle[8] = { 1, 255, 1, 255, 5, 255, 5, 255 };
+static WEBP_INLINE uint8x16_t DoGreenShuffle(const uint8x16_t argb,
+ const uint8x8_t shuffle) {
+ return vcombine_u8(vtbl1_u8(vget_low_u8(argb), shuffle),
+ vtbl1_u8(vget_high_u8(argb), shuffle));
+}
+#endif // USE_VTBLQ
+
static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
const uint32_t* const end = argb_data + (num_pixels & ~3);
+#ifdef USE_VTBLQ
+ const uint8x16_t shuffle = vld1q_u8(kGreenShuffle);
+#else
const uint8x8_t shuffle = vld1_u8(kGreenShuffle);
+#endif
for (; argb_data < end; argb_data += 4) {
const uint8x16_t argb = vld1q_u8((uint8_t*)argb_data);
- const uint8x16_t greens =
- vcombine_u8(vtbl1_u8(vget_low_u8(argb), shuffle),
- vtbl1_u8(vget_high_u8(argb), shuffle));
+ const uint8x16_t greens = DoGreenShuffle(argb, shuffle);
vst1q_u8((uint8_t*)argb_data, vsubq_u8(argb, greens));
}
// fallthrough and finish off with plain-C
@@ -281,19 +306,21 @@ static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
static void AddGreenToBlueAndRed(uint32_t* argb_data, int num_pixels) {
const uint32_t* const end = argb_data + (num_pixels & ~3);
+#ifdef USE_VTBLQ
+ const uint8x16_t shuffle = vld1q_u8(kGreenShuffle);
+#else
const uint8x8_t shuffle = vld1_u8(kGreenShuffle);
+#endif
for (; argb_data < end; argb_data += 4) {
const uint8x16_t argb = vld1q_u8((uint8_t*)argb_data);
- const uint8x16_t greens =
- vcombine_u8(vtbl1_u8(vget_low_u8(argb), shuffle),
- vtbl1_u8(vget_high_u8(argb), shuffle));
+ const uint8x16_t greens = DoGreenShuffle(argb, shuffle);
vst1q_u8((uint8_t*)argb_data, vaddq_u8(argb, greens));
}
// fallthrough and finish off with plain-C
VP8LAddGreenToBlueAndRed_C(argb_data, num_pixels & 3);
}
-#endif // !__aarch64__
+#undef USE_VTBLQ
#endif // USE_INTRINSICS
@@ -320,11 +347,9 @@ void VP8LDspInitNEON(void) {
VP8LPredictors[12] = Predictor12;
VP8LPredictors[13] = Predictor13;
-#if !defined(__aarch64__)
VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed;
VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed;
#endif
-#endif
#endif // WEBP_USE_NEON
}
diff --git a/third_party/libwebp/dsp/upsampling.c b/third_party/libwebp/dsp/upsampling.c
index 2b1656b..53c68d5 100644
--- a/third_party/libwebp/dsp/upsampling.c
+++ b/third_party/libwebp/dsp/upsampling.c
@@ -189,7 +189,12 @@ const WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = {
extern void WebPInitUpsamplersSSE2(void);
extern void WebPInitUpsamplersNEON(void);
+static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 =
+ (VP8CPUInfo)&upsampling_last_cpuinfo_used2;
+
void WebPInitUpsamplers(void) {
+ if (upsampling_last_cpuinfo_used2 == VP8GetCPUInfo) return;
+
#ifdef FANCY_UPSAMPLING
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
@@ -217,6 +222,7 @@ void WebPInitUpsamplers(void) {
#endif
}
#endif // FANCY_UPSAMPLING
+ upsampling_last_cpuinfo_used2 = VP8GetCPUInfo;
}
//------------------------------------------------------------------------------
diff --git a/third_party/libwebp/dsp/yuv.c b/third_party/libwebp/dsp/yuv.c
index d7cb4eb..6f422da 100644
--- a/third_party/libwebp/dsp/yuv.c
+++ b/third_party/libwebp/dsp/yuv.c
@@ -123,7 +123,12 @@ WebPSamplerRowFunc WebPSamplers[MODE_LAST];
extern void WebPInitSamplersSSE2(void);
extern void WebPInitSamplersMIPS32(void);
+static volatile VP8CPUInfo yuv_last_cpuinfo_used =
+ (VP8CPUInfo)&yuv_last_cpuinfo_used;
+
void WebPInitSamplers(void) {
+ if (yuv_last_cpuinfo_used == VP8GetCPUInfo) return;
+
WebPSamplers[MODE_RGB] = YuvToRgbRow;
WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
WebPSamplers[MODE_BGR] = YuvToBgrRow;
@@ -149,6 +154,7 @@ void WebPInitSamplers(void) {
}
#endif // WEBP_USE_MIPS32
}
+ yuv_last_cpuinfo_used = VP8GetCPUInfo;
}
//-----------------------------------------------------------------------------