[FFmpeg-cvslog] swr: Support flushing last samples out.

Michael Niedermayer git at videolan.org
Fri Nov 4 16:41:56 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Nov  4 16:31:51 2011 +0100| [71f5712cb52d970482655b3659156d7c0bed9e70] | committer: Michael Niedermayer

swr: Support flushing last samples out.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71f5712cb52d970482655b3659156d7c0bed9e70
---

 libswresample/swresample.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index d0fb96e..7d864df 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -291,7 +291,26 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
         out_count = in_count;
     }
 
-    fill_audiodata(in ,  (void*)in_arg);
+    if(!in_arg){
+        if(s->in_buffer_count){
+            AudioData *a= &s->in_buffer;
+            int i, j, ret;
+            if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0)
+                return ret;
+            av_assert0(a->planar);
+            for(i=0; i<a->ch_count; i++){
+                for(j=0; j<s->in_buffer_count; j++){
+                    memcpy(a->ch[i] + (s->in_buffer_index+s->in_buffer_count+j  )*a->bps,
+                           a->ch[i] + (s->in_buffer_index+s->in_buffer_count-j-1)*a->bps, a->bps);
+                }
+            }
+            s->in_buffer_count += (s->in_buffer_count+1)/2;
+            s->resample_in_constraint = 0;
+        }else{
+            return 0;
+        }
+    }else
+        fill_audiodata(in ,  (void*)in_arg);
     fill_audiodata(out, out_arg);
 
     if(s->full_convert){
@@ -365,6 +384,8 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
 //FIXME packed doesnt need more than 1 chan here!
         swr_audio_convert(s->out_convert, out, preout, out_count);
     }
+    if(!in_arg)
+        s->in_buffer_count = 0;
     return out_count;
 }
 



More information about the ffmpeg-cvslog mailing list