ref: a3cfc1510d8caa091bcfec5f9ab8892ae71638c3
parent: ee04582dff89592efbd9b2051f061ffc7f63e8cc
author: Alexander Grund <alexander.grund@tu-dresden.de>
date: Tue Aug 27 05:21:45 EDT 2019
Replace manually unrolled loops by regular ones
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -453,8 +453,8 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 1 < filter->b_len) ;
assert (data_index + 1 < filter->b_end) ;
- left [0] += icoeff * filter->buffer [data_index] ;
- left [1] += icoeff * filter->buffer [data_index + 1] ;
+ for (int ch = 0; ch < 2; ch++)
+ left [ch] += icoeff * filter->buffer [data_index + ch] ;
} ;
filter_index -= increment ;
@@ -476,8 +476,8 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 1 < filter->b_len) ;
assert (data_index + 1 < filter->b_end) ;
- right [0] += icoeff * filter->buffer [data_index] ;
- right [1] += icoeff * filter->buffer [data_index + 1] ;
+ for (int ch = 0; ch < 2; ch++)
+ right [ch] += icoeff * filter->buffer [data_index + ch] ;
filter_index -= increment ;
data_index = data_index - 2 ;
@@ -484,8 +484,8 @@
}
while (filter_index > MAKE_INCREMENT_T (0)) ;
- output [0] = (float) (scale * (left [0] + right [0])) ;
- output [1] = (float) (scale * (left [1] + right [1])) ;
+ for (int ch = 0; ch < 2; ch++)
+ output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_stereo */
static int
@@ -604,10 +604,8 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 3 < filter->b_len) ;
assert (data_index + 3 < filter->b_end) ;
- left [0] += icoeff * filter->buffer [data_index] ;
- left [1] += icoeff * filter->buffer [data_index + 1] ;
- left [2] += icoeff * filter->buffer [data_index + 2] ;
- left [3] += icoeff * filter->buffer [data_index + 3] ;
+ for (int ch = 0; ch < 4; ch++)
+ left [ch] += icoeff * filter->buffer [data_index + ch] ;
} ;
filter_index -= increment ;
@@ -629,20 +627,17 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 3 < filter->b_len) ;
assert (data_index + 3 < filter->b_end) ;
- right [0] += icoeff * filter->buffer [data_index] ;
- right [1] += icoeff * filter->buffer [data_index + 1] ;
- right [2] += icoeff * filter->buffer [data_index + 2] ;
- right [3] += icoeff * filter->buffer [data_index + 3] ;
+ for (int ch = 0; ch < 4; ch++)
+ right [ch] += icoeff * filter->buffer [data_index + ch] ;
+
filter_index -= increment ;
data_index = data_index - 4 ;
}
while (filter_index > MAKE_INCREMENT_T (0)) ;
- output [0] = (float) (scale * (left [0] + right [0])) ;
- output [1] = (float) (scale * (left [1] + right [1])) ;
- output [2] = (float) (scale * (left [2] + right [2])) ;
- output [3] = (float) (scale * (left [3] + right [3])) ;
+ for (int ch = 0; ch < 4; ch++)
+ output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_quad */
static int
@@ -761,12 +756,8 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 5 < filter->b_len) ;
assert (data_index + 5 < filter->b_end) ;
- left [0] += icoeff * filter->buffer [data_index] ;
- left [1] += icoeff * filter->buffer [data_index + 1] ;
- left [2] += icoeff * filter->buffer [data_index + 2] ;
- left [3] += icoeff * filter->buffer [data_index + 3] ;
- left [4] += icoeff * filter->buffer [data_index + 4] ;
- left [5] += icoeff * filter->buffer [data_index + 5] ;
+ for (int ch = 0; ch < 6; ch++)
+ left [ch] += icoeff * filter->buffer [data_index + ch] ;
} ;
filter_index -= increment ;
@@ -788,12 +779,8 @@
icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ;
assert (data_index >= 0 && data_index + 5 < filter->b_len) ;
assert (data_index + 5 < filter->b_end) ;
- right [0] += icoeff * filter->buffer [data_index] ;
- right [1] += icoeff * filter->buffer [data_index + 1] ;
- right [2] += icoeff * filter->buffer [data_index + 2] ;
- right [3] += icoeff * filter->buffer [data_index + 3] ;
- right [4] += icoeff * filter->buffer [data_index + 4] ;
- right [5] += icoeff * filter->buffer [data_index + 5] ;
+ for (int ch = 0; ch < 6; ch++)
+ right [ch] += icoeff * filter->buffer [data_index + ch] ;
filter_index -= increment ;
data_index = data_index - 6 ;
@@ -800,12 +787,8 @@
}
while (filter_index > MAKE_INCREMENT_T (0)) ;
- output [0] = (float) (scale * (left [0] + right [0])) ;
- output [1] = (float) (scale * (left [1] + right [1])) ;
- output [2] = (float) (scale * (left [2] + right [2])) ;
- output [3] = (float) (scale * (left [3] + right [3])) ;
- output [4] = (float) (scale * (left [4] + right [4])) ;
- output [5] = (float) (scale * (left [5] + right [5])) ;
+ for (int ch = 0; ch < 6; ch++)
+ output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_hex */
static int