1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ 12 #define MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ 13 14 #include <stdint.h> 15 #include <string.h> // Access to size_t. 16 17 #include "api/neteq/neteq.h" 18 #include "rtc_base/checks.h" 19 #include "rtc_base/constructor_magic.h" 20 #include "rtc_base/numerics/safe_conversions.h" 21 22 namespace webrtc { 23 24 // Forward declarations. 25 class AudioMultiVector; 26 class BackgroundNoise; 27 class DecoderDatabase; 28 class Expand; 29 30 // This class provides the "Normal" DSP operation, that is performed when 31 // there is no data loss, no need to stretch the timing of the signal, and 32 // no other "special circumstances" are at hand. 33 class Normal { 34 public: Normal(int fs_hz,DecoderDatabase * decoder_database,const BackgroundNoise & background_noise,Expand * expand)35 Normal(int fs_hz, 36 DecoderDatabase* decoder_database, 37 const BackgroundNoise& background_noise, 38 Expand* expand) 39 : fs_hz_(fs_hz), 40 decoder_database_(decoder_database), 41 background_noise_(background_noise), 42 expand_(expand), 43 samples_per_ms_(rtc::CheckedDivExact(fs_hz_, 1000)), 44 default_win_slope_Q14_( 45 rtc::dchecked_cast<uint16_t>((1 << 14) / samples_per_ms_)) {} 46 ~Normal()47 virtual ~Normal() {} 48 49 // Performs the "Normal" operation. The decoder data is supplied in |input|, 50 // having |length| samples in total for all channels (interleaved). The 51 // result is written to |output|. The number of channels allocated in 52 // |output| defines the number of channels that will be used when 53 // de-interleaving |input|. |last_mode| contains the mode used in the previous 54 // GetAudio call (i.e., not the current one). 55 int Process(const int16_t* input, 56 size_t length, 57 NetEq::Mode last_mode, 58 AudioMultiVector* output); 59 60 private: 61 int fs_hz_; 62 DecoderDatabase* decoder_database_; 63 const BackgroundNoise& background_noise_; 64 Expand* expand_; 65 const size_t samples_per_ms_; 66 const int16_t default_win_slope_Q14_; 67 68 RTC_DISALLOW_COPY_AND_ASSIGN(Normal); 69 }; 70 71 } // namespace webrtc 72 #endif // MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ 73