From 71f5712cb52d970482655b3659156d7c0bed9e70 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 4 Nov 2011 16:31:51 +0100 Subject: [PATCH] swr: Support flushing last samples out. Signed-off-by: Michael Niedermayer --- libswresample/swresample.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index d0fb96e008..7d864dfd48 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; ich_count; i++){ + for(j=0; jin_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; }