vpx_dec_fuzzer: Remove dependency on tools_common.c
Instead of calling get_vpx_decoder_by_name(), derive decoder interface directly. This will avoid dependecy on tools_common and hence any potential updates needed to build fuzzer, when tools_common uses functions defined in a different file With this dependency removed, fuzzer no longer needs to enable examples when building vpx_dec_fuzzer binaries Change-Id: I05753edf041b4bc742a6dc06e809a8a2929d379f
This commit is contained in:
@@ -33,7 +33,8 @@
|
|||||||
* Out of memory errors when running generated fuzzer binary
|
* Out of memory errors when running generated fuzzer binary
|
||||||
$../libvpx/configure --disable-unit-tests --size-limit=12288x12288 \
|
$../libvpx/configure --disable-unit-tests --size-limit=12288x12288 \
|
||||||
--extra-cflags="-DVPX_MAX_ALLOCABLE_MEMORY=1073741824" \
|
--extra-cflags="-DVPX_MAX_ALLOCABLE_MEMORY=1073741824" \
|
||||||
--disable-webm-io --enable-debug
|
--disable-webm-io --enable-debug --disable-vp8-encoder \
|
||||||
|
--disable-vp9-encoder --disable-examples
|
||||||
|
|
||||||
* Build libvpx
|
* Build libvpx
|
||||||
$make -j32
|
$make -j32
|
||||||
@@ -42,7 +43,7 @@
|
|||||||
$ $CXX $CXXFLAGS -std=c++11 -DDECODER=vp9 \
|
$ $CXX $CXXFLAGS -std=c++11 -DDECODER=vp9 \
|
||||||
-fsanitize=fuzzer -I../libvpx -I. -Wl,--start-group \
|
-fsanitize=fuzzer -I../libvpx -I. -Wl,--start-group \
|
||||||
../libvpx/examples/vpx_dec_fuzzer.cc -o ./vpx_dec_fuzzer_vp9 \
|
../libvpx/examples/vpx_dec_fuzzer.cc -o ./vpx_dec_fuzzer_vp9 \
|
||||||
./libvpx.a ./tools_common.c.o -Wl,--end-group
|
./libvpx.a -Wl,--end-group
|
||||||
|
|
||||||
* DECODER should be defined as vp9 or vp8 to enable vp9/vp8
|
* DECODER should be defined as vp9 or vp8 to enable vp9/vp8
|
||||||
*
|
*
|
||||||
@@ -66,13 +67,15 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "./tools_common.h"
|
|
||||||
#include "vpx/vp8dx.h"
|
#include "vpx/vp8dx.h"
|
||||||
#include "vpx/vpx_decoder.h"
|
#include "vpx/vpx_decoder.h"
|
||||||
#include "vpx_ports/mem_ops.h"
|
#include "vpx_ports/mem_ops.h"
|
||||||
|
|
||||||
#define VPX_TOSTRING(str) #str
|
#define IVF_FRAME_HDR_SZ (4 + 8) /* 4 byte size + 8 byte timestamp */
|
||||||
#define VPX_STRINGIFY(str) VPX_TOSTRING(str)
|
#define IVF_FILE_HDR_SZ 32
|
||||||
|
|
||||||
|
#define VPXD_INTERFACE(name) VPXD_INTERFACE_(name)
|
||||||
|
#define VPXD_INTERFACE_(name) vpx_codec_##name##_dx()
|
||||||
|
|
||||||
static void CloseFile(FILE *file) { fclose(file); }
|
static void CloseFile(FILE *file) { fclose(file); }
|
||||||
|
|
||||||
@@ -131,16 +134,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
if (fread(header, 1, IVF_FILE_HDR_SZ, file.get()) != IVF_FILE_HDR_SZ) {
|
if (fread(header, 1, IVF_FILE_HDR_SZ, file.get()) != IVF_FILE_HDR_SZ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const VpxInterface *decoder = get_vpx_decoder_by_name(VPX_STRINGIFY(DECODER));
|
|
||||||
if (decoder == nullptr) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
vpx_codec_ctx_t codec;
|
vpx_codec_ctx_t codec;
|
||||||
// Set thread count in the range [1, 64].
|
// Set thread count in the range [1, 64].
|
||||||
const unsigned int threads = (data[IVF_FILE_HDR_SZ] & 0x3f) + 1;
|
const unsigned int threads = (data[IVF_FILE_HDR_SZ] & 0x3f) + 1;
|
||||||
vpx_codec_dec_cfg_t cfg = { threads, 0, 0 };
|
vpx_codec_dec_cfg_t cfg = { threads, 0, 0 };
|
||||||
if (vpx_codec_dec_init(&codec, decoder->codec_interface(), &cfg, 0)) {
|
if (vpx_codec_dec_init(&codec, VPXD_INTERFACE(DECODER), &cfg, 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user