Speed up vp9 encoder reference fuzzer

Replace mock implmentation with manual noop implementaion.
libvpx interface is called a lot, and mock implementation of it adds
noticable overhead.

Bug: chromium:1281020
Change-Id: I7fe5cbfd08d5056a14d75e009acff368700c26a8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269214
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37656}
This commit is contained in:
Danil Chapovalov 2022-07-27 16:50:21 +02:00 committed by WebRTC LUCI CQ
parent d10b2b6560
commit bf607e2564
2 changed files with 83 additions and 5 deletions

View File

@ -698,7 +698,7 @@ if (rtc_build_libvpx) {
"../../api/video:video_frame",
"../../api/video_codecs:video_codecs_api",
"../../modules/video_coding:frame_dependencies_calculator",
"../../modules/video_coding:mock_libvpx_interface",
"../../modules/video_coding:webrtc_libvpx_interface",
"../../modules/video_coding:webrtc_vp9",
"../../rtc_base:safe_compare",
rtc_libvpx_dir,

View File

@ -18,12 +18,11 @@
#include "api/video/video_frame.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "modules/video_coding/codecs/interface/mock_libvpx_interface.h"
#include "modules/video_coding/codecs/interface/libvpx_interface.h"
#include "modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h"
#include "modules/video_coding/frame_dependencies_calculator.h"
#include "rtc_base/numerics/safe_compare.h"
#include "test/fuzzers/fuzz_data_helper.h"
#include "test/gmock.h"
// Fuzzer simulates various svc configurations and libvpx encoder dropping
// layer frames.
@ -32,7 +31,6 @@ namespace webrtc {
namespace {
using test::FuzzDataHelper;
using ::testing::NiceMock;
constexpr int kBitrateEnabledBps = 100'000;
@ -304,7 +302,7 @@ struct LibvpxState {
vpx_codec_cx_pkt pkt = {};
};
class StubLibvpx : public NiceMock<MockLibvpxInterface> {
class StubLibvpx : public LibvpxInterface {
public:
explicit StubLibvpx(LibvpxState* state) : state_(state) { RTC_CHECK(state_); }
@ -410,6 +408,86 @@ class StubLibvpx : public NiceMock<MockLibvpxInterface> {
return VPX_CODEC_OK;
}
vpx_image_t* img_alloc(vpx_image_t* img,
vpx_img_fmt_t fmt,
unsigned int d_w,
unsigned int d_h,
unsigned int align) const override {
return nullptr;
}
void img_free(vpx_image_t* img) const override {}
vpx_codec_err_t codec_enc_init_multi(vpx_codec_ctx_t* ctx,
vpx_codec_iface_t* iface,
vpx_codec_enc_cfg_t* cfg,
int num_enc,
vpx_codec_flags_t flags,
vpx_rational_t* dsf) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_destroy(vpx_codec_ctx_t* ctx) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
uint32_t param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
int param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
int* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_roi_map* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_active_map* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_scaling_mode* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_svc_extra_cfg_t* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(
vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_svc_spatial_layer_sync_t* param) const override {
return VPX_CODEC_OK;
}
vpx_codec_err_t codec_control(vpx_codec_ctx_t* ctx,
vp8e_enc_control_id ctrl_id,
vpx_rc_funcs_t* param) const override {
return VPX_CODEC_OK;
}
const vpx_codec_cx_pkt_t* codec_get_cx_data(
vpx_codec_ctx_t* ctx,
vpx_codec_iter_t* iter) const override {
return nullptr;
}
const char* codec_error_detail(vpx_codec_ctx_t* ctx) const override {
return nullptr;
}
const char* codec_error(vpx_codec_ctx_t* ctx) const override {
return nullptr;
}
const char* codec_err_to_string(vpx_codec_err_t err) const override {
return nullptr;
}
private:
LibvpxState* const state_;
};