diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2017-03-27 11:24:43 -0400 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2017-03-28 11:21:27 -0400 |
commit | 5ba8c3a0ed0e43e6418eabdf8af9549c9e806382 (patch) | |
tree | 5644876dde707aef7c7fe4c995bbbbe3f9e34c58 /libavcodec/dirac_arith.c | |
parent | 64b553998567141b05239dcf11ad4d24aeaead8e (diff) | |
download | ffmpeg-5ba8c3a0ed0e43e6418eabdf8af9549c9e806382.tar.gz |
dirac: make initialization of arithmetic coder tables threadsafe.
Diffstat (limited to 'libavcodec/dirac_arith.c')
-rw-r--r-- | libavcodec/dirac_arith.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/dirac_arith.c b/libavcodec/dirac_arith.c index bf913928b3..7eb9bd60b2 100644 --- a/libavcodec/dirac_arith.c +++ b/libavcodec/dirac_arith.c @@ -83,6 +83,16 @@ const uint8_t ff_dirac_next_ctx[DIRAC_CTX_COUNT] = { int16_t ff_dirac_prob_branchless[256][2]; +av_cold void ff_dirac_init_arith_tables(void) +{ + int i; + + for (i = 0; i < 256; i++) { + ff_dirac_prob_branchless[i][0] = ff_dirac_prob[255-i]; + ff_dirac_prob_branchless[i][1] = -ff_dirac_prob[i]; + } +} + void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length) { int i; @@ -106,11 +116,6 @@ void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length) c->counter = -16; c->range = 0xffff; - for (i = 0; i < 256; i++) { - ff_dirac_prob_branchless[i][0] = ff_dirac_prob[255-i]; - ff_dirac_prob_branchless[i][1] = -ff_dirac_prob[i]; - } - for (i = 0; i < DIRAC_CTX_COUNT; i++) c->contexts[i] = 0x8000; } |