[FFmpeg-devel] [PATCH] af_volume: fix integer clip

Zhao Zhili quinkblack at foxmail.com
Sun Jan 26 18:12:46 EET 2020


---
Or specify an upper limit on volume. What do you think?

 libavfilter/af_volume.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 213c57195a..029925cbfb 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -200,7 +200,7 @@ static inline void scale_samples_s16(uint8_t *dst, const uint8_t *src,
     int16_t *smp_dst       = (int16_t *)dst;
     const int16_t *smp_src = (const int16_t *)src;
     for (i = 0; i < nb_samples; i++)
-        smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
+        smp_dst[i] = (int16_t)av_clip64(((int64_t)smp_src[i] * volume + 128) >> 8, INT16_MIN, INT16_MAX);
 }
 
 static inline void scale_samples_s16_small(uint8_t *dst, const uint8_t *src,
-- 
2.24.0



More information about the ffmpeg-devel mailing list