Index: webrtc/modules/include/module_common_types.h |
diff --git a/webrtc/modules/include/module_common_types.h b/webrtc/modules/include/module_common_types.h |
index 4e431105966e22448c5c94b20a896e14221abe77..d7b1363688c1d0cad003e36bca09e105951fce12 100644 |
--- a/webrtc/modules/include/module_common_types.h |
+++ b/webrtc/modules/include/module_common_types.h |
@@ -516,8 +516,6 @@ class CallStatsObserver { |
* |
* - Stereo data is interleaved starting with the left channel. |
* |
- * - The +operator assume that you would never add exactly opposite frames when |
- * deciding the resulting state. To do this use the -operator. |
aleloi
2016/10/18 11:38:04
I think this comment is not valid: there is no -op
|
*/ |
class AudioFrame { |
public: |
@@ -541,37 +539,23 @@ class AudioFrame { |
AudioFrame(); |
- // Resets all members to their default state (except does not modify the |
- // contents of |data_|). |
- void Reset(); |
- |
- void UpdateFrame(int id, uint32_t timestamp, const int16_t* data, |
- size_t samples_per_channel, int sample_rate_hz, |
- SpeechType speech_type, VADActivity vad_activity, |
- size_t num_channels = 1); |
- |
void CopyFrom(const AudioFrame& src); |
- void Mute(); |
- |
- AudioFrame& operator>>=(const int rhs); |
- AudioFrame& operator+=(const AudioFrame& rhs); |
- |
- int id_; |
+ int id_ = -1; |
// RTP timestamp of the first sample in the AudioFrame. |
- uint32_t timestamp_; |
+ uint32_t timestamp_ = 0; |
// Time since the first frame in milliseconds. |
// -1 represents an uninitialized value. |
- int64_t elapsed_time_ms_; |
+ int64_t elapsed_time_ms_ = -1; |
// NTP time of the estimated capture time in local timebase in milliseconds. |
// -1 represents an uninitialized value. |
- int64_t ntp_time_ms_; |
+ int64_t ntp_time_ms_ = -1; |
int16_t data_[kMaxDataSizeSamples]; |
- size_t samples_per_channel_; |
- int sample_rate_hz_; |
- size_t num_channels_; |
- SpeechType speech_type_; |
- VADActivity vad_activity_; |
+ size_t samples_per_channel_ = 0; |
+ int sample_rate_hz_ = 0; |
+ size_t num_channels_ = 0; |
+ SpeechType speech_type_ = kUndefined; |
+ VADActivity vad_activity_ = kVadUnknown; |
private: |
RTC_DISALLOW_COPY_AND_ASSIGN(AudioFrame); |
@@ -581,47 +565,8 @@ class AudioFrame { |
// See https://bugs.chromium.org/p/webrtc/issues/detail?id=5647. |
inline AudioFrame::AudioFrame() |
: data_() { |
- Reset(); |
} |
-inline void AudioFrame::Reset() { |
- id_ = -1; |
- // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize |
- // to an invalid value, or add a new member to indicate invalidity. |
- timestamp_ = 0; |
- elapsed_time_ms_ = -1; |
- ntp_time_ms_ = -1; |
- samples_per_channel_ = 0; |
- sample_rate_hz_ = 0; |
- num_channels_ = 0; |
- speech_type_ = kUndefined; |
- vad_activity_ = kVadUnknown; |
-} |
- |
-inline void AudioFrame::UpdateFrame(int id, |
- uint32_t timestamp, |
- const int16_t* data, |
- size_t samples_per_channel, |
- int sample_rate_hz, |
- SpeechType speech_type, |
- VADActivity vad_activity, |
- size_t num_channels) { |
- id_ = id; |
- timestamp_ = timestamp; |
- samples_per_channel_ = samples_per_channel; |
- sample_rate_hz_ = sample_rate_hz; |
- speech_type_ = speech_type; |
- vad_activity_ = vad_activity; |
- num_channels_ = num_channels; |
- |
- const size_t length = samples_per_channel * num_channels; |
- assert(length <= kMaxDataSizeSamples); |
- if (data != NULL) { |
- memcpy(data_, data, sizeof(int16_t) * length); |
- } else { |
- memset(data_, 0, sizeof(int16_t) * length); |
- } |
-} |
inline void AudioFrame::CopyFrom(const AudioFrame& src) { |
if (this == &src) return; |
@@ -641,70 +586,6 @@ inline void AudioFrame::CopyFrom(const AudioFrame& src) { |
memcpy(data_, src.data_, sizeof(int16_t) * length); |
} |
-inline void AudioFrame::Mute() { |
- memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t)); |
-} |
- |
-inline AudioFrame& AudioFrame::operator>>=(const int rhs) { |
- assert((num_channels_ > 0) && (num_channels_ < 3)); |
- if ((num_channels_ > 2) || (num_channels_ < 1)) return *this; |
- |
- for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) { |
- data_[i] = static_cast<int16_t>(data_[i] >> rhs); |
- } |
- return *this; |
-} |
- |
-namespace { |
-inline int16_t ClampToInt16(int32_t input) { |
- if (input < -0x00008000) { |
- return -0x8000; |
- } else if (input > 0x00007FFF) { |
- return 0x7FFF; |
- } else { |
- return static_cast<int16_t>(input); |
- } |
-} |
-} |
- |
-inline AudioFrame& AudioFrame::operator+=(const AudioFrame& rhs) { |
- // Sanity check |
- assert((num_channels_ > 0) && (num_channels_ < 3)); |
- if ((num_channels_ > 2) || (num_channels_ < 1)) return *this; |
- if (num_channels_ != rhs.num_channels_) return *this; |
- |
- bool noPrevData = false; |
- if (samples_per_channel_ != rhs.samples_per_channel_) { |
- if (samples_per_channel_ == 0) { |
- // special case we have no data to start with |
- samples_per_channel_ = rhs.samples_per_channel_; |
- noPrevData = true; |
- } else { |
- return *this; |
- } |
- } |
- |
- if ((vad_activity_ == kVadActive) || rhs.vad_activity_ == kVadActive) { |
- vad_activity_ = kVadActive; |
- } else if (vad_activity_ == kVadUnknown || rhs.vad_activity_ == kVadUnknown) { |
- vad_activity_ = kVadUnknown; |
- } |
- |
- if (speech_type_ != rhs.speech_type_) speech_type_ = kUndefined; |
- |
- if (noPrevData) { |
- memcpy(data_, rhs.data_, |
- sizeof(int16_t) * rhs.samples_per_channel_ * num_channels_); |
- } else { |
- // IMPROVEMENT this can be done very fast in assembly |
- for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) { |
- int32_t wrap_guard = |
- static_cast<int32_t>(data_[i]) + static_cast<int32_t>(rhs.data_[i]); |
- data_[i] = ClampToInt16(wrap_guard); |
- } |
- } |
- return *this; |
-} |
inline bool IsNewerSequenceNumber(uint16_t sequence_number, |
uint16_t prev_sequence_number) { |