swresample: use the internal buffer for resampling the last few samples

Fixes out of array read
Fixes Ticket3193

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-12-04 20:25:43 +01:00
parent f3008f30fb
commit a6af5da7a2

View File

@ -534,6 +534,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
AudioData in, out, tmp;
int ret_sum=0;
int border=0;
int padless = ARCH_X86 && s->engine == SWR_ENGINE_SWR ? 7 : 0;
av_assert1(s->in_buffer.ch_count == in_param->ch_count);
av_assert1(s->in_buffer.planar == in_param->planar);
@ -564,9 +565,9 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
}
}
if((s->flushed || in_count) && !s->in_buffer_count){
if((s->flushed || in_count > padless) && !s->in_buffer_count){
s->in_buffer_index=0;
ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, in_count, &consumed);
ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, FFMAX(in_count-padless, 0), &consumed);
out_count -= ret;
ret_sum += ret;
buf_set(&out, &out, ret);
@ -598,6 +599,10 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
s->resample_in_constraint= 0;
if(s->in_buffer_count != count || in_count)
continue;
if (padless) {
padless = 0;
continue;
}
}
break;
}while(1);