[FFmpeg-cvslog] avfilter/af_silenceremove: add asserts to check for NaNs

Paul B Mahol git at videolan.org
Wed Sep 8 11:47:19 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Sep  8 09:42:27 2021 +0200| [c3e11e3092201e7cb98fb5e342705fa5d0c811df] | committer: Paul B Mahol

avfilter/af_silenceremove: add asserts to check for NaNs

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c3e11e3092201e7cb98fb5e342705fa5d0c811df
---

 libavfilter/af_silenceremove.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c
index 77a0b2e2fb..f2f563c5cd 100644
--- a/libavfilter/af_silenceremove.c
+++ b/libavfilter/af_silenceremove.c
@@ -23,6 +23,7 @@
 
 #include <float.h> /* DBL_MAX */
 
+#include "libavutil/avassert.h"
 #include "libavutil/opt.h"
 #include "libavutil/timestamp.h"
 #include "audio.h"
@@ -233,6 +234,7 @@ static double compute_rms_double(SilenceRemoveContext *s, AVFrame *frame, int ch
     new_sum -= wsample;
     new_sum += sample * sample;
 
+    av_assert2(new_sum >= 0.);
     return sqrt(new_sum / s->window_duration);
 }
 
@@ -260,6 +262,7 @@ static double compute_rms_float(SilenceRemoveContext *s, AVFrame *frame, int ch,
     new_sum -= wsample;
     new_sum += sample * sample;
 
+    av_assert2(new_sum >= 0.f);
     return sqrtf(new_sum / s->window_duration);
 }
 
@@ -341,6 +344,7 @@ static double compute_rms_doublep(SilenceRemoveContext *s, AVFrame *frame, int c
     new_sum -= wsample;
     new_sum += sample * sample;
 
+    av_assert2(new_sum >= 0.);
     return sqrt(new_sum / s->window_duration);
 }
 
@@ -368,6 +372,7 @@ static double compute_rms_floatp(SilenceRemoveContext *s, AVFrame *frame, int ch
     new_sum -= wsample;
     new_sum += sample * sample;
 
+    av_assert2(new_sum >= 0.f);
     return sqrtf(new_sum / s->window_duration);
 }
 



More information about the ffmpeg-cvslog mailing list