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
59df4b82
Commit
59df4b82
authored
Sep 07, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avplay: flush audio decoder with empty packets at EOF if the decoder has
CODEC_CAP_DELAY set.
parent
1993c684
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
avplay.c
avplay.c
+23
-6
No files found.
avplay.c
View file @
59df4b82
...
...
@@ -2008,10 +2008,15 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
AVCodecContext
*
dec
=
is
->
audio_st
->
codec
;
int
n
,
len1
,
data_size
;
double
pts
;
int
new_packet
=
0
;
int
flush_complete
=
0
;
for
(;;)
{
/* NOTE: the audio packet can contain several frames */
while
(
pkt_temp
->
size
>
0
)
{
while
(
pkt_temp
->
size
>
0
||
(
!
pkt_temp
->
data
&&
new_packet
))
{
if
(
flush_complete
)
break
;
new_packet
=
0
;
data_size
=
sizeof
(
is
->
audio_buf1
);
len1
=
avcodec_decode_audio3
(
dec
,
(
int16_t
*
)
is
->
audio_buf1
,
&
data_size
,
...
...
@@ -2024,8 +2029,13 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
pkt_temp
->
data
+=
len1
;
pkt_temp
->
size
-=
len1
;
if
(
data_size
<=
0
)
if
(
data_size
<=
0
)
{
/* stop sending empty packets if the decoder is finished */
if
(
!
pkt_temp
->
data
&&
dec
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
flush_complete
=
1
;
continue
;
}
if
(
dec
->
sample_fmt
!=
is
->
audio_src_fmt
)
{
if
(
is
->
reformat_ctx
)
...
...
@@ -2086,12 +2096,11 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
}
/* read next packet */
if
(
packet_queue_get
(
&
is
->
audioq
,
pkt
,
1
)
<
0
)
if
(
(
new_packet
=
packet_queue_get
(
&
is
->
audioq
,
pkt
,
1
)
)
<
0
)
return
-
1
;
if
(
pkt
->
data
==
flush_pkt
.
data
){
if
(
pkt
->
data
==
flush_pkt
.
data
)
avcodec_flush_buffers
(
dec
);
continue
;
}
pkt_temp
->
data
=
pkt
->
data
;
pkt_temp
->
size
=
pkt
->
size
;
...
...
@@ -2508,6 +2517,14 @@ static int decode_thread(void *arg)
pkt
->
stream_index
=
is
->
video_stream
;
packet_queue_put
(
&
is
->
videoq
,
pkt
);
}
if
(
is
->
audio_stream
>=
0
&&
is
->
audio_st
->
codec
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
{
av_init_packet
(
pkt
);
pkt
->
data
=
NULL
;
pkt
->
size
=
0
;
pkt
->
stream_index
=
is
->
audio_stream
;
packet_queue_put
(
&
is
->
audioq
,
pkt
);
}
SDL_Delay
(
10
);
if
(
is
->
audioq
.
size
+
is
->
videoq
.
size
+
is
->
subtitleq
.
size
==
0
){
if
(
loop
!=
1
&&
(
!
loop
||
--
loop
)){
...
...
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