Module: libav
Branch: release/9
Commit: d21bf0d27b547adcaabaa28d475e6b9f97dfe20a

Author:    Anton Khirnov <[email protected]>
Committer: Sean McGovern <[email protected]>
Date:      Tue Mar  4 21:18:27 2014 +0100

resample: fix avresample_get_delay() return value

The correct "next" input sample is not the first sample of the
resampling buffer, but the center sample of the filter_length-sized
block at the beginning.

CC:[email protected]

---

 libavresample/resample.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavresample/resample.c b/libavresample/resample.c
index dc121fe..047572b 100644
--- a/libavresample/resample.c
+++ b/libavresample/resample.c
@@ -46,6 +46,7 @@ struct ResampleContext {
     void (*resample_one)(struct ResampleContext *c, int no_filter, void *dst0,
                          int dst_index, const void *src0, int src_size,
                          int index, int frac);
+    int padding_size;
 };
 
 
@@ -211,6 +212,7 @@ ResampleContext 
*ff_audio_resample_init(AVAudioResampleContext *avr)
         goto error;
     c->ideal_dst_incr = c->dst_incr;
 
+    c->padding_size   = (c->filter_length - 1) / 2;
     c->index = -phase_count * ((c->filter_length - 1) / 2);
     c->frac  = 0;
 
@@ -461,8 +463,10 @@ int ff_audio_resample(ResampleContext *c, AudioData *dst, 
AudioData *src)
 
 int avresample_get_delay(AVAudioResampleContext *avr)
 {
+    ResampleContext *c = avr->resample;
+
     if (!avr->resample_needed || !avr->resample)
         return 0;
 
-    return avr->resample->buffer->nb_samples;
+    return FFMAX(c->buffer->nb_samples - c->padding_size, 0);
 }

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to