| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Maximum number of rate updates (i.e., calls to encoder to change bitrate | 54 // Maximum number of rate updates (i.e., calls to encoder to change bitrate |
| 55 // and/or frame rate) for the current tests. | 55 // and/or frame rate) for the current tests. |
| 56 const int kMaxNumRateUpdates = 3; | 56 const int kMaxNumRateUpdates = 3; |
| 57 | 57 |
| 58 // Maximum number of temporal layers to use in tests. | 58 // Maximum number of temporal layers to use in tests. |
| 59 const int kMaxNumTemporalLayers = 3; | 59 const int kMaxNumTemporalLayers = 3; |
| 60 | 60 |
| 61 const int kPercTargetvsActualMismatch = 20; | 61 const int kPercTargetvsActualMismatch = 20; |
| 62 const int kBaseKeyFrameInterval = 3000; | 62 const int kBaseKeyFrameInterval = 3000; |
| 63 | 63 |
| 64 // Default sequence is foreman (CIF): may be better to use VGA for resize test. | 64 // Process and network settings. |
| 65 const int kCifWidth = 352; | 65 struct ProcessParams { |
| 66 const int kCifHeight = 288; | 66 ProcessParams(bool hw_codec, |
| 67 const char kFilenameForemanCif[] = "foreman_cif"; | 67 bool use_single_core, |
| 68 float packet_loss_probability, |
| 69 int key_frame_interval, |
| 70 std::string filename, |
| 71 bool verbose_logging, |
| 72 bool batch_mode) |
| 73 : hw_codec(hw_codec), |
| 74 use_single_core(use_single_core), |
| 75 key_frame_interval(key_frame_interval), |
| 76 packet_loss_probability(packet_loss_probability), |
| 77 filename(filename), |
| 78 verbose_logging(verbose_logging), |
| 79 batch_mode(batch_mode) {} |
| 68 | 80 |
| 69 // Codec and network settings. | |
| 70 struct CodecParams { | |
| 71 VideoCodecType codec_type; | |
| 72 bool hw_codec; | 81 bool hw_codec; |
| 73 bool use_single_core; | 82 bool use_single_core; |
| 74 | |
| 75 int width; | |
| 76 int height; | |
| 77 | |
| 78 int num_temporal_layers; | |
| 79 int key_frame_interval; | 83 int key_frame_interval; |
| 80 bool error_concealment_on; | |
| 81 bool denoising_on; | |
| 82 bool frame_dropper_on; | |
| 83 bool spatial_resize_on; | |
| 84 bool resilience_on; | |
| 85 | |
| 86 float packet_loss_probability; // [0.0, 1.0]. | 84 float packet_loss_probability; // [0.0, 1.0]. |
| 87 | |
| 88 std::string filename; | 85 std::string filename; |
| 89 bool verbose_logging; | 86 bool verbose_logging; |
| 90 | 87 |
| 91 // In batch mode, the VideoProcessor is fed all the frames for processing | 88 // In batch mode, the VideoProcessor is fed all the frames for processing |
| 92 // before any metrics are calculated. This is useful for pipelining HW codecs, | 89 // before any metrics are calculated. This is useful for pipelining HW codecs, |
| 93 // for which some calculated metrics otherwise would be incorrect. The | 90 // for which some calculated metrics otherwise would be incorrect. The |
| 94 // downside with batch mode is that mid-test rate allocation is not supported. | 91 // downside with batch mode is that mid-test rate allocation is not supported. |
| 95 bool batch_mode; | 92 bool batch_mode; |
| 96 }; | 93 }; |
| 97 | 94 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 InitializeAndroidObjects(); | 159 InitializeAndroidObjects(); |
| 163 | 160 |
| 164 external_encoder_factory_.reset( | 161 external_encoder_factory_.reset( |
| 165 new webrtc_jni::MediaCodecVideoEncoderFactory()); | 162 new webrtc_jni::MediaCodecVideoEncoderFactory()); |
| 166 external_decoder_factory_.reset( | 163 external_decoder_factory_.reset( |
| 167 new webrtc_jni::MediaCodecVideoDecoderFactory()); | 164 new webrtc_jni::MediaCodecVideoDecoderFactory()); |
| 168 #endif | 165 #endif |
| 169 } | 166 } |
| 170 virtual ~VideoProcessorIntegrationTest() = default; | 167 virtual ~VideoProcessorIntegrationTest() = default; |
| 171 | 168 |
| 172 void CreateEncoderAndDecoder(bool hw_codec, VideoCodecType codec_type) { | 169 void CreateEncoderAndDecoder(bool hw_codec) { |
| 173 if (hw_codec) { | 170 if (hw_codec) { |
| 174 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) | 171 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
| 175 #if defined(WEBRTC_ANDROID) | 172 #if defined(WEBRTC_ANDROID) |
| 176 // In general, external codecs should be destroyed by the factories that | 173 // In general, external codecs should be destroyed by the factories that |
| 177 // allocated them. For the particular case of the Android | 174 // allocated them. For the particular case of the Android |
| 178 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is | 175 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is |
| 179 // fine for the std::unique_ptr to destroy the owned codec directly. | 176 // fine for the std::unique_ptr to destroy the owned codec directly. |
| 180 switch (codec_type) { | 177 switch (config_.codec_settings->codecType) { |
| 181 case kVideoCodecH264: | 178 case kVideoCodecH264: |
| 182 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 179 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| 183 cricket::VideoCodec(cricket::kH264CodecName))); | 180 cricket::VideoCodec(cricket::kH264CodecName))); |
| 184 decoder_.reset( | 181 decoder_.reset( |
| 185 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264)); | 182 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264)); |
| 186 break; | 183 break; |
| 187 case kVideoCodecVP8: | 184 case kVideoCodecVP8: |
| 188 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 185 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| 189 cricket::VideoCodec(cricket::kVp8CodecName))); | 186 cricket::VideoCodec(cricket::kVp8CodecName))); |
| 190 decoder_.reset( | 187 decoder_.reset( |
| 191 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8)); | 188 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8)); |
| 192 break; | 189 break; |
| 193 case kVideoCodecVP9: | 190 case kVideoCodecVP9: |
| 194 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 191 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| 195 cricket::VideoCodec(cricket::kVp9CodecName))); | 192 cricket::VideoCodec(cricket::kVp9CodecName))); |
| 196 decoder_.reset( | 193 decoder_.reset( |
| 197 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); | 194 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); |
| 198 break; | 195 break; |
| 199 default: | 196 default: |
| 200 RTC_NOTREACHED(); | 197 RTC_NOTREACHED(); |
| 201 break; | 198 break; |
| 202 } | 199 } |
| 203 #elif defined(WEBRTC_IOS) | 200 #elif defined(WEBRTC_IOS) |
| 204 ASSERT_EQ(kVideoCodecH264, codec_type) | 201 ASSERT_EQ(kVideoCodecH264, config_.codec_settings->codecType) |
| 205 << "iOS HW codecs only support H264."; | 202 << "iOS HW codecs only support H264."; |
| 206 encoder_.reset(new H264VideoToolboxEncoder( | 203 encoder_.reset(new H264VideoToolboxEncoder( |
| 207 cricket::VideoCodec(cricket::kH264CodecName))); | 204 cricket::VideoCodec(cricket::kH264CodecName))); |
| 208 decoder_.reset(new H264VideoToolboxDecoder()); | 205 decoder_.reset(new H264VideoToolboxDecoder()); |
| 209 #else | 206 #else |
| 210 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; | 207 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; |
| 211 #endif | 208 #endif |
| 212 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED | 209 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED |
| 213 RTC_CHECK(encoder_) << "HW encoder not successfully created."; | 210 RTC_CHECK(encoder_) << "HW encoder not successfully created."; |
| 214 RTC_CHECK(decoder_) << "HW decoder not successfully created."; | 211 RTC_CHECK(decoder_) << "HW decoder not successfully created."; |
| 215 return; | 212 return; |
| 216 } | 213 } |
| 217 | 214 |
| 218 // SW codecs. | 215 // SW codecs. |
| 219 switch (codec_type) { | 216 switch (config_.codec_settings->codecType) { |
| 220 case kVideoCodecH264: | 217 case kVideoCodecH264: |
| 221 encoder_.reset( | 218 encoder_.reset( |
| 222 H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName))); | 219 H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName))); |
| 223 decoder_.reset(H264Decoder::Create()); | 220 decoder_.reset(H264Decoder::Create()); |
| 224 break; | 221 break; |
| 225 case kVideoCodecVP8: | 222 case kVideoCodecVP8: |
| 226 encoder_.reset(VP8Encoder::Create()); | 223 encoder_.reset(VP8Encoder::Create()); |
| 227 decoder_.reset(VP8Decoder::Create()); | 224 decoder_.reset(VP8Decoder::Create()); |
| 228 break; | 225 break; |
| 229 case kVideoCodecVP9: | 226 case kVideoCodecVP9: |
| 230 encoder_.reset(VP9Encoder::Create()); | 227 encoder_.reset(VP9Encoder::Create()); |
| 231 decoder_.reset(VP9Decoder::Create()); | 228 decoder_.reset(VP9Decoder::Create()); |
| 232 break; | 229 break; |
| 233 default: | 230 default: |
| 234 RTC_NOTREACHED(); | 231 RTC_NOTREACHED(); |
| 235 break; | 232 break; |
| 236 } | 233 } |
| 237 } | 234 } |
| 238 | 235 |
| 239 void SetUpCodecConfig(const CodecParams& process, | 236 void SetUpCodecConfig(const ProcessParams& process, |
| 240 const VisualizationParams* visualization_params) { | 237 const VisualizationParams* visualization_params) { |
| 241 CreateEncoderAndDecoder(process.hw_codec, process.codec_type); | 238 CreateEncoderAndDecoder(process.hw_codec); |
| 242 | 239 |
| 243 // Configure input filename. | 240 // Configure input filename. |
| 244 config_.input_filename = test::ResourcePath(process.filename, "yuv"); | 241 config_.input_filename = test::ResourcePath(process.filename, "yuv"); |
| 245 if (process.verbose_logging) | 242 if (process.verbose_logging) |
| 246 printf("Filename: %s\n", process.filename.c_str()); | 243 printf("Filename: %s\n", process.filename.c_str()); |
| 247 // Generate an output filename in a safe way. | 244 // Generate an output filename in a safe way. |
| 248 config_.output_filename = test::TempFilename( | 245 config_.output_filename = test::TempFilename( |
| 249 test::OutputPath(), "videoprocessor_integrationtest"); | 246 test::OutputPath(), "videoprocessor_integrationtest"); |
| 250 | 247 |
| 251 config_.frame_length_in_bytes = | 248 config_.frame_length_in_bytes = |
| 252 CalcBufferSize(VideoType::kI420, process.width, process.height); | 249 CalcBufferSize(VideoType::kI420, config_.codec_settings->width, |
| 250 config_.codec_settings->height); |
| 253 config_.verbose = process.verbose_logging; | 251 config_.verbose = process.verbose_logging; |
| 254 config_.use_single_core = process.use_single_core; | 252 config_.use_single_core = process.use_single_core; |
| 253 |
| 255 // Key frame interval and packet loss are set for each test. | 254 // Key frame interval and packet loss are set for each test. |
| 256 config_.keyframe_interval = process.key_frame_interval; | 255 config_.keyframe_interval = process.key_frame_interval; |
| 257 config_.networking_config.packet_loss_probability = | 256 config_.networking_config.packet_loss_probability = |
| 258 packet_loss_probability_; | 257 process.packet_loss_probability; |
| 259 | |
| 260 // Configure codec settings. | |
| 261 VideoCodingModule::Codec(process.codec_type, &codec_settings_); | |
| 262 config_.codec_settings = &codec_settings_; | |
| 263 config_.codec_settings->startBitrate = start_bitrate_; | |
| 264 config_.codec_settings->width = process.width; | |
| 265 config_.codec_settings->height = process.height; | |
| 266 | |
| 267 // These features may be set depending on the test. | |
| 268 switch (config_.codec_settings->codecType) { | |
| 269 case kVideoCodecH264: | |
| 270 config_.codec_settings->H264()->frameDroppingOn = | |
| 271 process.frame_dropper_on; | |
| 272 config_.codec_settings->H264()->keyFrameInterval = | |
| 273 kBaseKeyFrameInterval; | |
| 274 break; | |
| 275 case kVideoCodecVP8: | |
| 276 config_.codec_settings->VP8()->errorConcealmentOn = | |
| 277 process.error_concealment_on; | |
| 278 config_.codec_settings->VP8()->denoisingOn = process.denoising_on; | |
| 279 config_.codec_settings->VP8()->numberOfTemporalLayers = | |
| 280 num_temporal_layers_; | |
| 281 config_.codec_settings->VP8()->frameDroppingOn = | |
| 282 process.frame_dropper_on; | |
| 283 config_.codec_settings->VP8()->automaticResizeOn = | |
| 284 process.spatial_resize_on; | |
| 285 config_.codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval; | |
| 286 config_.codec_settings->VP8()->resilience = | |
| 287 process.resilience_on ? kResilientStream : kResilienceOff; | |
| 288 break; | |
| 289 case kVideoCodecVP9: | |
| 290 config_.codec_settings->VP9()->denoisingOn = process.denoising_on; | |
| 291 config_.codec_settings->VP9()->numberOfTemporalLayers = | |
| 292 num_temporal_layers_; | |
| 293 config_.codec_settings->VP9()->frameDroppingOn = | |
| 294 process.frame_dropper_on; | |
| 295 config_.codec_settings->VP9()->automaticResizeOn = | |
| 296 process.spatial_resize_on; | |
| 297 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; | |
| 298 config_.codec_settings->VP9()->resilienceOn = process.resilience_on; | |
| 299 break; | |
| 300 default: | |
| 301 RTC_NOTREACHED(); | |
| 302 break; | |
| 303 } | |
| 304 | 258 |
| 305 // Create file objects for quality analysis. | 259 // Create file objects for quality analysis. |
| 306 analysis_frame_reader_.reset(new test::YuvFrameReaderImpl( | 260 analysis_frame_reader_.reset(new test::YuvFrameReaderImpl( |
| 307 config_.input_filename, config_.codec_settings->width, | 261 config_.input_filename, config_.codec_settings->width, |
| 308 config_.codec_settings->height)); | 262 config_.codec_settings->height)); |
| 309 analysis_frame_writer_.reset(new test::YuvFrameWriterImpl( | 263 analysis_frame_writer_.reset(new test::YuvFrameWriterImpl( |
| 310 config_.output_filename, config_.codec_settings->width, | 264 config_.output_filename, config_.codec_settings->width, |
| 311 config_.codec_settings->height)); | 265 config_.codec_settings->height)); |
| 312 RTC_CHECK(analysis_frame_reader_->Init()); | 266 RTC_CHECK(analysis_frame_reader_->Init()); |
| 313 RTC_CHECK(analysis_frame_writer_->Init()); | 267 RTC_CHECK(analysis_frame_writer_->Init()); |
| 314 | 268 |
| 315 if (visualization_params) { | 269 if (visualization_params) { |
| 316 // clang-format off | 270 // clang-format off |
| 317 const std::string output_filename_base = | 271 const std::string output_filename_base = |
| 318 test::OutputPath() + process.filename + | 272 test::OutputPath() + process.filename + |
| 319 "_cd-" + CodecTypeToPayloadName(process.codec_type).value_or("") + | 273 "_cd-" + CodecTypeToPayloadName( |
| 274 config_.codec_settings->codecType).value_or("") + |
| 320 "_hw-" + std::to_string(process.hw_codec) + | 275 "_hw-" + std::to_string(process.hw_codec) + |
| 321 "_fr-" + std::to_string(start_frame_rate_) + | 276 "_fr-" + std::to_string(start_frame_rate_) + |
| 322 "_br-" + std::to_string(static_cast<int>(start_bitrate_)); | 277 "_br-" + std::to_string( |
| 278 static_cast<int>(config_.codec_settings->startBitrate)); |
| 323 // clang-format on | 279 // clang-format on |
| 324 if (visualization_params->save_source_y4m) { | 280 if (visualization_params->save_source_y4m) { |
| 325 source_frame_writer_.reset(new test::Y4mFrameWriterImpl( | 281 source_frame_writer_.reset(new test::Y4mFrameWriterImpl( |
| 326 output_filename_base + "_source.y4m", config_.codec_settings->width, | 282 output_filename_base + "_source.y4m", config_.codec_settings->width, |
| 327 config_.codec_settings->height, start_frame_rate_)); | 283 config_.codec_settings->height, start_frame_rate_)); |
| 328 RTC_CHECK(source_frame_writer_->Init()); | 284 RTC_CHECK(source_frame_writer_->Init()); |
| 329 } | 285 } |
| 330 if (visualization_params->save_encoded_ivf) { | 286 if (visualization_params->save_encoded_ivf) { |
| 331 rtc::File post_encode_file = | 287 rtc::File post_encode_file = |
| 332 rtc::File::Create(output_filename_base + "_encoded.ivf"); | 288 rtc::File::Create(output_filename_base + "_encoded.ivf"); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 447 |
| 492 void VerifyQuality(const test::QualityMetricsResult& psnr_result, | 448 void VerifyQuality(const test::QualityMetricsResult& psnr_result, |
| 493 const test::QualityMetricsResult& ssim_result, | 449 const test::QualityMetricsResult& ssim_result, |
| 494 const QualityThresholds& quality_thresholds) { | 450 const QualityThresholds& quality_thresholds) { |
| 495 EXPECT_GT(psnr_result.average, quality_thresholds.min_avg_psnr); | 451 EXPECT_GT(psnr_result.average, quality_thresholds.min_avg_psnr); |
| 496 EXPECT_GT(psnr_result.min, quality_thresholds.min_min_psnr); | 452 EXPECT_GT(psnr_result.min, quality_thresholds.min_min_psnr); |
| 497 EXPECT_GT(ssim_result.average, quality_thresholds.min_avg_ssim); | 453 EXPECT_GT(ssim_result.average, quality_thresholds.min_avg_ssim); |
| 498 EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim); | 454 EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim); |
| 499 } | 455 } |
| 500 | 456 |
| 501 void VerifyQpParser(const CodecParams& process, int frame_number) { | 457 void VerifyQpParser(const ProcessParams& process, int frame_number) { |
| 502 if (!process.hw_codec && (process.codec_type == kVideoCodecVP8 || | 458 if (!process.hw_codec && |
| 503 process.codec_type == kVideoCodecVP9)) { | 459 (config_.codec_settings->codecType == kVideoCodecVP8 || |
| 460 config_.codec_settings->codecType == kVideoCodecVP9)) { |
| 504 EXPECT_EQ(processor_->GetQpFromEncoder(frame_number), | 461 EXPECT_EQ(processor_->GetQpFromEncoder(frame_number), |
| 505 processor_->GetQpFromBitstream(frame_number)); | 462 processor_->GetQpFromBitstream(frame_number)); |
| 506 } | 463 } |
| 507 } | 464 } |
| 508 | 465 |
| 466 int NumberOfTemporalLayers(const VideoCodec* codec_settings) { |
| 467 if (codec_settings->codecType == kVideoCodecVP8) { |
| 468 return codec_settings->VP8().numberOfTemporalLayers; |
| 469 } else if (codec_settings->codecType == kVideoCodecVP9) { |
| 470 return codec_settings->VP9().numberOfTemporalLayers; |
| 471 } else { |
| 472 return 1; |
| 473 } |
| 474 } |
| 475 |
| 509 // Temporal layer index corresponding to frame number, for up to 3 layers. | 476 // Temporal layer index corresponding to frame number, for up to 3 layers. |
| 510 int TemporalLayerIndexForFrame(int frame_number) { | 477 int TemporalLayerIndexForFrame(int frame_number) { |
| 511 int tl_idx = -1; | 478 int tl_idx = -1; |
| 512 switch (num_temporal_layers_) { | 479 switch (num_temporal_layers_) { |
| 513 case 1: | 480 case 1: |
| 514 tl_idx = 0; | 481 tl_idx = 0; |
| 515 break; | 482 break; |
| 516 case 2: | 483 case 2: |
| 517 // temporal layer 0: 0 2 4 ... | 484 // temporal layer 0: 0 2 4 ... |
| 518 // temporal layer 1: 1 3 | 485 // temporal layer 1: 1 3 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 526 } |
| 560 } | 527 } |
| 561 | 528 |
| 562 // Processes all frames in the clip and verifies the result. | 529 // Processes all frames in the clip and verifies the result. |
| 563 // TODO(brandtr): Change the second last argument to be a | 530 // TODO(brandtr): Change the second last argument to be a |
| 564 // const std::vector<RateControlThresholds>&, so we can ensure that the user | 531 // const std::vector<RateControlThresholds>&, so we can ensure that the user |
| 565 // does not expect us to do mid-clip rate updates when we are not able to, | 532 // does not expect us to do mid-clip rate updates when we are not able to, |
| 566 // e.g., when we are operating in batch mode. | 533 // e.g., when we are operating in batch mode. |
| 567 void ProcessFramesAndVerify(QualityThresholds quality_thresholds, | 534 void ProcessFramesAndVerify(QualityThresholds quality_thresholds, |
| 568 RateProfile rate_profile, | 535 RateProfile rate_profile, |
| 569 CodecParams process, | 536 ProcessParams process, |
| 570 RateControlThresholds* rc_thresholds, | 537 RateControlThresholds* rc_thresholds, |
| 571 const VisualizationParams* visualization_params) { | 538 const VisualizationParams* visualization_params) { |
| 572 // Codec/config settings. | 539 // Codec/config settings. |
| 573 start_bitrate_ = rate_profile.target_bit_rate[0]; | 540 RTC_CHECK(config_.codec_settings); |
| 541 num_temporal_layers_ = NumberOfTemporalLayers(config_.codec_settings); |
| 542 config_.codec_settings->startBitrate = rate_profile.target_bit_rate[0]; |
| 574 start_frame_rate_ = rate_profile.input_frame_rate[0]; | 543 start_frame_rate_ = rate_profile.input_frame_rate[0]; |
| 575 packet_loss_probability_ = process.packet_loss_probability; | |
| 576 num_temporal_layers_ = process.num_temporal_layers; | |
| 577 SetUpCodecConfig(process, visualization_params); | 544 SetUpCodecConfig(process, visualization_params); |
| 578 // Update the temporal layers and the codec with the initial rates. | 545 // Update the temporal layers and the codec with the initial rates. |
| 579 bit_rate_ = rate_profile.target_bit_rate[0]; | 546 bit_rate_ = rate_profile.target_bit_rate[0]; |
| 580 frame_rate_ = rate_profile.input_frame_rate[0]; | 547 frame_rate_ = rate_profile.input_frame_rate[0]; |
| 581 SetTemporalLayerRates(); | 548 SetTemporalLayerRates(); |
| 582 // Set the initial target size for key frame. | 549 // Set the initial target size for key frame. |
| 583 target_size_key_frame_initial_ = | 550 target_size_key_frame_initial_ = |
| 584 0.5 * kInitialBufferSize * bit_rate_layer_[0]; | 551 0.5 * kInitialBufferSize * bit_rate_layer_[0]; |
| 585 processor_->SetRates(bit_rate_, frame_rate_); | 552 processor_->SetRates(bit_rate_, frame_rate_); |
| 586 | 553 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 ssim_result.min); | 649 ssim_result.min); |
| 683 VerifyQuality(psnr_result, ssim_result, quality_thresholds); | 650 VerifyQuality(psnr_result, ssim_result, quality_thresholds); |
| 684 stats_.PrintSummary(); | 651 stats_.PrintSummary(); |
| 685 | 652 |
| 686 // Remove analysis file. | 653 // Remove analysis file. |
| 687 if (remove(config_.output_filename.c_str()) < 0) { | 654 if (remove(config_.output_filename.c_str()) < 0) { |
| 688 fprintf(stderr, "Failed to remove temporary file!\n"); | 655 fprintf(stderr, "Failed to remove temporary file!\n"); |
| 689 } | 656 } |
| 690 } | 657 } |
| 691 | 658 |
| 692 static void SetCodecParams(CodecParams* process_settings, | 659 static void SetCodecSettings(test::TestConfig* config, |
| 693 VideoCodecType codec_type, | 660 VideoCodec* codec_settings, |
| 694 bool hw_codec, | 661 VideoCodecType codec_type, |
| 695 bool use_single_core, | 662 int num_temporal_layers, |
| 696 float packet_loss_probability, | 663 bool error_concealment_on, |
| 697 int key_frame_interval, | 664 bool denoising_on, |
| 698 int num_temporal_layers, | 665 bool frame_dropper_on, |
| 699 bool error_concealment_on, | 666 bool spatial_resize_on, |
| 700 bool denoising_on, | 667 bool resilience_on, |
| 701 bool frame_dropper_on, | 668 int width, |
| 702 bool spatial_resize_on, | 669 int height) { |
| 703 bool resilience_on, | 670 VideoCodingModule::Codec(codec_type, codec_settings); |
| 704 int width, | 671 config->codec_settings = codec_settings; |
| 705 int height, | 672 config->codec_settings->width = width; |
| 706 const std::string& filename, | 673 config->codec_settings->height = height; |
| 707 bool verbose_logging, | 674 switch (config->codec_settings->codecType) { |
| 708 bool batch_mode) { | 675 case kVideoCodecH264: |
| 709 process_settings->codec_type = codec_type; | 676 config->codec_settings->H264()->frameDroppingOn = frame_dropper_on; |
| 710 process_settings->hw_codec = hw_codec; | 677 config->codec_settings->H264()->keyFrameInterval = |
| 711 process_settings->use_single_core = use_single_core; | 678 kBaseKeyFrameInterval; |
| 712 process_settings->packet_loss_probability = packet_loss_probability; | 679 break; |
| 713 process_settings->key_frame_interval = key_frame_interval; | 680 case kVideoCodecVP8: |
| 714 process_settings->num_temporal_layers = num_temporal_layers, | 681 config->codec_settings->VP8()->errorConcealmentOn = |
| 715 process_settings->error_concealment_on = error_concealment_on; | 682 error_concealment_on; |
| 716 process_settings->denoising_on = denoising_on; | 683 config->codec_settings->VP8()->denoisingOn = denoising_on; |
| 717 process_settings->frame_dropper_on = frame_dropper_on; | 684 config->codec_settings->VP8()->numberOfTemporalLayers = |
| 718 process_settings->spatial_resize_on = spatial_resize_on; | 685 num_temporal_layers; |
| 719 process_settings->resilience_on = resilience_on; | 686 config->codec_settings->VP8()->frameDroppingOn = frame_dropper_on; |
| 720 process_settings->width = width; | 687 config->codec_settings->VP8()->automaticResizeOn = spatial_resize_on; |
| 721 process_settings->height = height; | 688 config->codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval; |
| 722 process_settings->filename = filename; | 689 config->codec_settings->VP8()->resilience = |
| 723 process_settings->verbose_logging = verbose_logging; | 690 resilience_on ? kResilientStream : kResilienceOff; |
| 724 process_settings->batch_mode = batch_mode; | 691 break; |
| 725 } | 692 case kVideoCodecVP9: |
| 726 | 693 config->codec_settings->VP9()->denoisingOn = denoising_on; |
| 727 static void SetCodecParams(CodecParams* process_settings, | 694 config->codec_settings->VP9()->numberOfTemporalLayers = |
| 728 VideoCodecType codec_type, | 695 num_temporal_layers; |
| 729 bool hw_codec, | 696 config->codec_settings->VP9()->frameDroppingOn = frame_dropper_on; |
| 730 bool use_single_core, | 697 config->codec_settings->VP9()->automaticResizeOn = spatial_resize_on; |
| 731 float packet_loss_probability, | 698 config->codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; |
| 732 int key_frame_interval, | 699 config->codec_settings->VP9()->resilienceOn = resilience_on; |
| 733 int num_temporal_layers, | 700 break; |
| 734 bool error_concealment_on, | 701 default: |
| 735 bool denoising_on, | 702 RTC_NOTREACHED(); |
| 736 bool frame_dropper_on, | 703 break; |
| 737 bool spatial_resize_on, | 704 } |
| 738 bool resilience_on) { | |
| 739 SetCodecParams(process_settings, codec_type, hw_codec, use_single_core, | |
| 740 packet_loss_probability, key_frame_interval, | |
| 741 num_temporal_layers, error_concealment_on, denoising_on, | |
| 742 frame_dropper_on, spatial_resize_on, resilience_on, | |
| 743 kCifWidth, kCifHeight, kFilenameForemanCif, | |
| 744 false /* verbose_logging */, false /* batch_mode */); | |
| 745 } | 705 } |
| 746 | 706 |
| 747 static void SetQualityThresholds(QualityThresholds* quality_thresholds, | 707 static void SetQualityThresholds(QualityThresholds* quality_thresholds, |
| 748 double min_avg_psnr, | 708 double min_avg_psnr, |
| 749 double min_min_psnr, | 709 double min_min_psnr, |
| 750 double min_avg_ssim, | 710 double min_avg_ssim, |
| 751 double min_min_ssim) { | 711 double min_min_ssim) { |
| 752 quality_thresholds->min_avg_psnr = min_avg_psnr; | 712 quality_thresholds->min_avg_psnr = min_avg_psnr; |
| 753 quality_thresholds->min_min_psnr = min_min_psnr; | 713 quality_thresholds->min_min_psnr = min_min_psnr; |
| 754 quality_thresholds->min_avg_ssim = min_avg_ssim; | 714 quality_thresholds->min_avg_ssim = min_avg_ssim; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 float encoding_bitrate_total_; | 782 float encoding_bitrate_total_; |
| 823 float perc_encoding_rate_mismatch_; | 783 float perc_encoding_rate_mismatch_; |
| 824 int num_frames_to_hit_target_; | 784 int num_frames_to_hit_target_; |
| 825 bool encoding_rate_within_target_; | 785 bool encoding_rate_within_target_; |
| 826 int bit_rate_; | 786 int bit_rate_; |
| 827 int frame_rate_; | 787 int frame_rate_; |
| 828 float target_size_key_frame_initial_; | 788 float target_size_key_frame_initial_; |
| 829 float target_size_key_frame_; | 789 float target_size_key_frame_; |
| 830 float sum_key_frame_size_mismatch_; | 790 float sum_key_frame_size_mismatch_; |
| 831 int num_key_frames_; | 791 int num_key_frames_; |
| 832 float start_bitrate_; | |
| 833 int start_frame_rate_; | 792 int start_frame_rate_; |
| 834 | 793 |
| 835 // Codec and network settings. | 794 // Codec and network settings. |
| 836 float packet_loss_probability_; | |
| 837 int num_temporal_layers_; | 795 int num_temporal_layers_; |
| 838 }; | 796 }; |
| 839 | 797 |
| 840 } // namespace test | 798 } // namespace test |
| 841 } // namespace webrtc | 799 } // namespace webrtc |
| 842 | 800 |
| 843 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ | 801 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ |
| OLD | NEW |