audioquantize: fix 8-pole noise shaping
authorWim Taymans <wtaymans@redhat.com>
Wed, 28 Oct 2015 10:32:57 +0000 (11:32 +0100)
committerWim Taymans <wtaymans@redhat.com>
Wed, 28 Oct 2015 10:37:43 +0000 (11:37 +0100)
Fix the 8-pole noise shaping error update. We were mixing errors from
different channels.

gst/audioconvert/gstaudioquantize.c

index 91a8c12..d3df42c 100644 (file)
@@ -296,15 +296,14 @@ static const gdouble ns_high_coeffs[] = {
 #define ADD_NS_HIGH()                                                   \
         cur_error = 0.0;                                                \
         for (j = 0; j < 8; j++)                                         \
-          cur_error += errors[chan_pos + j] * ns_high_coeffs[j];          \
+          cur_error += errors[chan_pos*8 + j] * ns_high_coeffs[j];      \
         tmp -= cur_error;                                               \
         orig = tmp;
 
 #define UPDATE_ERROR_HIGH()                                             \
         for (j = 7; j > 0; j--)                                         \
-          errors[chan_pos + j] = errors[chan_pos + j-1];                \
-        errors[chan_pos] = (*dst)/factor - orig;
-
+          errors[chan_pos*8 + j] = errors[chan_pos*8 + j-1];            \
+        errors[chan_pos*8] = (*dst)/factor - orig;
 
 MAKE_QUANTIZE_FUNC_I (int_none_none, NONE_FUNC, NONE_FUNC, ROUND);
 MAKE_QUANTIZE_FUNC_I (int_rpdf_none, INIT_DITHER_RPDF_I, ADD_DITHER_RPDF_I,