ref: 42f801202531a6f9ce4d2aacb7b8f158e860b295
parent: 936ada3304ec17ce4aaa75e610f053d2103ad42c
author: Harish Mahendrakar <harish.mahendrakar@ittiam.com>
date: Fri Feb 1 07:25:03 EST 2019
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
--- a/examples/vpx_dec_fuzzer.cc
+++ b/examples/vpx_dec_fuzzer.cc
@@ -33,7 +33,8 @@
* Out of memory errors when running generated fuzzer binary
$../libvpx/configure --disable-unit-tests --size-limit=12288x12288 \
--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
$make -j32
@@ -42,7 +43,7 @@
$ $CXX $CXXFLAGS -std=c++11 -DDECODER=vp9 \
-fsanitize=fuzzer -I../libvpx -I. -Wl,--start-group \
../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
*
@@ -66,14 +67,16 @@
#include <stdlib.h>
#include <memory>
-#include "./tools_common.h"
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
#include "vpx_ports/mem_ops.h"
-#define VPX_TOSTRING(str) #str
-#define VPX_STRINGIFY(str) VPX_TOSTRING(str)
+#define IVF_FRAME_HDR_SZ (4 + 8) /* 4 byte size + 8 byte timestamp */
+#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); }
/* ReadFrame is derived from ivf_read_frame in ivfdec.c
@@ -131,16 +134,12 @@
if (fread(header, 1, IVF_FILE_HDR_SZ, file.get()) != IVF_FILE_HDR_SZ) {
return 0;
}
- const VpxInterface *decoder = get_vpx_decoder_by_name(VPX_STRINGIFY(DECODER));
- if (decoder == nullptr) {
- return 0;
- }
vpx_codec_ctx_t codec;
// Set thread count in the range [1, 64].
const unsigned int threads = (data[IVF_FILE_HDR_SZ] & 0x3f) + 1;
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;
}