Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take into account the filter size when calculating the delay #122

Closed
mmomtchev opened this issue Nov 30, 2023 · 1 comment · Fixed by #123
Closed

Take into account the filter size when calculating the delay #122

mmomtchev opened this issue Nov 30, 2023 · 1 comment · Fixed by #123

Comments

@mmomtchev
Copy link
Contributor

When calculating the number of samples that AudioResampler::pop will return, the filter size must be taken into account:

auto delay = swr_get_delay(m_raw, m_dstRate);

libswresample uses a filter and needs a number of bytes after the end of the sample to be able to resample - 16 in my case.

Otherwise, it risks returning partial frames.

The total value is available in SwrContext->filter_size, the number of samples needed is half that.

Ref: https://stackoverflow.com/questions/39587839/libswresample-swr-convert-not-producing-enough-samples

@h4tr3d
Copy link
Owner

h4tr3d commented Dec 1, 2023

Sounds like this field was added a far ago:

da9587952a8 (Michael Niedermayer 2012-04-26 01:35:22 +0200 127)     int filter_size;                                /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */

approve! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants