henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ |
| 12 | #define MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 14 | #include <string.h> // Access to size_t. |
| 15 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "modules/audio_coding/neteq/audio_multi_vector.h" |
| 19 | #include "modules/audio_coding/neteq/defines.h" |
| 20 | #include "rtc_base/checks.h" |
| 21 | #include "rtc_base/constructormagic.h" |
Karl Wiberg | e40468b | 2017-11-22 10:42:26 +0100 | [diff] [blame] | 22 | #include "rtc_base/numerics/safe_conversions.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 23 | #include "typedefs.h" // NOLINT(build/include) |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
| 26 | |
| 27 | // Forward declarations. |
| 28 | class BackgroundNoise; |
| 29 | class DecoderDatabase; |
| 30 | class Expand; |
| 31 | |
| 32 | // This class provides the "Normal" DSP operation, that is performed when |
| 33 | // there is no data loss, no need to stretch the timing of the signal, and |
| 34 | // no other "special circumstances" are at hand. |
| 35 | class Normal { |
| 36 | public: |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 37 | Normal(int fs_hz, |
| 38 | DecoderDatabase* decoder_database, |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 39 | const BackgroundNoise& background_noise, |
| 40 | Expand* expand) |
| 41 | : fs_hz_(fs_hz), |
| 42 | decoder_database_(decoder_database), |
| 43 | background_noise_(background_noise), |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 44 | expand_(expand), |
| 45 | samples_per_ms_(rtc::CheckedDivExact(fs_hz_, 1000)), |
| 46 | default_win_slope_Q14_( |
| 47 | rtc::dchecked_cast<uint16_t>((1 << 14) / samples_per_ms_)) {} |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 48 | |
| 49 | virtual ~Normal() {} |
| 50 | |
| 51 | // Performs the "Normal" operation. The decoder data is supplied in |input|, |
| 52 | // having |length| samples in total for all channels (interleaved). The |
| 53 | // result is written to |output|. The number of channels allocated in |
| 54 | // |output| defines the number of channels that will be used when |
| 55 | // de-interleaving |input|. |last_mode| contains the mode used in the previous |
Henrik Lundin | 6dc82e8 | 2018-05-22 10:40:23 +0200 | [diff] [blame] | 56 | // GetAudio call (i.e., not the current one). |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 57 | int Process(const int16_t* input, |
| 58 | size_t length, |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 59 | Modes last_mode, |
henrik.lundin@webrtc.org | fd11bbf | 2013-09-30 20:38:44 +0000 | [diff] [blame] | 60 | AudioMultiVector* output); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | int fs_hz_; |
| 64 | DecoderDatabase* decoder_database_; |
| 65 | const BackgroundNoise& background_noise_; |
| 66 | Expand* expand_; |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 67 | const size_t samples_per_ms_; |
| 68 | const int16_t default_win_slope_Q14_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 69 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 70 | RTC_DISALLOW_COPY_AND_ASSIGN(Normal); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 74 | #endif // MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ |