dsp/*: use WEBP_HAVE_* to determine Init availability

after:
  ece18e55 dsp.h: respect --disable-sse2/sse4.1/neon
WEBP_USE_* will be set when a module is targeting a particular
instruction set, e.g., sse4.1, and not overridden if WEBP_HAVE_SSE41 is
set, as previously this would ignore the case where the instruction set
was disabled via config.h and the HAVE macro was unset.

dsp.h not ensures WEBP_HAVE_* are set when WEBP_USE_* to cover cases
where the files are built without config.h.

Change-Id: Ia1c2dcf4100cc1081d968acb6e085e2a1768ece6
(cherry picked from commit 1fe3162541)
This commit is contained in:
James Zern 2021-07-23 22:19:07 -07:00
parent 3a4d3ecd40
commit d250f01d95
13 changed files with 53 additions and 41 deletions

View File

@ -453,10 +453,10 @@ WEBP_DSP_INIT_FUNC(WebPInitAlphaProcessing) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitAlphaProcessingSSE2(); WebPInitAlphaProcessingSSE2();
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
WebPInitAlphaProcessingSSE41(); WebPInitAlphaProcessingSSE41();
} }
@ -470,7 +470,7 @@ WEBP_DSP_INIT_FUNC(WebPInitAlphaProcessing) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
WebPInitAlphaProcessingNEON(); WebPInitAlphaProcessingNEON();

View File

@ -395,12 +395,12 @@ WEBP_DSP_INIT_FUNC(VP8EncDspCostInit) {
VP8EncDspCostInitMIPSdspR2(); VP8EncDspCostInitMIPSdspR2();
} }
#endif #endif
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8EncDspCostInitSSE2(); VP8EncDspCostInitSSE2();
} }
#endif #endif
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (VP8GetCPUInfo(kNEON)) { if (VP8GetCPUInfo(kNEON)) {
VP8EncDspCostInitNEON(); VP8EncDspCostInitNEON();
} }

View File

@ -189,17 +189,17 @@ VP8CPUInfo VP8GetCPUInfo = AndroidCPUInfo;
// Use compile flags as an indicator of SIMD support instead of a runtime check. // Use compile flags as an indicator of SIMD support instead of a runtime check.
static int wasmCPUInfo(CPUFeature feature) { static int wasmCPUInfo(CPUFeature feature) {
switch (feature) { switch (feature) {
#ifdef WEBP_USE_SSE2 #ifdef WEBP_HAVE_SSE2
case kSSE2: case kSSE2:
return 1; return 1;
#endif #endif
#ifdef WEBP_USE_SSE41 #ifdef WEBP_HAVE_SSE41
case kSSE3: case kSSE3:
case kSlowSSSE3: case kSlowSSSE3:
case kSSE4_1: case kSSE4_1:
return 1; return 1;
#endif #endif
#ifdef WEBP_USE_NEON #ifdef WEBP_HAVE_NEON
case kNEON: case kNEON:
return 1; return 1;
#endif #endif
@ -209,7 +209,7 @@ static int wasmCPUInfo(CPUFeature feature) {
return 0; return 0;
} }
VP8CPUInfo VP8GetCPUInfo = wasmCPUInfo; VP8CPUInfo VP8GetCPUInfo = wasmCPUInfo;
#elif defined(WEBP_USE_NEON) #elif defined(WEBP_HAVE_NEON)
// In most cases this function doesn't check for NEON support (it's assumed by // In most cases this function doesn't check for NEON support (it's assumed by
// the configuration), but enables turning off NEON at runtime, for testing // the configuration), but enables turning off NEON at runtime, for testing
// purposes, by setting VP8DecGetCPUInfo = NULL. // purposes, by setting VP8DecGetCPUInfo = NULL.

View File

@ -807,10 +807,10 @@ WEBP_DSP_INIT_FUNC(VP8DspInit) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8DspInitSSE2(); VP8DspInitSSE2();
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
VP8DspInitSSE41(); VP8DspInitSSE41();
} }
@ -834,7 +834,7 @@ WEBP_DSP_INIT_FUNC(VP8DspInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
VP8DspInitNEON(); VP8DspInitNEON();

View File

@ -89,11 +89,19 @@ extern "C" {
#define WEBP_USE_SSE2 #define WEBP_USE_SSE2
#endif #endif
#if defined(WEBP_USE_SSE2) && !defined(WEBP_HAVE_SSE2)
#define WEBP_HAVE_SSE2
#endif
#if (defined(__SSE4_1__) || defined(WEBP_MSC_SSE41)) && \ #if (defined(__SSE4_1__) || defined(WEBP_MSC_SSE41)) && \
(!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE41)) (!defined(HAVE_CONFIG_H) || defined(WEBP_HAVE_SSE41))
#define WEBP_USE_SSE41 #define WEBP_USE_SSE41
#endif #endif
#if defined(WEBP_USE_SSE41) && !defined(WEBP_HAVE_SSE41)
#define WEBP_HAVE_SSE41
#endif
#undef WEBP_MSC_SSE41 #undef WEBP_MSC_SSE41
#undef WEBP_MSC_SSE2 #undef WEBP_MSC_SSE2
@ -116,6 +124,10 @@ extern "C" {
#define WEBP_USE_INTRINSICS #define WEBP_USE_INTRINSICS
#endif #endif
#if defined(WEBP_USE_NEON) && !defined(WEBP_HAVE_NEON)
#define WEBP_HAVE_NEON
#endif
#if defined(__mips__) && !defined(__mips64) && \ #if defined(__mips__) && !defined(__mips64) && \
defined(__mips_isa_rev) && (__mips_isa_rev >= 1) && (__mips_isa_rev < 6) defined(__mips_isa_rev) && (__mips_isa_rev >= 1) && (__mips_isa_rev < 6)
#define WEBP_USE_MIPS32 #define WEBP_USE_MIPS32

View File

@ -773,10 +773,10 @@ WEBP_DSP_INIT_FUNC(VP8EncDspInit) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8EncDspInitSSE2(); VP8EncDspInitSSE2();
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
VP8EncDspInitSSE41(); VP8EncDspInitSSE41();
} }
@ -800,7 +800,7 @@ WEBP_DSP_INIT_FUNC(VP8EncDspInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
VP8EncDspInitNEON(); VP8EncDspInitNEON();

View File

@ -254,7 +254,7 @@ WEBP_DSP_INIT_FUNC(VP8FiltersInit) {
#endif #endif
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8FiltersInitSSE2(); VP8FiltersInitSSE2();
} }
@ -271,7 +271,7 @@ WEBP_DSP_INIT_FUNC(VP8FiltersInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
VP8FiltersInitNEON(); VP8FiltersInitNEON();

View File

@ -622,10 +622,10 @@ WEBP_DSP_INIT_FUNC(VP8LDspInit) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8LDspInitSSE2(); VP8LDspInitSSE2();
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
VP8LDspInitSSE41(); VP8LDspInitSSE41();
} }
@ -644,7 +644,7 @@ WEBP_DSP_INIT_FUNC(VP8LDspInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
VP8LDspInitNEON(); VP8LDspInitNEON();

View File

@ -862,10 +862,10 @@ WEBP_DSP_INIT_FUNC(VP8LEncDspInit) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8LEncDspInitSSE2(); VP8LEncDspInitSSE2();
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
VP8LEncDspInitSSE41(); VP8LEncDspInitSSE41();
} }
@ -889,7 +889,7 @@ WEBP_DSP_INIT_FUNC(VP8LEncDspInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
VP8LEncDspInitNEON(); VP8LEncDspInitNEON();

View File

@ -214,7 +214,7 @@ WEBP_DSP_INIT_FUNC(WebPRescalerDspInit) {
WebPRescalerImportRowShrink = WebPRescalerImportRowShrink_C; WebPRescalerImportRowShrink = WebPRescalerImportRowShrink_C;
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPRescalerDspInitSSE2(); WebPRescalerDspInitSSE2();
} }
@ -236,7 +236,7 @@ WEBP_DSP_INIT_FUNC(WebPRescalerDspInit) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
WebPRescalerDspInitNEON(); WebPRescalerDspInitNEON();

View File

@ -150,7 +150,7 @@ WEBP_DSP_INIT_FUNC(VP8SSIMDspInit) {
#endif #endif
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8SSIMDspInitSSE2(); VP8SSIMDspInitSSE2();
} }

View File

@ -233,12 +233,12 @@ WEBP_DSP_INIT_FUNC(WebPInitYUV444Converters) {
WebPYUV444Converters[MODE_rgbA_4444] = WebPYuv444ToRgba4444_C; WebPYUV444Converters[MODE_rgbA_4444] = WebPYuv444ToRgba4444_C;
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitYUV444ConvertersSSE2(); WebPInitYUV444ConvertersSSE2();
} }
#endif #endif
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
WebPInitYUV444ConvertersSSE41(); WebPInitYUV444ConvertersSSE41();
} }
@ -278,12 +278,12 @@ WEBP_DSP_INIT_FUNC(WebPInitUpsamplers) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitUpsamplersSSE2(); WebPInitUpsamplersSSE2();
} }
#endif #endif
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
WebPInitUpsamplersSSE41(); WebPInitUpsamplersSSE41();
} }
@ -300,7 +300,7 @@ WEBP_DSP_INIT_FUNC(WebPInitUpsamplers) {
#endif #endif
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
WebPInitUpsamplersNEON(); WebPInitUpsamplersNEON();

View File

@ -90,16 +90,16 @@ WEBP_DSP_INIT_FUNC(WebPInitSamplers) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitSamplersSSE2(); WebPInitSamplersSSE2();
} }
#endif // WEBP_USE_SSE2 #endif // WEBP_HAVE_SSE2
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
WebPInitSamplersSSE41(); WebPInitSamplersSSE41();
} }
#endif // WEBP_USE_SSE41 #endif // WEBP_HAVE_SSE41
#if defined(WEBP_USE_MIPS32) #if defined(WEBP_USE_MIPS32)
if (VP8GetCPUInfo(kMIPS32)) { if (VP8GetCPUInfo(kMIPS32)) {
WebPInitSamplersMIPS32(); WebPInitSamplersMIPS32();
@ -276,26 +276,26 @@ WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) {
#endif #endif
if (VP8GetCPUInfo != NULL) { if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2) #if defined(WEBP_HAVE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitConvertARGBToYUVSSE2(); WebPInitConvertARGBToYUVSSE2();
WebPInitSharpYUVSSE2(); WebPInitSharpYUVSSE2();
} }
#endif // WEBP_USE_SSE2 #endif // WEBP_HAVE_SSE2
#if defined(WEBP_USE_SSE41) #if defined(WEBP_HAVE_SSE41)
if (VP8GetCPUInfo(kSSE4_1)) { if (VP8GetCPUInfo(kSSE4_1)) {
WebPInitConvertARGBToYUVSSE41(); WebPInitConvertARGBToYUVSSE41();
} }
#endif // WEBP_USE_SSE41 #endif // WEBP_HAVE_SSE41
} }
#if defined(WEBP_USE_NEON) #if defined(WEBP_HAVE_NEON)
if (WEBP_NEON_OMIT_C_CODE || if (WEBP_NEON_OMIT_C_CODE ||
(VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) { (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kNEON))) {
WebPInitConvertARGBToYUVNEON(); WebPInitConvertARGBToYUVNEON();
WebPInitSharpYUVNEON(); WebPInitSharpYUVNEON();
} }
#endif // WEBP_USE_NEON #endif // WEBP_HAVE_NEON
assert(WebPConvertARGBToY != NULL); assert(WebPConvertARGBToY != NULL);
assert(WebPConvertARGBToUV != NULL); assert(WebPConvertARGBToUV != NULL);