Move TestConfig to separate file.

Move functions Set/PrintCodecSettings, NumberOfTemporalLayers to TestConfig.
Add function NumberOfCores.

Bug: none
Change-Id: Ic33d79681d59d62bf34d9c9ff056a751ed3f8da8
Reviewed-on: https://webrtc-review.googlesource.com/13120
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20358}
This commit is contained in:
Åsa Persson
2017-10-19 14:05:50 +02:00
committed by Commit Bot
parent 4696a159ef
commit 2d27fb5a33
13 changed files with 382 additions and 272 deletions

View File

@ -74,6 +74,7 @@ void Stats::PrintSummary() const {
size_t total_encoded_delta_frame_size_bytes = 0;
size_t num_key_frames = 0;
size_t num_delta_frames = 0;
int num_encode_failures = 0;
for (const FrameStatistic& stat : stats_) {
total_encoding_time_us += stat.encode_time_us;
@ -86,9 +87,13 @@ void Stats::PrintSummary() const {
total_encoded_delta_frame_size_bytes += stat.encoded_frame_size_bytes;
++num_delta_frames;
}
if (stat.encode_return_code != 0) {
++num_encode_failures;
}
}
// Encoding stats.
printf("# Encoded frame failures: %d\n", num_encode_failures);
printf("Encoding time:\n");
auto frame_it =
std::min_element(stats_.begin(), stats_.end(), LessForEncodeTime);

View File

@ -0,0 +1,140 @@
/*
* 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 "modules/video_coding/codecs/test/test_config.h"
#include <string.h>
#include "modules/video_coding/include/video_codec_interface.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/cpu_info.h"
#include "test/video_codec_settings.h"
namespace webrtc {
namespace test {
namespace {
const int kBaseKeyFrameInterval = 3000;
} // namespace
void TestConfig::SetCodecSettings(VideoCodecType codec_type,
int num_temporal_layers,
bool error_concealment_on,
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
int width,
int height) {
webrtc::test::CodecSettings(codec_type, &codec_settings);
// TODO(brandtr): Move the setting of |width| and |height| to the tests, and
// DCHECK that they are set before initializing the codec instead.
codec_settings.width = width;
codec_settings.height = height;
switch (codec_settings.codecType) {
case kVideoCodecVP8:
codec_settings.VP8()->resilience =
resilience_on ? kResilientStream : kResilienceOff;
codec_settings.VP8()->numberOfTemporalLayers = num_temporal_layers;
codec_settings.VP8()->denoisingOn = denoising_on;
codec_settings.VP8()->errorConcealmentOn = error_concealment_on;
codec_settings.VP8()->automaticResizeOn = spatial_resize_on;
codec_settings.VP8()->frameDroppingOn = frame_dropper_on;
codec_settings.VP8()->keyFrameInterval = kBaseKeyFrameInterval;
break;
case kVideoCodecVP9:
codec_settings.VP9()->resilienceOn = resilience_on;
codec_settings.VP9()->numberOfTemporalLayers = num_temporal_layers;
codec_settings.VP9()->denoisingOn = denoising_on;
codec_settings.VP9()->frameDroppingOn = frame_dropper_on;
codec_settings.VP9()->keyFrameInterval = kBaseKeyFrameInterval;
codec_settings.VP9()->automaticResizeOn = spatial_resize_on;
break;
case kVideoCodecH264:
codec_settings.H264()->frameDroppingOn = frame_dropper_on;
codec_settings.H264()->keyFrameInterval = kBaseKeyFrameInterval;
break;
default:
RTC_NOTREACHED();
break;
}
}
int TestConfig::NumberOfCores() const {
return use_single_core ? 1 : CpuInfo::DetectNumberOfCores();
}
int TestConfig::NumberOfTemporalLayers() const {
if (codec_settings.codecType == kVideoCodecVP8) {
return codec_settings.VP8().numberOfTemporalLayers;
} else if (codec_settings.codecType == kVideoCodecVP9) {
return codec_settings.VP9().numberOfTemporalLayers;
} else {
return 1;
}
}
void TestConfig::Print() const {
printf("Video config:\n");
printf(" Filename : %s\n", filename.c_str());
printf(" # CPU cores used : %u\n", NumberOfCores());
PrintCodecSettings();
printf("\n");
}
void TestConfig::PrintCodecSettings() const {
printf(" Codec settings:\n");
printf(" Codec type : %s\n",
CodecTypeToPayloadString(codec_settings.codecType));
printf(" Start bitrate : %d kbps\n", codec_settings.startBitrate);
printf(" Max bitrate : %d kbps\n", codec_settings.maxBitrate);
printf(" Min bitrate : %d kbps\n", codec_settings.minBitrate);
printf(" Width : %d\n", codec_settings.width);
printf(" Height : %d\n", codec_settings.height);
printf(" Max frame rate : %d\n", codec_settings.maxFramerate);
printf(" QPmax : %d\n", codec_settings.qpMax);
if (codec_settings.codecType == kVideoCodecVP8) {
printf(" Complexity : %d\n", codec_settings.VP8().complexity);
printf(" Resilience : %d\n", codec_settings.VP8().resilience);
printf(" # temporal layers : %d\n",
codec_settings.VP8().numberOfTemporalLayers);
printf(" Denoising : %d\n", codec_settings.VP8().denoisingOn);
printf(" Error concealment : %d\n",
codec_settings.VP8().errorConcealmentOn);
printf(" Automatic resize : %d\n",
codec_settings.VP8().automaticResizeOn);
printf(" Frame dropping : %d\n", codec_settings.VP8().frameDroppingOn);
printf(" Key frame interval: %d\n", codec_settings.VP8().keyFrameInterval);
} else if (codec_settings.codecType == kVideoCodecVP9) {
printf(" Complexity : %d\n", codec_settings.VP9().complexity);
printf(" Resilience : %d\n", codec_settings.VP9().resilienceOn);
printf(" # temporal layers : %d\n",
codec_settings.VP9().numberOfTemporalLayers);
printf(" Denoising : %d\n", codec_settings.VP9().denoisingOn);
printf(" Frame dropping : %d\n", codec_settings.VP9().frameDroppingOn);
printf(" Key frame interval: %d\n", codec_settings.VP9().keyFrameInterval);
printf(" Adaptive QP mode : %d\n", codec_settings.VP9().adaptiveQpMode);
printf(" Automatic resize : %d\n",
codec_settings.VP9().automaticResizeOn);
printf(" # spatial layers : %d\n",
codec_settings.VP9().numberOfSpatialLayers);
printf(" Flexible mode : %d\n", codec_settings.VP9().flexibleMode);
} else if (codec_settings.codecType == kVideoCodecH264) {
printf(" Frame dropping : %d\n", codec_settings.H264().frameDroppingOn);
printf(" Key frame interval: %d\n",
codec_settings.H264().keyFrameInterval);
printf(" Profile : %d\n", codec_settings.H264().profile);
}
}
} // namespace test
} // namespace webrtc

View File

@ -0,0 +1,111 @@
/*
* 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.
*/
#ifndef MODULES_VIDEO_CODING_CODECS_TEST_TEST_CONFIG_H_
#define MODULES_VIDEO_CODING_CODECS_TEST_TEST_CONFIG_H_
#include <string>
#include "common_types.h" // NOLINT(build/include)
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/test/packet_manipulator.h"
namespace webrtc {
namespace test {
// Defines which frame types shall be excluded from packet loss and when.
enum ExcludeFrameTypes {
// Will exclude the first keyframe in the video sequence from packet loss.
// Following keyframes will be targeted for packet loss.
kExcludeOnlyFirstKeyFrame,
// Exclude all keyframes from packet loss, no matter where in the video
// sequence they occur.
kExcludeAllKeyFrames
};
// Test configuration for a test run.
struct TestConfig {
void SetCodecSettings(VideoCodecType codec_type,
int num_temporal_layers,
bool error_concealment_on,
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
int width,
int height);
int NumberOfCores() const;
int NumberOfTemporalLayers() const;
void Print() const;
void PrintCodecSettings() const;
// Plain name of YUV file to process without file extension.
std::string filename;
// File to process. This must be a video file in the YUV format.
std::string input_filename;
// File to write to during processing for the test. Will be a video file in
// the YUV format.
std::string output_filename;
// Number of frames to process.
int num_frames = 0;
// Configurations related to networking.
NetworkingConfig networking_config;
// Decides how the packet loss simulations shall exclude certain frames from
// packet loss.
ExcludeFrameTypes exclude_frame_types = kExcludeOnlyFirstKeyFrame;
// Force the encoder and decoder to use a single core for processing.
// Using a single core is necessary to get a deterministic behavior for the
// encoded frames - using multiple cores will produce different encoded frames
// since multiple cores are competing to consume the byte budget for each
// frame in parallel.
// If set to false, the maximum number of available cores will be used.
bool use_single_core = false;
// Should cpu usage be measured?
// If set to true, the encoding will run in real-time.
bool measure_cpu = false;
// If > 0: forces the encoder to create a keyframe every Nth frame.
// Note that the encoder may create a keyframe in other locations in addition
// to this setting. Forcing key frames may also affect encoder planning
// optimizations in a negative way, since it will suddenly be forced to
// produce an expensive key frame.
int keyframe_interval = 0;
// Codec settings to use.
webrtc::VideoCodec codec_settings;
// If printing of information to stdout shall be performed during processing.
bool verbose = true;
// Should hardware accelerated codecs be used?
bool hw_encoder = false;
bool hw_decoder = false;
// Should the hardware codecs be wrapped in software fallbacks?
bool sw_fallback_encoder = false;
bool sw_fallback_decoder = false;
// RTP H264 packetization mode.
H264PacketizationMode packetization_mode =
webrtc::H264PacketizationMode::NonInterleaved;
};
} // namespace test
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_TEST_TEST_CONFIG_H_

View File

@ -0,0 +1,55 @@
/*
* 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 "modules/video_coding/codecs/test/test_config.h"
#include "test/gtest.h"
#include "test/video_codec_settings.h"
namespace webrtc {
namespace test {
namespace {
const int kNumTemporalLayers = 2;
} // namespace
TEST(TestConfig, NumberOfCoresWithUseSingleCore) {
TestConfig config;
config.use_single_core = true;
EXPECT_EQ(1, config.NumberOfCores());
}
TEST(TestConfig, NumberOfCoresWithoutUseSingleCore) {
TestConfig config;
config.use_single_core = false;
EXPECT_GE(config.NumberOfCores(), 1);
}
TEST(TestConfig, NumberOfTemporalLayersIsOne) {
TestConfig config;
webrtc::test::CodecSettings(kVideoCodecH264, &config.codec_settings);
EXPECT_EQ(1, config.NumberOfTemporalLayers());
}
TEST(TestConfig, NumberOfTemporalLayers_Vp8) {
TestConfig config;
webrtc::test::CodecSettings(kVideoCodecVP8, &config.codec_settings);
config.codec_settings.VP8()->numberOfTemporalLayers = kNumTemporalLayers;
EXPECT_EQ(kNumTemporalLayers, config.NumberOfTemporalLayers());
}
TEST(TestConfig, NumberOfTemporalLayers_Vp9) {
TestConfig config;
webrtc::test::CodecSettings(kVideoCodecVP9, &config.codec_settings);
config.codec_settings.VP9()->numberOfTemporalLayers = kNumTemporalLayers;
EXPECT_EQ(kNumTemporalLayers, config.NumberOfTemporalLayers());
}
} // namespace test
} // namespace webrtc

View File

@ -10,8 +10,6 @@
#include "modules/video_coding/codecs/test/videoprocessor.h"
#include <string.h>
#include <algorithm>
#include <limits>
#include <utility>
@ -23,9 +21,7 @@
#include "modules/video_coding/include/video_codec_initializer.h"
#include "modules/video_coding/utility/default_video_bitrate_allocator.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/timeutils.h"
#include "system_wrappers/include/cpu_info.h"
#include "test/gtest.h"
namespace webrtc {
@ -47,51 +43,6 @@ std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
std::move(tl_factory)));
}
void PrintCodecSettings(const VideoCodec& codec_settings) {
printf(" Codec settings:\n");
printf(" Codec type : %s\n",
CodecTypeToPayloadString(codec_settings.codecType));
printf(" Start bitrate : %d kbps\n", codec_settings.startBitrate);
printf(" Max bitrate : %d kbps\n", codec_settings.maxBitrate);
printf(" Min bitrate : %d kbps\n", codec_settings.minBitrate);
printf(" Width : %d\n", codec_settings.width);
printf(" Height : %d\n", codec_settings.height);
printf(" Max frame rate : %d\n", codec_settings.maxFramerate);
printf(" QPmax : %d\n", codec_settings.qpMax);
if (codec_settings.codecType == kVideoCodecVP8) {
printf(" Complexity : %d\n", codec_settings.VP8().complexity);
printf(" Resilience : %d\n", codec_settings.VP8().resilience);
printf(" # temporal layers : %d\n",
codec_settings.VP8().numberOfTemporalLayers);
printf(" Denoising : %d\n", codec_settings.VP8().denoisingOn);
printf(" Error concealment : %d\n",
codec_settings.VP8().errorConcealmentOn);
printf(" Automatic resize : %d\n",
codec_settings.VP8().automaticResizeOn);
printf(" Frame dropping : %d\n", codec_settings.VP8().frameDroppingOn);
printf(" Key frame interval: %d\n", codec_settings.VP8().keyFrameInterval);
} else if (codec_settings.codecType == kVideoCodecVP9) {
printf(" Complexity : %d\n", codec_settings.VP9().complexity);
printf(" Resilience : %d\n", codec_settings.VP9().resilienceOn);
printf(" # temporal layers : %d\n",
codec_settings.VP9().numberOfTemporalLayers);
printf(" Denoising : %d\n", codec_settings.VP9().denoisingOn);
printf(" Frame dropping : %d\n", codec_settings.VP9().frameDroppingOn);
printf(" Key frame interval: %d\n", codec_settings.VP9().keyFrameInterval);
printf(" Adaptive QP mode : %d\n", codec_settings.VP9().adaptiveQpMode);
printf(" Automatic resize : %d\n",
codec_settings.VP9().automaticResizeOn);
printf(" # spatial layers : %d\n",
codec_settings.VP9().numberOfSpatialLayers);
printf(" Flexible mode : %d\n", codec_settings.VP9().flexibleMode);
} else if (codec_settings.codecType == kVideoCodecH264) {
printf(" Frame dropping : %d\n", codec_settings.H264().frameDroppingOn);
printf(" Key frame interval: %d\n",
codec_settings.H264().keyFrameInterval);
printf(" Profile : %d\n", codec_settings.H264().profile);
}
}
void VerifyQpParser(const EncodedImage& encoded_frame,
const TestConfig& config) {
if (config.hw_encoder)
@ -135,10 +86,6 @@ int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
} // namespace
int TestConfig::NumberOfCores() const {
return use_single_core ? 1 : CpuInfo::DetectNumberOfCores();
}
VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
webrtc::VideoDecoder* decoder,
FrameReader* analysis_frame_reader,
@ -191,35 +138,16 @@ void VideoProcessor::Init() {
<< "Failed to register decode complete callback";
// Initialize the encoder and decoder.
int num_cores = config_.NumberOfCores();
RTC_CHECK_EQ(
encoder_->InitEncode(&config_.codec_settings, num_cores,
encoder_->InitEncode(&config_.codec_settings, config_.NumberOfCores(),
config_.networking_config.max_payload_size_in_bytes),
WEBRTC_VIDEO_CODEC_OK)
<< "Failed to initialize VideoEncoder";
RTC_CHECK_EQ(decoder_->InitDecode(&config_.codec_settings, num_cores),
WEBRTC_VIDEO_CODEC_OK)
RTC_CHECK_EQ(
decoder_->InitDecode(&config_.codec_settings, config_.NumberOfCores()),
WEBRTC_VIDEO_CODEC_OK)
<< "Failed to initialize VideoDecoder";
if (config_.verbose) {
printf("Video Processor:\n");
printf(" Filename : %s\n", config_.filename.c_str());
printf(" Total # of frames: %d\n",
analysis_frame_reader_->NumberOfFrames());
printf(" # CPU cores used : %d\n", num_cores);
const char* encoder_name = encoder_->ImplementationName();
printf(" Encoder implementation name: %s\n", encoder_name);
const char* decoder_name = decoder_->ImplementationName();
printf(" Decoder implementation name: %s\n", decoder_name);
if (strcmp(encoder_name, decoder_name) == 0) {
printf(" Codec implementation name : %s_%s\n",
CodecTypeToPayloadString(config_.codec_settings.codecType),
encoder_->ImplementationName());
}
PrintCodecSettings(config_.codec_settings);
printf("\n");
}
}
void VideoProcessor::Release() {
@ -269,12 +197,6 @@ void VideoProcessor::ProcessFrame() {
frame_stat->encode_start_ns = rtc::TimeNanos();
frame_stat->encode_return_code =
encoder_->Encode(source_frame, nullptr, &frame_types);
if (frame_stat->encode_return_code != WEBRTC_VIDEO_CODEC_OK) {
LOG(LS_WARNING) << "Failed to encode frame " << last_inputed_frame_num_
<< ", return code: " << frame_stat->encode_return_code
<< ".";
}
}
void VideoProcessor::SetRates(int bitrate_kbps, int framerate_fps) {
@ -457,9 +379,8 @@ void VideoProcessor::FrameDecoded(const VideoFrame& image) {
RTC_CHECK_GT(frame_number, last_decoded_frame_num_);
last_decoded_frame_num_ = frame_number;
// Check if frame size is different from the original size, and if so,
// scale back to original size. This is needed for the PSNR and SSIM
// calculations.
// Check if frame size is different from the original size, and if so, scale
// back to original size. This is needed for the PSNR and SSIM calculations.
size_t extracted_length;
rtc::Buffer extracted_buffer;
if (image.width() != config_.codec_settings.width ||

View File

@ -21,6 +21,7 @@
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/test/packet_manipulator.h"
#include "modules/video_coding/codecs/test/stats.h"
#include "modules/video_coding/codecs/test/test_config.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
#include "modules/video_coding/utility/vp8_header_parser.h"
@ -39,79 +40,6 @@ class VideoBitrateAllocator;
namespace test {
// Defines which frame types shall be excluded from packet loss and when.
enum ExcludeFrameTypes {
// Will exclude the first keyframe in the video sequence from packet loss.
// Following keyframes will be targeted for packet loss.
kExcludeOnlyFirstKeyFrame,
// Exclude all keyframes from packet loss, no matter where in the video
// sequence they occur.
kExcludeAllKeyFrames
};
// Test configuration for a test run.
struct TestConfig {
// Returns the number of cores to use.
int NumberOfCores() const;
// Plain name of YUV file to process without file extension.
std::string filename;
// File to process. This must be a video file in the YUV format.
std::string input_filename;
// File to write to during processing for the test. Will be a video file
// in the YUV format.
std::string output_filename;
// Number of frames to process.
int num_frames = 0;
// Configurations related to networking.
NetworkingConfig networking_config;
// Decides how the packet loss simulations shall exclude certain frames
// from packet loss.
ExcludeFrameTypes exclude_frame_types = kExcludeOnlyFirstKeyFrame;
// Force the encoder and decoder to use a single core for processing.
// Using a single core is necessary to get a deterministic behavior for the
// encoded frames - using multiple cores will produce different encoded frames
// since multiple cores are competing to consume the byte budget for each
// frame in parallel.
// If set to false, the maximum number of available cores will be used.
bool use_single_core = false;
// Should cpu usage be measured?
// If set to true, the encoding will run in real-time.
bool measure_cpu = false;
// If > 0: forces the encoder to create a keyframe every Nth frame.
// Note that the encoder may create a keyframe in other locations in addition
// to this setting. Forcing key frames may also affect encoder planning
// optimizations in a negative way, since it will suddenly be forced to
// produce an expensive key frame.
int keyframe_interval = 0;
// Codec settings to use.
webrtc::VideoCodec codec_settings;
// If printing of information to stdout shall be performed during processing.
bool verbose = true;
// Should hardware accelerated codecs be used?
bool hw_encoder = false;
bool hw_decoder = false;
// Should the hardware codecs be wrapped in software fallbacks?
bool sw_fallback_encoder = false;
bool sw_fallback_decoder = false;
// RTP H264 packetization mode.
H264PacketizationMode packetization_mode =
H264PacketizationMode::NonInterleaved;
};
// Handles encoding/decoding of video using the VideoEncoder/VideoDecoder
// interfaces. This is done in a sequential manner in order to be able to
// measure times properly.

View File

@ -32,12 +32,10 @@
#include "rtc_base/cpu_time.h"
#include "rtc_base/event.h"
#include "rtc_base/file.h"
#include "rtc_base/logging.h"
#include "rtc_base/ptr_util.h"
#include "system_wrappers/include/sleep.h"
#include "test/testsupport/fileutils.h"
#include "test/testsupport/metrics/video_metrics.h"
#include "test/video_codec_settings.h"
namespace webrtc {
namespace test {
@ -45,7 +43,6 @@ namespace test {
namespace {
const int kMaxBitrateMismatchPercent = 20;
const int kBaseKeyFrameInterval = 3000;
// Parameters from VP8 wrapper, which control target size of key frames.
const float kInitialBufferSize = 0.5f;
@ -68,16 +65,6 @@ void PrintQualityMetrics(const QualityMetricsResult& psnr_result,
printf("\n");
}
int NumberOfTemporalLayers(const VideoCodec& codec_settings) {
if (codec_settings.codecType == kVideoCodecVP8) {
return codec_settings.VP8().numberOfTemporalLayers;
} else if (codec_settings.codecType == kVideoCodecVP9) {
return codec_settings.VP9().numberOfTemporalLayers;
} else {
return 1;
}
}
bool RunEncodeInRealTime(const TestConfig& config) {
if (config.measure_cpu) {
return true;
@ -132,54 +119,6 @@ VideoProcessorIntegrationTest::VideoProcessorIntegrationTest() {
VideoProcessorIntegrationTest::~VideoProcessorIntegrationTest() = default;
void VideoProcessorIntegrationTest::SetCodecSettings(TestConfig* config,
VideoCodecType codec_type,
int num_temporal_layers,
bool error_concealment_on,
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
int width,
int height) {
webrtc::test::CodecSettings(codec_type, &config->codec_settings);
// TODO(brandtr): Move the setting of |width| and |height| to the tests, and
// DCHECK that they are set before initializing the codec instead.
config->codec_settings.width = width;
config->codec_settings.height = height;
switch (config->codec_settings.codecType) {
case kVideoCodecVP8:
config->codec_settings.VP8()->resilience =
resilience_on ? kResilientStream : kResilienceOff;
config->codec_settings.VP8()->numberOfTemporalLayers =
num_temporal_layers;
config->codec_settings.VP8()->denoisingOn = denoising_on;
config->codec_settings.VP8()->errorConcealmentOn = error_concealment_on;
config->codec_settings.VP8()->automaticResizeOn = spatial_resize_on;
config->codec_settings.VP8()->frameDroppingOn = frame_dropper_on;
config->codec_settings.VP8()->keyFrameInterval = kBaseKeyFrameInterval;
break;
case kVideoCodecVP9:
config->codec_settings.VP9()->resilienceOn = resilience_on;
config->codec_settings.VP9()->numberOfTemporalLayers =
num_temporal_layers;
config->codec_settings.VP9()->denoisingOn = denoising_on;
config->codec_settings.VP9()->frameDroppingOn = frame_dropper_on;
config->codec_settings.VP9()->keyFrameInterval = kBaseKeyFrameInterval;
config->codec_settings.VP9()->automaticResizeOn = spatial_resize_on;
break;
case kVideoCodecH264:
config->codec_settings.H264()->frameDroppingOn = frame_dropper_on;
config->codec_settings.H264()->keyFrameInterval = kBaseKeyFrameInterval;
break;
default:
RTC_NOTREACHED();
break;
}
}
// Processes all frames in the clip and verifies the result.
void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify(
const std::vector<RateProfile>& rate_profiles,
@ -195,6 +134,7 @@ void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify(
SetUpAndInitObjects(&task_queue, rate_profiles[0].target_kbps,
rate_profiles[0].input_fps, visualization_params);
MaybePrintSettings();
// Set initial rates.
int rate_update_index = 0;
@ -540,8 +480,7 @@ void VideoProcessorIntegrationTest::VerifyRateControlMetrics(
EXPECT_LE(actual_.BitrateMismatchPercent(target_.kbps),
rc_threshold.max_bitrate_mismatch_percent);
const int num_temporal_layers =
NumberOfTemporalLayers(config_.codec_settings);
const int num_temporal_layers = config_.NumberOfTemporalLayers();
for (int i = 0; i < num_temporal_layers; ++i) {
EXPECT_LE(actual_.DeltaFrameSizeMismatchPercent(i),
rc_threshold.max_delta_framesize_mismatch_percent);
@ -568,8 +507,7 @@ void VideoProcessorIntegrationTest::PrintRateControlMetrics(
printf(" Key frame rate mismatch: %d\n",
actual_.KeyFrameSizeMismatchPercent());
const int num_temporal_layers =
NumberOfTemporalLayers(config_.codec_settings);
const int num_temporal_layers = config_.NumberOfTemporalLayers();
for (int i = 0; i < num_temporal_layers; ++i) {
printf(" Temporal layer #%d:\n", i);
printf(" Layer target bitrate : %f\n", target_.kbps_layer[i]);
@ -586,6 +524,24 @@ void VideoProcessorIntegrationTest::PrintRateControlMetrics(
printf("\n");
}
void VideoProcessorIntegrationTest::MaybePrintSettings() const {
if (!config_.verbose)
return;
config_.Print();
printf(" Total # of frames: %d\n", analysis_frame_reader_->NumberOfFrames());
const char* encoder_name = encoder_->ImplementationName();
const char* decoder_name = decoder_->ImplementationName();
printf(" Encoder implementation name: %s\n", encoder_name);
printf(" Decoder implementation name: %s\n", decoder_name);
if (strcmp(encoder_name, decoder_name) == 0) {
printf(" Codec implementation name : %s_%s\n",
CodecTypeToPayloadString(config_.codec_settings.codecType),
encoder_name);
}
printf("\n");
}
void VideoProcessorIntegrationTest::VerifyBitstream(
int frame_number,
const BitstreamThresholds& bs_thresholds) {
@ -598,7 +554,7 @@ void VideoProcessorIntegrationTest::VerifyBitstream(
int VideoProcessorIntegrationTest::TemporalLayerIndexForFrame(
int frame_number) const {
int tl_idx = -1;
switch (NumberOfTemporalLayers(config_.codec_settings)) {
switch (config_.NumberOfTemporalLayers()) {
case 1:
tl_idx = 0;
break;
@ -659,8 +615,7 @@ void VideoProcessorIntegrationTest::ResetRateControlMetrics(
}
void VideoProcessorIntegrationTest::SetRatesPerTemporalLayer() {
const int num_temporal_layers =
NumberOfTemporalLayers(config_.codec_settings);
const int num_temporal_layers = config_.NumberOfTemporalLayers();
RTC_DCHECK_LE(num_temporal_layers, kMaxNumTemporalLayers);
for (int i = 0; i < num_temporal_layers; ++i) {

View File

@ -20,6 +20,7 @@
#include "media/engine/webrtcvideoencoderfactory.h"
#include "modules/video_coding/codecs/test/packet_manipulator.h"
#include "modules/video_coding/codecs/test/stats.h"
#include "modules/video_coding/codecs/test/test_config.h"
#include "modules/video_coding/codecs/test/videoprocessor.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
#include "test/gtest.h"
@ -93,17 +94,6 @@ class VideoProcessorIntegrationTest : public testing::Test {
VideoProcessorIntegrationTest();
~VideoProcessorIntegrationTest() override;
static void SetCodecSettings(TestConfig* config,
VideoCodecType codec_type,
int num_temporal_layers,
bool error_concealment_on,
bool denoising_on,
bool frame_dropper_on,
bool spatial_resize_on,
bool resilience_on,
int width,
int height);
void ProcessFramesAndMaybeVerify(
const std::vector<RateProfile>& rate_profiles,
const std::vector<RateControlThresholds>* rc_thresholds,
@ -183,6 +173,8 @@ class VideoProcessorIntegrationTest : public testing::Test {
void VerifyBitstream(int frame_number,
const BitstreamThresholds& bs_thresholds);
void MaybePrintSettings() const;
// Codecs.
std::unique_ptr<VideoEncoder> encoder_;
std::unique_ptr<VideoDecoder> decoder_;

View File

@ -57,8 +57,8 @@ class VideoProcessorIntegrationTestLibvpx
// VP9: Run with no packet loss and fixed bitrate. Quality should be very high.
// One key frame (first frame only) in sequence.
TEST_F(VideoProcessorIntegrationTestLibvpx, Process0PercentPacketLossVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -78,8 +78,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, Process0PercentPacketLossVP9) {
TEST_F(VideoProcessorIntegrationTestLibvpx, Process5PercentPacketLossVP9) {
config_.networking_config.packet_loss_probability = 0.05f;
config_.num_frames = kNumFramesShort;
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -98,8 +98,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, Process5PercentPacketLossVP9) {
// target rate/per-frame bandwidth (for each rate update) is within limits.
// One key frame (first frame only) in sequence.
TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessNoLossChangeBitRateVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -126,8 +126,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessNoLossChangeBitRateVP9) {
// metrics averaged over whole sequence run.
TEST_F(VideoProcessorIntegrationTestLibvpx,
ProcessNoLossChangeFrameRateFrameDropVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{100, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -148,8 +148,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx,
// VP9: Run with no packet loss and denoiser on. One key frame (first frame).
TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessNoLossDenoiserOnVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -169,8 +169,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessNoLossDenoiserOnVP9) {
// Resize happens on delta frame. Expect only one key frame (first frame).
TEST_F(VideoProcessorIntegrationTestLibvpx,
DISABLED_ProcessNoLossSpatialResizeFrameDropVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP9, 1, false, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{50, 30, kNumFramesLong + 1}};
@ -193,8 +193,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx,
// One key frame (first frame only) in sequence. Setting |key_frame_interval|
// to -1 below means no periodic key frames in test.
TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessZeroPacketLoss) {
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -213,8 +213,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessZeroPacketLoss) {
// lower. One key frame (first frame only) in sequence.
TEST_F(VideoProcessorIntegrationTestLibvpx, Process5PercentPacketLoss) {
config_.networking_config.packet_loss_probability = 0.05f;
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -233,8 +233,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, Process5PercentPacketLoss) {
// One key frame (first frame only) in sequence.
TEST_F(VideoProcessorIntegrationTestLibvpx, Process10PercentPacketLoss) {
config_.networking_config.packet_loss_probability = 0.1f;
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.num_frames = kNumFramesShort;
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
@ -273,8 +273,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx, Process10PercentPacketLoss) {
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx,
MAYBE_ProcessNoLossChangeBitRateVP8) {
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -309,8 +309,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx,
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx,
MAYBE_ProcessNoLossChangeFrameRateFrameDropVP8) {
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {
{80, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
@ -343,8 +343,8 @@ TEST_F(VideoProcessorIntegrationTestLibvpx,
#endif
TEST_F(VideoProcessorIntegrationTestLibvpx,
MAYBE_ProcessNoLossTemporalLayersVP8) {
SetCodecSettings(&config_, kVideoCodecVP8, 3, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecVP8, 3, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{200, 30, 150},
{400, 30, kNumFramesLong + 1}};

View File

@ -41,8 +41,8 @@ class VideoProcessorIntegrationTestMediaCodec
};
TEST_F(VideoProcessorIntegrationTestMediaCodec, ForemanCif500kbpsVp8) {
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, false, false, false,
false, 352, 288);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, false, false, false, false,
352, 288);
std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames + 1}};
@ -67,8 +67,8 @@ TEST_F(VideoProcessorIntegrationTestMediaCodec,
config_.filename = "foreman_320x240";
config_.input_filename = ResourcePath(config_.filename, "yuv");
config_.sw_fallback_encoder = true;
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, false, false, false,
false, 320, 240);
config_.SetCodecSettings(kVideoCodecVP8, 1, false, false, false, false, false,
320, 240);
std::vector<RateProfile> rate_profiles = {
{100, 10, 80}, // Start below |low_kbps|.

View File

@ -55,8 +55,8 @@ class VideoProcessorIntegrationTestOpenH264
// with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have
// not been added.
TEST_F(VideoProcessorIntegrationTestOpenH264, Process0PercentPacketLoss) {
SetCodecSettings(&config_, kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames + 1}};
@ -75,8 +75,8 @@ TEST_F(VideoProcessorIntegrationTestOpenH264, Process0PercentPacketLoss) {
TEST_F(VideoProcessorIntegrationTestOpenH264, ProcessNoLossSingleNalUnit) {
config_.packetization_mode = H264PacketizationMode::SingleNalUnit;
config_.networking_config.max_payload_size_in_bytes = 500;
SetCodecSettings(&config_, kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
config_.SetCodecSettings(kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames + 1}};

View File

@ -68,9 +68,9 @@ class VideoProcessorIntegrationTestParameterized
config_.hw_encoder = hw_codec_;
config_.hw_decoder = hw_codec_;
config_.num_frames = kNumFrames;
SetCodecSettings(&config_, codec_type_, kNumTemporalLayers,
kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn,
kSpatialResizeOn, kResilienceOn, width, height);
config_.SetCodecSettings(codec_type_, kNumTemporalLayers,
kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn,
kSpatialResizeOn, kResilienceOn, width, height);
std::vector<RateProfile> rate_profiles = {
{bitrate_, framerate, kNumFrames + 1}};