blob: c764155eff53fc251bad682b2b9f2063333c3072 [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
henrik.lundin@webrtc.org9c55f0f2014-06-09 08:10:28 +000011#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_NORMAL_H_
12#define WEBRTC_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
henrik.lundin@webrtc.org9c55f0f2014-06-09 08:10:28 +000018#include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
19#include "webrtc/modules/audio_coding/neteq/defines.h"
kjellanderc8fa6922017-06-30 14:02:00 -070020#include "webrtc/rtc_base/checks.h"
21#include "webrtc/rtc_base/constructormagic.h"
22#include "webrtc/rtc_base/safe_conversions.h"
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000023#include "webrtc/typedefs.h"
24
25namespace webrtc {
26
27// Forward declarations.
28class BackgroundNoise;
29class DecoderDatabase;
30class 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.
35class Normal {
36 public:
soren9f2c18e2017-04-10 02:22:46 -070037 Normal(int fs_hz,
38 DecoderDatabase* decoder_database,
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000039 const BackgroundNoise& background_noise,
40 Expand* expand)
41 : fs_hz_(fs_hz),
42 decoder_database_(decoder_database),
43 background_noise_(background_noise),
soren9f2c18e2017-04-10 02:22:46 -070044 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.orgd94659d2013-01-29 12:09:21 +000048
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
56 // GetAudio call (i.e., not the current one), and |external_mute_factor| is
57 // a pointer to the mute factor in the NetEqImpl class.
58 int Process(const int16_t* input, size_t length,
59 Modes last_mode,
60 int16_t* external_mute_factor_array,
henrik.lundin@webrtc.orgfd11bbf2013-09-30 20:38:44 +000061 AudioMultiVector* output);
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000062
63 private:
64 int fs_hz_;
65 DecoderDatabase* decoder_database_;
66 const BackgroundNoise& background_noise_;
67 Expand* expand_;
soren9f2c18e2017-04-10 02:22:46 -070068 const size_t samples_per_ms_;
69 const int16_t default_win_slope_Q14_;
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000070
henrikg3c089d72015-09-16 05:37:44 -070071 RTC_DISALLOW_COPY_AND_ASSIGN(Normal);
henrik.lundin@webrtc.orgd94659d2013-01-29 12:09:21 +000072};
73
74} // namespace webrtc
henrik.lundin@webrtc.org9c55f0f2014-06-09 08:10:28 +000075#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NORMAL_H_