Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
ddebfb15
Commit
ddebfb15
authored
19 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
thread mess check for avcodec_open/close()
Originally committed as revision 4472 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
91d44ffc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/utils.c
+25
-6
25 additions, 6 deletions
libavcodec/utils.c
with
25 additions
and
6 deletions
libavcodec/utils.c
+
25
−
6
View file @
ddebfb15
...
@@ -68,6 +68,8 @@ const uint8_t ff_reverse[256]={
...
@@ -68,6 +68,8 @@ const uint8_t ff_reverse[256]={
0x0F
,
0x8F
,
0x4F
,
0xCF
,
0x2F
,
0xAF
,
0x6F
,
0xEF
,
0x1F
,
0x9F
,
0x5F
,
0xDF
,
0x3F
,
0xBF
,
0x7F
,
0xFF
,
0x0F
,
0x8F
,
0x4F
,
0xCF
,
0x2F
,
0xAF
,
0x6F
,
0xEF
,
0x1F
,
0x9F
,
0x5F
,
0xDF
,
0x3F
,
0xBF
,
0x7F
,
0xFF
,
};
};
static
int
volatile
entangled_thread_counter
=
0
;
void
avcodec_default_free_buffers
(
AVCodecContext
*
s
);
void
avcodec_default_free_buffers
(
AVCodecContext
*
s
);
void
*
av_mallocz
(
unsigned
int
size
)
void
*
av_mallocz
(
unsigned
int
size
)
...
@@ -522,10 +524,16 @@ AVFrame *avcodec_alloc_frame(void){
...
@@ -522,10 +524,16 @@ AVFrame *avcodec_alloc_frame(void){
int
avcodec_open
(
AVCodecContext
*
avctx
,
AVCodec
*
codec
)
int
avcodec_open
(
AVCodecContext
*
avctx
,
AVCodec
*
codec
)
{
{
int
ret
;
int
ret
=
-
1
;
entangled_thread_counter
++
;
if
(
entangled_thread_counter
!=
1
){
av_log
(
avctx
,
AV_LOG_ERROR
,
"insufficient thread locking around avcodec_open/close()
\n
"
);
goto
end
;
}
if
(
avctx
->
codec
)
if
(
avctx
->
codec
)
return
-
1
;
goto
end
;
avctx
->
codec
=
codec
;
avctx
->
codec
=
codec
;
avctx
->
codec_id
=
codec
->
id
;
avctx
->
codec_id
=
codec
->
id
;
...
@@ -533,7 +541,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
...
@@ -533,7 +541,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
if
(
codec
->
priv_data_size
>
0
)
{
if
(
codec
->
priv_data_size
>
0
)
{
avctx
->
priv_data
=
av_mallocz
(
codec
->
priv_data_size
);
avctx
->
priv_data
=
av_mallocz
(
codec
->
priv_data_size
);
if
(
!
avctx
->
priv_data
)
if
(
!
avctx
->
priv_data
)
return
-
ENOMEM
;
goto
end
;
}
else
{
}
else
{
avctx
->
priv_data
=
NULL
;
avctx
->
priv_data
=
NULL
;
}
}
...
@@ -545,15 +553,18 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
...
@@ -545,15 +553,18 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
if
((
avctx
->
coded_width
||
avctx
->
coded_height
)
&&
avcodec_check_dimensions
(
avctx
,
avctx
->
coded_width
,
avctx
->
coded_height
)){
if
((
avctx
->
coded_width
||
avctx
->
coded_height
)
&&
avcodec_check_dimensions
(
avctx
,
avctx
->
coded_width
,
avctx
->
coded_height
)){
av_freep
(
&
avctx
->
priv_data
);
av_freep
(
&
avctx
->
priv_data
);
return
-
1
;
goto
end
;
}
}
ret
=
avctx
->
codec
->
init
(
avctx
);
ret
=
avctx
->
codec
->
init
(
avctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_freep
(
&
avctx
->
priv_data
);
av_freep
(
&
avctx
->
priv_data
);
return
ret
;
goto
end
;
}
}
return
0
;
ret
=
0
;
end:
entangled_thread_counter
--
;
return
ret
;
}
}
int
avcodec_encode_audio
(
AVCodecContext
*
avctx
,
uint8_t
*
buf
,
int
buf_size
,
int
avcodec_encode_audio
(
AVCodecContext
*
avctx
,
uint8_t
*
buf
,
int
buf_size
,
...
@@ -670,11 +681,19 @@ int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
...
@@ -670,11 +681,19 @@ int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int
avcodec_close
(
AVCodecContext
*
avctx
)
int
avcodec_close
(
AVCodecContext
*
avctx
)
{
{
entangled_thread_counter
++
;
if
(
entangled_thread_counter
!=
1
){
av_log
(
avctx
,
AV_LOG_ERROR
,
"insufficient thread locking around avcodec_open/close()
\n
"
);
entangled_thread_counter
--
;
return
-
1
;
}
if
(
avctx
->
codec
->
close
)
if
(
avctx
->
codec
->
close
)
avctx
->
codec
->
close
(
avctx
);
avctx
->
codec
->
close
(
avctx
);
avcodec_default_free_buffers
(
avctx
);
avcodec_default_free_buffers
(
avctx
);
av_freep
(
&
avctx
->
priv_data
);
av_freep
(
&
avctx
->
priv_data
);
avctx
->
codec
=
NULL
;
avctx
->
codec
=
NULL
;
entangled_thread_counter
--
;
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment