mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
SSE2 version of simple in-loop filtering
~10% faster decoding Patch by Somnath Banerjee (somnath at google dot com) Change-Id: I200db408272b4f61cda9d9261d2d4370a698d6c4
This commit is contained in:
@ -682,9 +682,62 @@ void (*VP8SimpleVFilter16i)(uint8_t*, int, int) = SimpleVFilter16i;
|
||||
void (*VP8SimpleHFilter16i)(uint8_t*, int, int) = SimpleHFilter16i;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SSE2 detection.
|
||||
//
|
||||
|
||||
#if defined(__pic__) && defined(__i386__)
|
||||
static inline void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||
__asm__ volatile (
|
||||
"mov %%ebx, %%edi\n"
|
||||
"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));
|
||||
}
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
static 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));
|
||||
}
|
||||
#elif defined(_MSC_VER) // Visual C++
|
||||
#define GetCPUInfo __cpuid
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
|
||||
static int x86CPUInfo(CPUFeature feature) {
|
||||
int cpu_info[4];
|
||||
GetCPUInfo(cpu_info, 1);
|
||||
if (feature == kSSE2) {
|
||||
return 0 != (cpu_info[3] & 0x04000000);
|
||||
}
|
||||
if (feature == kSSE3) {
|
||||
return 0 != (cpu_info[2] & 0x00000001);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
VP8CPUInfo VP8DecGetCPUInfo = x86CPUInfo;
|
||||
#else
|
||||
VP8CPUInfo VP8DecGetCPUInfo = NULL;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern void VP8DspInitSSE2(void);
|
||||
|
||||
void VP8DspInit(void) {
|
||||
// later we'll plug some SSE2 variant here
|
||||
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
||||
if (VP8DecGetCPUInfo) {
|
||||
if (VP8DecGetCPUInfo(kSSE2)) {
|
||||
#if defined(__SSE2__) || defined(_MSC_VER)
|
||||
VP8DspInitSSE2();
|
||||
#endif
|
||||
}
|
||||
if (VP8DecGetCPUInfo(kSSE3)) {
|
||||
// later we'll plug some SSE3 variant here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
Reference in New Issue
Block a user