Move ownership of webrtc::VideoCodec into TestConfig.

BUG=webrtc:6634

Review-Url: https://codereview.webrtc.org/2995603002
Cr-Commit-Position: refs/heads/master@{#19271}
This commit is contained in:
brandtr 2017-08-08 08:35:53 -07:00 committed by Commit Bot
parent d7a418f93a
commit 07734a5995
7 changed files with 147 additions and 160 deletions

View File

@ -68,10 +68,9 @@ class PlotVideoProcessorIntegrationTest
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, kPacketLoss,
kKeyFrameInterval, filename, kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, codec_type_,
kNumTemporalLayers, kErrorConcealmentOn, kDenoisingOn,
kFrameDropperOn, kSpatialResizeOn, kResilienceOn, width,
height);
SetCodecSettings(&config_, codec_type_, kNumTemporalLayers,
kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn,
kSpatialResizeOn, kResilienceOn, width, height);
// Use default thresholds for quality (PSNR and SSIM).
QualityThresholds quality_thresholds;

View File

@ -35,52 +35,48 @@ namespace {
const int kRtpClockRateHz = 90000;
std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
const TestConfig& config) {
TestConfig* config) {
std::unique_ptr<TemporalLayersFactory> tl_factory;
if (config.codec_settings->codecType == VideoCodecType::kVideoCodecVP8) {
if (config->codec_settings.codecType == VideoCodecType::kVideoCodecVP8) {
tl_factory.reset(new TemporalLayersFactory());
config.codec_settings->VP8()->tl_factory = tl_factory.get();
config->codec_settings.VP8()->tl_factory = tl_factory.get();
}
return std::unique_ptr<VideoBitrateAllocator>(
VideoCodecInitializer::CreateBitrateAllocator(*config.codec_settings,
VideoCodecInitializer::CreateBitrateAllocator(config->codec_settings,
std::move(tl_factory)));
}
void PrintCodecSettings(const VideoCodec* codec_settings) {
RTC_DCHECK(codec_settings);
void PrintCodecSettings(const VideoCodec& codec_settings) {
printf(" Codec settings:\n");
printf(" Codec type : %s\n",
CodecTypeToPayloadName(codec_settings->codecType).value_or("Unknown"));
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(" Denoising : %d\n", codec_settings->VP8().denoisingOn);
CodecTypeToPayloadName(codec_settings.codecType).value_or("Unknown"));
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(" Denoising : %d\n", codec_settings.VP8().denoisingOn);
printf(" Error concealment : %d\n",
codec_settings->VP8().errorConcealmentOn);
printf(" Frame dropping : %d\n", codec_settings->VP8().frameDroppingOn);
printf(" Resilience : %d\n", codec_settings->VP8().resilience);
codec_settings.VP8().errorConcealmentOn);
printf(" Frame dropping : %d\n", codec_settings.VP8().frameDroppingOn);
printf(" Resilience : %d\n", codec_settings.VP8().resilience);
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(" Denoising : %d\n", codec_settings.VP9().denoisingOn);
printf(" Frame dropping : %d\n", codec_settings.VP9().frameDroppingOn);
printf(" Resilience : %d\n", codec_settings.VP9().resilienceOn);
printf(" Key frame interval: %d\n", codec_settings.VP9().keyFrameInterval);
printf(" Adaptive QP mode : %d\n", codec_settings.VP9().adaptiveQpMode);
} else if (codec_settings.codecType == kVideoCodecH264) {
printf(" Frame dropping : %d\n", codec_settings.H264().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(" Denoising : %d\n", codec_settings->VP9().denoisingOn);
printf(" Frame dropping : %d\n", codec_settings->VP9().frameDroppingOn);
printf(" Resilience : %d\n", codec_settings->VP9().resilienceOn);
printf(" Key frame interval: %d\n",
codec_settings->VP9().keyFrameInterval);
printf(" Adaptive QP mode : %d\n", codec_settings->VP9().adaptiveQpMode);
} 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);
codec_settings.H264().keyFrameInterval);
printf(" Profile : %d\n", codec_settings.H264().profile);
}
}
@ -114,13 +110,13 @@ VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
Stats* stats,
IvfFileWriter* encoded_frame_writer,
FrameWriter* decoded_frame_writer)
: encoder_(encoder),
: config_(config),
encoder_(encoder),
decoder_(decoder),
bitrate_allocator_(CreateBitrateAllocator(config)),
bitrate_allocator_(CreateBitrateAllocator(&config_)),
encode_callback_(new VideoProcessorEncodeCompleteCallback(this)),
decode_callback_(new VideoProcessorDecodeCompleteCallback(this)),
packet_manipulator_(packet_manipulator),
config_(config),
analysis_frame_reader_(analysis_frame_reader),
analysis_frame_writer_(analysis_frame_writer),
encoded_frame_writer_(encoded_frame_writer),
@ -149,7 +145,6 @@ VideoProcessor::~VideoProcessor() {
void VideoProcessor::Init() {
RTC_DCHECK(!initialized_) << "VideoProcessor already initialized.";
RTC_DCHECK(config_.codec_settings) << "No codec settings supplied.";
initialized_ = true;
// Setup required callbacks for the encoder and decoder.
@ -164,12 +159,12 @@ void VideoProcessor::Init() {
uint32_t num_cores =
config_.use_single_core ? 1 : CpuInfo::DetectNumberOfCores();
RTC_CHECK_EQ(
encoder_->InitEncode(config_.codec_settings, num_cores,
encoder_->InitEncode(&config_.codec_settings, num_cores,
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),
RTC_CHECK_EQ(decoder_->InitDecode(&config_.codec_settings, num_cores),
WEBRTC_VIDEO_CODEC_OK)
<< "Failed to initialize VideoDecoder";
@ -185,7 +180,7 @@ void VideoProcessor::Init() {
printf(" Decoder implementation name: %s\n", decoder_name);
if (strcmp(encoder_name, decoder_name) == 0) {
printf(" Codec implementation name : %s_%s\n",
CodecTypeToPayloadName(config_.codec_settings->codecType)
CodecTypeToPayloadName(config_.codec_settings.codecType)
.value_or("Unknown"),
encoder_->ImplementationName());
}
@ -242,7 +237,7 @@ bool VideoProcessor::ProcessFrame(int frame_number) {
}
void VideoProcessor::SetRates(int bit_rate, int frame_rate) {
config_.codec_settings->maxFramerate = frame_rate;
config_.codec_settings.maxFramerate = frame_rate;
int set_rates_result = encoder_->SetRateAllocation(
bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate),
frame_rate);
@ -348,7 +343,7 @@ void VideoProcessor::FrameEncoded(
frame_stat->frame_type = encoded_image._frameType;
frame_stat->qp = encoded_image.qp_;
frame_stat->bit_rate_in_kbps = static_cast<int>(
encoded_image._length * config_.codec_settings->maxFramerate * 8 / 1000);
encoded_image._length * config_.codec_settings.maxFramerate * 8 / 1000);
frame_stat->total_packets =
encoded_image._length / config_.networking_config.packet_size_in_bytes +
1;
@ -453,10 +448,10 @@ void VideoProcessor::FrameDecoded(const VideoFrame& image) {
// calculations.
size_t extracted_length;
rtc::Buffer extracted_buffer;
if (image.width() != config_.codec_settings->width ||
image.height() != config_.codec_settings->height) {
if (image.width() != config_.codec_settings.width ||
image.height() != config_.codec_settings.height) {
rtc::scoped_refptr<I420Buffer> scaled_buffer(I420Buffer::Create(
config_.codec_settings->width, config_.codec_settings->height));
config_.codec_settings.width, config_.codec_settings.height));
// Should be the same aspect ratio, no cropping needed.
scaled_buffer->ScaleFrom(*image.video_frame_buffer()->ToI420());
@ -487,14 +482,14 @@ void VideoProcessor::FrameDecoded(const VideoFrame& image) {
uint32_t VideoProcessor::FrameNumberToTimestamp(int frame_number) {
RTC_DCHECK_GE(frame_number, 0);
const int ticks_per_frame =
kRtpClockRateHz / config_.codec_settings->maxFramerate;
kRtpClockRateHz / config_.codec_settings.maxFramerate;
return (frame_number + 1) * ticks_per_frame;
}
int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) {
RTC_DCHECK_GT(timestamp, 0);
const int ticks_per_frame =
kRtpClockRateHz / config_.codec_settings->maxFramerate;
kRtpClockRateHz / config_.codec_settings.maxFramerate;
RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0);
return (timestamp / ticks_per_frame) - 1;
}

View File

@ -101,9 +101,9 @@ struct TestConfig {
int keyframe_interval = 0;
// The codec settings to use for the test (target bitrate, video size,
// framerate and so on). This struct must be created and filled in using
// the VideoCodingModule::Codec() method.
webrtc::VideoCodec* codec_settings = nullptr;
// framerate and so on). This struct should be filled in using the
// VideoCodingModule::Codec() method.
webrtc::VideoCodec codec_settings;
// If printing of information to stdout shall be performed during processing.
bool verbose = true;
@ -270,6 +270,8 @@ class VideoProcessor {
uint32_t FrameNumberToTimestamp(int frame_number);
int TimestampToFrameNumber(uint32_t timestamp);
TestConfig config_;
webrtc::VideoEncoder* const encoder_;
webrtc::VideoDecoder* const decoder_;
const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
@ -278,8 +280,8 @@ class VideoProcessor {
const std::unique_ptr<EncodedImageCallback> encode_callback_;
const std::unique_ptr<DecodedImageCallback> decode_callback_;
// Fake network.
PacketManipulator* const packet_manipulator_;
const TestConfig& config_;
// These (mandatory) file manipulators are used for, e.g., objective PSNR and
// SSIM calculations at the end of a test run.

View File

@ -49,8 +49,8 @@ TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecH264, 1, false, false,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(35.0, 25.0, 0.93, 0.70);
// Thresholds for rate control.
@ -78,8 +78,8 @@ TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(37.0, 36.0, 0.93, 0.92);
// Thresholds for rate control.
@ -100,8 +100,8 @@ TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLossVP9) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.05f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(17.0, 14.0, 0.45, 0.36);
// Thresholds for rate control.
@ -126,8 +126,8 @@ TEST_F(VideoProcessorIntegrationTest, ProcessNoLossChangeBitRateVP9) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(35.5, 30.0, 0.90, 0.85);
// Thresholds for rate control.
@ -159,8 +159,8 @@ TEST_F(VideoProcessorIntegrationTest,
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(31.5, 18.0, 0.80, 0.43);
// Thresholds for rate control.
@ -182,8 +182,8 @@ TEST_F(VideoProcessorIntegrationTest, ProcessNoLossDenoiserOnVP9) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(36.8, 35.8, 0.92, 0.91);
// Thresholds for rate control.
@ -207,8 +207,8 @@ TEST_F(VideoProcessorIntegrationTest,
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
true, true, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(24.0, 13.0, 0.65, 0.37);
// Thresholds for rate control.
@ -235,8 +235,8 @@ TEST_F(VideoProcessorIntegrationTest, ProcessZeroPacketLoss) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(34.95, 33.0, 0.90, 0.89);
// Thresholds for rate control.
@ -257,8 +257,8 @@ TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLoss) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.05f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(20.0, 16.0, 0.60, 0.40);
// Thresholds for rate control.
@ -279,8 +279,8 @@ TEST_F(VideoProcessorIntegrationTest, Process10PercentPacketLoss) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.1f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(19.0, 16.0, 0.50, 0.35);
// Thresholds for rate control.
@ -303,8 +303,8 @@ TEST_F(VideoProcessorIntegrationTest, ProcessInBatchMode) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, true /* batch_mode */);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(34.95, 33.0, 0.90, 0.89);
// Thresholds for rate control.
@ -347,8 +347,8 @@ TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossChangeBitRateVP8) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(34.0, 32.0, 0.85, 0.80);
// Thresholds for rate control.
@ -388,8 +388,8 @@ TEST_F(VideoProcessorIntegrationTest,
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(31.0, 22.0, 0.80, 0.65);
// Thresholds for rate control.
@ -424,8 +424,8 @@ TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossTemporalLayersVP8) {
// Codec/network settings.
SetProcessParams(&config_, kHwCodec, kUseSingleCore, 0.0f, -1, kForemanCif,
kVerboseLogging, kBatchMode);
SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 3, false, true,
true, false, kResilienceOn, kCifWidth, kCifHeight);
SetCodecSettings(&config_, kVideoCodecVP8, 3, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds(32.5, 30.0, 0.85, 0.80);
// Thresholds for rate control.

View File

@ -151,7 +151,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
// allocated them. For the particular case of the Android
// MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is
// fine for the std::unique_ptr to destroy the owned codec directly.
switch (config_.codec_settings->codecType) {
switch (config_.codec_settings.codecType) {
case kVideoCodecH264:
encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
cricket::VideoCodec(cricket::kH264CodecName)));
@ -175,7 +175,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
break;
}
#elif defined(WEBRTC_IOS)
ASSERT_EQ(kVideoCodecH264, config_.codec_settings->codecType)
ASSERT_EQ(kVideoCodecH264, config_.codec_settings.codecType)
<< "iOS HW codecs only support H264.";
std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory =
CreateObjCEncoderFactory();
@ -194,7 +194,7 @@ class VideoProcessorIntegrationTest : public testing::Test {
}
// SW codecs.
switch (config_.codec_settings->codecType) {
switch (config_.codec_settings.codecType) {
case kVideoCodecH264:
encoder_.reset(
H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)));
@ -219,11 +219,11 @@ class VideoProcessorIntegrationTest : public testing::Test {
// Create file objects for quality analysis.
analysis_frame_reader_.reset(new test::YuvFrameReaderImpl(
config_.input_filename, config_.codec_settings->width,
config_.codec_settings->height));
config_.input_filename, config_.codec_settings.width,
config_.codec_settings.height));
analysis_frame_writer_.reset(new test::YuvFrameWriterImpl(
config_.output_filename, config_.codec_settings->width,
config_.codec_settings->height));
config_.output_filename, config_.codec_settings.width,
config_.codec_settings.height));
RTC_CHECK(analysis_frame_reader_->Init());
RTC_CHECK(analysis_frame_writer_->Init());
@ -232,10 +232,10 @@ class VideoProcessorIntegrationTest : public testing::Test {
const std::string output_filename_base =
test::OutputPath() + config_.filename +
"_cd-" + CodecTypeToPayloadName(
config_.codec_settings->codecType).value_or("") +
config_.codec_settings.codecType).value_or("") +
"_hw-" + std::to_string(config_.hw_codec) +
"_br-" + std::to_string(
static_cast<int>(config_.codec_settings->startBitrate));
static_cast<int>(config_.codec_settings.startBitrate));
// clang-format on
if (visualization_params->save_encoded_ivf) {
rtc::File post_encode_file =
@ -245,9 +245,8 @@ class VideoProcessorIntegrationTest : public testing::Test {
}
if (visualization_params->save_decoded_y4m) {
decoded_frame_writer_.reset(new test::Y4mFrameWriterImpl(
output_filename_base + "_decoded.y4m",
config_.codec_settings->width, config_.codec_settings->height,
start_frame_rate_));
output_filename_base + "_decoded.y4m", config_.codec_settings.width,
config_.codec_settings.height, start_frame_rate_));
RTC_CHECK(decoded_frame_writer_->Init());
}
}
@ -407,18 +406,18 @@ class VideoProcessorIntegrationTest : public testing::Test {
void VerifyQpParser(int frame_number) {
if (!config_.hw_codec &&
(config_.codec_settings->codecType == kVideoCodecVP8 ||
config_.codec_settings->codecType == kVideoCodecVP9)) {
(config_.codec_settings.codecType == kVideoCodecVP8 ||
config_.codec_settings.codecType == kVideoCodecVP9)) {
EXPECT_EQ(processor_->GetQpFromEncoder(frame_number),
processor_->GetQpFromBitstream(frame_number));
}
}
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;
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;
}
@ -487,9 +486,8 @@ class VideoProcessorIntegrationTest : public testing::Test {
RateControlThresholds* rc_thresholds,
const VisualizationParams* visualization_params) {
// Codec/config settings.
RTC_CHECK(config_.codec_settings);
num_temporal_layers_ = NumberOfTemporalLayers(config_.codec_settings);
config_.codec_settings->startBitrate = rate_profile.target_bit_rate[0];
config_.codec_settings.startBitrate = rate_profile.target_bit_rate[0];
start_frame_rate_ = rate_profile.input_frame_rate[0];
SetUpObjects(visualization_params);
// Update the temporal layers and the codec with the initial rates.
@ -588,8 +586,8 @@ class VideoProcessorIntegrationTest : public testing::Test {
test::QualityMetricsResult psnr_result, ssim_result;
EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(),
config_.output_filename.c_str(),
config_.codec_settings->width,
config_.codec_settings->height,
config_.codec_settings.width,
config_.codec_settings.height,
&psnr_result, &ssim_result));
VerifyQuality(psnr_result, ssim_result, quality_thresholds);
stats_.PrintSummary();
@ -627,7 +625,6 @@ class VideoProcessorIntegrationTest : public testing::Test {
}
static void SetCodecSettings(test::TestConfig* config,
VideoCodec* codec_settings,
VideoCodecType codec_type,
int num_temporal_layers,
bool error_concealment_on,
@ -637,36 +634,33 @@ class VideoProcessorIntegrationTest : public testing::Test {
bool resilience_on,
int width,
int height) {
VideoCodingModule::Codec(codec_type, codec_settings);
config->codec_settings = codec_settings;
config->codec_settings->width = width;
config->codec_settings->height = height;
switch (config->codec_settings->codecType) {
VideoCodingModule::Codec(codec_type, &config->codec_settings);
config->codec_settings.width = width;
config->codec_settings.height = height;
switch (config->codec_settings.codecType) {
case kVideoCodecH264:
config->codec_settings->H264()->frameDroppingOn = frame_dropper_on;
config->codec_settings->H264()->keyFrameInterval =
kBaseKeyFrameInterval;
config->codec_settings.H264()->frameDroppingOn = frame_dropper_on;
config->codec_settings.H264()->keyFrameInterval = kBaseKeyFrameInterval;
break;
case kVideoCodecVP8:
config->codec_settings->VP8()->errorConcealmentOn =
error_concealment_on;
config->codec_settings->VP8()->denoisingOn = denoising_on;
config->codec_settings->VP8()->numberOfTemporalLayers =
config->codec_settings.VP8()->errorConcealmentOn = error_concealment_on;
config->codec_settings.VP8()->denoisingOn = denoising_on;
config->codec_settings.VP8()->numberOfTemporalLayers =
num_temporal_layers;
config->codec_settings->VP8()->frameDroppingOn = frame_dropper_on;
config->codec_settings->VP8()->automaticResizeOn = spatial_resize_on;
config->codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval;
config->codec_settings->VP8()->resilience =
config->codec_settings.VP8()->frameDroppingOn = frame_dropper_on;
config->codec_settings.VP8()->automaticResizeOn = spatial_resize_on;
config->codec_settings.VP8()->keyFrameInterval = kBaseKeyFrameInterval;
config->codec_settings.VP8()->resilience =
resilience_on ? kResilientStream : kResilienceOff;
break;
case kVideoCodecVP9:
config->codec_settings->VP9()->denoisingOn = denoising_on;
config->codec_settings->VP9()->numberOfTemporalLayers =
config->codec_settings.VP9()->denoisingOn = denoising_on;
config->codec_settings.VP9()->numberOfTemporalLayers =
num_temporal_layers;
config->codec_settings->VP9()->frameDroppingOn = frame_dropper_on;
config->codec_settings->VP9()->automaticResizeOn = spatial_resize_on;
config->codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
config->codec_settings->VP9()->resilienceOn = resilience_on;
config->codec_settings.VP9()->frameDroppingOn = frame_dropper_on;
config->codec_settings.VP9()->automaticResizeOn = spatial_resize_on;
config->codec_settings.VP9()->keyFrameInterval = kBaseKeyFrameInterval;
config->codec_settings.VP9()->resilienceOn = resilience_on;
break;
default:
RTC_NOTREACHED();
@ -709,12 +703,14 @@ class VideoProcessorIntegrationTest : public testing::Test {
rc_thresholds[update_index].num_key_frames = num_key_frames;
}
// Config.
TestConfig config_;
// Codecs.
std::unique_ptr<VideoEncoder> encoder_;
std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_;
std::unique_ptr<VideoDecoder> decoder_;
std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_;
VideoCodec codec_settings_;
// Helper objects.
std::unique_ptr<test::FrameReader> analysis_frame_reader_;
@ -722,7 +718,6 @@ class VideoProcessorIntegrationTest : public testing::Test {
test::PacketReader packet_reader_;
std::unique_ptr<test::PacketManipulator> packet_manipulator_;
test::Stats stats_;
test::TestConfig config_;
// Must be destroyed before |encoder_| and |decoder_|.
std::unique_ptr<test::VideoProcessor> processor_;

View File

@ -45,12 +45,10 @@ class VideoProcessorTest : public testing::Test {
protected:
VideoProcessorTest() {
// Get a codec configuration struct and configure it.
VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
config_.codec_settings = &codec_settings_;
config_.codec_settings->startBitrate = 100;
config_.codec_settings->width = kWidth;
config_.codec_settings->height = kHeight;
config_.codec_settings->maxFramerate = kFramerate;
VideoCodingModule::Codec(kVideoCodecVP8, &config_.codec_settings);
config_.codec_settings.width = kWidth;
config_.codec_settings.height = kHeight;
config_.codec_settings.maxFramerate = kFramerate;
EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
.WillRepeatedly(Return(kNumFrames));
@ -71,13 +69,13 @@ class VideoProcessorTest : public testing::Test {
.Times(AtLeast(1));
}
TestConfig config_;
MockVideoEncoder encoder_mock_;
MockVideoDecoder decoder_mock_;
MockFrameReader frame_reader_mock_;
MockFrameWriter frame_writer_mock_;
MockPacketManipulator packet_manipulator_mock_;
VideoCodec codec_settings_;
TestConfig config_;
Stats stats_;
std::unique_ptr<VideoProcessor> video_processor_;
};

View File

@ -205,7 +205,7 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) {
// Get codec specific configuration.
webrtc::VideoCodingModule::Codec(webrtc::kVideoCodecVP8,
config->codec_settings);
&config->codec_settings);
// Check the temporal layers.
if (FLAGS_temporal_layers < 0 ||
@ -214,14 +214,14 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) {
FLAGS_temporal_layers);
return 13;
}
config->codec_settings->VP8()->numberOfTemporalLayers = FLAGS_temporal_layers;
config->codec_settings.VP8()->numberOfTemporalLayers = FLAGS_temporal_layers;
// Check the bit rate.
if (FLAGS_bitrate <= 0) {
fprintf(stderr, "Bit rate must be >0 kbps, was: %d\n", FLAGS_bitrate);
return 5;
}
config->codec_settings->startBitrate = FLAGS_bitrate;
config->codec_settings.startBitrate = FLAGS_bitrate;
// Check the keyframe interval.
if (FLAGS_keyframe_interval < 0) {
@ -253,13 +253,13 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) {
fprintf(stderr, "Width and height must be >0.");
return 9;
}
config->codec_settings->width = FLAGS_width;
config->codec_settings->height = FLAGS_height;
config->codec_settings->maxFramerate = FLAGS_framerate;
config->codec_settings.width = FLAGS_width;
config->codec_settings.height = FLAGS_height;
config->codec_settings.maxFramerate = FLAGS_framerate;
// Calculate the size of each frame to read (according to YUV spec).
config->frame_length_in_bytes =
3 * config->codec_settings->width * config->codec_settings->height / 2;
3 * config->codec_settings.width * config->codec_settings.height / 2;
// Check packet loss settings
if (FLAGS_packet_loss_mode != "uniform" &&
@ -303,7 +303,7 @@ void CalculateSsimVideoMetrics(webrtc::test::TestConfig* config,
Log("Calculating SSIM...\n");
I420SSIMFromFiles(
config->input_filename.c_str(), config->output_filename.c_str(),
config->codec_settings->width, config->codec_settings->height, result);
config->codec_settings.width, config->codec_settings.height, result);
Log(" Average: %3.2f\n", result->average);
Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number);
Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number);
@ -314,7 +314,7 @@ void CalculatePsnrVideoMetrics(webrtc::test::TestConfig* config,
Log("Calculating PSNR...\n");
I420PSNRFromFiles(
config->input_filename.c_str(), config->output_filename.c_str(),
config->codec_settings->width, config->codec_settings->height, result);
config->codec_settings.width, config->codec_settings.height, result);
Log(" Average: %3.2f\n", result->average);
Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number);
Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number);
@ -411,10 +411,10 @@ void PrintPythonOutput(const webrtc::test::TestConfig& config,
ExcludeFrameTypesToStr(config.exclude_frame_types),
config.frame_length_in_bytes, config.use_single_core ? "True " : "False",
config.keyframe_interval,
CodecTypeToPayloadName(config.codec_settings->codecType)
CodecTypeToPayloadName(config.codec_settings.codecType)
.value_or("Unknown"),
config.codec_settings->width, config.codec_settings->height,
config.codec_settings->startBitrate);
config.codec_settings.width, config.codec_settings.height,
config.codec_settings.startBitrate);
printf(
"frame_data_types = {"
"'frame_number': ('number', 'Frame number'),\n"
@ -473,10 +473,8 @@ int main(int argc, char* argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
// Create TestConfig and codec settings struct.
// Create TestConfig.
webrtc::test::TestConfig config;
webrtc::VideoCodec codec_settings;
config.codec_settings = &codec_settings;
int return_code = HandleCommandLineFlags(&config);
// Exit if an invalid argument is supplied.
@ -490,11 +488,11 @@ int main(int argc, char* argv[]) {
webrtc::VP8Decoder* decoder = webrtc::VP8Decoder::Create();
webrtc::test::Stats stats;
webrtc::test::YuvFrameReaderImpl frame_reader(config.input_filename,
config.codec_settings->width,
config.codec_settings->height);
config.codec_settings.width,
config.codec_settings.height);
webrtc::test::YuvFrameWriterImpl frame_writer(config.output_filename,
config.codec_settings->width,
config.codec_settings->height);
config.codec_settings.width,
config.codec_settings.height);
frame_reader.Init();
frame_writer.Init();
webrtc::test::PacketReader packet_reader;