[FFmpeg-cvslog] avfilter/af_afftdn: do not profile noise if number of sampled blocks is 0

Paul B Mahol git at videolan.org
Fri Mar 18 12:23:23 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Mar 18 11:21:52 2022 +0100| [b6af56c034759b81985f8ea094e41cbd5f7fecfb] | committer: Paul B Mahol

avfilter/af_afftdn: do not profile noise if number of sampled blocks is 0

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

 libavfilter/af_afftdn.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 75895fa3d9..c66545ac2e 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -125,6 +125,7 @@ typedef struct AudioFFTDeNoiseContext {
 
     int     channels;
     int     sample_noise;
+    int     sample_noise_blocks;
     int     sample_noise_mode;
     float   sample_rate;
     int     buffer_length;
@@ -1039,6 +1040,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
         }
         s->sample_noise_mode = SAMPLE_NONE;
         s->sample_noise = 1;
+        s->sample_noise_blocks = 0;
     }
 
     if (s->sample_noise) {
@@ -1047,6 +1049,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
 
             sample_noise_block(s, dnch, s->winframe, ch);
         }
+        s->sample_noise_blocks++;
     }
 
     if (s->sample_noise_mode == SAMPLE_STOP) {
@@ -1054,11 +1057,14 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
             DeNoiseChannel *dnch = &s->dnch[ch];
             double sample_noise[NB_PROFILE_BANDS];
 
+            if (s->sample_noise_blocks <= 0)
+                break;
             finish_sample_noise(s, dnch, sample_noise);
             set_noise_profile(s, dnch, sample_noise);
             set_parameters(s, dnch, 1, 1);
         }
         s->sample_noise = 0;
+        s->sample_noise_blocks = 0;
         s->sample_noise_mode = SAMPLE_NONE;
     }
 



More information about the ffmpeg-cvslog mailing list