mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
Merge changes I8ae09473,I678c8b1e
* changes: fuzz_utils.h: rename max() to Max() fuzz_utils.h: make functions WEBP_INLINE
This commit is contained in:
commit
eb44119c3d
@ -35,7 +35,7 @@ static const size_t kFuzzPxLimit = 1024 * 1024;
|
|||||||
static const int kFuzzFrameLimit = 3;
|
static const int kFuzzFrameLimit = 3;
|
||||||
|
|
||||||
// Reads and sums (up to) 128 spread-out bytes.
|
// Reads and sums (up to) 128 spread-out bytes.
|
||||||
static uint8_t FuzzHash(const uint8_t* const data, size_t size) {
|
static WEBP_INLINE uint8_t FuzzHash(const uint8_t* const data, size_t size) {
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
size_t incr = size / 128;
|
size_t incr = size / 128;
|
||||||
if (!incr) incr = 1;
|
if (!incr) incr = 1;
|
||||||
@ -46,7 +46,8 @@ static uint8_t FuzzHash(const uint8_t* const data, size_t size) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Extract an integer in [0, max_value].
|
// Extract an integer in [0, max_value].
|
||||||
|
|
||||||
static uint32_t Extract(uint32_t max_value, const uint8_t data[], size_t size,
|
static WEBP_INLINE uint32_t Extract(uint32_t max_value,
|
||||||
|
const uint8_t data[], size_t size,
|
||||||
uint32_t* const bit_pos) {
|
uint32_t* const bit_pos) {
|
||||||
uint32_t v = 0;
|
uint32_t v = 0;
|
||||||
uint32_t range = 1;
|
uint32_t range = 1;
|
||||||
@ -64,27 +65,30 @@ static uint32_t Extract(uint32_t max_value, const uint8_t data[], size_t size,
|
|||||||
|
|
||||||
static VP8CPUInfo GetCPUInfo;
|
static VP8CPUInfo GetCPUInfo;
|
||||||
|
|
||||||
static int GetCPUInfoNoSSE41(CPUFeature feature) {
|
static WEBP_INLINE int GetCPUInfoNoSSE41(CPUFeature feature) {
|
||||||
if (feature == kSSE4_1 || feature == kAVX) return 0;
|
if (feature == kSSE4_1 || feature == kAVX) return 0;
|
||||||
return GetCPUInfo(feature);
|
return GetCPUInfo(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetCPUInfoNoAVX(CPUFeature feature) {
|
static WEBP_INLINE int GetCPUInfoNoAVX(CPUFeature feature) {
|
||||||
if (feature == kAVX) return 0;
|
if (feature == kAVX) return 0;
|
||||||
return GetCPUInfo(feature);
|
return GetCPUInfo(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetCPUInfoForceSlowSSSE3(CPUFeature feature) {
|
static WEBP_INLINE int GetCPUInfoForceSlowSSSE3(CPUFeature feature) {
|
||||||
if (feature == kSlowSSSE3 && GetCPUInfo(kSSE3)) {
|
if (feature == kSlowSSSE3 && GetCPUInfo(kSSE3)) {
|
||||||
return 1; // we have SSE3 -> force SlowSSSE3
|
return 1; // we have SSE3 -> force SlowSSSE3
|
||||||
}
|
}
|
||||||
return GetCPUInfo(feature);
|
return GetCPUInfo(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetCPUInfoOnlyC(CPUFeature feature) { return 0; }
|
static WEBP_INLINE int GetCPUInfoOnlyC(CPUFeature feature) {
|
||||||
|
(void)feature;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void ExtractAndDisableOptimizations(VP8CPUInfo default_VP8GetCPUInfo,
|
static WEBP_INLINE void ExtractAndDisableOptimizations(
|
||||||
const uint8_t data[], size_t size,
|
VP8CPUInfo default_VP8GetCPUInfo, const uint8_t data[], size_t size,
|
||||||
uint32_t* const bit_pos) {
|
uint32_t* const bit_pos) {
|
||||||
GetCPUInfo = default_VP8GetCPUInfo;
|
GetCPUInfo = default_VP8GetCPUInfo;
|
||||||
const VP8CPUInfo kVP8CPUInfos[5] = {GetCPUInfoOnlyC, GetCPUInfoForceSlowSSSE3,
|
const VP8CPUInfo kVP8CPUInfos[5] = {GetCPUInfoOnlyC, GetCPUInfoForceSlowSSSE3,
|
||||||
@ -96,8 +100,9 @@ static void ExtractAndDisableOptimizations(VP8CPUInfo default_VP8GetCPUInfo,
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
static int ExtractWebPConfig(WebPConfig* const config, const uint8_t data[],
|
static WEBP_INLINE int ExtractWebPConfig(WebPConfig* const config,
|
||||||
size_t size, uint32_t* const bit_pos) {
|
const uint8_t data[], size_t size,
|
||||||
|
uint32_t* const bit_pos) {
|
||||||
if (config == NULL || !WebPConfigInit(config)) return 0;
|
if (config == NULL || !WebPConfigInit(config)) return 0;
|
||||||
config->lossless = Extract(1, data, size, bit_pos);
|
config->lossless = Extract(1, data, size, bit_pos);
|
||||||
config->quality = Extract(100, data, size, bit_pos);
|
config->quality = Extract(100, data, size, bit_pos);
|
||||||
@ -130,7 +135,7 @@ static int ExtractWebPConfig(WebPConfig* const config, const uint8_t data[],
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
static int ExtractSourcePicture(WebPPicture* const pic,
|
static WEBP_INLINE int ExtractSourcePicture(WebPPicture* const pic,
|
||||||
const uint8_t data[], size_t size,
|
const uint8_t data[], size_t size,
|
||||||
uint32_t* const bit_pos) {
|
uint32_t* const bit_pos) {
|
||||||
if (pic == NULL) return 0;
|
if (pic == NULL) return 0;
|
||||||
@ -164,10 +169,11 @@ static int ExtractSourcePicture(WebPPicture* const pic,
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
static int max(int a, int b) { return ((a < b) ? b : a); }
|
static WEBP_INLINE int Max(int a, int b) { return ((a < b) ? b : a); }
|
||||||
|
|
||||||
static int ExtractAndCropOrScale(WebPPicture* const pic, const uint8_t data[],
|
static WEBP_INLINE int ExtractAndCropOrScale(WebPPicture* const pic,
|
||||||
size_t size, uint32_t* const bit_pos) {
|
const uint8_t data[], size_t size,
|
||||||
|
uint32_t* const bit_pos) {
|
||||||
if (pic == NULL) return 0;
|
if (pic == NULL) return 0;
|
||||||
#if !defined(WEBP_REDUCE_SIZE)
|
#if !defined(WEBP_REDUCE_SIZE)
|
||||||
const int alter_input = Extract(1, data, size, bit_pos);
|
const int alter_input = Extract(1, data, size, bit_pos);
|
||||||
@ -178,8 +184,8 @@ static int ExtractAndCropOrScale(WebPPicture* const pic, const uint8_t data[],
|
|||||||
if (crop_or_scale) {
|
if (crop_or_scale) {
|
||||||
const uint32_t left_ratio = 1 + Extract(7, data, size, bit_pos);
|
const uint32_t left_ratio = 1 + Extract(7, data, size, bit_pos);
|
||||||
const uint32_t top_ratio = 1 + Extract(7, data, size, bit_pos);
|
const uint32_t top_ratio = 1 + Extract(7, data, size, bit_pos);
|
||||||
const int cropped_width = max(1, pic->width / width_ratio);
|
const int cropped_width = Max(1, pic->width / width_ratio);
|
||||||
const int cropped_height = max(1, pic->height / height_ratio);
|
const int cropped_height = Max(1, pic->height / height_ratio);
|
||||||
const int cropped_left = (pic->width - cropped_width) / left_ratio;
|
const int cropped_left = (pic->width - cropped_width) / left_ratio;
|
||||||
const int cropped_top = (pic->height - cropped_height) / top_ratio;
|
const int cropped_top = (pic->height - cropped_height) / top_ratio;
|
||||||
return WebPPictureCrop(pic, cropped_left, cropped_top, cropped_width,
|
return WebPPictureCrop(pic, cropped_left, cropped_top, cropped_width,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
CC = clang
|
CC = clang
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
CFLAGS = -fsanitize=fuzzer -I../../src -I../..
|
CFLAGS = -fsanitize=fuzzer -I../../src -I../.. -Wall -Wextra
|
||||||
CXXFLAGS = $(CFLAGS)
|
CXXFLAGS = $(CFLAGS)
|
||||||
LDFLAGS = -fsanitize=fuzzer
|
LDFLAGS = -fsanitize=fuzzer
|
||||||
LDLIBS = ../../src/mux/libwebpmux.a ../../src/demux/libwebpdemux.a
|
LDLIBS = ../../src/mux/libwebpmux.a ../../src/demux/libwebpdemux.a
|
||||||
@ -14,7 +14,7 @@ FUZZERS = advanced_api_fuzzer animation_api_fuzzer animencoder_fuzzer
|
|||||||
FUZZERS += animdecoder_fuzzer mux_demux_api_fuzzer enc_dec_fuzzer
|
FUZZERS += animdecoder_fuzzer mux_demux_api_fuzzer enc_dec_fuzzer
|
||||||
FUZZERS += simple_api_fuzzer
|
FUZZERS += simple_api_fuzzer
|
||||||
|
|
||||||
%.o: %.c %.cc fuzz_utils.h img_alpha.h img_grid.h img_peak.h
|
%.o: fuzz_utils.h img_alpha.h img_grid.h img_peak.h
|
||||||
all: $(FUZZERS)
|
all: $(FUZZERS)
|
||||||
|
|
||||||
define FUZZER_template
|
define FUZZER_template
|
||||||
|
Loading…
Reference in New Issue
Block a user