mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
webp: WEBP_OFFSET_PTR()
Removes undefined behavior of offsetting NULL. Change-Id: I7c83d0c913c631c091a5fb128f6d6b46b1d116db
This commit is contained in:
parent
687ab00e6e
commit
47309ef52d
@ -193,6 +193,12 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If 'ptr' is NULL, returns NULL. Otherwise returns 'ptr + off'.
|
||||||
|
// Prevents undefined behavior sanitizer nullptr-with-nonzero-offset warning.
|
||||||
|
#if !defined(WEBP_OFFSET_PTR)
|
||||||
|
#define WEBP_OFFSET_PTR(ptr, off) (((ptr) == NULL) ? NULL : ((ptr) + (off)))
|
||||||
|
#endif
|
||||||
|
|
||||||
// Regularize the definition of WEBP_SWAP_16BIT_CSP (backward compatibility)
|
// Regularize the definition of WEBP_SWAP_16BIT_CSP (backward compatibility)
|
||||||
#if !defined(WEBP_SWAP_16BIT_CSP)
|
#if !defined(WEBP_SWAP_16BIT_CSP)
|
||||||
#define WEBP_SWAP_16BIT_CSP 0
|
#define WEBP_SWAP_16BIT_CSP 0
|
||||||
|
@ -460,20 +460,22 @@ static void PredictorSub0_SSE2(const uint32_t* in, const uint32_t* upper,
|
|||||||
(void)upper;
|
(void)upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GENERATE_PREDICTOR_1(X, IN) \
|
#define GENERATE_PREDICTOR_1(X, IN) \
|
||||||
static void PredictorSub##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
|
static void PredictorSub##X##_SSE2(const uint32_t* const in, \
|
||||||
int num_pixels, uint32_t* out) { \
|
const uint32_t* const upper, \
|
||||||
int i; \
|
int num_pixels, uint32_t* const out) { \
|
||||||
for (i = 0; i + 4 <= num_pixels; i += 4) { \
|
int i; \
|
||||||
const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
|
for (i = 0; i + 4 <= num_pixels; i += 4) { \
|
||||||
const __m128i pred = _mm_loadu_si128((const __m128i*)&(IN)); \
|
const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
|
||||||
const __m128i res = _mm_sub_epi8(src, pred); \
|
const __m128i pred = _mm_loadu_si128((const __m128i*)&(IN)); \
|
||||||
_mm_storeu_si128((__m128i*)&out[i], res); \
|
const __m128i res = _mm_sub_epi8(src, pred); \
|
||||||
} \
|
_mm_storeu_si128((__m128i*)&out[i], res); \
|
||||||
if (i != num_pixels) { \
|
} \
|
||||||
VP8LPredictorsSub_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
|
if (i != num_pixels) { \
|
||||||
} \
|
VP8LPredictorsSub_C[(X)](in + i, WEBP_OFFSET_PTR(upper, i), \
|
||||||
}
|
num_pixels - i, out + i); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
GENERATE_PREDICTOR_1(1, in[i - 1]) // Predictor1: L
|
GENERATE_PREDICTOR_1(1, in[i - 1]) // Predictor1: L
|
||||||
GENERATE_PREDICTOR_1(2, upper[i]) // Predictor2: T
|
GENERATE_PREDICTOR_1(2, upper[i]) // Predictor2: T
|
||||||
|
Loading…
Reference in New Issue
Block a user