blob: b13f16e50dc818d1c0861ecc1fdc239c9877a92e [file] [log] [blame]
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_NETEQ_NORMAL_H_
12#define MODULES_AUDIO_CODING_NETEQ_NORMAL_H_
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000013
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000014#include <string.h> // Access to size_t.
15
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000016#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#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 Wiberge40468b2017-11-22 10:42:26 +010022#include "rtc_base/numerics/safe_conversions.h"
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000023
24namespace webrtc {
25
26// Forward declarations.
27class BackgroundNoise;
28class DecoderDatabase;
29class Expand;
30
31// This class provides the "Normal" DSP operation, that is performed when
32// there is no data loss, no need to stretch the timing of the signal, and
33// no other "special circumstances" are at hand.
34class Normal {
35 public:
soren9f2c18e2017-04-10 02:22:46 -070036 Normal(int fs_hz,
37 DecoderDatabase* decoder_database,
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000038 const BackgroundNoise& background_noise,
39 Expand* expand)
40 : fs_hz_(fs_hz),
41 decoder_database_(decoder_database),
42 background_noise_(background_noise),
soren9f2c18e2017-04-10 02:22:46 -070043 expand_(expand),
44 samples_per_ms_(rtc::CheckedDivExact(fs_hz_, 1000)),
45 default_win_slope_Q14_(
46 rtc::dchecked_cast<uint16_t>((1 << 14) / samples_per_ms_)) {}
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000047
48 virtual ~Normal() {}
49
50 // Performs the "Normal" operation. The decoder data is supplied in |input|,
51 // having |length| samples in total for all channels (interleaved). The
52 // result is written to |output|. The number of channels allocated in
53 // |output| defines the number of channels that will be used when
54 // de-interleaving |input|. |last_mode| contains the mode used in the previous
Henrik Lundin6dc82e82018-05-22 10:40:23 +020055 // GetAudio call (i.e., not the current one).
Yves Gerey665174f2018-06-19 15:03:05 +020056 int Process(const int16_t* input,
57 size_t length,
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000058 Modes last_mode,
henrik.lundin@webrtc.orgfd11bbf2013-09-30 20:38:44 +000059 AudioMultiVector* output);
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000060
61 private:
62 int fs_hz_;
63 DecoderDatabase* decoder_database_;
64 const BackgroundNoise& background_noise_;
65 Expand* expand_;
soren9f2c18e2017-04-10 02:22:46 -070066 const size_t samples_per_ms_;
67 const int16_t default_win_slope_Q14_;
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000068
henrikg3c089d72015-09-16 05:37:44 -070069 RTC_DISALLOW_COPY_AND_ASSIGN(Normal);
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000070};
71
72} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020073#endif // MODULES_AUDIO_CODING_NETEQ_NORMAL_H_