[vlc-devel] commit: ugly resampler: no need to allocate a buffer when down-sampling ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 30 14:43:00 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan 30 15:31:31 2010 +0200| [2e12c3f36dbbf65822bea82ec6338e95c8d4dffa] | committer: Rémi Denis-Courmont 

ugly resampler: no need to allocate a buffer when down-sampling

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

 modules/audio_filter/resampler/ugly.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/audio_filter/resampler/ugly.c b/modules/audio_filter/resampler/ugly.c
index fbc0772..e3a33f4 100644
--- a/modules/audio_filter/resampler/ugly.c
+++ b/modules/audio_filter/resampler/ugly.c
@@ -90,9 +90,12 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
                                     / p_filter->fmt_in.audio.i_rate;
     unsigned int i_sample_bytes = i_nb_channels * sizeof(int32_t);
 
-    block_t *p_out_buf = block_Alloc( i_out_nb * i_sample_bytes );
-    if( !p_out_buf )
-        goto out;
+    if( p_filter->fmt_out.audio.i_rate > p_filter->fmt_in.audio.i_rate )
+    {
+        p_out_buf = block_Alloc( i_out_nb * i_sample_bytes );
+        if( !p_out_buf )
+            goto out;
+    }
 
     int32_t *p_out = (int32_t*)p_out_buf->p_buffer;
     const int32_t *p_in = (int32_t*)p_in_buf->p_buffer;
@@ -120,7 +123,9 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
     p_out_buf->i_pts = p_in_buf->i_pts;
     p_out_buf->i_length = p_out_buf->i_nb_samples *
         1000000 / p_filter->fmt_out.audio.i_rate;
+
+    if( p_in_buf != p_out_buf )
 out:
-    block_Release( p_in_buf );
+        block_Release( p_in_buf );
     return p_out_buf;
 }




More information about the vlc-devel mailing list