Add format members to AudioConverter for DCHECKing.
And use a std::min. Post-commit fixes after: https://review.webrtc.org/30779004/ TBR=kwiberg Review URL: https://webrtc-codereview.appspot.com/25059004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7600 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
e451b756a8
commit
5804936052
@ -43,10 +43,13 @@ void UpmixFromMono(const float* src,
|
||||
} // namespace
|
||||
|
||||
AudioConverter::AudioConverter(int src_channels, int src_frames,
|
||||
int dst_channels, int dst_frames) {
|
||||
int dst_channels, int dst_frames)
|
||||
: src_channels_(src_channels),
|
||||
src_frames_(src_frames),
|
||||
dst_channels_(dst_channels),
|
||||
dst_frames_(dst_frames) {
|
||||
CHECK(dst_channels == src_channels || dst_channels == 1 || src_channels == 1);
|
||||
const int resample_channels = src_channels < dst_channels ? src_channels :
|
||||
dst_channels;
|
||||
const int resample_channels = std::min(src_channels, dst_channels);
|
||||
|
||||
// Prepare buffers as needed for intermediate stages.
|
||||
if (dst_channels < src_channels)
|
||||
@ -66,8 +69,11 @@ void AudioConverter::Convert(const float* const* src,
|
||||
int dst_channels,
|
||||
int dst_frames,
|
||||
float* const* dst) {
|
||||
DCHECK(dst_channels == src_channels || dst_channels == 1 ||
|
||||
src_channels == 1);
|
||||
DCHECK_EQ(src_channels_, src_channels);
|
||||
DCHECK_EQ(src_frames_, src_frames);
|
||||
DCHECK_EQ(dst_channels_, dst_channels);
|
||||
DCHECK_EQ(dst_frames_, dst_frames);;
|
||||
|
||||
if (src_channels == dst_channels && src_frames == dst_frames) {
|
||||
// Shortcut copy.
|
||||
if (src != dst) {
|
||||
|
@ -40,6 +40,10 @@ class AudioConverter {
|
||||
float* const* dest);
|
||||
|
||||
private:
|
||||
const int src_channels_;
|
||||
const int src_frames_;
|
||||
const int dst_channels_;
|
||||
const int dst_frames_;
|
||||
scoped_ptr<ChannelBuffer<float>> downmix_buffer_;
|
||||
ScopedVector<PushSincResampler> resamplers_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user