mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/vima: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
58ca07320b
commit
acde66082f
@ -26,13 +26,13 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/channel_layout.h"
|
||||
#include "libavutil/thread.h"
|
||||
|
||||
#include "adpcm_data.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "internal.h"
|
||||
|
||||
static int predict_table_init = 0;
|
||||
static uint16_t predict_table[5786 * 2];
|
||||
|
||||
static const uint8_t size_table[] = {
|
||||
@ -84,16 +84,9 @@ static const int8_t *const step_index_tables[] = {
|
||||
index_table4, index_table5, index_table6
|
||||
};
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
static av_cold void predict_table_init(void)
|
||||
{
|
||||
int start_pos;
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
|
||||
if (predict_table_init)
|
||||
return 0;
|
||||
|
||||
for (start_pos = 0; start_pos < 64; start_pos++) {
|
||||
for (int start_pos = 0; start_pos < 64; start_pos++) {
|
||||
unsigned int dest_pos, table_pos;
|
||||
|
||||
for (table_pos = 0, dest_pos = start_pos;
|
||||
@ -110,7 +103,15 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
predict_table[dest_pos] = put;
|
||||
}
|
||||
}
|
||||
predict_table_init = 1;
|
||||
}
|
||||
|
||||
static av_cold int decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
|
||||
ff_thread_once(&init_static_once, predict_table_init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -215,4 +216,5 @@ const AVCodec ff_adpcm_vima_decoder = {
|
||||
.init = decode_init,
|
||||
.decode = decode_frame,
|
||||
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user