diff mbox series

[FFmpeg-devel,06/12] avradio/avformat/sdrdemux: run clip check on the correct samples

Message ID 20230730221131.1205193-6-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/12] avradio/avformat/sdrdemux: Move agc_gain into local variable | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Michael Niedermayer July 30, 2023, 10:11 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/sdrdemux.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/sdrdemux.c b/libavformat/sdrdemux.c
index 44a6489bd2..69349add7b 100644
--- a/libavformat/sdrdemux.c
+++ b/libavformat/sdrdemux.c
@@ -1153,10 +1153,9 @@  static int demodulate_fm(SDRContext *sdr, Station *station, AVStream *st, AVPack
             sst->out_buf[2*i+0] =
             sst->out_buf[2*i+1] = m;
         }
-
-        if (fabs(sst->out_buf[i]) > clip) {
-            av_log(sdr->avfmt, AV_LOG_WARNING, "CLIP %f\n", sst->out_buf[i]);
-            clip = fabs(sst->out_buf[i]) * 1.1;
+        if (fmax(fabs(sst->out_buf[2*i+0]), fabs(sst->out_buf[2*i+1])) > clip) {
+            av_log(sdr->avfmt, AV_LOG_WARNING, "CLIP %f %f\n", sst->out_buf[2*i+0], sst->out_buf[2*i+1]);
+            clip = fmax(fabs(sst->out_buf[2*i+0]), fabs(sst->out_buf[2*i+1])) * 1.1;
         }
     }