| OLD | NEW |
| 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 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 struct RateControlMetrics { | 74 struct RateControlMetrics { |
| 75 int max_num_dropped_frames; | 75 int max_num_dropped_frames; |
| 76 int max_key_frame_size_mismatch; | 76 int max_key_frame_size_mismatch; |
| 77 int max_delta_frame_size_mismatch; | 77 int max_delta_frame_size_mismatch; |
| 78 int max_encoding_rate_mismatch; | 78 int max_encoding_rate_mismatch; |
| 79 int max_time_hit_target; | 79 int max_time_hit_target; |
| 80 int num_spatial_resizes; | 80 int num_spatial_resizes; |
| 81 int num_key_frames; | 81 int num_key_frames; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 | |
| 85 // Sequence used is foreman (CIF): may be better to use VGA for resize test. | 84 // Sequence used is foreman (CIF): may be better to use VGA for resize test. |
| 86 const int kCIFWidth = 352; | 85 const int kCIFWidth = 352; |
| 87 const int kCIFHeight = 288; | 86 const int kCIFHeight = 288; |
| 88 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence. | 87 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence. |
| 89 const int kNbrFramesLong = 299; | 88 const int kNbrFramesLong = 299; |
| 90 | 89 |
| 91 // Parameters from VP8 wrapper, which control target size of key frames. | 90 // Parameters from VP8 wrapper, which control target size of key frames. |
| 92 const float kInitialBufferSize = 0.5f; | 91 const float kInitialBufferSize = 0.5f; |
| 93 const float kOptimalBufferSize = 0.6f; | 92 const float kOptimalBufferSize = 0.6f; |
| 94 const float kScaleKeyFrameSize = 0.5f; | 93 const float kScaleKeyFrameSize = 0.5f; |
| 95 | 94 |
| 96 // Integration test for video processor. Encodes+decodes a clip and | 95 // Integration test for video processor. Encodes+decodes a clip and |
| 97 // writes it to the output directory. After completion, quality metrics | 96 // writes it to the output directory. After completion, quality metrics |
| 98 // (PSNR and SSIM) and rate control metrics are computed to verify that the | 97 // (PSNR and SSIM) and rate control metrics are computed to verify that the |
| 99 // quality and encoder response is acceptable. The rate control tests allow us | 98 // quality and encoder response is acceptable. The rate control tests allow us |
| 100 // to verify the behavior for changing bitrate, changing frame rate, frame | 99 // to verify the behavior for changing bitrate, changing frame rate, frame |
| 101 // dropping/spatial resize, and temporal layers. The limits for the rate | 100 // dropping/spatial resize, and temporal layers. The limits for the rate |
| 102 // control metrics are set to be fairly conservative, so failure should only | 101 // control metrics are set to be fairly conservative, so failure should only |
| 103 // happen when some significant regression or breakdown occurs. | 102 // happen when some significant regression or breakdown occurs. |
| 104 class VideoProcessorIntegrationTest: public testing::Test { | 103 class VideoProcessorIntegrationTest : public testing::Test { |
| 105 protected: | 104 protected: |
| 106 VideoEncoder* encoder_; | 105 VideoEncoder* encoder_; |
| 107 VideoDecoder* decoder_; | 106 VideoDecoder* decoder_; |
| 108 webrtc::test::FrameReader* frame_reader_; | 107 webrtc::test::FrameReader* frame_reader_; |
| 109 webrtc::test::FrameWriter* frame_writer_; | 108 webrtc::test::FrameWriter* frame_writer_; |
| 110 webrtc::test::PacketReader packet_reader_; | 109 webrtc::test::PacketReader packet_reader_; |
| 111 webrtc::test::PacketManipulator* packet_manipulator_; | 110 webrtc::test::PacketManipulator* packet_manipulator_; |
| 112 webrtc::test::Stats stats_; | 111 webrtc::test::Stats stats_; |
| 113 webrtc::test::TestConfig config_; | 112 webrtc::test::TestConfig config_; |
| 114 VideoCodec codec_settings_; | 113 VideoCodec codec_settings_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 141 // Codec and network settings. | 140 // Codec and network settings. |
| 142 VideoCodecType codec_type_; | 141 VideoCodecType codec_type_; |
| 143 float packet_loss_; | 142 float packet_loss_; |
| 144 int num_temporal_layers_; | 143 int num_temporal_layers_; |
| 145 int key_frame_interval_; | 144 int key_frame_interval_; |
| 146 bool error_concealment_on_; | 145 bool error_concealment_on_; |
| 147 bool denoising_on_; | 146 bool denoising_on_; |
| 148 bool frame_dropper_on_; | 147 bool frame_dropper_on_; |
| 149 bool spatial_resize_on_; | 148 bool spatial_resize_on_; |
| 150 | 149 |
| 151 | |
| 152 VideoProcessorIntegrationTest() {} | 150 VideoProcessorIntegrationTest() {} |
| 153 virtual ~VideoProcessorIntegrationTest() {} | 151 virtual ~VideoProcessorIntegrationTest() {} |
| 154 | 152 |
| 155 void SetUpCodecConfig() { | 153 void SetUpCodecConfig() { |
| 156 if (codec_type_ == kVideoCodecVP8) { | 154 if (codec_type_ == kVideoCodecVP8) { |
| 157 encoder_ = VP8Encoder::Create(); | 155 encoder_ = VP8Encoder::Create(); |
| 158 decoder_ = VP8Decoder::Create(); | 156 decoder_ = VP8Decoder::Create(); |
| 159 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); | 157 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); |
| 160 } else if (codec_type_ == kVideoCodecVP9) { | 158 } else if (codec_type_ == kVideoCodecVP9) { |
| 161 encoder_ = VP9Encoder::Create(); | 159 encoder_ = VP9Encoder::Create(); |
| 162 decoder_ = VP9Decoder::Create(); | 160 decoder_ = VP9Decoder::Create(); |
| 163 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); | 161 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); |
| 164 } | 162 } |
| 165 | 163 |
| 166 // CIF is currently used for all tests below. | 164 // CIF is currently used for all tests below. |
| 167 // Setup the TestConfig struct for processing of a clip in CIF resolution. | 165 // Setup the TestConfig struct for processing of a clip in CIF resolution. |
| 168 config_.input_filename = | 166 config_.input_filename = webrtc::test::ResourcePath("foreman_cif", "yuv"); |
| 169 webrtc::test::ResourcePath("foreman_cif", "yuv"); | |
| 170 | 167 |
| 171 // Generate an output filename in a safe way. | 168 // Generate an output filename in a safe way. |
| 172 config_.output_filename = webrtc::test::TempFilename( | 169 config_.output_filename = webrtc::test::TempFilename( |
| 173 webrtc::test::OutputPath(), "videoprocessor_integrationtest"); | 170 webrtc::test::OutputPath(), "videoprocessor_integrationtest"); |
| 174 config_.frame_length_in_bytes = CalcBufferSize(kI420, | 171 config_.frame_length_in_bytes = |
| 175 kCIFWidth, kCIFHeight); | 172 CalcBufferSize(kI420, kCIFWidth, kCIFHeight); |
| 176 config_.verbose = false; | 173 config_.verbose = false; |
| 177 // Only allow encoder/decoder to use single core, for predictability. | 174 // Only allow encoder/decoder to use single core, for predictability. |
| 178 config_.use_single_core = true; | 175 config_.use_single_core = true; |
| 179 // Key frame interval and packet loss are set for each test. | 176 // Key frame interval and packet loss are set for each test. |
| 180 config_.keyframe_interval = key_frame_interval_; | 177 config_.keyframe_interval = key_frame_interval_; |
| 181 config_.networking_config.packet_loss_probability = packet_loss_; | 178 config_.networking_config.packet_loss_probability = packet_loss_; |
| 182 | 179 |
| 183 // Configure codec settings. | 180 // Configure codec settings. |
| 184 config_.codec_settings = &codec_settings_; | 181 config_.codec_settings = &codec_settings_; |
| 185 config_.codec_settings->startBitrate = start_bitrate_; | 182 config_.codec_settings->startBitrate = start_bitrate_; |
| 186 config_.codec_settings->width = kCIFWidth; | 183 config_.codec_settings->width = kCIFWidth; |
| 187 config_.codec_settings->height = kCIFHeight; | 184 config_.codec_settings->height = kCIFHeight; |
| 188 | 185 |
| 189 // These features may be set depending on the test. | 186 // These features may be set depending on the test. |
| 190 switch (config_.codec_settings->codecType) { | 187 switch (config_.codec_settings->codecType) { |
| 191 case kVideoCodecVP8: | 188 case kVideoCodecVP8: |
| 192 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn = | 189 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn = |
| 193 error_concealment_on_; | 190 error_concealment_on_; |
| 194 config_.codec_settings->codecSpecific.VP8.denoisingOn = | 191 config_.codec_settings->codecSpecific.VP8.denoisingOn = denoising_on_; |
| 195 denoising_on_; | 192 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers = |
| 196 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers = | 193 num_temporal_layers_; |
| 197 num_temporal_layers_; | 194 config_.codec_settings->codecSpecific.VP8.frameDroppingOn = |
| 198 config_.codec_settings->codecSpecific.VP8.frameDroppingOn = | 195 frame_dropper_on_; |
| 199 frame_dropper_on_; | 196 config_.codec_settings->codecSpecific.VP8.automaticResizeOn = |
| 200 config_.codec_settings->codecSpecific.VP8.automaticResizeOn = | 197 spatial_resize_on_; |
| 201 spatial_resize_on_; | 198 config_.codec_settings->codecSpecific.VP8.keyFrameInterval = |
| 202 config_.codec_settings->codecSpecific.VP8.keyFrameInterval = | 199 kBaseKeyFrameInterval; |
| 203 kBaseKeyFrameInterval; | 200 break; |
| 204 break; | 201 case kVideoCodecVP9: |
| 205 case kVideoCodecVP9: | 202 config_.codec_settings->codecSpecific.VP9.denoisingOn = denoising_on_; |
| 206 config_.codec_settings->codecSpecific.VP9.denoisingOn = | 203 config_.codec_settings->codecSpecific.VP9.numberOfTemporalLayers = |
| 207 denoising_on_; | 204 num_temporal_layers_; |
| 208 config_.codec_settings->codecSpecific.VP9.numberOfTemporalLayers = | 205 config_.codec_settings->codecSpecific.VP9.frameDroppingOn = |
| 209 num_temporal_layers_; | 206 frame_dropper_on_; |
| 210 config_.codec_settings->codecSpecific.VP9.frameDroppingOn = | 207 config_.codec_settings->codecSpecific.VP9.automaticResizeOn = |
| 211 frame_dropper_on_; | 208 spatial_resize_on_; |
| 212 config_.codec_settings->codecSpecific.VP9.automaticResizeOn = | 209 config_.codec_settings->codecSpecific.VP9.keyFrameInterval = |
| 213 spatial_resize_on_; | 210 kBaseKeyFrameInterval; |
| 214 config_.codec_settings->codecSpecific.VP9.keyFrameInterval = | 211 break; |
| 215 kBaseKeyFrameInterval; | 212 default: |
| 216 break; | 213 assert(false); |
| 217 default: | 214 break; |
| 218 assert(false); | 215 } |
| 219 break; | 216 frame_reader_ = new webrtc::test::FrameReaderImpl( |
| 220 } | 217 config_.input_filename, config_.frame_length_in_bytes); |
| 221 frame_reader_ = | 218 frame_writer_ = new webrtc::test::FrameWriterImpl( |
| 222 new webrtc::test::FrameReaderImpl(config_.input_filename, | 219 config_.output_filename, config_.frame_length_in_bytes); |
| 223 config_.frame_length_in_bytes); | |
| 224 frame_writer_ = | |
| 225 new webrtc::test::FrameWriterImpl(config_.output_filename, | |
| 226 config_.frame_length_in_bytes); | |
| 227 ASSERT_TRUE(frame_reader_->Init()); | 220 ASSERT_TRUE(frame_reader_->Init()); |
| 228 ASSERT_TRUE(frame_writer_->Init()); | 221 ASSERT_TRUE(frame_writer_->Init()); |
| 229 | 222 |
| 230 packet_manipulator_ = new webrtc::test::PacketManipulatorImpl( | 223 packet_manipulator_ = new webrtc::test::PacketManipulatorImpl( |
| 231 &packet_reader_, config_.networking_config, config_.verbose); | 224 &packet_reader_, config_.networking_config, config_.verbose); |
| 232 processor_ = new webrtc::test::VideoProcessorImpl(encoder_, decoder_, | 225 processor_ = new webrtc::test::VideoProcessorImpl( |
| 233 frame_reader_, | 226 encoder_, decoder_, frame_reader_, frame_writer_, packet_manipulator_, |
| 234 frame_writer_, | 227 config_, &stats_); |
| 235 packet_manipulator_, | |
| 236 config_, &stats_); | |
| 237 ASSERT_TRUE(processor_->Init()); | 228 ASSERT_TRUE(processor_->Init()); |
| 238 } | 229 } |
| 239 | 230 |
| 240 // Reset quantities after each encoder update, update the target | 231 // Reset quantities after each encoder update, update the target |
| 241 // per-frame bandwidth. | 232 // per-frame bandwidth. |
| 242 void ResetRateControlMetrics(int num_frames) { | 233 void ResetRateControlMetrics(int num_frames) { |
| 243 for (int i = 0; i < num_temporal_layers_; i++) { | 234 for (int i = 0; i < num_temporal_layers_; i++) { |
| 244 num_frames_per_update_[i] = 0; | 235 num_frames_per_update_[i] = 0; |
| 245 sum_frame_size_mismatch_[i] = 0.0f; | 236 sum_frame_size_mismatch_[i] = 0.0f; |
| 246 sum_encoded_frame_size_[i] = 0.0f; | 237 sum_encoded_frame_size_[i] = 0.0f; |
| 247 encoding_bitrate_[i] = 0.0f; | 238 encoding_bitrate_[i] = 0.0f; |
| 248 // Update layer per-frame-bandwidth. | 239 // Update layer per-frame-bandwidth. |
| 249 per_frame_bandwidth_[i] = static_cast<float>(bit_rate_layer_[i]) / | 240 per_frame_bandwidth_[i] = static_cast<float>(bit_rate_layer_[i]) / |
| 250 static_cast<float>(frame_rate_layer_[i]); | 241 static_cast<float>(frame_rate_layer_[i]); |
| 251 } | 242 } |
| 252 // Set maximum size of key frames, following setting in the VP8 wrapper. | 243 // Set maximum size of key frames, following setting in the VP8 wrapper. |
| 253 float max_key_size = kScaleKeyFrameSize * kOptimalBufferSize * frame_rate_; | 244 float max_key_size = kScaleKeyFrameSize * kOptimalBufferSize * frame_rate_; |
| 254 // We don't know exact target size of the key frames (except for first one), | 245 // We don't know exact target size of the key frames (except for first one), |
| 255 // but the minimum in libvpx is ~|3 * per_frame_bandwidth| and maximum is | 246 // but the minimum in libvpx is ~|3 * per_frame_bandwidth| and maximum is |
| 256 // set by |max_key_size_ * per_frame_bandwidth|. Take middle point/average | 247 // set by |max_key_size_ * per_frame_bandwidth|. Take middle point/average |
| 257 // as reference for mismatch. Note key frames always correspond to base | 248 // as reference for mismatch. Note key frames always correspond to base |
| 258 // layer frame in this test. | 249 // layer frame in this test. |
| 259 target_size_key_frame_ = 0.5 * (3 + max_key_size) * per_frame_bandwidth_[0]; | 250 target_size_key_frame_ = 0.5 * (3 + max_key_size) * per_frame_bandwidth_[0]; |
| 260 num_frames_total_ = 0; | 251 num_frames_total_ = 0; |
| 261 sum_encoded_frame_size_total_ = 0.0f; | 252 sum_encoded_frame_size_total_ = 0.0f; |
| 262 encoding_bitrate_total_ = 0.0f; | 253 encoding_bitrate_total_ = 0.0f; |
| 263 perc_encoding_rate_mismatch_ = 0.0f; | 254 perc_encoding_rate_mismatch_ = 0.0f; |
| 264 num_frames_to_hit_target_ = num_frames; | 255 num_frames_to_hit_target_ = num_frames; |
| 265 encoding_rate_within_target_ = false; | 256 encoding_rate_within_target_ = false; |
| 266 sum_key_frame_size_mismatch_ = 0.0; | 257 sum_key_frame_size_mismatch_ = 0.0; |
| 267 num_key_frames_ = 0; | 258 num_key_frames_ = 0; |
| 268 } | 259 } |
| 269 | 260 |
| 270 // For every encoded frame, update the rate control metrics. | 261 // For every encoded frame, update the rate control metrics. |
| 271 void UpdateRateControlMetrics(int frame_num, FrameType frame_type) { | 262 void UpdateRateControlMetrics(int frame_num, FrameType frame_type) { |
| 272 float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; | 263 float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; |
| 273 // Update layer data. | 264 // Update layer data. |
| 274 // Update rate mismatch relative to per-frame bandwidth for delta frames. | 265 // Update rate mismatch relative to per-frame bandwidth for delta frames. |
| 275 if (frame_type == kVideoFrameDelta) { | 266 if (frame_type == kVideoFrameDelta) { |
| 276 // TODO(marpan): Should we count dropped (zero size) frames in mismatch? | 267 // TODO(marpan): Should we count dropped (zero size) frames in mismatch? |
| 277 sum_frame_size_mismatch_[layer_] += fabs(encoded_size_kbits - | 268 sum_frame_size_mismatch_[layer_] += |
| 278 per_frame_bandwidth_[layer_]) / | 269 fabs(encoded_size_kbits - per_frame_bandwidth_[layer_]) / |
| 279 per_frame_bandwidth_[layer_]; | 270 per_frame_bandwidth_[layer_]; |
| 280 } else { | 271 } else { |
| 281 float target_size = (frame_num == 1) ? target_size_key_frame_initial_ : | 272 float target_size = (frame_num == 1) ? target_size_key_frame_initial_ |
| 282 target_size_key_frame_; | 273 : target_size_key_frame_; |
| 283 sum_key_frame_size_mismatch_ += fabs(encoded_size_kbits - target_size) / | 274 sum_key_frame_size_mismatch_ += |
| 284 target_size; | 275 fabs(encoded_size_kbits - target_size) / target_size; |
| 285 num_key_frames_ += 1; | 276 num_key_frames_ += 1; |
| 286 } | 277 } |
| 287 sum_encoded_frame_size_[layer_] += encoded_size_kbits; | 278 sum_encoded_frame_size_[layer_] += encoded_size_kbits; |
| 288 // Encoding bitrate per layer: from the start of the update/run to the | 279 // Encoding bitrate per layer: from the start of the update/run to the |
| 289 // current frame. | 280 // current frame. |
| 290 encoding_bitrate_[layer_] = sum_encoded_frame_size_[layer_] * | 281 encoding_bitrate_[layer_] = sum_encoded_frame_size_[layer_] * |
| 291 frame_rate_layer_[layer_] / | 282 frame_rate_layer_[layer_] / |
| 292 num_frames_per_update_[layer_]; | 283 num_frames_per_update_[layer_]; |
| 293 // Total encoding rate: from the start of the update/run to current frame. | 284 // Total encoding rate: from the start of the update/run to current frame. |
| 294 sum_encoded_frame_size_total_ += encoded_size_kbits; | 285 sum_encoded_frame_size_total_ += encoded_size_kbits; |
| 295 encoding_bitrate_total_ = sum_encoded_frame_size_total_ * frame_rate_ / | 286 encoding_bitrate_total_ = |
| 296 num_frames_total_; | 287 sum_encoded_frame_size_total_ * frame_rate_ / num_frames_total_; |
| 297 perc_encoding_rate_mismatch_ = 100 * fabs(encoding_bitrate_total_ - | 288 perc_encoding_rate_mismatch_ = |
| 298 bit_rate_) / bit_rate_; | 289 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_; |
| 299 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && | 290 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && |
| 300 !encoding_rate_within_target_) { | 291 !encoding_rate_within_target_) { |
| 301 num_frames_to_hit_target_ = num_frames_total_; | 292 num_frames_to_hit_target_ = num_frames_total_; |
| 302 encoding_rate_within_target_ = true; | 293 encoding_rate_within_target_ = true; |
| 303 } | 294 } |
| 304 } | 295 } |
| 305 | 296 |
| 306 // Verify expected behavior of rate control and print out data. | 297 // Verify expected behavior of rate control and print out data. |
| 307 void VerifyRateControl(int update_index, | 298 void VerifyRateControl(int update_index, |
| 308 int max_key_frame_size_mismatch, | 299 int max_key_frame_size_mismatch, |
| 309 int max_delta_frame_size_mismatch, | 300 int max_delta_frame_size_mismatch, |
| 310 int max_encoding_rate_mismatch, | 301 int max_encoding_rate_mismatch, |
| 311 int max_time_hit_target, | 302 int max_time_hit_target, |
| 312 int max_num_dropped_frames, | 303 int max_num_dropped_frames, |
| 313 int num_spatial_resizes, | 304 int num_spatial_resizes, |
| 314 int num_key_frames) { | 305 int num_key_frames) { |
| 315 int num_dropped_frames = processor_->NumberDroppedFrames(); | 306 int num_dropped_frames = processor_->NumberDroppedFrames(); |
| 316 int num_resize_actions = processor_->NumberSpatialResizes(); | 307 int num_resize_actions = processor_->NumberSpatialResizes(); |
| 317 printf("For update #: %d,\n " | 308 printf( |
| 309 "For update #: %d,\n " |
| 318 " Target Bitrate: %d,\n" | 310 " Target Bitrate: %d,\n" |
| 319 " Encoding bitrate: %f,\n" | 311 " Encoding bitrate: %f,\n" |
| 320 " Frame rate: %d \n", | 312 " Frame rate: %d \n", |
| 321 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); | 313 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); |
| 322 printf(" Number of frames to approach target rate = %d, \n" | 314 printf( |
| 323 " Number of dropped frames = %d, \n" | 315 " Number of frames to approach target rate = %d, \n" |
| 324 " Number of spatial resizes = %d, \n", | 316 " Number of dropped frames = %d, \n" |
| 325 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions); | 317 " Number of spatial resizes = %d, \n", |
| 318 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions); |
| 326 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch); | 319 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch); |
| 327 if (num_key_frames_ > 0) { | 320 if (num_key_frames_ > 0) { |
| 328 int perc_key_frame_size_mismatch = 100 * sum_key_frame_size_mismatch_ / | 321 int perc_key_frame_size_mismatch = |
| 329 num_key_frames_; | 322 100 * sum_key_frame_size_mismatch_ / num_key_frames_; |
| 330 printf(" Number of Key frames: %d \n" | 323 printf( |
| 331 " Key frame rate mismatch: %d \n", | 324 " Number of Key frames: %d \n" |
| 332 num_key_frames_, perc_key_frame_size_mismatch); | 325 " Key frame rate mismatch: %d \n", |
| 326 num_key_frames_, perc_key_frame_size_mismatch); |
| 333 EXPECT_LE(perc_key_frame_size_mismatch, max_key_frame_size_mismatch); | 327 EXPECT_LE(perc_key_frame_size_mismatch, max_key_frame_size_mismatch); |
| 334 } | 328 } |
| 335 printf("\n"); | 329 printf("\n"); |
| 336 printf("Rates statistics for Layer data \n"); | 330 printf("Rates statistics for Layer data \n"); |
| 337 for (int i = 0; i < num_temporal_layers_ ; i++) { | 331 for (int i = 0; i < num_temporal_layers_; i++) { |
| 338 printf("Layer #%d \n", i); | 332 printf("Layer #%d \n", i); |
| 339 int perc_frame_size_mismatch = 100 * sum_frame_size_mismatch_[i] / | 333 int perc_frame_size_mismatch = |
| 340 num_frames_per_update_[i]; | 334 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i]; |
| 341 int perc_encoding_rate_mismatch = 100 * fabs(encoding_bitrate_[i] - | 335 int perc_encoding_rate_mismatch = |
| 342 bit_rate_layer_[i]) / | 336 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) / |
| 343 bit_rate_layer_[i]; | 337 bit_rate_layer_[i]; |
| 344 printf(" Target Layer Bit rate: %f \n" | 338 printf( |
| 339 " Target Layer Bit rate: %f \n" |
| 345 " Layer frame rate: %f, \n" | 340 " Layer frame rate: %f, \n" |
| 346 " Layer per frame bandwidth: %f, \n" | 341 " Layer per frame bandwidth: %f, \n" |
| 347 " Layer Encoding bit rate: %f, \n" | 342 " Layer Encoding bit rate: %f, \n" |
| 348 " Layer Percent frame size mismatch: %d, \n" | 343 " Layer Percent frame size mismatch: %d, \n" |
| 349 " Layer Percent encoding rate mismatch = %d, \n" | 344 " Layer Percent encoding rate mismatch = %d, \n" |
| 350 " Number of frame processed per layer = %d \n", | 345 " Number of frame processed per layer = %d \n", |
| 351 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i], | 346 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i], |
| 352 encoding_bitrate_[i], perc_frame_size_mismatch, | 347 encoding_bitrate_[i], perc_frame_size_mismatch, |
| 353 perc_encoding_rate_mismatch, num_frames_per_update_[i]); | 348 perc_encoding_rate_mismatch, num_frames_per_update_[i]); |
| 354 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); | 349 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); |
| 355 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); | 350 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); |
| 356 } | 351 } |
| 357 printf("\n"); | 352 printf("\n"); |
| 358 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); | 353 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); |
| 359 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); | 354 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); |
| 360 EXPECT_EQ(num_resize_actions, num_spatial_resizes); | 355 EXPECT_EQ(num_resize_actions, num_spatial_resizes); |
| 361 EXPECT_EQ(num_key_frames_, num_key_frames); | 356 EXPECT_EQ(num_key_frames_, num_key_frames); |
| 362 } | 357 } |
| 363 | 358 |
| 364 // Layer index corresponding to frame number, for up to 3 layers. | 359 // Layer index corresponding to frame number, for up to 3 layers. |
| 365 void LayerIndexForFrame(int frame_number) { | 360 void LayerIndexForFrame(int frame_number) { |
| 366 if (num_temporal_layers_ == 1) { | 361 if (num_temporal_layers_ == 1) { |
| 367 layer_ = 0; | 362 layer_ = 0; |
| 368 } else if (num_temporal_layers_ == 2) { | 363 } else if (num_temporal_layers_ == 2) { |
| 369 // layer 0: 0 2 4 ... | 364 // layer 0: 0 2 4 ... |
| 370 // layer 1: 1 3 | 365 // layer 1: 1 3 |
| 371 if (frame_number % 2 == 0) { | 366 if (frame_number % 2 == 0) { |
| 372 layer_ = 0; | 367 layer_ = 0; |
| 373 } else { | 368 } else { |
| 374 layer_ = 1; | 369 layer_ = 1; |
| 375 } | 370 } |
| 376 } else if (num_temporal_layers_ == 3) { | 371 } else if (num_temporal_layers_ == 3) { |
| 377 // layer 0: 0 4 8 ... | 372 // layer 0: 0 4 8 ... |
| 378 // layer 1: 2 6 | 373 // layer 1: 2 6 |
| 379 // layer 2: 1 3 5 7 | 374 // layer 2: 1 3 5 7 |
| 380 if (frame_number % 4 == 0) { | 375 if (frame_number % 4 == 0) { |
| 381 layer_ = 0; | 376 layer_ = 0; |
| 382 } else if ((frame_number + 2) % 4 == 0) { | 377 } else if ((frame_number + 2) % 4 == 0) { |
| 383 layer_ = 1; | 378 layer_ = 1; |
| 384 } else if ((frame_number + 1) % 2 == 0) { | 379 } else if ((frame_number + 1) % 2 == 0) { |
| 385 layer_ = 2; | 380 layer_ = 2; |
| 386 } | 381 } |
| 387 } else { | 382 } else { |
| 388 assert(false); // Only up to 3 layers. | 383 assert(false); // Only up to 3 layers. |
| 389 } | 384 } |
| 390 } | 385 } |
| 391 | 386 |
| 392 // Set the bitrate and frame rate per layer, for up to 3 layers. | 387 // Set the bitrate and frame rate per layer, for up to 3 layers. |
| 393 void SetLayerRates() { | 388 void SetLayerRates() { |
| 394 assert(num_temporal_layers_<= 3); | 389 assert(num_temporal_layers_ <= 3); |
| 395 for (int i = 0; i < num_temporal_layers_; i++) { | 390 for (int i = 0; i < num_temporal_layers_; i++) { |
| 396 float bit_rate_ratio = | 391 float bit_rate_ratio = |
| 397 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i]; | 392 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i]; |
| 398 if (i > 0) { | 393 if (i > 0) { |
| 399 float bit_rate_delta_ratio = kVp8LayerRateAlloction | 394 float bit_rate_delta_ratio = |
| 400 [num_temporal_layers_ - 1][i] - | 395 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i] - |
| 401 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1]; | 396 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1]; |
| 402 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio; | 397 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio; |
| 403 } else { | 398 } else { |
| 404 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio; | 399 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio; |
| 405 } | 400 } |
| 406 frame_rate_layer_[i] = frame_rate_ / static_cast<float>( | 401 frame_rate_layer_[i] = |
| 407 1 << (num_temporal_layers_ - 1)); | 402 frame_rate_ / static_cast<float>(1 << (num_temporal_layers_ - 1)); |
| 408 } | 403 } |
| 409 if (num_temporal_layers_ == 3) { | 404 if (num_temporal_layers_ == 3) { |
| 410 frame_rate_layer_[2] = frame_rate_ / 2.0f; | 405 frame_rate_layer_[2] = frame_rate_ / 2.0f; |
| 411 } | 406 } |
| 412 } | 407 } |
| 413 | 408 |
| 414 void TearDown() { | 409 void TearDown() { |
| 415 delete processor_; | 410 delete processor_; |
| 416 delete packet_manipulator_; | 411 delete packet_manipulator_; |
| 417 delete frame_writer_; | 412 delete frame_writer_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 430 start_bitrate_ = rate_profile.target_bit_rate[0]; | 425 start_bitrate_ = rate_profile.target_bit_rate[0]; |
| 431 packet_loss_ = process.packet_loss; | 426 packet_loss_ = process.packet_loss; |
| 432 key_frame_interval_ = process.key_frame_interval; | 427 key_frame_interval_ = process.key_frame_interval; |
| 433 num_temporal_layers_ = process.num_temporal_layers; | 428 num_temporal_layers_ = process.num_temporal_layers; |
| 434 error_concealment_on_ = process.error_concealment_on; | 429 error_concealment_on_ = process.error_concealment_on; |
| 435 denoising_on_ = process.denoising_on; | 430 denoising_on_ = process.denoising_on; |
| 436 frame_dropper_on_ = process.frame_dropper_on; | 431 frame_dropper_on_ = process.frame_dropper_on; |
| 437 spatial_resize_on_ = process.spatial_resize_on; | 432 spatial_resize_on_ = process.spatial_resize_on; |
| 438 SetUpCodecConfig(); | 433 SetUpCodecConfig(); |
| 439 // Update the layers and the codec with the initial rates. | 434 // Update the layers and the codec with the initial rates. |
| 440 bit_rate_ = rate_profile.target_bit_rate[0]; | 435 bit_rate_ = rate_profile.target_bit_rate[0]; |
| 441 frame_rate_ = rate_profile.input_frame_rate[0]; | 436 frame_rate_ = rate_profile.input_frame_rate[0]; |
| 442 SetLayerRates(); | 437 SetLayerRates(); |
| 443 // Set the initial target size for key frame. | 438 // Set the initial target size for key frame. |
| 444 target_size_key_frame_initial_ = 0.5 * kInitialBufferSize * | 439 target_size_key_frame_initial_ = |
| 445 bit_rate_layer_[0]; | 440 0.5 * kInitialBufferSize * bit_rate_layer_[0]; |
| 446 processor_->SetRates(bit_rate_, frame_rate_); | 441 processor_->SetRates(bit_rate_, frame_rate_); |
| 447 // Process each frame, up to |num_frames|. | 442 // Process each frame, up to |num_frames|. |
| 448 int num_frames = rate_profile.num_frames; | 443 int num_frames = rate_profile.num_frames; |
| 449 int update_index = 0; | 444 int update_index = 0; |
| 450 ResetRateControlMetrics( | 445 ResetRateControlMetrics( |
| 451 rate_profile.frame_index_rate_update[update_index + 1]); | 446 rate_profile.frame_index_rate_update[update_index + 1]); |
| 452 int frame_number = 0; | 447 int frame_number = 0; |
| 453 FrameType frame_type = kVideoFrameDelta; | 448 FrameType frame_type = kVideoFrameDelta; |
| 454 while (processor_->ProcessFrame(frame_number) && | 449 while (processor_->ProcessFrame(frame_number) && |
| 455 frame_number < num_frames) { | 450 frame_number < num_frames) { |
| 456 // Get the layer index for the frame |frame_number|. | 451 // Get the layer index for the frame |frame_number|. |
| 457 LayerIndexForFrame(frame_number); | 452 LayerIndexForFrame(frame_number); |
| 458 // Get the frame_type. | 453 // Get the frame_type. |
| 459 frame_type = processor_->EncodedFrameType(); | 454 frame_type = processor_->EncodedFrameType(); |
| 460 // Counter for whole sequence run. | 455 // Counter for whole sequence run. |
| 461 ++frame_number; | 456 ++frame_number; |
| 462 // Counters for each rate update. | 457 // Counters for each rate update. |
| 463 ++num_frames_per_update_[layer_]; | 458 ++num_frames_per_update_[layer_]; |
| 464 ++num_frames_total_; | 459 ++num_frames_total_; |
| 465 UpdateRateControlMetrics(frame_number, frame_type); | 460 UpdateRateControlMetrics(frame_number, frame_type); |
| 466 // If we hit another/next update, verify stats for current state and | 461 // If we hit another/next update, verify stats for current state and |
| 467 // update layers and codec with new rates. | 462 // update layers and codec with new rates. |
| 468 if (frame_number == | 463 if (frame_number == |
| 469 rate_profile.frame_index_rate_update[update_index + 1]) { | 464 rate_profile.frame_index_rate_update[update_index + 1]) { |
| 470 VerifyRateControl( | 465 VerifyRateControl( |
| 471 update_index, | 466 update_index, rc_metrics[update_index].max_key_frame_size_mismatch, |
| 472 rc_metrics[update_index].max_key_frame_size_mismatch, | |
| 473 rc_metrics[update_index].max_delta_frame_size_mismatch, | 467 rc_metrics[update_index].max_delta_frame_size_mismatch, |
| 474 rc_metrics[update_index].max_encoding_rate_mismatch, | 468 rc_metrics[update_index].max_encoding_rate_mismatch, |
| 475 rc_metrics[update_index].max_time_hit_target, | 469 rc_metrics[update_index].max_time_hit_target, |
| 476 rc_metrics[update_index].max_num_dropped_frames, | 470 rc_metrics[update_index].max_num_dropped_frames, |
| 477 rc_metrics[update_index].num_spatial_resizes, | 471 rc_metrics[update_index].num_spatial_resizes, |
| 478 rc_metrics[update_index].num_key_frames); | 472 rc_metrics[update_index].num_key_frames); |
| 479 // Update layer rates and the codec with new rates. | 473 // Update layer rates and the codec with new rates. |
| 480 ++update_index; | 474 ++update_index; |
| 481 bit_rate_ = rate_profile.target_bit_rate[update_index]; | 475 bit_rate_ = rate_profile.target_bit_rate[update_index]; |
| 482 frame_rate_ = rate_profile.input_frame_rate[update_index]; | 476 frame_rate_ = rate_profile.input_frame_rate[update_index]; |
| 483 SetLayerRates(); | 477 SetLayerRates(); |
| 484 ResetRateControlMetrics(rate_profile. | 478 ResetRateControlMetrics( |
| 485 frame_index_rate_update[update_index + 1]); | 479 rate_profile.frame_index_rate_update[update_index + 1]); |
| 486 processor_->SetRates(bit_rate_, frame_rate_); | 480 processor_->SetRates(bit_rate_, frame_rate_); |
| 487 } | 481 } |
| 488 } | 482 } |
| 489 VerifyRateControl( | 483 VerifyRateControl(update_index, |
| 490 update_index, | 484 rc_metrics[update_index].max_key_frame_size_mismatch, |
| 491 rc_metrics[update_index].max_key_frame_size_mismatch, | 485 rc_metrics[update_index].max_delta_frame_size_mismatch, |
| 492 rc_metrics[update_index].max_delta_frame_size_mismatch, | 486 rc_metrics[update_index].max_encoding_rate_mismatch, |
| 493 rc_metrics[update_index].max_encoding_rate_mismatch, | 487 rc_metrics[update_index].max_time_hit_target, |
| 494 rc_metrics[update_index].max_time_hit_target, | 488 rc_metrics[update_index].max_num_dropped_frames, |
| 495 rc_metrics[update_index].max_num_dropped_frames, | 489 rc_metrics[update_index].num_spatial_resizes, |
| 496 rc_metrics[update_index].num_spatial_resizes, | 490 rc_metrics[update_index].num_key_frames); |
| 497 rc_metrics[update_index].num_key_frames); | |
| 498 EXPECT_EQ(num_frames, frame_number); | 491 EXPECT_EQ(num_frames, frame_number); |
| 499 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); | 492 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); |
| 500 | 493 |
| 501 // Release encoder and decoder to make sure they have finished processing: | 494 // Release encoder and decoder to make sure they have finished processing: |
| 502 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); | 495 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
| 503 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); | 496 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
| 504 // Close the files before we start using them for SSIM/PSNR calculations. | 497 // Close the files before we start using them for SSIM/PSNR calculations. |
| 505 frame_reader_->Close(); | 498 frame_reader_->Close(); |
| 506 frame_writer_->Close(); | 499 frame_writer_->Close(); |
| 507 | 500 |
| 508 // TODO(marpan): should compute these quality metrics per SetRates update. | 501 // TODO(marpan): should compute these quality metrics per SetRates update. |
| 509 webrtc::test::QualityMetricsResult psnr_result, ssim_result; | 502 webrtc::test::QualityMetricsResult psnr_result, ssim_result; |
| 510 EXPECT_EQ(0, webrtc::test::I420MetricsFromFiles( | 503 EXPECT_EQ( |
| 511 config_.input_filename.c_str(), | 504 0, webrtc::test::I420MetricsFromFiles( |
| 512 config_.output_filename.c_str(), | 505 config_.input_filename.c_str(), config_.output_filename.c_str(), |
| 513 config_.codec_settings->width, | 506 config_.codec_settings->width, config_.codec_settings->height, |
| 514 config_.codec_settings->height, | 507 &psnr_result, &ssim_result)); |
| 515 &psnr_result, | |
| 516 &ssim_result)); | |
| 517 printf("PSNR avg: %f, min: %f SSIM avg: %f, min: %f\n", | 508 printf("PSNR avg: %f, min: %f SSIM avg: %f, min: %f\n", |
| 518 psnr_result.average, psnr_result.min, | 509 psnr_result.average, psnr_result.min, ssim_result.average, |
| 519 ssim_result.average, ssim_result.min); | 510 ssim_result.min); |
| 520 stats_.PrintSummary(); | 511 stats_.PrintSummary(); |
| 521 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); | 512 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); |
| 522 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); | 513 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); |
| 523 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); | 514 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); |
| 524 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); | 515 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); |
| 525 if (!remove(config_.output_filename.c_str())) { | 516 if (!remove(config_.output_filename.c_str())) { |
| 526 fprintf(stderr, "Failed to remove temporary file!"); | 517 fprintf(stderr, "Failed to remove temporary file!"); |
| 527 } | 518 } |
| 528 } | 519 } |
| 529 }; | 520 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 542 VideoCodecType codec_type, | 533 VideoCodecType codec_type, |
| 543 float packet_loss, | 534 float packet_loss, |
| 544 int key_frame_interval, | 535 int key_frame_interval, |
| 545 int num_temporal_layers, | 536 int num_temporal_layers, |
| 546 bool error_concealment_on, | 537 bool error_concealment_on, |
| 547 bool denoising_on, | 538 bool denoising_on, |
| 548 bool frame_dropper_on, | 539 bool frame_dropper_on, |
| 549 bool spatial_resize_on) { | 540 bool spatial_resize_on) { |
| 550 process_settings->codec_type = codec_type; | 541 process_settings->codec_type = codec_type; |
| 551 process_settings->packet_loss = packet_loss; | 542 process_settings->packet_loss = packet_loss; |
| 552 process_settings->key_frame_interval = key_frame_interval; | 543 process_settings->key_frame_interval = key_frame_interval; |
| 553 process_settings->num_temporal_layers = num_temporal_layers, | 544 process_settings->num_temporal_layers = num_temporal_layers, |
| 554 process_settings->error_concealment_on = error_concealment_on; | 545 process_settings->error_concealment_on = error_concealment_on; |
| 555 process_settings->denoising_on = denoising_on; | 546 process_settings->denoising_on = denoising_on; |
| 556 process_settings->frame_dropper_on = frame_dropper_on; | 547 process_settings->frame_dropper_on = frame_dropper_on; |
| 557 process_settings->spatial_resize_on = spatial_resize_on; | 548 process_settings->spatial_resize_on = spatial_resize_on; |
| 558 } | 549 } |
| 559 | 550 |
| 560 void SetQualityMetrics(QualityMetrics* quality_metrics, | 551 void SetQualityMetrics(QualityMetrics* quality_metrics, |
| 561 double minimum_avg_psnr, | 552 double minimum_avg_psnr, |
| 562 double minimum_min_psnr, | 553 double minimum_min_psnr, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 // Codec/network settings. | 592 // Codec/network settings. |
| 602 CodecConfigPars process_settings; | 593 CodecConfigPars process_settings; |
| 603 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, | 594 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, |
| 604 false, true, false); | 595 false, true, false); |
| 605 // Metrics for expected quality. | 596 // Metrics for expected quality. |
| 606 QualityMetrics quality_metrics; | 597 QualityMetrics quality_metrics; |
| 607 SetQualityMetrics(&quality_metrics, 37.0, 36.0, 0.93, 0.92); | 598 SetQualityMetrics(&quality_metrics, 37.0, 36.0, 0.93, 0.92); |
| 608 // Metrics for rate control. | 599 // Metrics for rate control. |
| 609 RateControlMetrics rc_metrics[1]; | 600 RateControlMetrics rc_metrics[1]; |
| 610 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); | 601 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); |
| 611 ProcessFramesAndVerify(quality_metrics, | 602 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 612 rate_profile, | |
| 613 process_settings, | |
| 614 rc_metrics); | 603 rc_metrics); |
| 615 } | 604 } |
| 616 | 605 |
| 617 // VP9: Run with 5% packet loss and fixed bitrate. Quality should be a bit | 606 // VP9: Run with 5% packet loss and fixed bitrate. Quality should be a bit |
| 618 // lower. One key frame (first frame only) in sequence. | 607 // lower. One key frame (first frame only) in sequence. |
| 619 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLossVP9) { | 608 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLossVP9) { |
| 620 // Bitrate and frame rate profile. | 609 // Bitrate and frame rate profile. |
| 621 RateProfile rate_profile; | 610 RateProfile rate_profile; |
| 622 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 611 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 623 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 612 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 624 rate_profile.num_frames = kNbrFramesShort; | 613 rate_profile.num_frames = kNbrFramesShort; |
| 625 // Codec/network settings. | 614 // Codec/network settings. |
| 626 CodecConfigPars process_settings; | 615 CodecConfigPars process_settings; |
| 627 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.05f, -1, 1, false, | 616 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.05f, -1, 1, false, |
| 628 false, true, false); | 617 false, true, false); |
| 629 // Metrics for expected quality. | 618 // Metrics for expected quality. |
| 630 QualityMetrics quality_metrics; | 619 QualityMetrics quality_metrics; |
| 631 SetQualityMetrics(&quality_metrics, 17.0, 14.0, 0.45, 0.36); | 620 SetQualityMetrics(&quality_metrics, 17.0, 14.0, 0.45, 0.36); |
| 632 // Metrics for rate control. | 621 // Metrics for rate control. |
| 633 RateControlMetrics rc_metrics[1]; | 622 RateControlMetrics rc_metrics[1]; |
| 634 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); | 623 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); |
| 635 ProcessFramesAndVerify(quality_metrics, | 624 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 636 rate_profile, | |
| 637 process_settings, | |
| 638 rc_metrics); | 625 rc_metrics); |
| 639 } | 626 } |
| 640 | 627 |
| 641 | |
| 642 // VP9: Run with no packet loss, with varying bitrate (3 rate updates): | 628 // VP9: Run with no packet loss, with varying bitrate (3 rate updates): |
| 643 // low to high to medium. Check that quality and encoder response to the new | 629 // low to high to medium. Check that quality and encoder response to the new |
| 644 // target rate/per-frame bandwidth (for each rate update) is within limits. | 630 // target rate/per-frame bandwidth (for each rate update) is within limits. |
| 645 // One key frame (first frame only) in sequence. | 631 // One key frame (first frame only) in sequence. |
| 646 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossChangeBitRateVP9) { | 632 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossChangeBitRateVP9) { |
| 647 // Bitrate and frame rate profile. | 633 // Bitrate and frame rate profile. |
| 648 RateProfile rate_profile; | 634 RateProfile rate_profile; |
| 649 SetRateProfilePars(&rate_profile, 0, 200, 30, 0); | 635 SetRateProfilePars(&rate_profile, 0, 200, 30, 0); |
| 650 SetRateProfilePars(&rate_profile, 1, 700, 30, 100); | 636 SetRateProfilePars(&rate_profile, 1, 700, 30, 100); |
| 651 SetRateProfilePars(&rate_profile, 2, 500, 30, 200); | 637 SetRateProfilePars(&rate_profile, 2, 500, 30, 200); |
| 652 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1; | 638 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1; |
| 653 rate_profile.num_frames = kNbrFramesLong; | 639 rate_profile.num_frames = kNbrFramesLong; |
| 654 // Codec/network settings. | 640 // Codec/network settings. |
| 655 CodecConfigPars process_settings; | 641 CodecConfigPars process_settings; |
| 656 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, | 642 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, |
| 657 false, true, false); | 643 false, true, false); |
| 658 // Metrics for expected quality. | 644 // Metrics for expected quality. |
| 659 QualityMetrics quality_metrics; | 645 QualityMetrics quality_metrics; |
| 660 SetQualityMetrics(&quality_metrics, 35.7, 30.0, 0.90, 0.85); | 646 SetQualityMetrics(&quality_metrics, 35.7, 30.0, 0.90, 0.85); |
| 661 // Metrics for rate control. | 647 // Metrics for rate control. |
| 662 RateControlMetrics rc_metrics[3]; | 648 RateControlMetrics rc_metrics[3]; |
| 663 SetRateControlMetrics(rc_metrics, 0, 0, 30, 20, 20, 30, 0, 1); | 649 SetRateControlMetrics(rc_metrics, 0, 0, 30, 20, 20, 30, 0, 1); |
| 664 SetRateControlMetrics(rc_metrics, 1, 2, 0, 20, 20, 60, 0, 0); | 650 SetRateControlMetrics(rc_metrics, 1, 2, 0, 20, 20, 60, 0, 0); |
| 665 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 20, 40, 0, 0); | 651 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 20, 40, 0, 0); |
| 666 ProcessFramesAndVerify(quality_metrics, | 652 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 667 rate_profile, | |
| 668 process_settings, | |
| 669 rc_metrics); | 653 rc_metrics); |
| 670 } | 654 } |
| 671 | 655 |
| 672 // VP9: Run with no packet loss, with an update (decrease) in frame rate. | 656 // VP9: Run with no packet loss, with an update (decrease) in frame rate. |
| 673 // Lower frame rate means higher per-frame-bandwidth, so easier to encode. | 657 // Lower frame rate means higher per-frame-bandwidth, so easier to encode. |
| 674 // At the low bitrate in this test, this means better rate control after the | 658 // At the low bitrate in this test, this means better rate control after the |
| 675 // update(s) to lower frame rate. So expect less frame drops, and max values | 659 // update(s) to lower frame rate. So expect less frame drops, and max values |
| 676 // for the rate control metrics can be lower. One key frame (first frame only). | 660 // for the rate control metrics can be lower. One key frame (first frame only). |
| 677 // Note: quality after update should be higher but we currently compute quality | 661 // Note: quality after update should be higher but we currently compute quality |
| 678 // metrics averaged over whole sequence run. | 662 // metrics averaged over whole sequence run. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 691 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, | 675 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, |
| 692 false, true, false); | 676 false, true, false); |
| 693 // Metrics for expected quality. | 677 // Metrics for expected quality. |
| 694 QualityMetrics quality_metrics; | 678 QualityMetrics quality_metrics; |
| 695 SetQualityMetrics(&quality_metrics, 31.5, 18.0, 0.80, 0.44); | 679 SetQualityMetrics(&quality_metrics, 31.5, 18.0, 0.80, 0.44); |
| 696 // Metrics for rate control. | 680 // Metrics for rate control. |
| 697 RateControlMetrics rc_metrics[3]; | 681 RateControlMetrics rc_metrics[3]; |
| 698 SetRateControlMetrics(rc_metrics, 0, 35, 50, 75, 15, 45, 0, 1); | 682 SetRateControlMetrics(rc_metrics, 0, 35, 50, 75, 15, 45, 0, 1); |
| 699 SetRateControlMetrics(rc_metrics, 1, 10, 0, 40, 10, 30, 0, 0); | 683 SetRateControlMetrics(rc_metrics, 1, 10, 0, 40, 10, 30, 0, 0); |
| 700 SetRateControlMetrics(rc_metrics, 2, 5, 0, 30, 5, 20, 0, 0); | 684 SetRateControlMetrics(rc_metrics, 2, 5, 0, 30, 5, 20, 0, 0); |
| 701 ProcessFramesAndVerify(quality_metrics, | 685 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 702 rate_profile, | |
| 703 process_settings, | |
| 704 rc_metrics); | 686 rc_metrics); |
| 705 } | 687 } |
| 706 | 688 |
| 707 // VP9: Run with no packet loss and denoiser on. One key frame (first frame). | 689 // VP9: Run with no packet loss and denoiser on. One key frame (first frame). |
| 708 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossDenoiserOnVP9) { | 690 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossDenoiserOnVP9) { |
| 709 // Bitrate and frame rate profile. | 691 // Bitrate and frame rate profile. |
| 710 RateProfile rate_profile; | 692 RateProfile rate_profile; |
| 711 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 693 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 712 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 694 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 713 rate_profile.num_frames = kNbrFramesShort; | 695 rate_profile.num_frames = kNbrFramesShort; |
| 714 // Codec/network settings. | 696 // Codec/network settings. |
| 715 CodecConfigPars process_settings; | 697 CodecConfigPars process_settings; |
| 716 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, | 698 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, |
| 717 true, true, false); | 699 true, true, false); |
| 718 // Metrics for expected quality. | 700 // Metrics for expected quality. |
| 719 QualityMetrics quality_metrics; | 701 QualityMetrics quality_metrics; |
| 720 SetQualityMetrics(&quality_metrics, 36.8, 35.8, 0.92, 0.91); | 702 SetQualityMetrics(&quality_metrics, 36.8, 35.8, 0.92, 0.91); |
| 721 // Metrics for rate control. | 703 // Metrics for rate control. |
| 722 RateControlMetrics rc_metrics[1]; | 704 RateControlMetrics rc_metrics[1]; |
| 723 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); | 705 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1); |
| 724 ProcessFramesAndVerify(quality_metrics, | 706 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 725 rate_profile, | |
| 726 process_settings, | |
| 727 rc_metrics); | 707 rc_metrics); |
| 728 } | 708 } |
| 729 | 709 |
| 730 // Run with no packet loss, at low bitrate. | 710 // Run with no packet loss, at low bitrate. |
| 731 // spatial_resize is on, for this low bitrate expect one resize in sequence. | 711 // spatial_resize is on, for this low bitrate expect one resize in sequence. |
| 732 // Resize happens on delta frame. Expect only one key frame (first frame). | 712 // Resize happens on delta frame. Expect only one key frame (first frame). |
| 733 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossSpatialResizeFrameDropVP9) { | 713 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossSpatialResizeFrameDropVP9) { |
| 734 config_.networking_config.packet_loss_probability = 0; | 714 config_.networking_config.packet_loss_probability = 0; |
| 735 // Bitrate and frame rate profile. | 715 // Bitrate and frame rate profile. |
| 736 RateProfile rate_profile; | 716 RateProfile rate_profile; |
| 737 SetRateProfilePars(&rate_profile, 0, 50, 30, 0); | 717 SetRateProfilePars(&rate_profile, 0, 50, 30, 0); |
| 738 rate_profile.frame_index_rate_update[1] = kNbrFramesLong + 1; | 718 rate_profile.frame_index_rate_update[1] = kNbrFramesLong + 1; |
| 739 rate_profile.num_frames = kNbrFramesLong; | 719 rate_profile.num_frames = kNbrFramesLong; |
| 740 // Codec/network settings. | 720 // Codec/network settings. |
| 741 CodecConfigPars process_settings; | 721 CodecConfigPars process_settings; |
| 742 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, | 722 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false, |
| 743 1, false, false, true, true); | 723 false, true, true); |
| 744 // Metrics for expected quality. | 724 // Metrics for expected quality. |
| 745 QualityMetrics quality_metrics; | 725 QualityMetrics quality_metrics; |
| 746 SetQualityMetrics(&quality_metrics, 25.0, 13.0, 0.70, 0.37); | 726 SetQualityMetrics(&quality_metrics, 25.0, 13.0, 0.70, 0.37); |
| 747 // Metrics for rate control. | 727 // Metrics for rate control. |
| 748 RateControlMetrics rc_metrics[1]; | 728 RateControlMetrics rc_metrics[1]; |
| 749 SetRateControlMetrics(rc_metrics, 0, 225, 70, 160, 15, 80, 1, 1); | 729 SetRateControlMetrics(rc_metrics, 0, 225, 70, 160, 15, 80, 1, 1); |
| 750 ProcessFramesAndVerify(quality_metrics, | 730 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 751 rate_profile, | |
| 752 process_settings, | |
| 753 rc_metrics); | 731 rc_metrics); |
| 754 } | 732 } |
| 755 | 733 |
| 756 // TODO(marpan): Add temporal layer test for VP9, once changes are in | 734 // TODO(marpan): Add temporal layer test for VP9, once changes are in |
| 757 // vp9 wrapper for this. | 735 // vp9 wrapper for this. |
| 758 | 736 |
| 759 // VP8: Run with no packet loss and fixed bitrate. Quality should be very high. | 737 // VP8: Run with no packet loss and fixed bitrate. Quality should be very high. |
| 760 // One key frame (first frame only) in sequence. Setting |key_frame_interval| | 738 // One key frame (first frame only) in sequence. Setting |key_frame_interval| |
| 761 // to -1 below means no periodic key frames in test. | 739 // to -1 below means no periodic key frames in test. |
| 762 TEST_F(VideoProcessorIntegrationTest, ProcessZeroPacketLoss) { | 740 TEST_F(VideoProcessorIntegrationTest, ProcessZeroPacketLoss) { |
| 763 // Bitrate and frame rate profile. | 741 // Bitrate and frame rate profile. |
| 764 RateProfile rate_profile; | 742 RateProfile rate_profile; |
| 765 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 743 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 766 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 744 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 767 rate_profile.num_frames = kNbrFramesShort; | 745 rate_profile.num_frames = kNbrFramesShort; |
| 768 // Codec/network settings. | 746 // Codec/network settings. |
| 769 CodecConfigPars process_settings; | 747 CodecConfigPars process_settings; |
| 770 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, | 748 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, |
| 771 true, true, false); | 749 true, true, false); |
| 772 // Metrics for expected quality. | 750 // Metrics for expected quality. |
| 773 QualityMetrics quality_metrics; | 751 QualityMetrics quality_metrics; |
| 774 SetQualityMetrics(&quality_metrics, 34.95, 33.0, 0.90, 0.89); | 752 SetQualityMetrics(&quality_metrics, 34.95, 33.0, 0.90, 0.89); |
| 775 // Metrics for rate control. | 753 // Metrics for rate control. |
| 776 RateControlMetrics rc_metrics[1]; | 754 RateControlMetrics rc_metrics[1]; |
| 777 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); | 755 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); |
| 778 ProcessFramesAndVerify(quality_metrics, | 756 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 779 rate_profile, | |
| 780 process_settings, | |
| 781 rc_metrics); | 757 rc_metrics); |
| 782 } | 758 } |
| 783 | 759 |
| 784 // VP8: Run with 5% packet loss and fixed bitrate. Quality should be a bit | 760 // VP8: Run with 5% packet loss and fixed bitrate. Quality should be a bit |
| 785 // lower. One key frame (first frame only) in sequence. | 761 // lower. One key frame (first frame only) in sequence. |
| 786 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLoss) { | 762 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLoss) { |
| 787 // Bitrate and frame rate profile. | 763 // Bitrate and frame rate profile. |
| 788 RateProfile rate_profile; | 764 RateProfile rate_profile; |
| 789 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 765 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 790 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 766 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 791 rate_profile.num_frames = kNbrFramesShort; | 767 rate_profile.num_frames = kNbrFramesShort; |
| 792 // Codec/network settings. | 768 // Codec/network settings. |
| 793 CodecConfigPars process_settings; | 769 CodecConfigPars process_settings; |
| 794 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.05f, -1, 1, false, | 770 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.05f, -1, 1, false, |
| 795 true, true, false); | 771 true, true, false); |
| 796 // Metrics for expected quality. | 772 // Metrics for expected quality. |
| 797 QualityMetrics quality_metrics; | 773 QualityMetrics quality_metrics; |
| 798 SetQualityMetrics(&quality_metrics, 20.0, 16.0, 0.60, 0.40); | 774 SetQualityMetrics(&quality_metrics, 20.0, 16.0, 0.60, 0.40); |
| 799 // Metrics for rate control. | 775 // Metrics for rate control. |
| 800 RateControlMetrics rc_metrics[1]; | 776 RateControlMetrics rc_metrics[1]; |
| 801 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); | 777 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); |
| 802 ProcessFramesAndVerify(quality_metrics, | 778 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 803 rate_profile, | |
| 804 process_settings, | |
| 805 rc_metrics); | 779 rc_metrics); |
| 806 } | 780 } |
| 807 | 781 |
| 808 // VP8: Run with 10% packet loss and fixed bitrate. Quality should be lower. | 782 // VP8: Run with 10% packet loss and fixed bitrate. Quality should be lower. |
| 809 // One key frame (first frame only) in sequence. | 783 // One key frame (first frame only) in sequence. |
| 810 TEST_F(VideoProcessorIntegrationTest, Process10PercentPacketLoss) { | 784 TEST_F(VideoProcessorIntegrationTest, Process10PercentPacketLoss) { |
| 811 // Bitrate and frame rate profile. | 785 // Bitrate and frame rate profile. |
| 812 RateProfile rate_profile; | 786 RateProfile rate_profile; |
| 813 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 787 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 814 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 788 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 815 rate_profile.num_frames = kNbrFramesShort; | 789 rate_profile.num_frames = kNbrFramesShort; |
| 816 // Codec/network settings. | 790 // Codec/network settings. |
| 817 CodecConfigPars process_settings; | 791 CodecConfigPars process_settings; |
| 818 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.1f, -1, 1, false, | 792 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.1f, -1, 1, false, |
| 819 true, true, false); | 793 true, true, false); |
| 820 // Metrics for expected quality. | 794 // Metrics for expected quality. |
| 821 QualityMetrics quality_metrics; | 795 QualityMetrics quality_metrics; |
| 822 SetQualityMetrics(&quality_metrics, 19.0, 16.0, 0.50, 0.35); | 796 SetQualityMetrics(&quality_metrics, 19.0, 16.0, 0.50, 0.35); |
| 823 // Metrics for rate control. | 797 // Metrics for rate control. |
| 824 RateControlMetrics rc_metrics[1]; | 798 RateControlMetrics rc_metrics[1]; |
| 825 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); | 799 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1); |
| 826 ProcessFramesAndVerify(quality_metrics, | 800 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 827 rate_profile, | |
| 828 process_settings, | |
| 829 rc_metrics); | 801 rc_metrics); |
| 830 } | 802 } |
| 831 | 803 |
| 832 // The tests below are currently disabled for Android. For ARM, the encoder | 804 // The tests below are currently disabled for Android. For ARM, the encoder |
| 833 // uses |cpu_speed| = 12, as opposed to default |cpu_speed| <= 6 for x86, | 805 // uses |cpu_speed| = 12, as opposed to default |cpu_speed| <= 6 for x86, |
| 834 // which leads to significantly different quality. The quality and rate control | 806 // which leads to significantly different quality. The quality and rate control |
| 835 // settings in the tests below are defined for encoder speed setting | 807 // settings in the tests below are defined for encoder speed setting |
| 836 // |cpu_speed| <= ~6. A number of settings would need to be significantly | 808 // |cpu_speed| <= ~6. A number of settings would need to be significantly |
| 837 // modified for the |cpu_speed| = 12 case. For now, keep the tests below | 809 // modified for the |cpu_speed| = 12 case. For now, keep the tests below |
| 838 // disabled on Android. Some quality parameter in the above test has been | 810 // disabled on Android. Some quality parameter in the above test has been |
| (...skipping 17 matching lines...) Expand all Loading... |
| 856 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, | 828 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, |
| 857 true, true, false); | 829 true, true, false); |
| 858 // Metrics for expected quality. | 830 // Metrics for expected quality. |
| 859 QualityMetrics quality_metrics; | 831 QualityMetrics quality_metrics; |
| 860 SetQualityMetrics(&quality_metrics, 34.0, 32.0, 0.85, 0.80); | 832 SetQualityMetrics(&quality_metrics, 34.0, 32.0, 0.85, 0.80); |
| 861 // Metrics for rate control. | 833 // Metrics for rate control. |
| 862 RateControlMetrics rc_metrics[3]; | 834 RateControlMetrics rc_metrics[3]; |
| 863 SetRateControlMetrics(rc_metrics, 0, 0, 45, 20, 10, 15, 0, 1); | 835 SetRateControlMetrics(rc_metrics, 0, 0, 45, 20, 10, 15, 0, 1); |
| 864 SetRateControlMetrics(rc_metrics, 1, 0, 0, 25, 20, 10, 0, 0); | 836 SetRateControlMetrics(rc_metrics, 1, 0, 0, 25, 20, 10, 0, 0); |
| 865 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 15, 10, 0, 0); | 837 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 15, 10, 0, 0); |
| 866 ProcessFramesAndVerify(quality_metrics, | 838 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 867 rate_profile, | |
| 868 process_settings, | |
| 869 rc_metrics); | 839 rc_metrics); |
| 870 } | 840 } |
| 871 | 841 |
| 872 // VP8: Run with no packet loss, with an update (decrease) in frame rate. | 842 // VP8: Run with no packet loss, with an update (decrease) in frame rate. |
| 873 // Lower frame rate means higher per-frame-bandwidth, so easier to encode. | 843 // Lower frame rate means higher per-frame-bandwidth, so easier to encode. |
| 874 // At the bitrate in this test, this means better rate control after the | 844 // At the bitrate in this test, this means better rate control after the |
| 875 // update(s) to lower frame rate. So expect less frame drops, and max values | 845 // update(s) to lower frame rate. So expect less frame drops, and max values |
| 876 // for the rate control metrics can be lower. One key frame (first frame only). | 846 // for the rate control metrics can be lower. One key frame (first frame only). |
| 877 // Note: quality after update should be higher but we currently compute quality | 847 // Note: quality after update should be higher but we currently compute quality |
| 878 // metrics averaged over whole sequence run. | 848 // metrics averaged over whole sequence run. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 891 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, | 861 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, |
| 892 true, true, false); | 862 true, true, false); |
| 893 // Metrics for expected quality. | 863 // Metrics for expected quality. |
| 894 QualityMetrics quality_metrics; | 864 QualityMetrics quality_metrics; |
| 895 SetQualityMetrics(&quality_metrics, 31.0, 22.0, 0.80, 0.65); | 865 SetQualityMetrics(&quality_metrics, 31.0, 22.0, 0.80, 0.65); |
| 896 // Metrics for rate control. | 866 // Metrics for rate control. |
| 897 RateControlMetrics rc_metrics[3]; | 867 RateControlMetrics rc_metrics[3]; |
| 898 SetRateControlMetrics(rc_metrics, 0, 40, 20, 75, 15, 60, 0, 1); | 868 SetRateControlMetrics(rc_metrics, 0, 40, 20, 75, 15, 60, 0, 1); |
| 899 SetRateControlMetrics(rc_metrics, 1, 10, 0, 25, 10, 35, 0, 0); | 869 SetRateControlMetrics(rc_metrics, 1, 10, 0, 25, 10, 35, 0, 0); |
| 900 SetRateControlMetrics(rc_metrics, 2, 0, 0, 20, 10, 15, 0, 0); | 870 SetRateControlMetrics(rc_metrics, 2, 0, 0, 20, 10, 15, 0, 0); |
| 901 ProcessFramesAndVerify(quality_metrics, | 871 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 902 rate_profile, | |
| 903 process_settings, | |
| 904 rc_metrics); | 872 rc_metrics); |
| 905 } | 873 } |
| 906 | 874 |
| 907 // Run with no packet loss, at low bitrate. During this time we should've | 875 // Run with no packet loss, at low bitrate. During this time we should've |
| 908 // resized once. Expect 2 key frames generated (first and one for resize). | 876 // resized once. Expect 2 key frames generated (first and one for resize). |
| 909 TEST_F(VideoProcessorIntegrationTest, | 877 TEST_F(VideoProcessorIntegrationTest, |
| 910 DISABLED_ON_ANDROID(ProcessNoLossSpatialResizeFrameDropVP8)) { | 878 DISABLED_ON_ANDROID(ProcessNoLossSpatialResizeFrameDropVP8)) { |
| 911 config_.networking_config.packet_loss_probability = 0; | 879 config_.networking_config.packet_loss_probability = 0; |
| 912 // Bitrate and frame rate profile. | 880 // Bitrate and frame rate profile. |
| 913 RateProfile rate_profile; | 881 RateProfile rate_profile; |
| 914 SetRateProfilePars(&rate_profile, 0, 50, 30, 0); | 882 SetRateProfilePars(&rate_profile, 0, 50, 30, 0); |
| 915 rate_profile.frame_index_rate_update[1] = kNbrFramesLong + 1; | 883 rate_profile.frame_index_rate_update[1] = kNbrFramesLong + 1; |
| 916 rate_profile.num_frames = kNbrFramesLong; | 884 rate_profile.num_frames = kNbrFramesLong; |
| 917 // Codec/network settings. | 885 // Codec/network settings. |
| 918 CodecConfigPars process_settings; | 886 CodecConfigPars process_settings; |
| 919 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, | 887 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false, |
| 920 1, false, true, true, true); | 888 true, true, true); |
| 921 // Metrics for expected quality. | 889 // Metrics for expected quality. |
| 922 QualityMetrics quality_metrics; | 890 QualityMetrics quality_metrics; |
| 923 SetQualityMetrics(&quality_metrics, 25.0, 15.0, 0.70, 0.40); | 891 SetQualityMetrics(&quality_metrics, 25.0, 15.0, 0.70, 0.40); |
| 924 // Metrics for rate control. | 892 // Metrics for rate control. |
| 925 RateControlMetrics rc_metrics[1]; | 893 RateControlMetrics rc_metrics[1]; |
| 926 SetRateControlMetrics(rc_metrics, 0, 160, 60, 120, 20, 70, 1, 2); | 894 SetRateControlMetrics(rc_metrics, 0, 160, 60, 120, 20, 70, 1, 2); |
| 927 ProcessFramesAndVerify(quality_metrics, | 895 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 928 rate_profile, | |
| 929 process_settings, | |
| 930 rc_metrics); | 896 rc_metrics); |
| 931 } | 897 } |
| 932 | 898 |
| 933 // VP8: Run with no packet loss, with 3 temporal layers, with a rate update in | 899 // VP8: Run with no packet loss, with 3 temporal layers, with a rate update in |
| 934 // the middle of the sequence. The max values for the frame size mismatch and | 900 // the middle of the sequence. The max values for the frame size mismatch and |
| 935 // encoding rate mismatch are applied to each layer. | 901 // encoding rate mismatch are applied to each layer. |
| 936 // No dropped frames in this test, and internal spatial resizer is off. | 902 // No dropped frames in this test, and internal spatial resizer is off. |
| 937 // One key frame (first frame only) in sequence, so no spatial resizing. | 903 // One key frame (first frame only) in sequence, so no spatial resizing. |
| 938 TEST_F(VideoProcessorIntegrationTest, | 904 TEST_F(VideoProcessorIntegrationTest, |
| 939 DISABLED_ON_ANDROID(ProcessNoLossTemporalLayersVP8)) { | 905 DISABLED_ON_ANDROID(ProcessNoLossTemporalLayersVP8)) { |
| 940 config_.networking_config.packet_loss_probability = 0; | 906 config_.networking_config.packet_loss_probability = 0; |
| 941 // Bitrate and frame rate profile. | 907 // Bitrate and frame rate profile. |
| 942 RateProfile rate_profile; | 908 RateProfile rate_profile; |
| 943 SetRateProfilePars(&rate_profile, 0, 200, 30, 0); | 909 SetRateProfilePars(&rate_profile, 0, 200, 30, 0); |
| 944 SetRateProfilePars(&rate_profile, 1, 400, 30, 150); | 910 SetRateProfilePars(&rate_profile, 1, 400, 30, 150); |
| 945 rate_profile.frame_index_rate_update[2] = kNbrFramesLong + 1; | 911 rate_profile.frame_index_rate_update[2] = kNbrFramesLong + 1; |
| 946 rate_profile.num_frames = kNbrFramesLong; | 912 rate_profile.num_frames = kNbrFramesLong; |
| 947 // Codec/network settings. | 913 // Codec/network settings. |
| 948 CodecConfigPars process_settings; | 914 CodecConfigPars process_settings; |
| 949 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 3, false, | 915 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 3, false, |
| 950 true, true, false); | 916 true, true, false); |
| 951 // Metrics for expected quality. | 917 // Metrics for expected quality. |
| 952 QualityMetrics quality_metrics; | 918 QualityMetrics quality_metrics; |
| 953 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80); | 919 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80); |
| 954 // Metrics for rate control. | 920 // Metrics for rate control. |
| 955 RateControlMetrics rc_metrics[2]; | 921 RateControlMetrics rc_metrics[2]; |
| 956 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); | 922 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); |
| 957 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); | 923 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); |
| 958 ProcessFramesAndVerify(quality_metrics, | 924 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 959 rate_profile, | |
| 960 process_settings, | |
| 961 rc_metrics); | 925 rc_metrics); |
| 962 } | 926 } |
| 963 } // namespace webrtc | 927 } // namespace webrtc |
| OLD | NEW |