Commit 4f16153d authored by Michael Niedermayer's avatar Michael Niedermayer

swr: allow flushing in multiple steps if the output is too small.

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 8bf95e8b
...@@ -435,19 +435,22 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun ...@@ -435,19 +435,22 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
if(!in_arg){ if(!in_arg){
if(s->in_buffer_count){ if(s->in_buffer_count){
AudioData *a= &s->in_buffer; if (!s->flushed) {
int i, j, ret; AudioData *a= &s->in_buffer;
if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0) int i, j, ret;
return ret; if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0)
av_assert0(a->planar); return ret;
for(i=0; i<a->ch_count; i++){ av_assert0(a->planar);
for(j=0; j<s->in_buffer_count; j++){ for(i=0; i<a->ch_count; i++){
memcpy(a->ch[i] + (s->in_buffer_index+s->in_buffer_count+j )*a->bps, for(j=0; j<s->in_buffer_count; j++){
a->ch[i] + (s->in_buffer_index+s->in_buffer_count-j-1)*a->bps, a->bps); 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;
s->flushed = 1;
} }
s->in_buffer_count += (s->in_buffer_count+1)/2;
s->resample_in_constraint = 0;
}else{ }else{
return 0; return 0;
} }
......
...@@ -64,6 +64,7 @@ struct SwrContext { ...@@ -64,6 +64,7 @@ struct SwrContext {
int in_buffer_index; ///< cached buffer position int in_buffer_index; ///< cached buffer position
int in_buffer_count; ///< cached buffer length int in_buffer_count; ///< cached buffer length
int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise
int flushed; ///< 1 if data is to be flushed and no further input is expected
struct AudioConvert *in_convert; ///< input conversion context struct AudioConvert *in_convert; ///< input conversion context
struct AudioConvert *out_convert; ///< output conversion context struct AudioConvert *out_convert; ///< output conversion context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment