webrtc/modules/video_coding/codecs/test/videocodec_test_parameterized.cc
Kári Tristan Helgason 9d96e92316 Rewrite videoprocessor integrationtest to use public fixture.
This CL creates a test fixture for the videoprocessor integration tests
and exposes it as part of the public API. It also rewrites the current
versions of the tests to build on this new paradigm. The motivation for
this is to easily allow projects that build on top of webrtc to add
integration-level tests for their own custom codec implementations in a
way that does not link them too tightly to the internal implementations
of said tests.

Bug: None
Change-Id: I7cf9f29322a6934b3cfc32da02ea7dfa5858c2b2
Reviewed-on: https://webrtc-review.googlesource.com/72481
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23118}
2018-05-04 12:02:44 +00:00

107 lines
3.6 KiB
C++

/*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/create_videocodec_test_fixture.h"
#include "test/gtest.h"
#include "test/testsupport/fileutils.h"
namespace webrtc {
namespace test {
namespace {
// Loop variables.
const size_t kBitrates[] = {500};
const VideoCodecType kVideoCodecType[] = {kVideoCodecVP8};
const bool kHwCodec[] = {false};
// Codec settings.
const int kNumSpatialLayers = 1;
const int kNumTemporalLayers = 1;
const bool kDenoisingOn = false;
const bool kSpatialResizeOn = false;
const bool kFrameDropperOn = false;
// Test settings.
const bool kUseSingleCore = false;
const bool kMeasureCpu = false;
const VisualizationParams kVisualizationParams = {
false, // save_encoded_ivf
false, // save_decoded_y4m
};
const int kNumFrames = 30;
} // namespace
// Tests for plotting statistics from logs.
class VideoProcessorIntegrationTestParameterized
: public ::testing::Test,
public ::testing::WithParamInterface<
::testing::tuple<size_t, VideoCodecType, bool>> {
protected:
VideoProcessorIntegrationTestParameterized()
: bitrate_(::testing::get<0>(GetParam())),
codec_type_(::testing::get<1>(GetParam())),
hw_codec_(::testing::get<2>(GetParam())) {}
~VideoProcessorIntegrationTestParameterized() override = default;
void RunTest(size_t width,
size_t height,
size_t framerate,
const std::string& filename) {
TestConfig config;
config.filename = filename;
config.filepath = ResourcePath(filename, "yuv");
config.use_single_core = kUseSingleCore;
config.measure_cpu = kMeasureCpu;
config.hw_encoder = hw_codec_;
config.hw_decoder = hw_codec_;
config.num_frames = kNumFrames;
const size_t num_simulcast_streams =
codec_type_ == kVideoCodecVP8 ? kNumSpatialLayers : 1;
const size_t num_spatial_layers =
codec_type_ == kVideoCodecVP9 ? kNumSpatialLayers : 1;
const std::string codec_name = CodecTypeToPayloadString(codec_type_);
config.SetCodecSettings(codec_name, num_simulcast_streams,
num_spatial_layers, kNumTemporalLayers,
kDenoisingOn, kFrameDropperOn, kSpatialResizeOn,
width, height);
std::vector<RateProfile> rate_profiles = {
{bitrate_, framerate, kNumFrames}};
fixture_ = CreateVideoCodecTestFixture(config);
fixture_->RunTest(rate_profiles, nullptr, nullptr, nullptr,
&kVisualizationParams);
}
std::unique_ptr<VideoCodecTestFixture> fixture_;
const size_t bitrate_;
const VideoCodecType codec_type_;
const bool hw_codec_;
};
INSTANTIATE_TEST_CASE_P(CodecSettings,
VideoProcessorIntegrationTestParameterized,
::testing::Combine(::testing::ValuesIn(kBitrates),
::testing::ValuesIn(kVideoCodecType),
::testing::ValuesIn(kHwCodec)));
TEST_P(VideoProcessorIntegrationTestParameterized, Foreman_352x288_30) {
RunTest(352, 288, 30, "foreman_cif");
}
TEST_P(VideoProcessorIntegrationTestParameterized,
DISABLED_FourPeople_1280x720_30) {
RunTest(1280, 720, 30, "FourPeople_1280x720_30");
}
} // namespace test
} // namespace webrtc