summaryrefslogtreecommitdiff
path: root/libswresample/resample.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2014-05-27 08:39:12 -0400
committerMichael Niedermayer <michaelni@gmx.at>2014-06-02 15:06:24 +0200
commitcdfd9717edac118968e63e6f83c3e45a7e337833 (patch)
tree7e3a0b8f80e11182ccb6b459168f2d235d672d27 /libswresample/resample.c
parentbfb3ed1a9d5dafdc185080fdd88d02ff7221d30a (diff)
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 <michaelni@gmx.at> I could not reproduce any off by 1 error, results are bit exact (michael)
Diffstat (limited to 'libswresample/resample.c')
-rw-r--r--libswresample/resample.c10
1 files changed, 10 insertions, 0 deletions
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; i<dst->ch_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;
}