swr/dither: fix division by 0
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 14 Jan 2013 00:06:48 +0000 (01:06 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 14 Jan 2013 01:57:00 +0000 (02:57 +0100)
Found-by: Daemon404
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/dither.c

index ae56c8c..d70505c 100644 (file)
@@ -97,7 +97,7 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
     s->dither.ns_pos = 0;
     s->dither.noise_scale=   scale;
     s->dither.ns_scale   =   scale;
-    s->dither.ns_scale_1 = 1/scale;
+    s->dither.ns_scale_1 = scale ? 1/scale : 0;
     memset(s->dither.ns_errors, 0, sizeof(s->dither.ns_errors));
     for (i=0; filters[i].coefs; i++) {
         const filter_t *f = &filters[i];