aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-04 16:31:51 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-04 16:31:51 +0100
commit71f5712cb52d970482655b3659156d7c0bed9e70 (patch)
tree87b364eb3de80a33d2f3ffb78fb934d145316950
parent259a960f1b74339626f8da890cc261a4043097fe (diff)
downloadffmpeg-71f5712cb52d970482655b3659156d7c0bed9e70.tar.gz
swr: Support flushing last samples out.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libswresample/swresample.c23
1 files changed, 22 insertions, 1 deletions
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; 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;
}