Skip to content

Commit

Permalink
Audio: Optimize TDFB direction calculation for robustness and perform…
Browse files Browse the repository at this point in the history
…ance

Enhance performance by addressing infinite loops.
Reduce computational overhead by optimizing loops and redundant checks.


Signed-off-by: Shriram Shastry <malladi.sastry@intel.com>
  • Loading branch information
ShriramShastry committed Jun 18, 2024
1 parent 4adec5d commit 3e7956e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/audio/tdfb/tdfb_direction.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ static int16_t max_mic_distance(struct tdfb_comp_data *cd)

/* Max lag based on largest array dimension. Microphone coordinates are Q4.12 meters */
for (i = 0; i < cd->config->num_mic_locations; i++) {
/* Start from i+1 halves the amount of iteration & to eliminate redundant checks */
for (j = i + 1; j < cd->config->num_mic_locations; j++) {
dx = cd->mic_locations[i].x - cd->mic_locations[j].x;
dy = cd->mic_locations[i].y - cd->mic_locations[j].y;
dz = cd->mic_locations[i].z - cd->mic_locations[j].z;
Expand Down Expand Up @@ -279,6 +281,7 @@ static void level_update(struct tdfb_comp_data *cd, int frames, int ch_count, in
/* Calculate mean square level */
for (n = 0; n < frames; n++) {
s = *p;
tmp += ((int32_t)s * s);
p += ch_count;
tdfb_cinc_s16(&p, cd->direction.d_end, cd->direction.d_size);
}
Expand Down

0 comments on commit 3e7956e

Please sign in to comment.