Reland "Removing webrtc::AudioFrame::energy_."
Some WebRTC client had a problem with the change "Removing webrtc::AudioFrame::energy_". Now it is solved. This reverts commit 2bdcfadc8abd418a30dd5cdf54ba45a429d3d9bf. BUG=webrtc:3315 Review URL: https://codereview.webrtc.org/1638553003 Cr-Commit-Position: refs/heads/master@{#11448}
This commit is contained in:
parent
d8de1154c9
commit
e37a2d1802
@ -583,17 +583,16 @@ void AudioConferenceMixerImpl::UpdateToMix(
|
|||||||
// There are already more active participants than should be
|
// There are already more active participants than should be
|
||||||
// mixed. Only keep the ones with the highest energy.
|
// mixed. Only keep the ones with the highest energy.
|
||||||
AudioFrameList::iterator replaceItem;
|
AudioFrameList::iterator replaceItem;
|
||||||
CalculateEnergy(*audioFrame);
|
uint32_t lowestEnergy = CalculateEnergy(*audioFrame);
|
||||||
uint32_t lowestEnergy = audioFrame->energy_;
|
|
||||||
|
|
||||||
bool found_replace_item = false;
|
bool found_replace_item = false;
|
||||||
for (AudioFrameList::iterator iter = activeList.begin();
|
for (AudioFrameList::iterator iter = activeList.begin();
|
||||||
iter != activeList.end();
|
iter != activeList.end();
|
||||||
++iter) {
|
++iter) {
|
||||||
CalculateEnergy(**iter);
|
const uint32_t energy = CalculateEnergy(**iter);
|
||||||
if((*iter)->energy_ < lowestEnergy) {
|
if(energy < lowestEnergy) {
|
||||||
replaceItem = iter;
|
replaceItem = iter;
|
||||||
lowestEnergy = (*iter)->energy_;
|
lowestEnergy = energy;
|
||||||
found_replace_item = true;
|
found_replace_item = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -783,18 +782,6 @@ void AudioConferenceMixerImpl::ClearAudioFrameList(
|
|||||||
audioFrameList->clear();
|
audioFrameList->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioConferenceMixerImpl::UpdateVADPositiveParticipants(
|
|
||||||
AudioFrameList* mixList) const {
|
|
||||||
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
|
|
||||||
"UpdateVADPositiveParticipants(mixList)");
|
|
||||||
|
|
||||||
for (AudioFrameList::const_iterator iter = mixList->begin();
|
|
||||||
iter != mixList->end();
|
|
||||||
++iter) {
|
|
||||||
CalculateEnergy(**iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AudioConferenceMixerImpl::IsParticipantInList(
|
bool AudioConferenceMixerImpl::IsParticipantInList(
|
||||||
const MixerParticipant& participant,
|
const MixerParticipant& participant,
|
||||||
const MixerParticipantList& participantList) const {
|
const MixerParticipantList& participantList) const {
|
||||||
|
|||||||
@ -116,10 +116,6 @@ private:
|
|||||||
// Clears audioFrameList and reclaims all memory associated with it.
|
// Clears audioFrameList and reclaims all memory associated with it.
|
||||||
void ClearAudioFrameList(AudioFrameList* audioFrameList) const;
|
void ClearAudioFrameList(AudioFrameList* audioFrameList) const;
|
||||||
|
|
||||||
// Update the list of MixerParticipants who have a positive VAD. mixList
|
|
||||||
// should be a list of AudioFrames
|
|
||||||
void UpdateVADPositiveParticipants(AudioFrameList* mixList) const;
|
|
||||||
|
|
||||||
// This function returns true if it finds the MixerParticipant in the
|
// This function returns true if it finds the MixerParticipant in the
|
||||||
// specified list of MixerParticipants.
|
// specified list of MixerParticipants.
|
||||||
bool IsParticipantInList(const MixerParticipant& participant,
|
bool IsParticipantInList(const MixerParticipant& participant,
|
||||||
|
|||||||
@ -39,16 +39,16 @@ const size_t rampSize = sizeof(rampArray)/sizeof(rampArray[0]);
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
void CalculateEnergy(AudioFrame& audioFrame)
|
uint32_t CalculateEnergy(const AudioFrame& audioFrame)
|
||||||
{
|
{
|
||||||
audioFrame.energy_ = 0;
|
uint32_t energy = 0;
|
||||||
for(size_t position = 0; position < audioFrame.samples_per_channel_;
|
for(size_t position = 0; position < audioFrame.samples_per_channel_;
|
||||||
position++)
|
position++)
|
||||||
{
|
{
|
||||||
// TODO(andrew): this can easily overflow.
|
// TODO(andrew): this can easily overflow.
|
||||||
audioFrame.energy_ += audioFrame.data_[position] *
|
energy += audioFrame.data_[position] * audioFrame.data_[position];
|
||||||
audioFrame.data_[position];
|
|
||||||
}
|
}
|
||||||
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RampIn(AudioFrame& audioFrame)
|
void RampIn(AudioFrame& audioFrame)
|
||||||
|
|||||||
@ -11,11 +11,13 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_FRAME_MANIPULATOR_H_
|
#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_FRAME_MANIPULATOR_H_
|
||||||
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_FRAME_MANIPULATOR_H_
|
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_FRAME_MANIPULATOR_H_
|
||||||
|
|
||||||
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class AudioFrame;
|
class AudioFrame;
|
||||||
|
|
||||||
// Updates the audioFrame's energy (based on its samples).
|
// Updates the audioFrame's energy (based on its samples).
|
||||||
void CalculateEnergy(AudioFrame& audioFrame);
|
uint32_t CalculateEnergy(const AudioFrame& audioFrame);
|
||||||
|
|
||||||
// Apply linear step function that ramps in/out the audio samples in audioFrame
|
// Apply linear step function that ramps in/out the audio samples in audioFrame
|
||||||
void RampIn(AudioFrame& audioFrame);
|
void RampIn(AudioFrame& audioFrame);
|
||||||
|
|||||||
@ -508,7 +508,7 @@ class AudioFrame {
|
|||||||
void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
|
void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
|
||||||
size_t samples_per_channel, int sample_rate_hz,
|
size_t samples_per_channel, int sample_rate_hz,
|
||||||
SpeechType speech_type, VADActivity vad_activity,
|
SpeechType speech_type, VADActivity vad_activity,
|
||||||
size_t num_channels = 1, uint32_t energy = -1);
|
size_t num_channels = 1);
|
||||||
|
|
||||||
AudioFrame& Append(const AudioFrame& rhs);
|
AudioFrame& Append(const AudioFrame& rhs);
|
||||||
|
|
||||||
@ -535,11 +535,6 @@ class AudioFrame {
|
|||||||
size_t num_channels_;
|
size_t num_channels_;
|
||||||
SpeechType speech_type_;
|
SpeechType speech_type_;
|
||||||
VADActivity vad_activity_;
|
VADActivity vad_activity_;
|
||||||
// Note that there is no guarantee that |energy_| is correct. Any user of this
|
|
||||||
// member must verify that the value is correct.
|
|
||||||
// TODO(henrike) Remove |energy_|.
|
|
||||||
// See https://code.google.com/p/webrtc/issues/detail?id=3315.
|
|
||||||
uint32_t energy_;
|
|
||||||
bool interleaved_;
|
bool interleaved_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -563,7 +558,6 @@ inline void AudioFrame::Reset() {
|
|||||||
num_channels_ = 0;
|
num_channels_ = 0;
|
||||||
speech_type_ = kUndefined;
|
speech_type_ = kUndefined;
|
||||||
vad_activity_ = kVadUnknown;
|
vad_activity_ = kVadUnknown;
|
||||||
energy_ = 0xffffffff;
|
|
||||||
interleaved_ = true;
|
interleaved_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,8 +568,7 @@ inline void AudioFrame::UpdateFrame(int id,
|
|||||||
int sample_rate_hz,
|
int sample_rate_hz,
|
||||||
SpeechType speech_type,
|
SpeechType speech_type,
|
||||||
VADActivity vad_activity,
|
VADActivity vad_activity,
|
||||||
size_t num_channels,
|
size_t num_channels) {
|
||||||
uint32_t energy) {
|
|
||||||
id_ = id;
|
id_ = id;
|
||||||
timestamp_ = timestamp;
|
timestamp_ = timestamp;
|
||||||
samples_per_channel_ = samples_per_channel;
|
samples_per_channel_ = samples_per_channel;
|
||||||
@ -583,7 +576,6 @@ inline void AudioFrame::UpdateFrame(int id,
|
|||||||
speech_type_ = speech_type;
|
speech_type_ = speech_type;
|
||||||
vad_activity_ = vad_activity;
|
vad_activity_ = vad_activity;
|
||||||
num_channels_ = num_channels;
|
num_channels_ = num_channels;
|
||||||
energy_ = energy;
|
|
||||||
|
|
||||||
const size_t length = samples_per_channel * num_channels;
|
const size_t length = samples_per_channel * num_channels;
|
||||||
assert(length <= kMaxDataSizeSamples);
|
assert(length <= kMaxDataSizeSamples);
|
||||||
@ -606,7 +598,6 @@ inline void AudioFrame::CopyFrom(const AudioFrame& src) {
|
|||||||
speech_type_ = src.speech_type_;
|
speech_type_ = src.speech_type_;
|
||||||
vad_activity_ = src.vad_activity_;
|
vad_activity_ = src.vad_activity_;
|
||||||
num_channels_ = src.num_channels_;
|
num_channels_ = src.num_channels_;
|
||||||
energy_ = src.energy_;
|
|
||||||
interleaved_ = src.interleaved_;
|
interleaved_ = src.interleaved_;
|
||||||
|
|
||||||
const size_t length = samples_per_channel_ * num_channels_;
|
const size_t length = samples_per_channel_ * num_channels_;
|
||||||
@ -701,7 +692,6 @@ inline AudioFrame& AudioFrame::operator+=(const AudioFrame& rhs) {
|
|||||||
data_[i] = ClampToInt16(wrap_guard);
|
data_[i] = ClampToInt16(wrap_guard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
energy_ = 0xffffffff;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +715,6 @@ inline AudioFrame& AudioFrame::operator-=(const AudioFrame& rhs) {
|
|||||||
static_cast<int32_t>(data_[i]) - static_cast<int32_t>(rhs.data_[i]);
|
static_cast<int32_t>(data_[i]) - static_cast<int32_t>(rhs.data_[i]);
|
||||||
data_[i] = ClampToInt16(wrap_guard);
|
data_[i] = ClampToInt16(wrap_guard);
|
||||||
}
|
}
|
||||||
energy_ = 0xffffffff;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user