From f17976d01993391c002d7a333bd1d882f2741180 Mon Sep 17 00:00:00 2001 From: Kuang-che Wu Date: Thu, 10 Oct 2019 21:11:47 +0800 Subject: [PATCH] Use single thread vp9 decoder for fuzzing Single thread vp9 decoder is more fuzzer friendly. Bug: chromium:1009073 Change-Id: I7f98680f1ce227126a62a1beccd8a283c9423aa6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/156361 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Kuang-che Wu Cr-Commit-Position: refs/heads/master@{#29435} --- modules/video_coding/codecs/vp9/vp9_impl.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc index bbc1f715b3..74d8e894d7 100644 --- a/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -1625,10 +1625,20 @@ int VP9DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) { vpx_codec_dec_cfg_t cfg; memset(&cfg, 0, sizeof(cfg)); +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + // We focus on webrtc fuzzing here, not libvpx itself. Use single thread for + // fuzzing, because: + // - libvpx's VP9 single thread decoder is more fuzzer friendly. It detects + // errors earlier than the multi-threads version. + // - Make peak CPU usage under control (not depending on input) + cfg.threads = 1; + (void)kMaxNumTiles4kVideo; // unused +#else // We want to use multithreading when decoding high resolution videos. But, // since we don't know resolution of input stream at this stage, we always // enable it. cfg.threads = std::min(number_of_cores, kMaxNumTiles4kVideo); +#endif vpx_codec_flags_t flags = 0; if (vpx_codec_dec_init(decoder_, vpx_codec_vp9_dx(), &cfg, flags)) {