On 2017-08-22 03:23, Tyler Jones wrote:
+
+/**
+ * Calculate the variance of a block of samples
+ *
+ * @param in Array of input samples
+ * @param length Number of input samples being analyzed
+ * @return The variance for the current block
+ */
+static float variance(const float *in, int length, AVFloatDSPContext *fdsp)
+{
+ int i;
+ float mean = 0.0f, square_sum = 0.0f;
+
+ for (i = 0; i < length; i++) {
+ mean += in[i];
+ }
+
+ square_sum = fdsp->scalarproduct_float(in, in, length);
+
+ mean /= length;
+ return (square_sum - length * mean * mean) / (length - 1);
+}
Isn't this method much more numerically unstable compared to the naïve
method? Might not matter too much when the source data is 16-bit, but
throwing it out there anyway
DSP methods for computing mean and variance could be a good project for
someone wanting to learn
/Tomas
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel