opus_demo: fixes potential division by zero on files with no active frame
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 4 Dec 2015 19:40:50 +0000 (14:40 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 4 Dec 2015 19:40:50 +0000 (14:40 -0500)
src/opus_demo.c

index 173ec51..9e99a3b 100644 (file)
@@ -866,7 +866,7 @@ int main(int argc, char *argv[])
                      1e-3*bits_max*sampling_rate/frame_size);
     if (!decode_only)
        fprintf (stderr, "active bitrate:              %7.3f kb/s\n",
-               1e-3*bits_act*sampling_rate/(frame_size*(double)count_act));
+               1e-3*bits_act*sampling_rate/(1e-15+frame_size*(double)count_act));
     fprintf (stderr, "bitrate standard deviation:  %7.3f kb/s\n",
             1e-3*sqrt(bits2/count - bits*bits/(count*(double)count))*sampling_rate/frame_size);
     /* Close any files to which intermediate results were stored */