From 0d343fa39dfdc9a35cae6e792474893890a242f8 Mon Sep 17 00:00:00 2001 From: solenberg Date: Tue, 29 Mar 2016 16:42:06 -0700 Subject: [PATCH] Remove unused stuff from AudioFrame: - The interleaved_ field. Never set to anything but 'true'. AudioFrame data appears to always be treated as interleaved. - The Append() method. - operator-=(). BUG= Review URL: https://codereview.webrtc.org/1830713003 Cr-Commit-Position: refs/heads/master@{#12152} --- .../modules/audio_coding/neteq/sync_buffer.cc | 1 - webrtc/modules/include/module_common_types.h | 55 ------------------- .../utility/source/audio_frame_operations.cc | 1 - 3 files changed, 57 deletions(-) diff --git a/webrtc/modules/audio_coding/neteq/sync_buffer.cc b/webrtc/modules/audio_coding/neteq/sync_buffer.cc index 543f78bdc4..f841f754a8 100644 --- a/webrtc/modules/audio_coding/neteq/sync_buffer.cc +++ b/webrtc/modules/audio_coding/neteq/sync_buffer.cc @@ -79,7 +79,6 @@ void SyncBuffer::GetNextAudioInterleaved(size_t requested_len, ReadInterleavedFromIndex(next_index_, samples_to_read, output->data_); const size_t samples_read_per_channel = tot_samples_read / Channels(); next_index_ += samples_read_per_channel; - output->interleaved_ = true; output->num_channels_ = Channels(); output->samples_per_channel_ = samples_read_per_channel; } diff --git a/webrtc/modules/include/module_common_types.h b/webrtc/modules/include/module_common_types.h index 853b431ebc..82d87d5c5c 100644 --- a/webrtc/modules/include/module_common_types.h +++ b/webrtc/modules/include/module_common_types.h @@ -505,21 +505,17 @@ class AudioFrame { // contents of |data_|). void Reset(); - // |interleaved_| is not changed by this method. 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); - AudioFrame& Append(const AudioFrame& rhs); - void CopyFrom(const AudioFrame& src); void Mute(); AudioFrame& operator>>=(const int rhs); AudioFrame& operator+=(const AudioFrame& rhs); - AudioFrame& operator-=(const AudioFrame& rhs); int id_; // RTP timestamp of the first sample in the AudioFrame. @@ -536,7 +532,6 @@ class AudioFrame { size_t num_channels_; SpeechType speech_type_; VADActivity vad_activity_; - bool interleaved_; private: RTC_DISALLOW_COPY_AND_ASSIGN(AudioFrame); @@ -561,7 +556,6 @@ inline void AudioFrame::Reset() { num_channels_ = 0; speech_type_ = kUndefined; vad_activity_ = kVadUnknown; - interleaved_ = true; } inline void AudioFrame::UpdateFrame(int id, @@ -601,7 +595,6 @@ inline void AudioFrame::CopyFrom(const AudioFrame& src) { speech_type_ = src.speech_type_; vad_activity_ = src.vad_activity_; num_channels_ = src.num_channels_; - interleaved_ = src.interleaved_; const size_t length = samples_per_channel_ * num_channels_; assert(length <= kMaxDataSizeSamples); @@ -622,30 +615,6 @@ inline AudioFrame& AudioFrame::operator>>=(const int rhs) { return *this; } -inline AudioFrame& AudioFrame::Append(const AudioFrame& rhs) { - // Sanity check - assert((num_channels_ > 0) && (num_channels_ < 3)); - assert(interleaved_ == rhs.interleaved_); - if ((num_channels_ > 2) || (num_channels_ < 1)) return *this; - if (num_channels_ != rhs.num_channels_) 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; - } - - size_t offset = samples_per_channel_ * num_channels_; - for (size_t i = 0; i < rhs.samples_per_channel_ * rhs.num_channels_; i++) { - data_[offset + i] = rhs.data_[i]; - } - samples_per_channel_ += rhs.samples_per_channel_; - return *this; -} - namespace { inline int16_t ClampToInt16(int32_t input) { if (input < -0x00008000) { @@ -661,7 +630,6 @@ inline int16_t ClampToInt16(int32_t input) { inline AudioFrame& AudioFrame::operator+=(const AudioFrame& rhs) { // Sanity check assert((num_channels_ > 0) && (num_channels_ < 3)); - assert(interleaved_ == rhs.interleaved_); if ((num_channels_ > 2) || (num_channels_ < 1)) return *this; if (num_channels_ != rhs.num_channels_) return *this; @@ -698,29 +666,6 @@ inline AudioFrame& AudioFrame::operator+=(const AudioFrame& rhs) { return *this; } -inline AudioFrame& AudioFrame::operator-=(const AudioFrame& rhs) { - // Sanity check - assert((num_channels_ > 0) && (num_channels_ < 3)); - assert(interleaved_ == rhs.interleaved_); - if ((num_channels_ > 2) || (num_channels_ < 1)) return *this; - - if ((samples_per_channel_ != rhs.samples_per_channel_) || - (num_channels_ != rhs.num_channels_)) { - return *this; - } - if ((vad_activity_ != kVadPassive) || rhs.vad_activity_ != kVadPassive) { - vad_activity_ = kVadUnknown; - } - speech_type_ = kUndefined; - - for (size_t i = 0; i < samples_per_channel_ * num_channels_; i++) { - int32_t wrap_guard = - static_cast(data_[i]) - static_cast(rhs.data_[i]); - data_[i] = ClampToInt16(wrap_guard); - } - return *this; -} - inline bool IsNewerSequenceNumber(uint16_t sequence_number, uint16_t prev_sequence_number) { // Distinguish between elements that are exactly 0x8000 apart. diff --git a/webrtc/modules/utility/source/audio_frame_operations.cc b/webrtc/modules/utility/source/audio_frame_operations.cc index 435d676f13..102407d0f0 100644 --- a/webrtc/modules/utility/source/audio_frame_operations.cc +++ b/webrtc/modules/utility/source/audio_frame_operations.cc @@ -80,7 +80,6 @@ void AudioFrameOperations::SwapStereoChannels(AudioFrame* frame) { void AudioFrameOperations::Mute(AudioFrame* frame, bool previous_frame_muted, bool current_frame_muted) { RTC_DCHECK(frame); - RTC_DCHECK(frame->interleaved_); if (!previous_frame_muted && !current_frame_muted) { // Not muted, don't touch. } else if (previous_frame_muted && current_frame_muted) {