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
ad99cbc9
Commit
ad99cbc9
authored
Jul 27, 2018
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode: flush the internal bsfs instead of constantly reinitalizing them
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
0e27e276
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+19
-10
decode.c
libavcodec/decode.c
+10
-10
decode.h
libavcodec/decode.h
+2
-0
utils.c
libavcodec/utils.c
+7
-0
No files found.
libavcodec/decode.c
View file @
ad99cbc9
...
...
@@ -156,7 +156,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
return
0
;
}
static
int
bsfs_init
(
AVCodecContext
*
avctx
)
int
ff_decode_
bsfs_init
(
AVCodecContext
*
avctx
)
{
AVCodecInternal
*
avci
=
avctx
->
internal
;
DecodeFilterContext
*
s
=
&
avci
->
filter
;
...
...
@@ -449,10 +449,6 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke
if
(
avctx
->
internal
->
draining
)
return
AVERROR_EOF
;
ret
=
bsfs_init
(
avctx
);
if
(
ret
<
0
)
return
ret
;
av_packet_unref
(
avci
->
buffer_pkt
);
if
(
avpkt
&&
(
avpkt
->
data
||
avpkt
->
side_data_elems
))
{
ret
=
av_packet_ref
(
avci
->
buffer_pkt
,
avpkt
);
...
...
@@ -511,10 +507,6 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
if
(
!
avcodec_is_open
(
avctx
)
||
!
av_codec_is_decoder
(
avctx
->
codec
))
return
AVERROR
(
EINVAL
);
ret
=
bsfs_init
(
avctx
);
if
(
ret
<
0
)
return
ret
;
if
(
avci
->
buffer_frame
->
buf
[
0
])
{
av_frame_move_ref
(
frame
,
avci
->
buffer_frame
);
}
else
{
...
...
@@ -1394,6 +1386,14 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
return
0
;
}
static
void
bsfs_flush
(
AVCodecContext
*
avctx
)
{
DecodeFilterContext
*
s
=
&
avctx
->
internal
->
filter
;
for
(
int
i
=
0
;
i
<
s
->
nb_bsfs
;
i
++
)
av_bsf_flush
(
s
->
bsfs
[
i
]);
}
void
avcodec_flush_buffers
(
AVCodecContext
*
avctx
)
{
avctx
->
internal
->
draining
=
0
;
...
...
@@ -1410,7 +1410,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
else
if
(
avctx
->
codec
->
flush
)
avctx
->
codec
->
flush
(
avctx
);
ff_decode_bsfs_uninit
(
avctx
);
bsfs_flush
(
avctx
);
if
(
!
avctx
->
refcounted_frames
)
av_frame_unref
(
avctx
->
internal
->
to_free
);
...
...
libavcodec/decode.h
View file @
ad99cbc9
...
...
@@ -69,6 +69,8 @@ typedef struct FrameDecodeData {
*/
int
ff_decode_get_packet
(
AVCodecContext
*
avctx
,
AVPacket
*
pkt
);
int
ff_decode_bsfs_init
(
AVCodecContext
*
avctx
);
void
ff_decode_bsfs_uninit
(
AVCodecContext
*
avctx
);
/**
...
...
libavcodec/utils.c
View file @
ad99cbc9
...
...
@@ -512,6 +512,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
avctx
->
time_base
.
den
=
avctx
->
sample_rate
;
}
if
(
av_codec_is_decoder
(
avctx
->
codec
))
{
ret
=
ff_decode_bsfs_init
(
avctx
);
if
(
ret
<
0
)
goto
free_and_end
;
}
if
(
HAVE_THREADS
)
{
ret
=
ff_thread_init
(
avctx
);
if
(
ret
<
0
)
{
...
...
@@ -706,6 +712,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_packet_free
(
&
avctx
->
internal
->
last_pkt_props
);
av_packet_free
(
&
avctx
->
internal
->
ds
.
in_pkt
);
ff_decode_bsfs_uninit
(
avctx
);
av_freep
(
&
avctx
->
internal
->
pool
);
}
...
...
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