Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc

Issue 2639203005: Use std::unique_ptr in VideoProcessorIntegrationTest. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <math.h> 11 #include <math.h>
12 12
13 #include <memory>
14
13 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
14 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" 16 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
15 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" 17 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 19 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
18 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 20 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
19 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 21 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
20 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 22 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
21 #include "webrtc/modules/video_coding/include/video_coding.h" 23 #include "webrtc/modules/video_coding/include/video_coding.h"
22 #include "webrtc/test/gtest.h" 24 #include "webrtc/test/gtest.h"
23 #include "webrtc/test/testsupport/fileutils.h" 25 #include "webrtc/test/testsupport/fileutils.h"
24 #include "webrtc/test/testsupport/frame_reader.h" 26 #include "webrtc/test/testsupport/frame_reader.h"
25 #include "webrtc/test/testsupport/frame_writer.h" 27 #include "webrtc/test/testsupport/frame_writer.h"
26 #include "webrtc/test/testsupport/metrics/video_metrics.h" 28 #include "webrtc/test/testsupport/metrics/video_metrics.h"
27 #include "webrtc/test/testsupport/packet_reader.h" 29 #include "webrtc/test/testsupport/packet_reader.h"
28 #include "webrtc/typedefs.h" 30 #include "webrtc/typedefs.h"
29 31
30 namespace webrtc { 32 namespace webrtc {
31 33 namespace {
32 // Maximum number of rate updates (i.e., calls to encoder to change bitrate 34 // Maximum number of rate updates (i.e., calls to encoder to change bitrate
33 // and/or frame rate) for the current tests. 35 // and/or frame rate) for the current tests.
34 const int kMaxNumRateUpdates = 3; 36 const int kMaxNumRateUpdates = 3;
35 37
36 const int kPercTargetvsActualMismatch = 20; 38 const int kPercTargetvsActualMismatch = 20;
37 const int kBaseKeyFrameInterval = 3000; 39 const int kBaseKeyFrameInterval = 3000;
38 40
39 // Codec and network settings. 41 // Codec and network settings.
40 struct CodecConfigPars { 42 struct CodecConfigPars {
41 VideoCodecType codec_type; 43 VideoCodecType codec_type;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const int kCIFHeight = 288; 88 const int kCIFHeight = 288;
87 #if !defined(WEBRTC_IOS) 89 #if !defined(WEBRTC_IOS)
88 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence. 90 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence.
89 #endif 91 #endif
90 const int kNbrFramesLong = 299; 92 const int kNbrFramesLong = 299;
91 93
92 // Parameters from VP8 wrapper, which control target size of key frames. 94 // Parameters from VP8 wrapper, which control target size of key frames.
93 const float kInitialBufferSize = 0.5f; 95 const float kInitialBufferSize = 0.5f;
94 const float kOptimalBufferSize = 0.6f; 96 const float kOptimalBufferSize = 0.6f;
95 const float kScaleKeyFrameSize = 0.5f; 97 const float kScaleKeyFrameSize = 0.5f;
98 } // namespace
96 99
97 // Integration test for video processor. Encodes+decodes a clip and 100 // Integration test for video processor. Encodes+decodes a clip and
98 // writes it to the output directory. After completion, quality metrics 101 // writes it to the output directory. After completion, quality metrics
99 // (PSNR and SSIM) and rate control metrics are computed to verify that the 102 // (PSNR and SSIM) and rate control metrics are computed to verify that the
100 // quality and encoder response is acceptable. The rate control tests allow us 103 // quality and encoder response is acceptable. The rate control tests allow us
101 // to verify the behavior for changing bitrate, changing frame rate, frame 104 // to verify the behavior for changing bitrate, changing frame rate, frame
102 // dropping/spatial resize, and temporal layers. The limits for the rate 105 // dropping/spatial resize, and temporal layers. The limits for the rate
103 // control metrics are set to be fairly conservative, so failure should only 106 // control metrics are set to be fairly conservative, so failure should only
104 // happen when some significant regression or breakdown occurs. 107 // happen when some significant regression or breakdown occurs.
105 class VideoProcessorIntegrationTest : public testing::Test { 108 class VideoProcessorIntegrationTest : public testing::Test {
106 protected: 109 protected:
107 VideoEncoder* encoder_; 110 std::unique_ptr<VideoEncoder> encoder_;
108 VideoDecoder* decoder_; 111 std::unique_ptr<VideoDecoder> decoder_;
109 webrtc::test::FrameReader* frame_reader_; 112 std::unique_ptr<test::FrameReader> frame_reader_;
110 webrtc::test::FrameWriter* frame_writer_; 113 std::unique_ptr<test::FrameWriter> frame_writer_;
111 webrtc::test::PacketReader packet_reader_; 114 test::PacketReader packet_reader_;
112 webrtc::test::PacketManipulator* packet_manipulator_; 115 std::unique_ptr<test::PacketManipulator> packet_manipulator_;
113 webrtc::test::Stats stats_; 116 test::Stats stats_;
114 webrtc::test::TestConfig config_; 117 test::TestConfig config_;
115 VideoCodec codec_settings_; 118 VideoCodec codec_settings_;
116 webrtc::test::VideoProcessor* processor_; 119 std::unique_ptr<test::VideoProcessor> processor_;
117 TemporalLayersFactory tl_factory_; 120 TemporalLayersFactory tl_factory_;
118 121
119 // Quantities defined/updated for every encoder rate update. 122 // Quantities defined/updated for every encoder rate update.
120 // Some quantities defined per temporal layer (at most 3 layers in this test). 123 // Some quantities defined per temporal layer (at most 3 layers in this test).
121 int num_frames_per_update_[3]; 124 int num_frames_per_update_[3];
122 float sum_frame_size_mismatch_[3]; 125 float sum_frame_size_mismatch_[3];
123 float sum_encoded_frame_size_[3]; 126 float sum_encoded_frame_size_[3];
124 float encoding_bitrate_[3]; 127 float encoding_bitrate_[3];
125 float per_frame_bandwidth_[3]; 128 float per_frame_bandwidth_[3];
126 float bit_rate_layer_[3]; 129 float bit_rate_layer_[3];
(...skipping 21 matching lines...) Expand all
148 bool error_concealment_on_; 151 bool error_concealment_on_;
149 bool denoising_on_; 152 bool denoising_on_;
150 bool frame_dropper_on_; 153 bool frame_dropper_on_;
151 bool spatial_resize_on_; 154 bool spatial_resize_on_;
152 155
153 VideoProcessorIntegrationTest() {} 156 VideoProcessorIntegrationTest() {}
154 virtual ~VideoProcessorIntegrationTest() {} 157 virtual ~VideoProcessorIntegrationTest() {}
155 158
156 void SetUpCodecConfig() { 159 void SetUpCodecConfig() {
157 if (codec_type_ == kVideoCodecH264) { 160 if (codec_type_ == kVideoCodecH264) {
158 encoder_ = H264Encoder::Create(cricket::VideoCodec("H264")); 161 encoder_.reset(H264Encoder::Create(cricket::VideoCodec("H264")));
159 decoder_ = H264Decoder::Create(); 162 decoder_.reset(H264Decoder::Create());
160 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_); 163 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_);
161 } else if (codec_type_ == kVideoCodecVP8) { 164 } else if (codec_type_ == kVideoCodecVP8) {
162 encoder_ = VP8Encoder::Create(); 165 encoder_.reset(VP8Encoder::Create());
163 decoder_ = VP8Decoder::Create(); 166 decoder_.reset(VP8Decoder::Create());
164 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); 167 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
165 } else if (codec_type_ == kVideoCodecVP9) { 168 } else if (codec_type_ == kVideoCodecVP9) {
166 encoder_ = VP9Encoder::Create(); 169 encoder_.reset(VP9Encoder::Create());
167 decoder_ = VP9Decoder::Create(); 170 decoder_.reset(VP9Decoder::Create());
168 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); 171 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_);
169 } 172 }
170 173
171 // CIF is currently used for all tests below. 174 // CIF is currently used for all tests below.
172 // Setup the TestConfig struct for processing of a clip in CIF resolution. 175 // Setup the TestConfig struct for processing of a clip in CIF resolution.
173 config_.input_filename = webrtc::test::ResourcePath("foreman_cif", "yuv"); 176 config_.input_filename = webrtc::test::ResourcePath("foreman_cif", "yuv");
174 177
175 // Generate an output filename in a safe way. 178 // Generate an output filename in a safe way.
176 config_.output_filename = webrtc::test::TempFilename( 179 config_.output_filename = webrtc::test::TempFilename(
177 webrtc::test::OutputPath(), "videoprocessor_integrationtest"); 180 webrtc::test::OutputPath(), "videoprocessor_integrationtest");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 config_.codec_settings->VP9()->numberOfTemporalLayers = 215 config_.codec_settings->VP9()->numberOfTemporalLayers =
213 num_temporal_layers_; 216 num_temporal_layers_;
214 config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_; 217 config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_;
215 config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_; 218 config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_;
216 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; 219 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
217 break; 220 break;
218 default: 221 default:
219 assert(false); 222 assert(false);
220 break; 223 break;
221 } 224 }
222 frame_reader_ = new webrtc::test::FrameReaderImpl( 225 frame_reader_.reset(new test::FrameReaderImpl(
223 config_.input_filename, config_.codec_settings->width, 226 config_.input_filename, config_.codec_settings->width,
224 config_.codec_settings->height); 227 config_.codec_settings->height));
225 frame_writer_ = new webrtc::test::FrameWriterImpl( 228 frame_writer_.reset(new test::FrameWriterImpl(
226 config_.output_filename, config_.frame_length_in_bytes); 229 config_.output_filename, config_.frame_length_in_bytes));
227 ASSERT_TRUE(frame_reader_->Init()); 230 ASSERT_TRUE(frame_reader_->Init());
228 ASSERT_TRUE(frame_writer_->Init()); 231 ASSERT_TRUE(frame_writer_->Init());
229 232
230 packet_manipulator_ = new webrtc::test::PacketManipulatorImpl( 233 packet_manipulator_.reset(new test::PacketManipulatorImpl(
231 &packet_reader_, config_.networking_config, config_.verbose); 234 &packet_reader_, config_.networking_config, config_.verbose));
232 processor_ = new webrtc::test::VideoProcessorImpl( 235 processor_.reset(new test::VideoProcessorImpl(
233 encoder_, decoder_, frame_reader_, frame_writer_, packet_manipulator_, 236 encoder_.get(), decoder_.get(), frame_reader_.get(),
234 config_, &stats_); 237 frame_writer_.get(), packet_manipulator_.get(), config_, &stats_));
235 ASSERT_TRUE(processor_->Init()); 238 ASSERT_TRUE(processor_->Init());
236 } 239 }
237 240
238 // Reset quantities after each encoder update, update the target 241 // Reset quantities after each encoder update, update the target
239 // per-frame bandwidth. 242 // per-frame bandwidth.
240 void ResetRateControlMetrics(int num_frames) { 243 void ResetRateControlMetrics(int num_frames) {
241 for (int i = 0; i < num_temporal_layers_; i++) { 244 for (int i = 0; i < num_temporal_layers_; i++) {
242 num_frames_per_update_[i] = 0; 245 num_frames_per_update_[i] = 0;
243 sum_frame_size_mismatch_[i] = 0.0f; 246 sum_frame_size_mismatch_[i] = 0.0f;
244 sum_encoded_frame_size_[i] = 0.0f; 247 sum_encoded_frame_size_[i] = 0.0f;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 int num_key_frames) { 315 int num_key_frames) {
313 int num_dropped_frames = processor_->NumberDroppedFrames(); 316 int num_dropped_frames = processor_->NumberDroppedFrames();
314 int num_resize_actions = processor_->NumberSpatialResizes(); 317 int num_resize_actions = processor_->NumberSpatialResizes();
315 printf( 318 printf(
316 "For update #: %d,\n " 319 "For update #: %d,\n "
317 " Target Bitrate: %d,\n" 320 " Target Bitrate: %d,\n"
318 " Encoding bitrate: %f,\n" 321 " Encoding bitrate: %f,\n"
319 " Frame rate: %d \n", 322 " Frame rate: %d \n",
320 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); 323 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
321 printf( 324 printf(
322 " Number of frames to approach target rate = %d, \n" 325 " Number of frames to approach target rate: %d, \n"
323 " Number of dropped frames = %d, \n" 326 " Number of dropped frames: %d, \n"
324 " Number of spatial resizes = %d, \n", 327 " Number of spatial resizes: %d, \n",
325 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions); 328 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions);
326 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch); 329 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch);
327 if (num_key_frames_ > 0) { 330 if (num_key_frames_ > 0) {
328 int perc_key_frame_size_mismatch = 331 int perc_key_frame_size_mismatch =
329 100 * sum_key_frame_size_mismatch_ / num_key_frames_; 332 100 * sum_key_frame_size_mismatch_ / num_key_frames_;
330 printf( 333 printf(
331 " Number of Key frames: %d \n" 334 " Number of Key frames: %d \n"
332 " Key frame rate mismatch: %d \n", 335 " Key frame rate mismatch: %d \n",
333 num_key_frames_, perc_key_frame_size_mismatch); 336 num_key_frames_, perc_key_frame_size_mismatch);
334 EXPECT_LE(perc_key_frame_size_mismatch, max_key_frame_size_mismatch); 337 EXPECT_LE(perc_key_frame_size_mismatch, max_key_frame_size_mismatch);
335 } 338 }
336 printf("\n"); 339 printf("\n");
337 printf("Rates statistics for Layer data \n"); 340 printf("Rates statistics for Layer data \n");
338 for (int i = 0; i < num_temporal_layers_; i++) { 341 for (int i = 0; i < num_temporal_layers_; i++) {
339 printf("Layer #%d \n", i); 342 printf("Temporal layer #%d \n", i);
340 int perc_frame_size_mismatch = 343 int perc_frame_size_mismatch =
341 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i]; 344 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i];
342 int perc_encoding_rate_mismatch = 345 int perc_encoding_rate_mismatch =
343 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) / 346 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) /
344 bit_rate_layer_[i]; 347 bit_rate_layer_[i];
345 printf( 348 printf(
346 " Target Layer Bit rate: %f \n" 349 " Target Layer Bit rate: %f \n"
347 " Layer frame rate: %f, \n" 350 " Layer frame rate: %f, \n"
348 " Layer per frame bandwidth: %f, \n" 351 " Layer per frame bandwidth: %f, \n"
349 " Layer Encoding bit rate: %f, \n" 352 " Layer Encoding bit rate: %f, \n"
350 " Layer Percent frame size mismatch: %d, \n" 353 " Layer Percent frame size mismatch: %d, \n"
351 " Layer Percent encoding rate mismatch = %d, \n" 354 " Layer Percent encoding rate mismatch: %d, \n"
352 " Number of frame processed per layer = %d \n", 355 " Number of frame processed per layer: %d \n",
353 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i], 356 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i],
354 encoding_bitrate_[i], perc_frame_size_mismatch, 357 encoding_bitrate_[i], perc_frame_size_mismatch,
355 perc_encoding_rate_mismatch, num_frames_per_update_[i]); 358 perc_encoding_rate_mismatch, num_frames_per_update_[i]);
356 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); 359 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch);
357 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); 360 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch);
358 } 361 }
359 printf("\n"); 362 printf("\n");
360 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); 363 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target);
361 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); 364 EXPECT_LE(num_dropped_frames, max_num_dropped_frames);
362 EXPECT_EQ(num_resize_actions, num_spatial_resizes); 365 EXPECT_EQ(num_resize_actions, num_spatial_resizes);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio; 409 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio;
407 } 410 }
408 frame_rate_layer_[i] = 411 frame_rate_layer_[i] =
409 frame_rate_ / static_cast<float>(1 << (num_temporal_layers_ - 1)); 412 frame_rate_ / static_cast<float>(1 << (num_temporal_layers_ - 1));
410 } 413 }
411 if (num_temporal_layers_ == 3) { 414 if (num_temporal_layers_ == 3) {
412 frame_rate_layer_[2] = frame_rate_ / 2.0f; 415 frame_rate_layer_[2] = frame_rate_ / 2.0f;
413 } 416 }
414 } 417 }
415 418
416 void TearDown() {
417 delete processor_;
418 delete packet_manipulator_;
419 delete frame_writer_;
420 delete frame_reader_;
421 delete decoder_;
422 delete encoder_;
423 }
424
425 // Processes all frames in the clip and verifies the result. 419 // Processes all frames in the clip and verifies the result.
426 void ProcessFramesAndVerify(QualityMetrics quality_metrics, 420 void ProcessFramesAndVerify(QualityMetrics quality_metrics,
427 RateProfile rate_profile, 421 RateProfile rate_profile,
428 CodecConfigPars process, 422 CodecConfigPars process,
429 RateControlMetrics* rc_metrics) { 423 RateControlMetrics* rc_metrics) {
430 // Codec/config settings. 424 // Codec/config settings.
431 codec_type_ = process.codec_type; 425 codec_type_ = process.codec_type;
432 start_bitrate_ = rate_profile.target_bit_rate[0]; 426 start_bitrate_ = rate_profile.target_bit_rate[0];
433 packet_loss_ = process.packet_loss; 427 packet_loss_ = process.packet_loss;
434 key_frame_interval_ = process.key_frame_interval; 428 key_frame_interval_ = process.key_frame_interval;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); 493 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size()));
500 494
501 // Release encoder and decoder to make sure they have finished processing: 495 // Release encoder and decoder to make sure they have finished processing:
502 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); 496 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
503 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); 497 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
504 // Close the files before we start using them for SSIM/PSNR calculations. 498 // Close the files before we start using them for SSIM/PSNR calculations.
505 frame_reader_->Close(); 499 frame_reader_->Close();
506 frame_writer_->Close(); 500 frame_writer_->Close();
507 501
508 // TODO(marpan): should compute these quality metrics per SetRates update. 502 // TODO(marpan): should compute these quality metrics per SetRates update.
509 webrtc::test::QualityMetricsResult psnr_result, ssim_result; 503 test::QualityMetricsResult psnr_result, ssim_result;
510 EXPECT_EQ( 504 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(),
511 0, webrtc::test::I420MetricsFromFiles( 505 config_.output_filename.c_str(),
512 config_.input_filename.c_str(), config_.output_filename.c_str(), 506 config_.codec_settings->width,
513 config_.codec_settings->width, config_.codec_settings->height, 507 config_.codec_settings->height,
514 &psnr_result, &ssim_result)); 508 &psnr_result, &ssim_result));
515 printf("PSNR avg: %f, min: %f SSIM avg: %f, min: %f\n", 509 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n",
516 psnr_result.average, psnr_result.min, ssim_result.average, 510 psnr_result.average, psnr_result.min, ssim_result.average,
517 ssim_result.min); 511 ssim_result.min);
518 stats_.PrintSummary(); 512 stats_.PrintSummary();
519 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); 513 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr);
520 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); 514 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr);
521 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); 515 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim);
522 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); 516 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim);
523 if (remove(config_.output_filename.c_str()) < 0) { 517 if (remove(config_.output_filename.c_str()) < 0) {
524 fprintf(stderr, "Failed to remove temporary file!\n"); 518 fprintf(stderr, "Failed to remove temporary file!\n");
525 } 519 }
526 } 520 }
521
522 void SetRateProfilePars(RateProfile* rate_profile,
brandtr 2017/02/07 08:25:53 Make these four functions static?
åsapersson 2017/02/07 08:57:05 Done.
523 int update_index,
524 int bit_rate,
525 int frame_rate,
526 int frame_index_rate_update) {
527 rate_profile->target_bit_rate[update_index] = bit_rate;
528 rate_profile->input_frame_rate[update_index] = frame_rate;
529 rate_profile->frame_index_rate_update[update_index] =
530 frame_index_rate_update;
531 }
532
533 void SetCodecParameters(CodecConfigPars* process_settings,
534 VideoCodecType codec_type,
535 float packet_loss,
536 int key_frame_interval,
537 int num_temporal_layers,
538 bool error_concealment_on,
539 bool denoising_on,
540 bool frame_dropper_on,
541 bool spatial_resize_on) {
542 process_settings->codec_type = codec_type;
543 process_settings->packet_loss = packet_loss;
544 process_settings->key_frame_interval = key_frame_interval;
545 process_settings->num_temporal_layers = num_temporal_layers,
546 process_settings->error_concealment_on = error_concealment_on;
547 process_settings->denoising_on = denoising_on;
548 process_settings->frame_dropper_on = frame_dropper_on;
549 process_settings->spatial_resize_on = spatial_resize_on;
550 }
551
552 void SetQualityMetrics(QualityMetrics* quality_metrics,
553 double minimum_avg_psnr,
554 double minimum_min_psnr,
555 double minimum_avg_ssim,
556 double minimum_min_ssim) {
557 quality_metrics->minimum_avg_psnr = minimum_avg_psnr;
558 quality_metrics->minimum_min_psnr = minimum_min_psnr;
559 quality_metrics->minimum_avg_ssim = minimum_avg_ssim;
560 quality_metrics->minimum_min_ssim = minimum_min_ssim;
561 }
562
563 void SetRateControlMetrics(RateControlMetrics* rc_metrics,
564 int update_index,
565 int max_num_dropped_frames,
566 int max_key_frame_size_mismatch,
567 int max_delta_frame_size_mismatch,
568 int max_encoding_rate_mismatch,
569 int max_time_hit_target,
570 int num_spatial_resizes,
571 int num_key_frames) {
572 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames;
573 rc_metrics[update_index].max_key_frame_size_mismatch =
574 max_key_frame_size_mismatch;
575 rc_metrics[update_index].max_delta_frame_size_mismatch =
576 max_delta_frame_size_mismatch;
577 rc_metrics[update_index].max_encoding_rate_mismatch =
578 max_encoding_rate_mismatch;
579 rc_metrics[update_index].max_time_hit_target = max_time_hit_target;
580 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes;
581 rc_metrics[update_index].num_key_frames = num_key_frames;
582 }
527 }; 583 };
528 584
529 void SetRateProfilePars(RateProfile* rate_profile,
530 int update_index,
531 int bit_rate,
532 int frame_rate,
533 int frame_index_rate_update) {
534 rate_profile->target_bit_rate[update_index] = bit_rate;
535 rate_profile->input_frame_rate[update_index] = frame_rate;
536 rate_profile->frame_index_rate_update[update_index] = frame_index_rate_update;
537 }
538
539 void SetCodecParameters(CodecConfigPars* process_settings,
540 VideoCodecType codec_type,
541 float packet_loss,
542 int key_frame_interval,
543 int num_temporal_layers,
544 bool error_concealment_on,
545 bool denoising_on,
546 bool frame_dropper_on,
547 bool spatial_resize_on) {
548 process_settings->codec_type = codec_type;
549 process_settings->packet_loss = packet_loss;
550 process_settings->key_frame_interval = key_frame_interval;
551 process_settings->num_temporal_layers = num_temporal_layers,
552 process_settings->error_concealment_on = error_concealment_on;
553 process_settings->denoising_on = denoising_on;
554 process_settings->frame_dropper_on = frame_dropper_on;
555 process_settings->spatial_resize_on = spatial_resize_on;
556 }
557
558 void SetQualityMetrics(QualityMetrics* quality_metrics,
559 double minimum_avg_psnr,
560 double minimum_min_psnr,
561 double minimum_avg_ssim,
562 double minimum_min_ssim) {
563 quality_metrics->minimum_avg_psnr = minimum_avg_psnr;
564 quality_metrics->minimum_min_psnr = minimum_min_psnr;
565 quality_metrics->minimum_avg_ssim = minimum_avg_ssim;
566 quality_metrics->minimum_min_ssim = minimum_min_ssim;
567 }
568
569 void SetRateControlMetrics(RateControlMetrics* rc_metrics,
570 int update_index,
571 int max_num_dropped_frames,
572 int max_key_frame_size_mismatch,
573 int max_delta_frame_size_mismatch,
574 int max_encoding_rate_mismatch,
575 int max_time_hit_target,
576 int num_spatial_resizes,
577 int num_key_frames) {
578 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames;
579 rc_metrics[update_index].max_key_frame_size_mismatch =
580 max_key_frame_size_mismatch;
581 rc_metrics[update_index].max_delta_frame_size_mismatch =
582 max_delta_frame_size_mismatch;
583 rc_metrics[update_index].max_encoding_rate_mismatch =
584 max_encoding_rate_mismatch;
585 rc_metrics[update_index].max_time_hit_target = max_time_hit_target;
586 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes;
587 rc_metrics[update_index].num_key_frames = num_key_frames;
588 }
589
590 #if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS) 585 #if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS)
591 586
592 // H264: Run with no packet loss and fixed bitrate. Quality should be very high. 587 // H264: Run with no packet loss and fixed bitrate. Quality should be very high.
593 // Note(hbos): The PacketManipulatorImpl code used to simulate packet loss in 588 // Note(hbos): The PacketManipulatorImpl code used to simulate packet loss in
594 // these unittests appears to drop "packets" in a way that is not compatible 589 // these unittests appears to drop "packets" in a way that is not compatible
595 // with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have 590 // with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have
596 // not been added. 591 // not been added.
597 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) { 592 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) {
598 // Bitrate and frame rate profile. 593 // Bitrate and frame rate profile.
599 RateProfile rate_profile; 594 RateProfile rate_profile;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 QualityMetrics quality_metrics; 956 QualityMetrics quality_metrics;
962 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80); 957 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80);
963 // Metrics for rate control. 958 // Metrics for rate control.
964 RateControlMetrics rc_metrics[2]; 959 RateControlMetrics rc_metrics[2];
965 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); 960 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1);
966 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); 961 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0);
967 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, 962 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
968 rc_metrics); 963 rc_metrics);
969 } 964 }
970 } // namespace webrtc 965 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698