mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-28 06:43:18 +01:00
multi-thread fix: lock each entry points with a static var
we compare the current VP8GetCPUInfo pointer to the last used. This is less code overall and each implementation is still testable separately (by just changing VP8GetCPUInfo, but not a separate threads!) (cherry picked from commit a437694a17e2ee4c68bf0abba8e45e0dfd2a8e27) Conflicts: src/dsp/alpha_processing.c src/dsp/argb.c src/dsp/dec.c src/dsp/enc.c src/dsp/lossless.c src/dsp/upsampling.c src/dsp/yuv.c Change-Id: Ia13fa8ffc4561a884508f6ab71ed0d1b9f1ce59b
This commit is contained in:
parent
5c1eeda922
commit
3ae78eb757
@ -311,7 +311,11 @@ int (*WebPExtractAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
|
||||
|
||||
extern void WebPInitAlphaProcessingSSE2(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
||||
|
||||
void WebPInitAlphaProcessing(void) {
|
||||
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
||||
|
||||
WebPMultARGBRow = MultARGBRow;
|
||||
WebPMultRow = MultRow;
|
||||
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
|
||||
@ -326,4 +330,5 @@ void WebPInitAlphaProcessing(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
last_cpuinfo_used = VP8GetCPUInfo;
|
||||
}
|
||||
|
@ -688,7 +688,11 @@ extern void VP8DspInitSSE2(void);
|
||||
extern void VP8DspInitNEON(void);
|
||||
extern void VP8DspInitMIPS32(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
||||
|
||||
void VP8DspInit(void) {
|
||||
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
||||
|
||||
VP8InitClipTables();
|
||||
|
||||
VP8TransformWHT = TransformWHT;
|
||||
@ -727,5 +731,5 @@ void VP8DspInit(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
last_cpuinfo_used = VP8GetCPUInfo;
|
||||
}
|
||||
|
||||
|
@ -692,7 +692,11 @@ extern void VP8EncDspInitAVX2(void);
|
||||
extern void VP8EncDspInitNEON(void);
|
||||
extern void VP8EncDspInitMIPS32(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
||||
|
||||
void VP8EncDspInit(void) {
|
||||
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
||||
|
||||
VP8DspInit(); // common inverse transforms
|
||||
InitTables();
|
||||
|
||||
@ -737,5 +741,6 @@ void VP8EncDspInit(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
last_cpuinfo_used = VP8GetCPUInfo;
|
||||
}
|
||||
|
||||
|
@ -1590,7 +1590,11 @@ extern void VP8LDspInitSSE2(void);
|
||||
extern void VP8LDspInitNEON(void);
|
||||
extern void VP8LDspInitMIPS32(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
||||
|
||||
void VP8LDspInit(void) {
|
||||
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
||||
|
||||
memcpy(VP8LPredictors, kPredictorsC, sizeof(VP8LPredictors));
|
||||
|
||||
VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;
|
||||
@ -1634,6 +1638,7 @@ void VP8LDspInit(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
last_cpuinfo_used = VP8GetCPUInfo;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -189,7 +189,11 @@ const WebPYUV444Converter WebPYUV444Converters[MODE_LAST] = {
|
||||
extern void WebPInitUpsamplersSSE2(void);
|
||||
extern void WebPInitUpsamplersNEON(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used2 = (VP8CPUInfo)&last_cpuinfo_used2;
|
||||
|
||||
void WebPInitUpsamplers(void) {
|
||||
if (last_cpuinfo_used2 == VP8GetCPUInfo) return;
|
||||
|
||||
#ifdef FANCY_UPSAMPLING
|
||||
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
|
||||
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
|
||||
@ -217,6 +221,7 @@ void WebPInitUpsamplers(void) {
|
||||
#endif
|
||||
}
|
||||
#endif // FANCY_UPSAMPLING
|
||||
last_cpuinfo_used2 = VP8GetCPUInfo;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -123,7 +123,11 @@ WebPSamplerRowFunc WebPSamplers[MODE_LAST];
|
||||
extern void WebPInitSamplersSSE2(void);
|
||||
extern void WebPInitSamplersMIPS32(void);
|
||||
|
||||
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
||||
|
||||
void WebPInitSamplers(void) {
|
||||
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
||||
|
||||
WebPSamplers[MODE_RGB] = YuvToRgbRow;
|
||||
WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
|
||||
WebPSamplers[MODE_BGR] = YuvToBgrRow;
|
||||
@ -149,6 +153,7 @@ void WebPInitSamplers(void) {
|
||||
}
|
||||
#endif // WEBP_USE_MIPS32
|
||||
}
|
||||
last_cpuinfo_used = VP8GetCPUInfo;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user