diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-21 16:56:14 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-21 16:56:22 +0200 |
commit | 6e3830cca297996736784016a8bc908f8cb98cf3 (patch) | |
tree | 6fc159bb36e4aa048d851a3892b7c33d88124721 | |
parent | 6a356801952b6c38042ef267808dbacbdb700eef (diff) | |
parent | d21bf0d27b547adcaabaa28d475e6b9f97dfe20a (diff) | |
download | ffmpeg-6e3830cca297996736784016a8bc908f8cb98cf3.tar.gz |
Merge commit 'd21bf0d27b547adcaabaa28d475e6b9f97dfe20a' into release/1.1
* commit 'd21bf0d27b547adcaabaa28d475e6b9f97dfe20a':
resample: fix avresample_get_delay() return value
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavresample/resample.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavresample/resample.c b/libavresample/resample.c index dc121fe56d..047572bcb9 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); } |