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

Side by Side Diff: webrtc/modules/audio_coding/neteq/decision_logic_normal.h

Issue 1945863002: NetEq: Replace timescale_holdoff_ with a Countdown timer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 10 matching lines...) Expand all
21 // kPlayoutStreaming. 21 // kPlayoutStreaming.
22 class DecisionLogicNormal : public DecisionLogic { 22 class DecisionLogicNormal : public DecisionLogic {
23 public: 23 public:
24 // Constructor. 24 // Constructor.
25 DecisionLogicNormal(int fs_hz, 25 DecisionLogicNormal(int fs_hz,
26 size_t output_size_samples, 26 size_t output_size_samples,
27 NetEqPlayoutMode playout_mode, 27 NetEqPlayoutMode playout_mode,
28 DecoderDatabase* decoder_database, 28 DecoderDatabase* decoder_database,
29 const PacketBuffer& packet_buffer, 29 const PacketBuffer& packet_buffer,
30 DelayManager* delay_manager, 30 DelayManager* delay_manager,
31 BufferLevelFilter* buffer_level_filter) 31 BufferLevelFilter* buffer_level_filter,
32 : DecisionLogic(fs_hz, output_size_samples, playout_mode, 32 const TickTimer* tick_timer)
33 decoder_database, packet_buffer, delay_manager, 33 : DecisionLogic(fs_hz,
34 buffer_level_filter) { 34 output_size_samples,
35 } 35 playout_mode,
36 decoder_database,
37 packet_buffer,
38 delay_manager,
39 buffer_level_filter,
40 tick_timer) {}
36 41
37 protected: 42 protected:
38 static const int kAllowMergeWithoutExpandMs = 20; // 20 ms. 43 static const int kAllowMergeWithoutExpandMs = 20; // 20 ms.
39 static const int kReinitAfterExpands = 100; 44 static const int kReinitAfterExpands = 100;
40 static const int kMaxWaitForPacket = 10; 45 static const int kMaxWaitForPacket = 10;
41 46
42 // Returns the operation that should be done next. |sync_buffer| and |expand| 47 // Returns the operation that should be done next. |sync_buffer| and |expand|
43 // are provided for reference. |decoder_frame_length| is the number of samples 48 // are provided for reference. |decoder_frame_length| is the number of samples
44 // obtained from the last decoded frame. If there is a packet available, the 49 // obtained from the last decoded frame. If there is a packet available, the
45 // packet header should be supplied in |packet_header|; otherwise it should 50 // packet header should be supplied in |packet_header|; otherwise it should
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 private: 84 private:
80 // Returns the operation given that the next available packet is a comfort 85 // Returns the operation given that the next available packet is a comfort
81 // noise payload (RFC 3389 only, not codec-internal). 86 // noise payload (RFC 3389 only, not codec-internal).
82 Operations CngOperation(Modes prev_mode, 87 Operations CngOperation(Modes prev_mode,
83 uint32_t target_timestamp, 88 uint32_t target_timestamp,
84 uint32_t available_timestamp, 89 uint32_t available_timestamp,
85 size_t generated_noise_samples); 90 size_t generated_noise_samples);
86 91
87 // Checks if enough time has elapsed since the last successful timescale 92 // Checks if enough time has elapsed since the last successful timescale
88 // operation was done (i.e., accelerate or preemptive expand). 93 // operation was done (i.e., accelerate or preemptive expand).
89 bool TimescaleAllowed() const { return timescale_hold_off_ == 0; } 94 bool TimescaleAllowed() const {
95 return !timescale_countdown_ || timescale_countdown_->Finished();
96 }
90 97
91 // Checks if the current (filtered) buffer level is under the target level. 98 // Checks if the current (filtered) buffer level is under the target level.
92 bool UnderTargetLevel() const; 99 bool UnderTargetLevel() const;
93 100
94 // Checks if |timestamp_leap| is so long into the future that a reset due 101 // Checks if |timestamp_leap| is so long into the future that a reset due
95 // to exceeding kReinitAfterExpands will be done. 102 // to exceeding kReinitAfterExpands will be done.
96 bool ReinitAfterExpands(uint32_t timestamp_leap) const; 103 bool ReinitAfterExpands(uint32_t timestamp_leap) const;
97 104
98 // Checks if we still have not done enough expands to cover the distance from 105 // Checks if we still have not done enough expands to cover the distance from
99 // the last decoded packet to the next available packet, the distance beeing 106 // the last decoded packet to the next available packet, the distance beeing
100 // conveyed in |timestamp_leap|. 107 // conveyed in |timestamp_leap|.
101 bool PacketTooEarly(uint32_t timestamp_leap) const; 108 bool PacketTooEarly(uint32_t timestamp_leap) const;
102 109
103 // Checks if num_consecutive_expands_ >= kMaxWaitForPacket. 110 // Checks if num_consecutive_expands_ >= kMaxWaitForPacket.
104 bool MaxWaitForPacket() const; 111 bool MaxWaitForPacket() const;
105 112
106 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogicNormal); 113 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogicNormal);
107 }; 114 };
108 115
109 } // namespace webrtc 116 } // namespace webrtc
110 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_ 117 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698