mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avcodec/atrac: Make generating tables thread-safe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
d5d1c697bd
commit
94a55f28aa
@ -30,6 +30,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libavutil/thread.h"
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "atrac.h"
|
#include "atrac.h"
|
||||||
|
|
||||||
@ -45,22 +47,23 @@ static const float qmf_48tap_half[24] = {
|
|||||||
-0.043596379, -0.099384367, 0.13207909, 0.46424159
|
-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 */
|
/* Generate scale factors */
|
||||||
if (!ff_atrac_sf_table[63])
|
for (int i = 0; i < 64; i++)
|
||||||
for (i=0 ; i<64 ; i++)
|
ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
|
||||||
ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
|
|
||||||
|
|
||||||
/* Generate the QMF window. */
|
/* Generate the QMF window. */
|
||||||
if (!qmf_window[47])
|
for (int i = 0; i < 24; i++) {
|
||||||
for (i=0 ; i<24; i++) {
|
float s = qmf_48tap_half[i] * 2.0;
|
||||||
s = qmf_48tap_half[i] * 2.0;
|
qmf_window[i] = qmf_window[47 - i] = s;
|
||||||
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,
|
av_cold void ff_atrac_init_gain_compensation(AtracGCContext *gctx, int id2exp_offset,
|
||||||
|
Loading…
Reference in New Issue
Block a user