[FFmpeg-devel] [PATCH] Don't needlessly reinitialize ff_cos_## tables.

Dale Curtis dalecurtis at chromium.org
Wed Oct 21 01:57:49 CEST 2015


Minor waste and more annoyingly triggers race detectors when the
re-initialization happens across multiple threads. cos(0) == 1 and by
default statics initialize to 0, so this check is safe.

Signed-off-by: Dale Curtis <dalecurtis at chromium.org>
---
 libavcodec/fft_template.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
index 23ea453..2165ed0 100644
--- a/libavcodec/fft_template.c
+++ b/libavcodec/fft_template.c
@@ -92,6 +92,8 @@ av_cold void ff_init_ff_cos_tabs(int index)
     int m = 1<<index;
     double freq = 2*M_PI/m;
     FFTSample *tab = FFT_NAME(ff_cos_tabs)[index];
+    if (tab[0])
+        return;
     for(i=0; i<=m/4; i++)
         tab[i] = FIX15(cos(i*freq));
     for(i=1; i<m/4; i++)
-- 
2.6.0.rc2.230.g3dd15c0


More information about the ffmpeg-devel mailing list