Backport Hermite Resampler bypass code from Libretro version

This commit is contained in:
Dwedit 2018-06-06 19:45:52 -05:00
parent e4f1a75279
commit 412c655432
1 changed files with 13 additions and 0 deletions

View File

@ -66,6 +66,13 @@ class HermiteResampler : public Resampler
void
read (short *data, int num_samples)
{
//If we are outputting the exact same ratio as the input, pull directly from the input buffer
if (r_step == 1.0)
{
ring_buffer::pull((unsigned char*)data, num_samples * sizeof(short));
return;
}
assert((num_samples & 1) == 0); // resampler always processes both stereo samples
int i_position = start >> 1;
int max_samples = buffer_size >> 1;
@ -121,6 +128,12 @@ class HermiteResampler : public Resampler
inline int
avail (void)
{
//If we are outputting the exact same ratio as the input, find out directly from the input buffer
if (r_step == 1.0)
{
return (ring_buffer::space_filled() + sizeof(short) - 1) / sizeof(short);
}
return (int) floor (((size >> 2) - r_frac) / r_step) * 2;
}
};