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
6af83263
Commit
6af83263
authored
Jul 13, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/ff_init_vlc_sparse: use a spinlock for thread sync
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
a9903f7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
bitstream.c
libavcodec/bitstream.c
+19
-9
get_bits.h
libavcodec/get_bits.h
+1
-0
No files found.
libavcodec/bitstream.c
View file @
6af83263
...
...
@@ -28,6 +28,7 @@
* bitstream api.
*/
#include "libavutil/atomic.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "mathops.h"
...
...
@@ -269,14 +270,17 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
{
VLCcode
*
buf
;
int
i
,
j
,
ret
;
void
*
state
;
vlc
->
bits
=
nb_bits
;
if
(
flags
&
INIT_VLC_USE_NEW_STATIC
)
{
if
(
vlc
->
table_size
&&
vlc
->
table_size
==
vlc
->
table_allocated
)
{
return
0
;
}
else
if
(
vlc
->
table_size
)
{
abort
();
// fatal error, we are called on a partially initialized table
while
(
state
=
avpriv_atomic_ptr_cas
(
&
vlc
->
init_state
,
NULL
,
vlc
))
{
if
(
state
==
vlc
+
1
)
{
av_assert0
(
vlc
->
table_size
&&
vlc
->
table_size
==
vlc
->
table_allocated
);
return
0
;
}
}
av_assert0
(
!
vlc
->
table_size
);
}
else
{
vlc
->
table
=
NULL
;
vlc
->
table_allocated
=
0
;
...
...
@@ -326,12 +330,18 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
ret
=
build_table
(
vlc
,
nb_bits
,
nb_codes
,
buf
,
flags
);
av_free
(
buf
);
if
(
ret
<
0
)
{
av_freep
(
&
vlc
->
table
);
return
ret
;
if
(
flags
&
INIT_VLC_USE_NEW_STATIC
)
{
if
(
vlc
->
table_size
!=
vlc
->
table_allocated
)
av_log
(
NULL
,
AV_LOG_ERROR
,
"needed %d had %d
\n
"
,
vlc
->
table_size
,
vlc
->
table_allocated
);
state
=
avpriv_atomic_ptr_cas
(
&
vlc
->
init_state
,
vlc
,
vlc
+
1
);
av_assert0
(
state
==
vlc
);
av_assert0
(
ret
>=
0
);
}
else
{
if
(
ret
<
0
)
{
av_freep
(
&
vlc
->
table
);
return
ret
;
}
}
if
((
flags
&
INIT_VLC_USE_NEW_STATIC
)
&&
vlc
->
table_size
!=
vlc
->
table_allocated
)
av_log
(
NULL
,
AV_LOG_ERROR
,
"needed %d had %d
\n
"
,
vlc
->
table_size
,
vlc
->
table_allocated
);
return
0
;
}
...
...
libavcodec/get_bits.h
View file @
6af83263
...
...
@@ -64,6 +64,7 @@ typedef struct VLC {
int
bits
;
VLC_TYPE
(
*
table
)[
2
];
///< code, bits
int
table_size
,
table_allocated
;
void
*
init_state
;
}
VLC
;
typedef
struct
RL_VLC_ELEM
{
...
...
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