mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:28:46 +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);
|
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 getMinInput(int outputFrames);
|
||||||
int getMaxInput(int outputFrames);
|
int getMaxInput(int outputFrames);
|
||||||
|
|
||||||
|
int getExactInput(int outputFrames);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float* _polyphaseFilter;
|
float* _polyphaseFilter;
|
||||||
int* _stepTable;
|
int* _stepTable;
|
||||||
|
|
Loading…
Reference in a new issue