From cdfd9717edac118968e63e6f83c3e45a7e337833 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 27 May 2014 08:39:12 -0400 Subject: swr: move compensation_distance handling to swri_resample caller. I think there's an off-by-one in terms of the switchpoint where we switch from dst_incr to ideal_dst_incr, I don't think that's a massive issue, but just be aware of that. It's probably trivial to prevent but I don't care. Signed-off-by: Michael Niedermayer I could not reproduce any off by 1 error, results are bit exact (michael) --- libswresample/resample.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libswresample/resample.c') diff --git a/libswresample/resample.c b/libswresample/resample.c index 0fef28373b..a657a0394e 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -336,6 +336,9 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A int av_unused mm_flags = av_get_cpu_flags(); int need_emms= 0; + if (c->compensation_distance) + dst_size = FFMIN(dst_size, c->compensation_distance); + for(i=0; ich_count; i++){ #if HAVE_MMXEXT_INLINE #if HAVE_SSE2_INLINE @@ -366,6 +369,13 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A } if(need_emms) emms_c(); + + if (c->compensation_distance) { + c->compensation_distance -= ret; + if (!c->compensation_distance) + c->dst_incr = c->ideal_dst_incr / c->src_incr; + } + return ret; } -- cgit v1.2.3