Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
mod_filtering: move first magnitude before the loop
Browse files Browse the repository at this point in the history
Prevent a potential cache miss by going back at the beginning of the
array.
  • Loading branch information
ubitux committed Sep 26, 2021
1 parent 9cbce37 commit f47e886
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/mod_filtering.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,9 @@ static void audio_frame_to_sound_texture(struct filtering_ctx *ctx, AVFrame *dst
* the last complex (highest frequency one).
*/
#define MAGNITUDE(re, im) sqrtf(((re)*(re) + (im)*(im)) * scale)
fft_dst[0] = MAGNITUDE(bins[0], 0); // lowest frequency
for (int i = 1; i < width; i++)
fft_dst[i] = MAGNITUDE(bins[2*i], bins[2*i + 1]);

/* First complex (lowest frequency one) is one of the two special cases
* mentioned above */
fft_dst[0] = MAGNITUDE(bins[0], 0);
}

/* Downscaled versions of the FFT */
Expand Down

0 comments on commit f47e886

Please sign in to comment.