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