Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 rc_threshold->max_num_frames_to_hit_target = max_num_frames_to_hit_target; | 168 rc_threshold->max_num_frames_to_hit_target = max_num_frames_to_hit_target; |
| 169 rc_threshold->num_spatial_resizes = num_spatial_resizes; | 169 rc_threshold->num_spatial_resizes = num_spatial_resizes; |
| 170 rc_threshold->num_key_frames = num_key_frames; | 170 rc_threshold->num_key_frames = num_key_frames; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Processes all frames in the clip and verifies the result. | 173 // Processes all frames in the clip and verifies the result. |
| 174 void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify( | 174 void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify( |
| 175 const RateProfile& rate_profile, | 175 const RateProfile& rate_profile, |
| 176 const std::vector<RateControlThresholds>* rc_thresholds, | 176 const std::vector<RateControlThresholds>* rc_thresholds, |
| 177 const QualityThresholds* quality_thresholds, | 177 const QualityThresholds* quality_thresholds, |
| 178 const BitstreamThresholds* bs_thresholds, | |
| 178 const VisualizationParams* visualization_params) { | 179 const VisualizationParams* visualization_params) { |
| 179 // The Android HW codec needs to be run on a task queue, so we simply always | 180 // The Android HW codec needs to be run on a task queue, so we simply always |
| 180 // run the test on a task queue. | 181 // run the test on a task queue. |
| 181 rtc::TaskQueue task_queue("VidProc TQ"); | 182 rtc::TaskQueue task_queue("VidProc TQ"); |
| 182 rtc::Event sync_event(false, false); | 183 rtc::Event sync_event(false, false); |
| 183 | 184 |
| 184 SetUpAndInitObjects(&task_queue, rate_profile.target_bit_rate[0], | 185 SetUpAndInitObjects(&task_queue, rate_profile.target_bit_rate[0], |
| 185 rate_profile.input_frame_rate[0], visualization_params); | 186 rate_profile.input_frame_rate[0], visualization_params); |
| 186 | 187 |
| 187 // Set initial rates. | 188 // Set initial rates. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 sync_event.Set(); | 239 sync_event.Set(); |
| 239 }); | 240 }); |
| 240 sync_event.Wait(rtc::Event::kForever); | 241 sync_event.Wait(rtc::Event::kForever); |
| 241 | 242 |
| 242 rate_update_index = 0; | 243 rate_update_index = 0; |
| 243 frame_number = 0; | 244 frame_number = 0; |
| 244 ResetRateControlMetrics(rate_update_index, rate_profile); | 245 ResetRateControlMetrics(rate_update_index, rate_profile); |
| 245 while (frame_number < num_frames) { | 246 while (frame_number < num_frames) { |
| 246 UpdateRateControlMetrics(frame_number); | 247 UpdateRateControlMetrics(frame_number); |
| 247 | 248 |
| 249 if (bs_thresholds) { | |
| 250 VerifyBitstream(frame_number, bs_thresholds); | |
| 251 } | |
| 252 | |
| 248 ++frame_number; | 253 ++frame_number; |
| 249 | 254 |
| 250 if (frame_number == | 255 if (frame_number == |
| 251 rate_profile.frame_index_rate_update[rate_update_index + 1]) { | 256 rate_profile.frame_index_rate_update[rate_update_index + 1]) { |
| 252 PrintRateControlMetrics(rate_update_index, num_dropped_frames, | 257 PrintRateControlMetrics(rate_update_index, num_dropped_frames, |
| 253 num_spatial_resizes); | 258 num_spatial_resizes); |
| 254 VerifyRateControlMetrics(rate_update_index, rc_thresholds, | 259 VerifyRateControlMetrics(rate_update_index, rc_thresholds, |
| 255 num_dropped_frames, num_spatial_resizes); | 260 num_dropped_frames, num_spatial_resizes); |
| 256 ++rate_update_index; | 261 ++rate_update_index; |
| 257 ResetRateControlMetrics(rate_update_index, rate_profile); | 262 ResetRateControlMetrics(rate_update_index, rate_profile); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 break; | 332 break; |
| 328 case kVideoCodecVP9: | 333 case kVideoCodecVP9: |
| 329 codec = cricket::VideoCodec(cricket::kVp9CodecName); | 334 codec = cricket::VideoCodec(cricket::kVp9CodecName); |
| 330 encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); | 335 encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); |
| 331 decoder_ = | 336 decoder_ = |
| 332 decoder_factory_->CreateVideoDecoderWithParams(codec, decoder_params); | 337 decoder_factory_->CreateVideoDecoderWithParams(codec, decoder_params); |
| 333 break; | 338 break; |
| 334 case kVideoCodecH264: | 339 case kVideoCodecH264: |
| 335 // TODO(brandtr): Generalize so that we support multiple profiles here. | 340 // TODO(brandtr): Generalize so that we support multiple profiles here. |
| 336 codec = cricket::VideoCodec(cricket::kH264CodecName); | 341 codec = cricket::VideoCodec(cricket::kH264CodecName); |
| 342 if (config_.packetization_mode == H264PacketizationMode::NonInterleaved) { | |
| 343 codec.SetParam(cricket::kH264FmtpPacketizationMode, "1"); | |
| 344 } else { | |
| 345 RTC_CHECK_EQ(config_.packetization_mode, | |
| 346 H264PacketizationMode::SingleNalUnit); | |
| 347 codec.SetParam(cricket::kH264FmtpPacketizationMode, "0"); | |
| 348 } | |
| 337 encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); | 349 encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); |
| 338 decoder_ = | 350 decoder_ = |
| 339 decoder_factory_->CreateVideoDecoderWithParams(codec, decoder_params); | 351 decoder_factory_->CreateVideoDecoderWithParams(codec, decoder_params); |
| 340 break; | 352 break; |
| 341 default: | 353 default: |
| 342 RTC_NOTREACHED(); | 354 RTC_NOTREACHED(); |
| 343 break; | 355 break; |
| 344 } | 356 } |
| 345 | 357 |
| 346 if (config_.sw_fallback_encoder) { | 358 if (config_.sw_fallback_encoder) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 printf(" Layer encoded bitrate : %f\n", actual_.kbps_layer[i]); | 565 printf(" Layer encoded bitrate : %f\n", actual_.kbps_layer[i]); |
| 554 printf(" Layer frame size %% mismatch : %d\n", | 566 printf(" Layer frame size %% mismatch : %d\n", |
| 555 actual_.DeltaFrameSizeMismatchPercent(i)); | 567 actual_.DeltaFrameSizeMismatchPercent(i)); |
| 556 printf(" Layer bitrate %% mismatch : %d\n", | 568 printf(" Layer bitrate %% mismatch : %d\n", |
| 557 actual_.BitrateMismatchPercent(i, target_.kbps_layer[i])); | 569 actual_.BitrateMismatchPercent(i, target_.kbps_layer[i])); |
| 558 printf(" # processed frames per layer: %d\n", actual_.num_frames_layer[i]); | 570 printf(" # processed frames per layer: %d\n", actual_.num_frames_layer[i]); |
| 559 } | 571 } |
| 560 printf("\n"); | 572 printf("\n"); |
| 561 } | 573 } |
| 562 | 574 |
| 575 void VideoProcessorIntegrationTest::VerifyBitstream( | |
| 576 int frame_number, | |
| 577 const BitstreamThresholds* bs_thresholds) { | |
|
brandtr
2017/09/26 11:20:55
Since this method is always called with a non-null
ssilkin
2017/09/26 12:05:33
Right. Done.
| |
| 578 RTC_CHECK_GE(frame_number, 0); | |
| 579 const FrameStatistic* frame_stat = stats_.GetFrame(frame_number); | |
| 580 EXPECT_LE(*(frame_stat->max_nalu_length), bs_thresholds->max_nalu_length); | |
|
brandtr
2017/09/26 11:20:55
This is a bit dangerous: whenever |bs_thresholds|
ssilkin
2017/09/26 12:05:33
Such check is done within rtc:Optional
| |
| 581 } | |
| 582 | |
| 563 // Temporal layer index corresponding to frame number, for up to 3 layers. | 583 // Temporal layer index corresponding to frame number, for up to 3 layers. |
| 564 int VideoProcessorIntegrationTest::TemporalLayerIndexForFrame( | 584 int VideoProcessorIntegrationTest::TemporalLayerIndexForFrame( |
| 565 int frame_number) const { | 585 int frame_number) const { |
| 566 int tl_idx = -1; | 586 int tl_idx = -1; |
| 567 switch (NumberOfTemporalLayers(config_.codec_settings)) { | 587 switch (NumberOfTemporalLayers(config_.codec_settings)) { |
| 568 case 1: | 588 case 1: |
| 569 tl_idx = 0; | 589 tl_idx = 0; |
| 570 break; | 590 break; |
| 571 case 2: | 591 case 2: |
| 572 // temporal layer 0: 0 2 4 ... | 592 // temporal layer 0: 0 2 4 ... |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 | 666 |
| 647 // Update layer per-frame-bandwidth. | 667 // Update layer per-frame-bandwidth. |
| 648 for (int i = 0; i < num_temporal_layers; ++i) { | 668 for (int i = 0; i < num_temporal_layers; ++i) { |
| 649 target_.framesize_kbits_layer[i] = | 669 target_.framesize_kbits_layer[i] = |
| 650 target_.kbps_layer[i] / target_.fps_layer[i]; | 670 target_.kbps_layer[i] / target_.fps_layer[i]; |
| 651 } | 671 } |
| 652 } | 672 } |
| 653 | 673 |
| 654 } // namespace test | 674 } // namespace test |
| 655 } // namespace webrtc | 675 } // namespace webrtc |
| OLD | NEW |