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
915bb788
Commit
915bb788
authored
Mar 15, 2017
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffplay: convert to new decode API
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
f6b5a5c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
47 deletions
+54
-47
ffplay.c
ffplay.c
+54
-47
No files found.
ffplay.c
View file @
915bb788
...
@@ -187,7 +187,6 @@ enum {
...
@@ -187,7 +187,6 @@ enum {
typedef
struct
Decoder
{
typedef
struct
Decoder
{
AVPacket
pkt
;
AVPacket
pkt
;
AVPacket
pkt_temp
;
PacketQueue
*
queue
;
PacketQueue
*
queue
;
AVCodecContext
*
avctx
;
AVCodecContext
*
avctx
;
int
pkt_serial
;
int
pkt_serial
;
...
@@ -551,40 +550,24 @@ static void decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue,
...
@@ -551,40 +550,24 @@ static void decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue,
d
->
queue
=
queue
;
d
->
queue
=
queue
;
d
->
empty_queue_cond
=
empty_queue_cond
;
d
->
empty_queue_cond
=
empty_queue_cond
;
d
->
start_pts
=
AV_NOPTS_VALUE
;
d
->
start_pts
=
AV_NOPTS_VALUE
;
d
->
pkt_serial
=
-
1
;
}
}
static
int
decoder_decode_frame
(
Decoder
*
d
,
AVFrame
*
frame
,
AVSubtitle
*
sub
)
{
static
int
decoder_decode_frame
(
Decoder
*
d
,
AVFrame
*
frame
,
AVSubtitle
*
sub
)
{
int
got_frame
=
0
;
int
ret
=
AVERROR
(
EAGAIN
)
;
do
{
for
(;;)
{
int
ret
=
-
1
;
AVPacket
pkt
;
if
(
d
->
queue
->
serial
==
d
->
pkt_serial
)
{
do
{
if
(
d
->
queue
->
abort_request
)
if
(
d
->
queue
->
abort_request
)
return
-
1
;
return
-
1
;
if
(
!
d
->
packet_pending
||
d
->
queue
->
serial
!=
d
->
pkt_serial
)
{
AVPacket
pkt
;
do
{
if
(
d
->
queue
->
nb_packets
==
0
)
SDL_CondSignal
(
d
->
empty_queue_cond
);
if
(
packet_queue_get
(
d
->
queue
,
&
pkt
,
1
,
&
d
->
pkt_serial
)
<
0
)
return
-
1
;
if
(
pkt
.
data
==
flush_pkt
.
data
)
{
avcodec_flush_buffers
(
d
->
avctx
);
d
->
finished
=
0
;
d
->
next_pts
=
d
->
start_pts
;
d
->
next_pts_tb
=
d
->
start_pts_tb
;
}
}
while
(
pkt
.
data
==
flush_pkt
.
data
||
d
->
queue
->
serial
!=
d
->
pkt_serial
);
av_packet_unref
(
&
d
->
pkt
);
d
->
pkt_temp
=
d
->
pkt
=
pkt
;
d
->
packet_pending
=
1
;
}
switch
(
d
->
avctx
->
codec_type
)
{
switch
(
d
->
avctx
->
codec_type
)
{
case
AVMEDIA_TYPE_VIDEO
:
case
AVMEDIA_TYPE_VIDEO
:
ret
=
avcodec_
decode_video2
(
d
->
avctx
,
frame
,
&
got_frame
,
&
d
->
pkt_temp
);
ret
=
avcodec_
receive_frame
(
d
->
avctx
,
frame
);
if
(
got_frame
)
{
if
(
ret
>=
0
)
{
if
(
decoder_reorder_pts
==
-
1
)
{
if
(
decoder_reorder_pts
==
-
1
)
{
frame
->
pts
=
av_frame_get_best_effort_timestamp
(
frame
);
frame
->
pts
=
av_frame_get_best_effort_timestamp
(
frame
);
}
else
if
(
!
decoder_reorder_pts
)
{
}
else
if
(
!
decoder_reorder_pts
)
{
...
@@ -593,8 +576,8 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
...
@@ -593,8 +576,8 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
}
}
break
;
break
;
case
AVMEDIA_TYPE_AUDIO
:
case
AVMEDIA_TYPE_AUDIO
:
ret
=
avcodec_
decode_audio4
(
d
->
avctx
,
frame
,
&
got_frame
,
&
d
->
pkt_temp
);
ret
=
avcodec_
receive_frame
(
d
->
avctx
,
frame
);
if
(
got_frame
)
{
if
(
ret
>=
0
)
{
AVRational
tb
=
(
AVRational
){
1
,
frame
->
sample_rate
};
AVRational
tb
=
(
AVRational
){
1
,
frame
->
sample_rate
};
if
(
frame
->
pts
!=
AV_NOPTS_VALUE
)
if
(
frame
->
pts
!=
AV_NOPTS_VALUE
)
frame
->
pts
=
av_rescale_q
(
frame
->
pts
,
av_codec_get_pkt_timebase
(
d
->
avctx
),
tb
);
frame
->
pts
=
av_rescale_q
(
frame
->
pts
,
av_codec_get_pkt_timebase
(
d
->
avctx
),
tb
);
...
@@ -606,33 +589,57 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
...
@@ -606,33 +589,57 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
}
}
}
}
break
;
break
;
case
AVMEDIA_TYPE_SUBTITLE
:
}
ret
=
avcodec_decode_subtitle2
(
d
->
avctx
,
sub
,
&
got_frame
,
&
d
->
pkt_temp
);
if
(
ret
==
AVERROR_EOF
)
{
break
;
d
->
finished
=
d
->
pkt_serial
;
avcodec_flush_buffers
(
d
->
avctx
);
return
0
;
}
if
(
ret
>=
0
)
return
1
;
}
while
(
ret
!=
AVERROR
(
EAGAIN
));
}
}
if
(
ret
<
0
)
{
do
{
d
->
packet_pending
=
0
;
if
(
d
->
queue
->
nb_packets
==
0
)
SDL_CondSignal
(
d
->
empty_queue_cond
);
if
(
d
->
packet_pending
)
{
av_packet_move_ref
(
&
pkt
,
&
d
->
pkt
);
d
->
packet_pending
=
0
;
}
else
{
if
(
packet_queue_get
(
d
->
queue
,
&
pkt
,
1
,
&
d
->
pkt_serial
)
<
0
)
return
-
1
;
}
}
while
(
d
->
queue
->
serial
!=
d
->
pkt_serial
);
if
(
pkt
.
data
==
flush_pkt
.
data
)
{
avcodec_flush_buffers
(
d
->
avctx
);
d
->
finished
=
0
;
d
->
next_pts
=
d
->
start_pts
;
d
->
next_pts_tb
=
d
->
start_pts_tb
;
}
else
{
}
else
{
d
->
pkt_temp
.
dts
=
if
(
d
->
avctx
->
codec_type
==
AVMEDIA_TYPE_SUBTITLE
)
{
d
->
pkt_temp
.
pts
=
AV_NOPTS_VALUE
;
int
got_frame
=
0
;
if
(
d
->
pkt_temp
.
data
)
{
ret
=
avcodec_decode_subtitle2
(
d
->
avctx
,
sub
,
&
got_frame
,
&
pkt
);
if
(
d
->
avctx
->
codec_type
!=
AVMEDIA_TYPE_AUDIO
)
if
(
ret
<
0
)
{
ret
=
d
->
pkt_temp
.
size
;
ret
=
AVERROR
(
EAGAIN
);
d
->
pkt_temp
.
data
+=
ret
;
}
else
{
d
->
pkt_temp
.
size
-=
ret
;
if
(
got_frame
&&
!
pkt
.
data
)
{
if
(
d
->
pkt_temp
.
size
<=
0
)
d
->
packet_pending
=
1
;
d
->
packet_pending
=
0
;
av_packet_move_ref
(
&
d
->
pkt
,
&
pkt
);
}
ret
=
got_frame
?
0
:
(
pkt
.
data
?
AVERROR
(
EAGAIN
)
:
AVERROR_EOF
);
}
}
else
{
}
else
{
if
(
!
got_frame
)
{
if
(
avcodec_send_packet
(
d
->
avctx
,
&
pkt
)
==
AVERROR
(
EAGAIN
))
{
d
->
packet_pending
=
0
;
av_log
(
d
->
avctx
,
AV_LOG_ERROR
,
"Receive_frame and send_packet both returned EAGAIN, which is an API violation.
\n
"
);
d
->
finished
=
d
->
pkt_serial
;
d
->
packet_pending
=
1
;
av_packet_move_ref
(
&
d
->
pkt
,
&
pkt
);
}
}
}
}
av_packet_unref
(
&
pkt
);
}
}
}
while
(
!
got_frame
&&
!
d
->
finished
);
}
return
got_frame
;
}
}
static
void
decoder_destroy
(
Decoder
*
d
)
{
static
void
decoder_destroy
(
Decoder
*
d
)
{
...
...
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