Make Videoprocessor integration test stringly typed.

This allows use of arbitrarily-named codecs.

Bug: None
Change-Id: If7ecbfe3ae8f08f8ebfb224219ef9192a4a0b884
Reviewed-on: https://webrtc-review.googlesource.com/69681
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22860}
This commit is contained in:
Kári Tristan Helgason
2018-04-13 14:25:22 +02:00
committed by Commit Bot
parent 19a68d405d
commit 8cbb1c9162
9 changed files with 63 additions and 59 deletions

View File

@ -104,7 +104,7 @@ std::string CodecSpecificToString(const VideoCodec& codec) {
} // namespace
void TestConfig::SetCodecSettings(VideoCodecType codec_type,
void TestConfig::SetCodecSettings(std::string codec_name,
size_t num_simulcast_streams,
size_t num_spatial_layers,
size_t num_temporal_layers,
@ -114,6 +114,8 @@ void TestConfig::SetCodecSettings(VideoCodecType codec_type,
bool resilience_on,
size_t width,
size_t height) {
this->codec_name = codec_name;
VideoCodecType codec_type = PayloadStringToCodecType(codec_name);
webrtc::test::CodecSettings(codec_type, &codec_settings);
// TODO(brandtr): Move the setting of |width| and |height| to the tests, and
@ -166,7 +168,6 @@ void TestConfig::SetCodecSettings(VideoCodecType codec_type,
codec_settings.H264()->keyFrameInterval = kBaseKeyFrameInterval;
break;
default:
RTC_NOTREACHED();
break;
}
@ -240,44 +241,37 @@ std::string TestConfig::ToString() const {
}
SdpVideoFormat TestConfig::ToSdpVideoFormat() const {
switch (codec_settings.codecType) {
case kVideoCodecVP8:
return SdpVideoFormat(cricket::kVp8CodecName);
case kVideoCodecVP9:
return SdpVideoFormat(cricket::kVp9CodecName);
case kVideoCodecH264: {
const char* packetization_mode =
h264_codec_settings.packetization_mode ==
H264PacketizationMode::NonInterleaved
? "1"
: "0";
return SdpVideoFormat(
cricket::kH264CodecName,
{{cricket::kH264FmtpProfileLevelId,
*H264::ProfileLevelIdToString(H264::ProfileLevelId(
h264_codec_settings.profile, H264::kLevel3_1))},
{cricket::kH264FmtpPacketizationMode, packetization_mode}});
}
default:
RTC_NOTREACHED();
return SdpVideoFormat("");
if (codec_settings.codecType == kVideoCodecH264) {
const char* packetization_mode =
h264_codec_settings.packetization_mode ==
H264PacketizationMode::NonInterleaved
? "1"
: "0";
return SdpVideoFormat(
codec_name,
{{cricket::kH264FmtpProfileLevelId,
*H264::ProfileLevelIdToString(H264::ProfileLevelId(
h264_codec_settings.profile, H264::kLevel3_1))},
{cricket::kH264FmtpPacketizationMode, packetization_mode}});
}
return SdpVideoFormat(codec_name);
}
std::string TestConfig::CodecName() const {
std::string codec_name = CodecTypeToPayloadString(codec_settings.codecType);
std::string name = codec_name;
if (name.empty()) {
name = CodecTypeToPayloadString(codec_settings.codecType);
}
if (codec_settings.codecType == kVideoCodecH264) {
if (h264_codec_settings.profile == H264::kProfileConstrainedHigh) {
codec_name += "-CHP";
return name + "-CHP";
} else {
RTC_DCHECK_EQ(h264_codec_settings.profile,
H264::kProfileConstrainedBaseline);
codec_name += "-CBP";
return name + "-CBP";
}
}
return codec_name;
return name;
}
std::string TestConfig::FilenameWithParams() const {

View File

@ -31,7 +31,7 @@ struct TestConfig {
const EncodedImage& encoded_frame) const = 0;
};
void SetCodecSettings(VideoCodecType codec_type,
void SetCodecSettings(std::string codec_name,
size_t num_simulcast_streams,
size_t num_spatial_layers,
size_t num_temporal_layers,
@ -82,6 +82,9 @@ struct TestConfig {
// Codec settings to use.
webrtc::VideoCodec codec_settings;
// Name of the codec being tested.
std::string codec_name;
// H.264 specific settings.
struct H264CodecSettings {
H264::Profile profile = H264::kProfileConstrainedBaseline;

View File

@ -12,6 +12,7 @@
#include <vector>
#include "media/base/mediaconstants.h"
#include "modules/video_coding/codecs/test/test_config.h"
#include "modules/video_coding/utility/vp8_header_parser.h"
#include "modules/video_coding/utility/vp9_uncompressed_header_parser.h"
@ -96,7 +97,7 @@ class VideoProcessorIntegrationTestLibvpx
#if !defined(RTC_DISABLE_VP9)
TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP9) {
config_.SetCodecSettings(kVideoCodecVP9, 1, 1, 1, false, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
@ -112,7 +113,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP9) {
}
TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeBitrateVP9) {
config_.SetCodecSettings(kVideoCodecVP9, 1, 1, 1, false, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
@ -133,7 +134,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeBitrateVP9) {
}
TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeFramerateVP9) {
config_.SetCodecSettings(kVideoCodecVP9, 1, 1, 1, false, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
@ -156,7 +157,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ChangeFramerateVP9) {
}
TEST_F(VideoProcessorIntegrationTestLibvpx, DenoiserOnVP9) {
config_.SetCodecSettings(kVideoCodecVP9, 1, 1, 1, true, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
@ -172,7 +173,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DenoiserOnVP9) {
}
TEST_F(VideoProcessorIntegrationTestLibvpx, VeryLowBitrateVP9) {
config_.SetCodecSettings(kVideoCodecVP9, 1, 1, 1, false, true, true,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 1, 1, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{50, 30, kNumFramesLong}};
@ -192,7 +193,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, VeryLowBitrateVP9) {
#endif // !defined(RTC_DISABLE_VP9)
TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP8) {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 1, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
@ -228,7 +229,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, HighBitrateVP8) {
#define MAYBE_ChangeBitrateVP8 ChangeBitrateVP8
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeBitrateVP8) {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 1, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
@ -259,7 +260,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeBitrateVP8) {
#define MAYBE_ChangeFramerateVP8 ChangeFramerateVP8
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeFramerateVP8) {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 1, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
@ -296,7 +297,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_ChangeFramerateVP8) {
#define MAYBE_TemporalLayersVP8 TemporalLayersVP8
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_TemporalLayersVP8) {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 3, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{200, 30, 150},
@ -331,7 +332,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_MultiresVP8) {
config_.filename = "ConferenceMotion_1280_720_50";
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 100;
config_.SetCodecSettings(kVideoCodecVP8, 3, 1, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -355,7 +356,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_SimulcastVP8) {
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 100;
config_.simulcast_adapted_encoder = true;
config_.SetCodecSettings(kVideoCodecVP8, 3, 1, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -378,7 +379,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, MAYBE_SvcVP9) {
config_.filename = "ConferenceMotion_1280_720_50";
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 100;
config_.SetCodecSettings(kVideoCodecVP9, 1, 3, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 3, 3, true, true, false,
kResilienceOn, 1280, 720);
std::vector<RateProfile> rate_profiles = {{1500, 30, config_.num_frames}};
@ -396,7 +397,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DISABLED_MultiresVP8RdPerf) {
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 300;
config_.print_frame_level_stats = true;
config_.SetCodecSettings(kVideoCodecVP8, 3, 1, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp8CodecName, 3, 1, 3, true, true, false,
kResilienceOn, 1280, 720);
std::map<size_t, std::vector<VideoStatistics>> rd_stats;
@ -419,7 +420,7 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, DISABLED_SvcVP9RdPerf) {
config_.filepath = ResourcePath(config_.filename, "yuv");
config_.num_frames = 300;
config_.print_frame_level_stats = true;
config_.SetCodecSettings(kVideoCodecVP9, 1, 3, 3, true, true, false,
config_.SetCodecSettings(cricket::kVp9CodecName, 1, 3, 3, true, true, false,
kResilienceOn, 1280, 720);
std::map<size_t, std::vector<VideoStatistics>> rd_stats;

View File

@ -13,6 +13,7 @@
#include <vector>
#include "common_types.h" // NOLINT(build/include)
#include "media/base/mediaconstants.h"
#include "test/field_trial.h"
#include "test/testsupport/fileutils.h"
@ -36,8 +37,8 @@ class VideoProcessorIntegrationTestMediaCodec
};
TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsVp8) {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 1, false, false, false, false,
352, 288);
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, false, false, false,
false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};
@ -55,8 +56,8 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsVp8) {
TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsH264CBP) {
config_.encoded_frame_checker = &h264_keyframe_checker_;
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, false, false, false,
352, 288);
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};
@ -80,8 +81,8 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec,
config_.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config_.encoded_frame_checker = &h264_keyframe_checker_;
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, false, false, false,
352, 288);
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};

View File

@ -12,6 +12,7 @@
#include <vector>
#include "media/base/mediaconstants.h"
#include "test/testsupport/fileutils.h"
namespace webrtc {
@ -43,7 +44,7 @@ class VideoProcessorIntegrationTestOpenH264
};
TEST_F(VideoProcessorIntegrationTestOpenH264, ConstantHighBitrate) {
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, true, false,
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames}};
@ -63,7 +64,7 @@ TEST_F(VideoProcessorIntegrationTestOpenH264, SingleNalUnit) {
config_.h264_codec_settings.packetization_mode =
H264PacketizationMode::SingleNalUnit;
config_.max_payload_size_bytes = 500;
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, true, false,
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames}};

View File

@ -71,7 +71,8 @@ class VideoProcessorIntegrationTestParameterized
const size_t num_spatial_layers =
codec_type_ == kVideoCodecVP9 ? kNumSpatialLayers : 1;
config_.SetCodecSettings(codec_type_, num_simulcast_streams,
const std::string codec_name = CodecTypeToPayloadString(codec_type_);
config_.SetCodecSettings(codec_name, num_simulcast_streams,
num_spatial_layers, kNumTemporalLayers,
kDenoisingOn, kFrameDropperOn, kSpatialResizeOn,
kResilienceOn, width, height);

View File

@ -12,6 +12,7 @@
#include <vector>
#include "media/base/mediaconstants.h"
#include "modules/video_coding/codecs/test/objc_codec_factory_helper.h"
#include "test/field_trial.h"
#include "test/testsupport/fileutils.h"
@ -68,8 +69,8 @@ class VideoProcessorIntegrationTestVideoToolbox
// longer in use.
MAYBE_TEST_F(VideoProcessorIntegrationTestVideoToolbox,
ForemanCif500kbpsH264CBP) {
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, false, false, false,
352, 288);
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};
@ -84,8 +85,8 @@ MAYBE_TEST_F(VideoProcessorIntegrationTestVideoToolbox,
ScopedFieldTrials override_field_trials("WebRTC-H264HighProfile/Enabled/");
config_.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config_.SetCodecSettings(kVideoCodecH264, 1, 1, 1, false, false, false, false,
352, 288);
config_.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false,
false, false, 352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames}};

View File

@ -12,6 +12,7 @@
#include "api/video/i420_buffer.h"
#include "common_types.h" // NOLINT(build/include)
#include "media/base/mediaconstants.h"
#include "modules/video_coding/codecs/test/videoprocessor.h"
#include "modules/video_coding/include/mock/mock_video_codec_interface.h"
#include "modules/video_coding/include/video_coding.h"
@ -51,8 +52,8 @@ const int kFrameSize = kWidth * kHeight * 3 / 2; // I420.
class VideoProcessorTest : public testing::Test {
protected:
VideoProcessorTest() : q_("VP queue") {
config_.SetCodecSettings(kVideoCodecVP8, 1, 1, 1, false, false, false,
false, kWidth, kHeight);
config_.SetCodecSettings(cricket::kVp8CodecName, 1, 1, 1, false, false,
false, false, kWidth, kHeight);
decoder_mock_ = new MockVideoDecoder();
decoders_.push_back(std::unique_ptr<VideoDecoder>(decoder_mock_));