Skip to content

Commit

Permalink
use WEBP_DSP_INIT_FUNC for Init{GammaTables*,GetCoeffs}
Browse files Browse the repository at this point in the history
this provides stronger synchronization when pthreads are available as
was done in 'd77bf512 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC' for the
other init functions.

Change-Id: I2ffe4e24454d276c2411ece34dca38d23d4756d5
  • Loading branch information
jzern committed Sep 11, 2020
1 parent 55a080e commit cf847cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/dec/vp8_dec.c
Expand Up @@ -494,13 +494,11 @@ static int GetCoeffsAlt(VP8BitReader* const br,
return 16;
}

static WEBP_TSAN_IGNORE_FUNCTION void InitGetCoeffs(void) {
if (GetCoeffs == NULL) {
if (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kSlowSSSE3)) {
GetCoeffs = GetCoeffsAlt;
} else {
GetCoeffs = GetCoeffsFast;
}
WEBP_DSP_INIT_FUNC(InitGetCoeffs) {
if (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kSlowSSSE3)) {
GetCoeffs = GetCoeffsAlt;
} else {
GetCoeffs = GetCoeffsFast;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/enc/picture_csp_enc.c
Expand Up @@ -90,8 +90,9 @@ int WebPPictureHasTransparency(const WebPPicture* picture) {
static int kLinearToGammaTab[kGammaTabSize + 1];
static uint16_t kGammaToLinearTab[256];
static volatile int kGammaTablesOk = 0;
static void InitGammaTables(void);

static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTables(void) {
WEBP_DSP_INIT_FUNC(InitGammaTables) {
if (!kGammaTablesOk) {
int v;
const double scale = (double)(1 << kGammaTabFix) / kGammaScale;
Expand Down Expand Up @@ -181,8 +182,9 @@ static uint32_t kLinearToGammaTabS[kGammaTabSize + 2];
#define GAMMA_TO_LINEAR_BITS 14
static uint32_t kGammaToLinearTabS[MAX_Y_T + 1]; // size scales with Y_FIX
static volatile int kGammaTablesSOk = 0;
static void InitGammaTablesS(void);

static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTablesS(void) {
WEBP_DSP_INIT_FUNC(InitGammaTablesS) {
assert(2 * GAMMA_TO_LINEAR_BITS < 32); // we use uint32_t intermediate values
if (!kGammaTablesSOk) {
int v;
Expand Down

0 comments on commit cf847cb

Please sign in to comment.