Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc

Issue 3013613002: Added configurable offsets to the per-packet overhead in ANA. (Closed)
Patch Set: Set prev_direction_increase in the Frame length controller. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 14 matching lines...) Expand all
25 frame_length_ms); 25 frame_length_ms);
26 } 26 }
27 } 27 }
28 28
29 FrameLengthController::Config::Config( 29 FrameLengthController::Config::Config(
30 const std::vector<int>& encoder_frame_lengths_ms, 30 const std::vector<int>& encoder_frame_lengths_ms,
31 int initial_frame_length_ms, 31 int initial_frame_length_ms,
32 int min_encoder_bitrate_bps, 32 int min_encoder_bitrate_bps,
33 float fl_increasing_packet_loss_fraction, 33 float fl_increasing_packet_loss_fraction,
34 float fl_decreasing_packet_loss_fraction, 34 float fl_decreasing_packet_loss_fraction,
35 int fl_increase_overhead_offset,
36 int fl_decrease_overhead_offset,
35 std::map<FrameLengthChange, int> fl_changing_bandwidths_bps) 37 std::map<FrameLengthChange, int> fl_changing_bandwidths_bps)
36 : encoder_frame_lengths_ms(encoder_frame_lengths_ms), 38 : encoder_frame_lengths_ms(encoder_frame_lengths_ms),
37 initial_frame_length_ms(initial_frame_length_ms), 39 initial_frame_length_ms(initial_frame_length_ms),
38 min_encoder_bitrate_bps(min_encoder_bitrate_bps), 40 min_encoder_bitrate_bps(min_encoder_bitrate_bps),
39 fl_increasing_packet_loss_fraction(fl_increasing_packet_loss_fraction), 41 fl_increasing_packet_loss_fraction(fl_increasing_packet_loss_fraction),
40 fl_decreasing_packet_loss_fraction(fl_decreasing_packet_loss_fraction), 42 fl_decreasing_packet_loss_fraction(fl_decreasing_packet_loss_fraction),
43 fl_increase_overhead_offset(fl_increase_overhead_offset),
44 fl_decrease_overhead_offset(fl_decrease_overhead_offset),
41 fl_changing_bandwidths_bps(std::move(fl_changing_bandwidths_bps)) {} 45 fl_changing_bandwidths_bps(std::move(fl_changing_bandwidths_bps)) {}
42 46
43 FrameLengthController::Config::Config(const Config& other) = default; 47 FrameLengthController::Config::Config(const Config& other) = default;
44 48
45 FrameLengthController::Config::~Config() = default; 49 FrameLengthController::Config::~Config() = default;
46 50
47 FrameLengthController::FrameLengthController(const Config& config) 51 FrameLengthController::FrameLengthController(const Config& config)
48 : config_(config) { 52 : config_(config) {
49 frame_length_ms_ = std::find(config_.encoder_frame_lengths_ms.begin(), 53 frame_length_ms_ = std::find(config_.encoder_frame_lengths_ms.begin(),
50 config_.encoder_frame_lengths_ms.end(), 54 config_.encoder_frame_lengths_ms.end(),
(...skipping 13 matching lines...) Expand all
64 if (network_metrics.overhead_bytes_per_packet) 68 if (network_metrics.overhead_bytes_per_packet)
65 overhead_bytes_per_packet_ = network_metrics.overhead_bytes_per_packet; 69 overhead_bytes_per_packet_ = network_metrics.overhead_bytes_per_packet;
66 } 70 }
67 71
68 void FrameLengthController::MakeDecision(AudioEncoderRuntimeConfig* config) { 72 void FrameLengthController::MakeDecision(AudioEncoderRuntimeConfig* config) {
69 // Decision on |frame_length_ms| should not have been made. 73 // Decision on |frame_length_ms| should not have been made.
70 RTC_DCHECK(!config->frame_length_ms); 74 RTC_DCHECK(!config->frame_length_ms);
71 75
72 if (FrameLengthIncreasingDecision(*config)) { 76 if (FrameLengthIncreasingDecision(*config)) {
73 ++frame_length_ms_; 77 ++frame_length_ms_;
78 prev_decision_increase_ = true;
74 } else if (FrameLengthDecreasingDecision(*config)) { 79 } else if (FrameLengthDecreasingDecision(*config)) {
75 --frame_length_ms_; 80 --frame_length_ms_;
81 prev_decision_increase_ = false;
76 } 82 }
83 config->last_fl_change_increase = prev_decision_increase_;
77 config->frame_length_ms = rtc::Optional<int>(*frame_length_ms_); 84 config->frame_length_ms = rtc::Optional<int>(*frame_length_ms_);
78 } 85 }
79 86
80 FrameLengthController::Config::FrameLengthChange::FrameLengthChange( 87 FrameLengthController::Config::FrameLengthChange::FrameLengthChange(
81 int from_frame_length_ms, 88 int from_frame_length_ms,
82 int to_frame_length_ms) 89 int to_frame_length_ms)
83 : from_frame_length_ms(from_frame_length_ms), 90 : from_frame_length_ms(from_frame_length_ms),
84 to_frame_length_ms(to_frame_length_ms) {} 91 to_frame_length_ms(to_frame_length_ms) {}
85 92
86 bool FrameLengthController::Config::FrameLengthChange::operator<( 93 bool FrameLengthController::Config::FrameLengthChange::operator<(
(...skipping 19 matching lines...) Expand all
106 113
107 auto increase_threshold = config_.fl_changing_bandwidths_bps.find( 114 auto increase_threshold = config_.fl_changing_bandwidths_bps.find(
108 Config::FrameLengthChange(*frame_length_ms_, *longer_frame_length_ms)); 115 Config::FrameLengthChange(*frame_length_ms_, *longer_frame_length_ms));
109 116
110 if (increase_threshold == config_.fl_changing_bandwidths_bps.end()) 117 if (increase_threshold == config_.fl_changing_bandwidths_bps.end())
111 return false; 118 return false;
112 119
113 if (uplink_bandwidth_bps_ && overhead_bytes_per_packet_ && 120 if (uplink_bandwidth_bps_ && overhead_bytes_per_packet_ &&
114 *uplink_bandwidth_bps_ <= 121 *uplink_bandwidth_bps_ <=
115 config_.min_encoder_bitrate_bps + kPreventOveruseMarginBps + 122 config_.min_encoder_bitrate_bps + kPreventOveruseMarginBps +
116 OverheadRateBps(*overhead_bytes_per_packet_, *frame_length_ms_)) { 123 OverheadRateBps(*overhead_bytes_per_packet_ +
124 config_.fl_increase_overhead_offset,
125 *frame_length_ms_)) {
117 return true; 126 return true;
118 } 127 }
119 128
120 return (uplink_bandwidth_bps_ && 129 return (uplink_bandwidth_bps_ &&
121 *uplink_bandwidth_bps_ <= increase_threshold->second) && 130 *uplink_bandwidth_bps_ <= increase_threshold->second) &&
122 (uplink_packet_loss_fraction_ && 131 (uplink_packet_loss_fraction_ &&
123 *uplink_packet_loss_fraction_ <= 132 *uplink_packet_loss_fraction_ <=
124 config_.fl_increasing_packet_loss_fraction); 133 config_.fl_increasing_packet_loss_fraction);
125 } 134 }
126 135
(...skipping 11 matching lines...) Expand all
138 return false; 147 return false;
139 148
140 auto shorter_frame_length_ms = std::prev(frame_length_ms_); 149 auto shorter_frame_length_ms = std::prev(frame_length_ms_);
141 auto decrease_threshold = config_.fl_changing_bandwidths_bps.find( 150 auto decrease_threshold = config_.fl_changing_bandwidths_bps.find(
142 Config::FrameLengthChange(*frame_length_ms_, *shorter_frame_length_ms)); 151 Config::FrameLengthChange(*frame_length_ms_, *shorter_frame_length_ms));
143 152
144 if (decrease_threshold == config_.fl_changing_bandwidths_bps.end()) 153 if (decrease_threshold == config_.fl_changing_bandwidths_bps.end())
145 return false; 154 return false;
146 155
147 if (uplink_bandwidth_bps_ && overhead_bytes_per_packet_ && 156 if (uplink_bandwidth_bps_ && overhead_bytes_per_packet_ &&
148 *uplink_bandwidth_bps_ <= config_.min_encoder_bitrate_bps + 157 *uplink_bandwidth_bps_ <=
149 kPreventOveruseMarginBps + 158 config_.min_encoder_bitrate_bps + kPreventOveruseMarginBps +
150 OverheadRateBps(*overhead_bytes_per_packet_, 159 OverheadRateBps(*overhead_bytes_per_packet_ +
151 *shorter_frame_length_ms)) { 160 config_.fl_decrease_overhead_offset,
161 *shorter_frame_length_ms)) {
152 return false; 162 return false;
153 } 163 }
154 164
155 return (uplink_bandwidth_bps_ && 165 return (uplink_bandwidth_bps_ &&
156 *uplink_bandwidth_bps_ >= decrease_threshold->second) || 166 *uplink_bandwidth_bps_ >= decrease_threshold->second) ||
157 (uplink_packet_loss_fraction_ && 167 (uplink_packet_loss_fraction_ &&
158 *uplink_packet_loss_fraction_ >= 168 *uplink_packet_loss_fraction_ >=
159 config_.fl_decreasing_packet_loss_fraction); 169 config_.fl_decreasing_packet_loss_fraction);
160 } 170 }
161 171
162 } // namespace webrtc 172 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698