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 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 15 | #include <string.h> // Access to size_t. |
| 16 | |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 17 | #include "api/neteq/neteq.h" |
Pablo Barrera González | ff0e01f | 2021-02-10 10:38:50 +0100 | [diff] [blame] | 18 | #include "modules/audio_coding/neteq/statistics_calculator.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/checks.h" |
Karl Wiberg | e40468b | 2017-11-22 10:42:26 +0100 | [diff] [blame] | 20 | #include "rtc_base/numerics/safe_conversions.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Forward declarations. |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 25 | class AudioMultiVector; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 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: |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 35 | Normal(int fs_hz, |
| 36 | DecoderDatabase* decoder_database, |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 37 | const BackgroundNoise& background_noise, |
Pablo Barrera González | ff0e01f | 2021-02-10 10:38:50 +0100 | [diff] [blame] | 38 | Expand* expand, |
| 39 | StatisticsCalculator* statistics) |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 40 | : fs_hz_(fs_hz), |
| 41 | decoder_database_(decoder_database), |
| 42 | background_noise_(background_noise), |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 43 | expand_(expand), |
| 44 | samples_per_ms_(rtc::CheckedDivExact(fs_hz_, 1000)), |
| 45 | default_win_slope_Q14_( |
Pablo Barrera González | ff0e01f | 2021-02-10 10:38:50 +0100 | [diff] [blame] | 46 | rtc::dchecked_cast<uint16_t>((1 << 14) / samples_per_ms_)), |
| 47 | statistics_(statistics) {} |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 48 | |
| 49 | virtual ~Normal() {} |
| 50 | |
Byoungchan Lee | 604fd2f | 2022-01-21 09:49:39 +0900 | [diff] [blame^] | 51 | Normal(const Normal&) = delete; |
| 52 | Normal& operator=(const Normal&) = delete; |
| 53 | |
Artem Titov | d00ce74 | 2021-07-28 20:00:17 +0200 | [diff] [blame] | 54 | // Performs the "Normal" operation. The decoder data is supplied in `input`, |
| 55 | // having `length` samples in total for all channels (interleaved). The |
| 56 | // result is written to `output`. The number of channels allocated in |
| 57 | // `output` defines the number of channels that will be used when |
| 58 | // de-interleaving `input`. `last_mode` contains the mode used in the previous |
Henrik Lundin | 6dc82e8 | 2018-05-22 10:40:23 +0200 | [diff] [blame] | 59 | // GetAudio call (i.e., not the current one). |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 60 | int Process(const int16_t* input, |
| 61 | size_t length, |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame] | 62 | NetEq::Mode last_mode, |
henrik.lundin@webrtc.org | fd11bbf | 2013-09-30 20:38:44 +0000 | [diff] [blame] | 63 | AudioMultiVector* output); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 64 | |
| 65 | private: |
| 66 | int fs_hz_; |
| 67 | DecoderDatabase* decoder_database_; |
| 68 | const BackgroundNoise& background_noise_; |
| 69 | Expand* expand_; |
soren | 9f2c18e | 2017-04-10 02:22:46 -0700 | [diff] [blame] | 70 | const size_t samples_per_ms_; |
| 71 | const int16_t default_win_slope_Q14_; |
Pablo Barrera González | ff0e01f | 2021-02-10 10:38:50 +0100 | [diff] [blame] | 72 | StatisticsCalculator* const statistics_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 76 | #endif // MODULES_AUDIO_CODING_NETEQ_NORMAL_H_ |