summaryrefslogtreecommitdiff
path: root/libswresample/resample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-18 23:02:10 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-18 23:02:10 +0200
commit4def5d2b64d78a6f15c6c8869c28ece1f823626e (patch)
treec87e238e24d5ed09fae8476808aa0bea3ace5756 /libswresample/resample.c
parent6ba692f8a7110c3960edb4b8e7a6736ee7124e2e (diff)
swr: add swr_get_delay() to find the exact delay the swresampler introduces.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/resample.c')
-rw-r--r--libswresample/resample.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libswresample/resample.c b/libswresample/resample.c
index 868f3eb949..558401c459 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -367,3 +367,18 @@ int swri_multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, Aud
return ret;
}
+
+int64_t swr_get_delay(struct SwrContext *s, int64_t base){
+ ResampleContext *c = s->resample;
+ if(c){
+ int64_t num = s->in_buffer_count - (c->filter_length-1)/2;
+ num <<= c->phase_shift;
+ num -= c->index;
+ num *= c->src_incr;
+ num -= c->frac;
+
+ return av_rescale(num, base, s->in_sample_rate*(int64_t)c->src_incr << c->phase_shift);
+ }else{
+ return (s->in_buffer_count*base + (s->in_sample_rate>>1))/ s->in_sample_rate;
+ }
+}