Commit 52c57e93 authored by conrad's avatar conrad

oggzinfo: fix overflow in standard deviation calculation, and avoid a divide

by zero in the unlikely case where we have only one packet.
Patch from ogg.k.ogg.k


git-svn-id: http://svn.annodex.net/liboggz/trunk@3547 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4c445365
......@@ -108,7 +108,7 @@ struct _OI_Stats {
/* Pass 2 */
long length_avg;
long length_deviation_total;
ogg_int64_t length_deviation_total;
double length_stddev;
};
......@@ -313,9 +313,13 @@ oi_stats_stddev (OI_Stats * stats)
{
double variance;
variance = (double)stats->length_deviation_total / (double)(stats->count - 1);
stats->length_stddev = sqrt (variance);
if (stats->count <= 1) {
stats->length_stddev = 0.0;
}
else {
variance = (double)stats->length_deviation_total / (double)(stats->count - 1);
stats->length_stddev = sqrt (variance);
}
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment