Skip to content

Commit ee2bdab

Browse files
Audio: Bugfix: Optimize level_update function and improve comments
Use int32_t instead of int64_t to improve performance in level_update. Improve comments in max_mic_distance function to better explain the distance calculation between all possible microphone pairs. Correct the typo in line_array_mode_check function. Signed-off-by: Shriram Shastry <malladi.sastry@intel.com> Address reviewer comments: Improve comments in max_mic_distance and correct typo in line_array_mode_check
1 parent 8adadca commit ee2bdab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/audio/tdfb/tdfb_direction.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ static int16_t max_mic_distance(struct tdfb_comp_data *cd)
125125

126126
/* Max lag based on largest array dimension. Microphone coordinates are Q4.12 meters */
127127
for (i = 0; i < cd->config->num_mic_locations; i++) {
128-
/* Start from i+1 halves the amount of iteration & to eliminate redundant checks */
128+
/* Calculate distances between all possible microphone pairs to
129+
* find the maximum distance
130+
*/
129131
for (j = i + 1; j < cd->config->num_mic_locations; j++) {
130132
dx = cd->mic_locations[i].x - cd->mic_locations[j].x;
131133
dy = cd->mic_locations[i].y - cd->mic_locations[j].y;
@@ -155,7 +157,7 @@ static bool line_array_mode_check(struct tdfb_comp_data *cd)
155157

156158
/* Cross product of vectors AB and AC is (0, 0, 0) if they are co-linear.
157159
* Form vector AB(a,b,c) from x(i+1) - x(i), y(i+1) - y(i), z(i+1) - z(i)
158-
* Form vector AC(d,e,f) from x(i+2) - x(i), y(i+2) - y(1), z(i+2) - z(i)
160+
* Form vector AC(d,e,f) from x(i+2) - x(i), y(i+2) - y(i), z(i+2) - z(i)
159161
*/
160162
for (i = 0; i < num_mic_locations - 2; i++) {
161163
a = cd->mic_locations[i + 1].x - cd->mic_locations[i].x;
@@ -280,9 +282,9 @@ static void level_update(struct tdfb_comp_data *cd, int frames, int ch_count, in
280282
/* Calculate mean square level */
281283
for (n = 0; n < frames; n++) {
282284
s = *p;
285+
tmp += ((int32_t)s * s);
283286
p += ch_count;
284287
tdfb_cinc_s16(&p, cd->direction.d_end, cd->direction.d_size);
285-
tmp += ((int64_t)s * s);
286288
}
287289

288290
/* Calculate mean square power */

0 commit comments

Comments
 (0)