| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 encoding_rate_within_target_ = false; | 265 encoding_rate_within_target_ = false; |
| 266 sum_key_frame_size_mismatch_ = 0.0; | 266 sum_key_frame_size_mismatch_ = 0.0; |
| 267 num_key_frames_ = 0; | 267 num_key_frames_ = 0; |
| 268 } | 268 } |
| 269 | 269 |
| 270 // For every encoded frame, update the rate control metrics. | 270 // For every encoded frame, update the rate control metrics. |
| 271 void UpdateRateControlMetrics(int frame_num, FrameType frame_type) { | 271 void UpdateRateControlMetrics(int frame_num, FrameType frame_type) { |
| 272 float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; | 272 float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; |
| 273 // Update layer data. | 273 // Update layer data. |
| 274 // Update rate mismatch relative to per-frame bandwidth for delta frames. | 274 // Update rate mismatch relative to per-frame bandwidth for delta frames. |
| 275 if (frame_type == kDeltaFrame) { | 275 if (frame_type == kVideoFrameDelta) { |
| 276 // TODO(marpan): Should we count dropped (zero size) frames in mismatch? | 276 // TODO(marpan): Should we count dropped (zero size) frames in mismatch? |
| 277 sum_frame_size_mismatch_[layer_] += fabs(encoded_size_kbits - | 277 sum_frame_size_mismatch_[layer_] += fabs(encoded_size_kbits - |
| 278 per_frame_bandwidth_[layer_]) / | 278 per_frame_bandwidth_[layer_]) / |
| 279 per_frame_bandwidth_[layer_]; | 279 per_frame_bandwidth_[layer_]; |
| 280 } else { | 280 } else { |
| 281 float target_size = (frame_num == 1) ? target_size_key_frame_initial_ : | 281 float target_size = (frame_num == 1) ? target_size_key_frame_initial_ : |
| 282 target_size_key_frame_; | 282 target_size_key_frame_; |
| 283 sum_key_frame_size_mismatch_ += fabs(encoded_size_kbits - target_size) / | 283 sum_key_frame_size_mismatch_ += fabs(encoded_size_kbits - target_size) / |
| 284 target_size; | 284 target_size; |
| 285 num_key_frames_ += 1; | 285 num_key_frames_ += 1; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // Set the initial target size for key frame. | 443 // Set the initial target size for key frame. |
| 444 target_size_key_frame_initial_ = 0.5 * kInitialBufferSize * | 444 target_size_key_frame_initial_ = 0.5 * kInitialBufferSize * |
| 445 bit_rate_layer_[0]; | 445 bit_rate_layer_[0]; |
| 446 processor_->SetRates(bit_rate_, frame_rate_); | 446 processor_->SetRates(bit_rate_, frame_rate_); |
| 447 // Process each frame, up to |num_frames|. | 447 // Process each frame, up to |num_frames|. |
| 448 int num_frames = rate_profile.num_frames; | 448 int num_frames = rate_profile.num_frames; |
| 449 int update_index = 0; | 449 int update_index = 0; |
| 450 ResetRateControlMetrics( | 450 ResetRateControlMetrics( |
| 451 rate_profile.frame_index_rate_update[update_index + 1]); | 451 rate_profile.frame_index_rate_update[update_index + 1]); |
| 452 int frame_number = 0; | 452 int frame_number = 0; |
| 453 FrameType frame_type = kDeltaFrame; | 453 FrameType frame_type = kVideoFrameDelta; |
| 454 while (processor_->ProcessFrame(frame_number) && | 454 while (processor_->ProcessFrame(frame_number) && |
| 455 frame_number < num_frames) { | 455 frame_number < num_frames) { |
| 456 // Get the layer index for the frame |frame_number|. | 456 // Get the layer index for the frame |frame_number|. |
| 457 LayerIndexForFrame(frame_number); | 457 LayerIndexForFrame(frame_number); |
| 458 // Get the frame_type. | 458 // Get the frame_type. |
| 459 frame_type = processor_->EncodedFrameType(); | 459 frame_type = processor_->EncodedFrameType(); |
| 460 // Counter for whole sequence run. | 460 // Counter for whole sequence run. |
| 461 ++frame_number; | 461 ++frame_number; |
| 462 // Counters for each rate update. | 462 // Counters for each rate update. |
| 463 ++num_frames_per_update_[layer_]; | 463 ++num_frames_per_update_[layer_]; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 // Metrics for rate control. | 955 // Metrics for rate control. |
| 956 RateControlMetrics rc_metrics[2]; | 956 RateControlMetrics rc_metrics[2]; |
| 957 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); | 957 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); |
| 958 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); | 958 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); |
| 959 ProcessFramesAndVerify(quality_metrics, | 959 ProcessFramesAndVerify(quality_metrics, |
| 960 rate_profile, | 960 rate_profile, |
| 961 process_settings, | 961 process_settings, |
| 962 rc_metrics); | 962 rc_metrics); |
| 963 } | 963 } |
| 964 } // namespace webrtc | 964 } // namespace webrtc |
| OLD | NEW |