tina.legrand@webrtc.org fb389e3b02 This CL is divided in several patches, to make review easier.
Patch Set 1: Removing blanks at end of lines.
Patch Set 2: Removing tabs.
Patch Set 3: Fixing include-guards.
Patch Set 4-7: Formatting files in the list.
Patch Set 8: Formatting CNG.

Patch Set 9: 
* Fixing comments from code review
* Fixing formating in acm_dtmf_playout.cc
* Started fixing formating of acm_g7221.cc. More work needed, so don't spend too much time reviewing.
* Refactored constructor of ACMGenericCodec. Rest of file still to be fixed.
* Fixing break; after return ...; in several files.

Patch Set 10:
* Chaning from reintepret_cast to static_cast in three files, acm_amr.cc, acm_cng.cc and acm_g722.cc
NOTE! Not all files have the right format. That work will continue in separate CLs.

Review URL: http://webrtc-codereview.appspot.com/175002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@881 4adac7df-926f-26a2-2b94-8c16560cd09d
2011-11-03 17:20:10 +00:00

91 lines
2.2 KiB
C++

/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <string.h>
#include "acm_resampler.h"
#include "critical_section_wrapper.h"
#include "resampler.h"
#include "signal_processing_library.h"
#include "trace.h"
namespace webrtc
{
ACMResampler::ACMResampler():
_resamplerCritSect(*CriticalSectionWrapper::CreateCriticalSection())
{
}
ACMResampler::~ACMResampler()
{
delete &_resamplerCritSect;
}
WebRtc_Word16
ACMResampler::Resample10Msec(
const WebRtc_Word16* inAudio,
WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio,
WebRtc_Word32 outFreqHz,
WebRtc_UWord8 numAudioChannels)
{
CriticalSectionScoped cs(_resamplerCritSect);
if(inFreqHz == outFreqHz)
{
memcpy(outAudio, inAudio, (inFreqHz*numAudioChannels / 100) * sizeof(WebRtc_Word16));
return (WebRtc_Word16)(inFreqHz / 100);
}
int maxLen = 480 * numAudioChannels; //max number of samples for 10ms at 48kHz
int lengthIn = (WebRtc_Word16)(inFreqHz / 100) * numAudioChannels;
int outLen;
WebRtc_Word32 ret;
ResamplerType type;
type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo;
ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type);
if (ret < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in reset of resampler");
return -1;
}
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
if (ret < 0 )
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in resampler: resampler.Push");
return -1;
}
WebRtc_Word16 outAudioLenSmpl = (WebRtc_Word16) outLen / numAudioChannels;
return outAudioLenSmpl;
}
void
ACMResampler::SetUniqueId(
WebRtc_Word32 id)
{
CriticalSectionScoped lock(_resamplerCritSect);
_id = id;
}
} // namespace webrtc