[FFmpeg-devel] [PATCH] swresample/soxr: never return negative delay

wm4 nfxjfg at googlemail.com
Thu Jun 4 19:54:15 CEST 2015


This makes no sense in this context, and can cause swr_get_out_samples()
and swr_get_delay() negative numbers that are not error codes.
---
 libswresample/soxr_resample.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswresample/soxr_resample.c b/libswresample/soxr_resample.c
index 0f75bc5..9597e1f 100644
--- a/libswresample/soxr_resample.c
+++ b/libswresample/soxr_resample.c
@@ -88,7 +88,7 @@ static int process(
 
 static int64_t get_delay(struct SwrContext *s, int64_t base){
     double delay_s = soxr_delay((soxr_t)s->resample) / s->out_sample_rate;
-    return (int64_t)(delay_s * base + .5);
+    return (int64_t)(FFMAX(delay_s, 0) * base + .5);
 }
 
 static int invert_initial_buffer(struct ResampleContext *c, AudioData *dst, const AudioData *src,
-- 
2.1.4



More information about the ffmpeg-devel mailing list