Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
5ba8c3a0
Commit
5ba8c3a0
authored
Mar 27, 2017
by
Ronald S. Bultje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dirac: make initialization of arithmetic coder tables threadsafe.
parent
64b55399
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
dirac_arith.c
libavcodec/dirac_arith.c
+10
-5
dirac_arith.h
libavcodec/dirac_arith.h
+1
-0
diracdec.c
libavcodec/diracdec.c
+8
-1
No files found.
libavcodec/dirac_arith.c
View file @
5ba8c3a0
...
...
@@ -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
;
}
libavcodec/dirac_arith.h
View file @
5ba8c3a0
...
...
@@ -190,6 +190,7 @@ static inline int dirac_get_arith_int(DiracArith *c, int follow_ctx, int data_ct
return
ret
;
}
void
ff_dirac_init_arith_tables
(
void
);
void
ff_dirac_init_arith_decoder
(
DiracArith
*
c
,
GetBitContext
*
gb
,
int
length
);
#endif
/* AVCODEC_DIRAC_ARITH_H */
libavcodec/diracdec.c
View file @
5ba8c3a0
...
...
@@ -26,6 +26,7 @@
* @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz <nenjordi@gmail.com>
*/
#include "libavutil/thread.h"
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
...
...
@@ -379,10 +380,12 @@ static void free_sequence_buffers(DiracContext *s)
av_freep
(
&
s
->
mcscratch
);
}
static
AVOnce
dirac_arith_init
=
AV_ONCE_INIT
;
static
av_cold
int
dirac_decode_init
(
AVCodecContext
*
avctx
)
{
DiracContext
*
s
=
avctx
->
priv_data
;
int
i
;
int
i
,
ret
;
s
->
avctx
=
avctx
;
s
->
frame_number
=
-
1
;
...
...
@@ -404,6 +407,9 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
return
AVERROR
(
ENOMEM
);
}
}
ret
=
ff_thread_once
(
&
dirac_arith_init
,
ff_dirac_init_arith_tables
);
if
(
ret
!=
0
)
return
AVERROR_UNKNOWN
;
return
0
;
}
...
...
@@ -2299,5 +2305,6 @@ AVCodec ff_dirac_decoder = {
.
close
=
dirac_decode_end
,
.
decode
=
dirac_decode_frame
,
.
capabilities
=
AV_CODEC_CAP_DELAY
|
AV_CODEC_CAP_SLICE_THREADS
|
AV_CODEC_CAP_DR1
,
.
caps_internal
=
FF_CODEC_CAP_INIT_THREADSAFE
,
.
flush
=
dirac_decode_flush
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment