| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef COMMON_AUDIO_RESAMPLER_INCLUDE_RESAMPLER_H_ |
| 16 |
#define COMMON_AUDIO_RESAMPLER_INCLUDE_RESAMPLER_H_ |
| 17 |
|
| 18 |
#include <stddef.h> |
| 19 |
#include <stdint.h> |
| 20 |
|
| 21 |
namespace webrtc { |
| 22 |
|
| 23 |
|
| 24 |
class Resampler { |
| 25 |
public: |
| 26 |
Resampler(); |
| 27 |
Resampler(int inFreq, int outFreq, size_t num_channels); |
| 28 |
~Resampler(); |
| 29 |
|
| 30 |
|
| 31 |
int Reset(int inFreq, int outFreq, size_t num_channels); |
| 32 |
|
| 33 |
|
| 34 |
int ResetIfNeeded(int inFreq, int outFreq, size_t num_channels); |
| 35 |
|
| 36 |
|
| 37 |
int Push(const int16_t* samplesIn, |
| 38 |
size_t lengthIn, |
| 39 |
int16_t* samplesOut, |
| 40 |
size_t maxLen, |
| 41 |
size_t& outLen); |
| 42 |
|
| 43 |
private: |
| 44 |
enum ResamplerMode { |
| 45 |
kResamplerMode1To1, |
| 46 |
kResamplerMode1To2, |
| 47 |
kResamplerMode1To3, |
| 48 |
kResamplerMode1To4, |
| 49 |
kResamplerMode1To6, |
| 50 |
kResamplerMode1To12, |
| 51 |
kResamplerMode2To3, |
| 52 |
kResamplerMode2To11, |
| 53 |
kResamplerMode4To11, |
| 54 |
kResamplerMode8To11, |
| 55 |
kResamplerMode11To16, |
| 56 |
kResamplerMode11To32, |
| 57 |
kResamplerMode2To1, |
| 58 |
kResamplerMode3To1, |
| 59 |
kResamplerMode4To1, |
| 60 |
kResamplerMode6To1, |
| 61 |
kResamplerMode12To1, |
| 62 |
kResamplerMode3To2, |
| 63 |
kResamplerMode11To2, |
| 64 |
kResamplerMode11To4, |
| 65 |
kResamplerMode11To8 |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
static int ComputeResamplerMode(int in_freq_hz, |
| 71 |
int out_freq_hz, |
| 72 |
ResamplerMode* mode); |
| 73 |
|
| 74 |
|
| 75 |
void* state1_; |
| 76 |
void* state2_; |
| 77 |
void* state3_; |
| 78 |
|
| 79 |
|
| 80 |
int16_t* in_buffer_; |
| 81 |
int16_t* out_buffer_; |
| 82 |
size_t in_buffer_size_; |
| 83 |
size_t out_buffer_size_; |
| 84 |
size_t in_buffer_size_max_; |
| 85 |
size_t out_buffer_size_max_; |
| 86 |
|
| 87 |
int my_in_frequency_khz_; |
| 88 |
int my_out_frequency_khz_; |
| 89 |
ResamplerMode my_mode_; |
| 90 |
size_t num_channels_; |
| 91 |
|
| 92 |
|
| 93 |
Resampler* helper_left_; |
| 94 |
Resampler* helper_right_; |
| 95 |
}; |
| 96 |
|
| 97 |
} |
| 98 |
|
| 99 |
#endif |