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
9eb29657
Commit
9eb29657
authored
Sep 21, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: use a malloced AVFrame in try_decode_frame().
This allows using avcodec_free_frame() to free it properly.
parent
a42aadab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
utils.c
libavformat/utils.c
+17
-8
No files found.
libavformat/utils.c
View file @
9eb29657
...
...
@@ -2084,9 +2084,12 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
{
const
AVCodec
*
codec
;
int
got_picture
=
1
,
ret
=
0
;
AVFrame
picture
;
AVFrame
*
frame
=
avcodec_alloc_frame
()
;
AVPacket
pkt
=
*
avpkt
;
if
(
!
frame
)
return
AVERROR
(
ENOMEM
);
if
(
!
avcodec_is_open
(
st
->
codec
)
&&
!
st
->
info
->
found_decoder
)
{
AVDictionary
*
thread_opt
=
NULL
;
...
...
@@ -2095,7 +2098,8 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
if
(
!
codec
)
{
st
->
info
->
found_decoder
=
-
1
;
return
-
1
;
ret
=
-
1
;
goto
fail
;
}
/* force thread count to 1 since the h264 decoder will not extract SPS
...
...
@@ -2106,14 +2110,16 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
av_dict_free
(
&
thread_opt
);
if
(
ret
<
0
)
{
st
->
info
->
found_decoder
=
-
1
;
return
ret
;
goto
fail
;
}
st
->
info
->
found_decoder
=
1
;
}
else
if
(
!
st
->
info
->
found_decoder
)
st
->
info
->
found_decoder
=
1
;
if
(
st
->
info
->
found_decoder
<
0
)
return
-
1
;
if
(
st
->
info
->
found_decoder
<
0
)
{
ret
=
-
1
;
goto
fail
;
}
while
((
pkt
.
size
>
0
||
(
!
pkt
.
data
&&
got_picture
))
&&
ret
>=
0
&&
...
...
@@ -2121,14 +2127,14 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
!
has_decode_delay_been_guessed
(
st
)
||
(
!
st
->
codec_info_nb_frames
&&
st
->
codec
->
codec
->
capabilities
&
CODEC_CAP_CHANNEL_CONF
)))
{
got_picture
=
0
;
avcodec_get_frame_defaults
(
&
pictur
e
);
avcodec_get_frame_defaults
(
fram
e
);
switch
(
st
->
codec
->
codec_type
)
{
case
AVMEDIA_TYPE_VIDEO
:
ret
=
avcodec_decode_video2
(
st
->
codec
,
&
pictur
e
,
ret
=
avcodec_decode_video2
(
st
->
codec
,
fram
e
,
&
got_picture
,
&
pkt
);
break
;
case
AVMEDIA_TYPE_AUDIO
:
ret
=
avcodec_decode_audio4
(
st
->
codec
,
&
pictur
e
,
&
got_picture
,
&
pkt
);
ret
=
avcodec_decode_audio4
(
st
->
codec
,
fram
e
,
&
got_picture
,
&
pkt
);
break
;
default
:
break
;
...
...
@@ -2141,6 +2147,9 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option
ret
=
got_picture
;
}
}
fail
:
avcodec_free_frame
(
&
frame
);
return
ret
;
}
...
...
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