[vlc-commits] soxr: factor output len calculation
Thomas Guillem
git at videolan.org
Tue Nov 3 16:26:45 CET 2015
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Nov 2 15:51:01 2015 +0100| [dfbb6e18508d981007b21196ad96fb79253ad162] | committer: Thomas Guillem
soxr: factor output len calculation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dfbb6e18508d981007b21196ad96fb79253ad162
---
modules/audio_filter/resampler/soxr.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/audio_filter/resampler/soxr.c b/modules/audio_filter/resampler/soxr.c
index 128bea5..3a84960 100644
--- a/modules/audio_filter/resampler/soxr.c
+++ b/modules/audio_filter/resampler/soxr.c
@@ -212,6 +212,14 @@ Close( vlc_object_t *p_obj )
free( p_sys );
}
+static size_t
+SoXR_GetOutLen( size_t i_ilen, double f_ratio )
+{
+ /* Processed output len might be a little bigger than expected. Indeed SoXR
+ * can hold a few samples to meet the need of the resampling filter. */
+ return lrint( ( i_ilen + 2 ) * f_ratio * 11. / 10. );
+}
+
static block_t *
Resample( filter_t *p_filter, block_t *p_in )
{
@@ -244,13 +252,12 @@ Resample( filter_t *p_filter, block_t *p_in )
if( f_ratio == 1.0f )
return p_in;
- /* processed output len might be a little bigger than expected */
- i_olen = lrint( ( i_ilen + 2 ) * f_ratio * 11. / 10. );
+ i_olen = SoXR_GetOutLen( i_ilen, f_ratio );
soxr_set_io_ratio( p_sys->soxr, 1 / f_ratio, i_olen );
}
else
- i_olen = lrint( i_ilen * p_sys->f_fixed_ratio );
+ i_olen = SoXR_GetOutLen( i_ilen, p_sys->f_fixed_ratio );
/* Use input buffer as output if there is enough room */
block_t *p_out = i_ilen >= i_olen ? p_in
More information about the vlc-commits
mailing list