From 1af615683e4a1a858407afbaa2fd686842da7e49 Mon Sep 17 00:00:00 2001 From: Muhammad Faiz Date: Wed, 5 Jul 2017 12:33:22 +0700 Subject: avcodec/fft_template: use ff_thread_once on costable initialization Make it thread-safe and avoid redundant initialization. Reviewed-by: Rostislav Pehlivanov Reviewed-by: wm4 Signed-off-by: Muhammad Faiz --- libavcodec/fft_template.c | 81 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 10 deletions(-) (limited to 'libavcodec/fft_template.c') diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c index 6477372274..6c77854e41 100644 --- a/libavcodec/fft_template.c +++ b/libavcodec/fft_template.c @@ -29,11 +29,19 @@ #include #include #include "libavutil/mathematics.h" +#include "libavutil/thread.h" #include "fft.h" #include "fft-internal.h" #if FFT_FIXED_32 #include "fft_table.h" + +static void av_cold fft_lut_init(void) +{ + int n = 0; + ff_fft_lut_init(ff_fft_offsets_lut, 0, 1 << 17, &n); +} + #else /* FFT_FIXED_32 */ /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ @@ -52,6 +60,66 @@ COSTABLE(16384); COSTABLE(32768); COSTABLE(65536); COSTABLE(131072); + +static av_cold void init_ff_cos_tabs(int index) +{ + int i; + int m = 1<