aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample/swresample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-04 20:25:43 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-04 20:40:42 +0100
commita6af5da7a2f817d52ea00e2aa93ccf5804afa3e0 (patch)
tree9f9d008b1a680ad44b4269e8041ce68db87fe514 /libswresample/swresample.c
parentf3008f30fb58f8df291c61fecd903e38bd1b12f8 (diff)
downloadffmpeg-a6af5da7a2f817d52ea00e2aa93ccf5804afa3e0.tar.gz
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>
Diffstat (limited to 'libswresample/swresample.c')
-rw-r--r--libswresample/swresample.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 30c34348e4..93c96ceb6a 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -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);