1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/atrac: Make generating tables thread-safe

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-11-22 13:30:07 +01:00
parent d5d1c697bd
commit 94a55f28aa

View File

@ -30,6 +30,8 @@
#include <stdio.h>
#include <string.h>
#include "libavutil/thread.h"
#include "avcodec.h"
#include "atrac.h"
@ -45,22 +47,23 @@ static const float qmf_48tap_half[24] = {
-0.043596379, -0.099384367, 0.13207909, 0.46424159
};
av_cold void ff_atrac_generate_tables(void)
static av_cold void atrac_generate_tables(void)
{
int i;
float s;
/* Generate scale factors */
if (!ff_atrac_sf_table[63])
for (i=0 ; i<64 ; i++)
ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
for (int i = 0; i < 64; i++)
ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
/* Generate the QMF window. */
if (!qmf_window[47])
for (i=0 ; i<24; i++) {
s = qmf_48tap_half[i] * 2.0;
qmf_window[i] = qmf_window[47 - i] = s;
}
for (int i = 0; i < 24; i++) {
float s = qmf_48tap_half[i] * 2.0;
qmf_window[i] = qmf_window[47 - i] = s;
}
}
av_cold void ff_atrac_generate_tables(void)
{
static AVOnce init_static_once = AV_ONCE_INIT;
ff_thread_once(&init_static_once, atrac_generate_tables);
}
av_cold void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset,