[vlc-commits] soxr: don't handle the case where input is not fully processed

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:58:22 2015 +0100| [c08ef22cc8ad67ee69be21707cc45f5df31495a1] | committer: Thomas Guillem

soxr: don't handle the case where input is not fully processed

Keep it simpler, it shouldn't happen since we alloc an output buffer that is
slightly bigger than expected (in order to have enough room for data that is
held by SoxR).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c08ef22cc8ad67ee69be21707cc45f5df31495a1
---

 modules/audio_filter/resampler/soxr.c |   34 ++-------------------------------
 1 file changed, 2 insertions(+), 32 deletions(-)

diff --git a/modules/audio_filter/resampler/soxr.c b/modules/audio_filter/resampler/soxr.c
index 3a84960..5c7a9a7 100644
--- a/modules/audio_filter/resampler/soxr.c
+++ b/modules/audio_filter/resampler/soxr.c
@@ -82,7 +82,6 @@ struct filter_sys_t
 {
     soxr_t  soxr;
     double  f_fixed_ratio;
-    block_t *p_last_in;
 };
 
 static block_t *Resample( filter_t *, block_t * );
@@ -206,9 +205,6 @@ Close( vlc_object_t *p_obj )
 
     soxr_delete( p_sys->soxr );
 
-    if( unlikely( p_sys->p_last_in ) )
-        block_Release( p_sys->p_last_in );
-
     free( p_sys );
 }
 
@@ -225,20 +221,6 @@ Resample( filter_t *p_filter, block_t *p_in )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    /* Prepend last remaining input buffer to the current one */
-    if( unlikely( p_sys->p_last_in ) )
-    {
-        p_in = block_Realloc( p_in, p_sys->p_last_in->i_buffer, p_in->i_buffer );
-        if( unlikely( p_in == NULL ) )
-            return NULL;
-
-        memcpy( p_in->p_buffer, p_sys->p_last_in->p_buffer,
-                p_sys->p_last_in->i_buffer );
-        p_in->i_nb_samples += p_sys->p_last_in->i_nb_samples;
-        block_Release( p_sys->p_last_in );
-        p_sys->p_last_in = NULL;
-    }
-
     const size_t i_oframesize = p_filter->fmt_out.audio.i_bytes_per_frame;
     const size_t i_ilen = p_in->i_nb_samples;
     size_t i_olen, i_idone, i_odone;
@@ -276,20 +258,8 @@ Resample( filter_t *p_filter, block_t *p_in )
     }
 
     if( unlikely( i_idone < i_ilen ) )
-    {
-        msg_Warn( p_filter, "processed input len < input len, "
-                  "keeping buffer for next Resample call" );
-        const size_t i_done_size = i_idone
-                                 * p_filter->fmt_out.audio.i_bytes_per_frame;
-
-        /* Realloc since p_in can be used as p_out */
-        p_sys->p_last_in = block_Alloc( p_in->i_buffer - i_done_size );
-        if( unlikely( p_sys->p_last_in == NULL ) )
-            goto error;
-        memcpy( p_sys->p_last_in->p_buffer,
-                p_in->p_buffer + i_done_size, p_in->i_buffer - i_done_size );
-        p_sys->p_last_in->i_nb_samples = p_in->i_nb_samples - i_idone;
-    }
+        msg_Err( p_filter, "lost %zd of %zd input frames",
+                 i_ilen - i_idone, i_idone);
 
     p_out->i_buffer = i_odone * i_oframesize;
     p_out->i_nb_samples = i_odone;



More information about the vlc-commits mailing list