mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
Add resampler support for downsampling with variable-input constant-output buffering mode
This commit is contained in:
parent
3355a90e7d
commit
d9f12e44dc
2 changed files with 20 additions and 0 deletions
|
@ -1030,3 +1030,21 @@ int AudioSRC::getMaxInput(int outputFrames) {
|
|||
return (int)(((int64_t)outputFrames * _step) >> 32);
|
||||
}
|
||||
}
|
||||
|
||||
// the input frames that will produce exactly outputFrames
|
||||
int AudioSRC::getExactInput(int outputFrames) {
|
||||
//
|
||||
// For upsampling, a correct implementation is more complicated
|
||||
// because it requires early exit of the multirate filter.
|
||||
// This is not currently supported.
|
||||
//
|
||||
if (_upFactor > _downFactor) {
|
||||
return -1;
|
||||
}
|
||||
if (_step == 0) {
|
||||
int64_t offset = ((int64_t)_phase * _downFactor) % _upFactor;
|
||||
return (int)(((int64_t)outputFrames * _downFactor + offset) / _upFactor);
|
||||
} else {
|
||||
return (int)(((int64_t)outputFrames * _step + _offset) >> 32);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
int getMinInput(int outputFrames);
|
||||
int getMaxInput(int outputFrames);
|
||||
|
||||
int getExactInput(int outputFrames);
|
||||
|
||||
private:
|
||||
float* _polyphaseFilter;
|
||||
int* _stepTable;
|
||||
|
|
Loading…
Reference in a new issue