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
e939dde4
Commit
e939dde4
authored
Mar 12, 2016
by
Sasi Inguva
Committed by
Michael Niedermayer
Mar 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/utils: factor update_dts_from_pts() out
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
9d4ab138
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
21 deletions
+43
-21
utils.c
libavformat/utils.c
+43
-21
No files found.
libavformat/utils.c
View file @
e939dde4
...
@@ -936,14 +936,44 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t
...
@@ -936,14 +936,44 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t
return
dts
;
return
dts
;
}
}
/**
* Updates the dts of packets of a stream in pkt_buffer, by re-ordering the pts
* of the packets in a window.
*/
static
void
update_dts_from_pts
(
AVFormatContext
*
s
,
int
stream_index
,
AVPacketList
*
pkt_buffer
)
{
AVStream
*
st
=
s
->
streams
[
stream_index
];
int
delay
=
st
->
codec
->
has_b_frames
;
int
i
;
int64_t
pts_buffer
[
MAX_REORDER_DELAY
+
1
];
for
(
i
=
0
;
i
<
MAX_REORDER_DELAY
+
1
;
i
++
)
pts_buffer
[
i
]
=
AV_NOPTS_VALUE
;
for
(;
pkt_buffer
;
pkt_buffer
=
get_next_pkt
(
s
,
st
,
pkt_buffer
))
{
if
(
pkt_buffer
->
pkt
.
stream_index
!=
stream_index
)
continue
;
if
(
pkt_buffer
->
pkt
.
pts
!=
AV_NOPTS_VALUE
&&
delay
<=
MAX_REORDER_DELAY
)
{
pts_buffer
[
0
]
=
pkt_buffer
->
pkt
.
pts
;
for
(
i
=
0
;
i
<
delay
&&
pts_buffer
[
i
]
>
pts_buffer
[
i
+
1
];
i
++
)
FFSWAP
(
int64_t
,
pts_buffer
[
i
],
pts_buffer
[
i
+
1
]);
pkt_buffer
->
pkt
.
dts
=
select_from_pts_buffer
(
st
,
pts_buffer
,
pkt_buffer
->
pkt
.
dts
);
}
}
}
static
void
update_initial_timestamps
(
AVFormatContext
*
s
,
int
stream_index
,
static
void
update_initial_timestamps
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
dts
,
int64_t
pts
,
AVPacket
*
pkt
)
int64_t
dts
,
int64_t
pts
,
AVPacket
*
pkt
)
{
{
AVStream
*
st
=
s
->
streams
[
stream_index
];
AVStream
*
st
=
s
->
streams
[
stream_index
];
AVPacketList
*
pktl
=
s
->
internal
->
packet_buffer
?
s
->
internal
->
packet_buffer
:
s
->
internal
->
parse_queue
;
AVPacketList
*
pktl
=
s
->
internal
->
packet_buffer
?
s
->
internal
->
packet_buffer
:
s
->
internal
->
parse_queue
;
int64_t
pts_buffer
[
MAX_REORDER_DELAY
+
1
];
AVPacketList
*
pktl_it
;
uint64_t
shift
;
uint64_t
shift
;
int
i
,
delay
;
if
(
st
->
first_dts
!=
AV_NOPTS_VALUE
||
if
(
st
->
first_dts
!=
AV_NOPTS_VALUE
||
dts
==
AV_NOPTS_VALUE
||
dts
==
AV_NOPTS_VALUE
||
...
@@ -951,36 +981,28 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
...
@@ -951,36 +981,28 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
is_relative
(
dts
))
is_relative
(
dts
))
return
;
return
;
delay
=
st
->
codec
->
has_b_frames
;
st
->
first_dts
=
dts
-
(
st
->
cur_dts
-
RELATIVE_TS_BASE
);
st
->
first_dts
=
dts
-
(
st
->
cur_dts
-
RELATIVE_TS_BASE
);
st
->
cur_dts
=
dts
;
st
->
cur_dts
=
dts
;
shift
=
(
uint64_t
)
st
->
first_dts
-
RELATIVE_TS_BASE
;
shift
=
(
uint64_t
)
st
->
first_dts
-
RELATIVE_TS_BASE
;
for
(
i
=
0
;
i
<
MAX_REORDER_DELAY
+
1
;
i
++
)
pts_buffer
[
i
]
=
AV_NOPTS_VALUE
;
if
(
is_relative
(
pts
))
if
(
is_relative
(
pts
))
pts
+=
shift
;
pts
+=
shift
;
for
(
;
pktl
;
pktl
=
get_next_pkt
(
s
,
st
,
pktl
))
{
for
(
pktl_it
=
pktl
;
pktl_it
;
pktl_it
=
get_next_pkt
(
s
,
st
,
pktl_it
))
{
if
(
pktl
->
pkt
.
stream_index
!=
stream_index
)
if
(
pktl
_it
->
pkt
.
stream_index
!=
stream_index
)
continue
;
continue
;
if
(
is_relative
(
pktl
->
pkt
.
pts
))
if
(
is_relative
(
pktl_it
->
pkt
.
pts
))
pktl
->
pkt
.
pts
+=
shift
;
pktl_it
->
pkt
.
pts
+=
shift
;
if
(
is_relative
(
pktl
->
pkt
.
dts
))
pktl
->
pkt
.
dts
+=
shift
;
if
(
st
->
start_time
==
AV_NOPTS_VALUE
&&
pktl
->
pkt
.
pts
!=
AV_NOPTS_VALUE
)
if
(
is_relative
(
pktl_it
->
pkt
.
dts
)
)
st
->
start_time
=
pktl
->
pkt
.
pts
;
pktl_it
->
pkt
.
dts
+=
shift
;
if
(
pktl
->
pkt
.
pts
!=
AV_NOPTS_VALUE
&&
delay
<=
MAX_REORDER_DELAY
&&
has_decode_delay_been_guessed
(
st
))
{
if
(
st
->
start_time
==
AV_NOPTS_VALUE
&&
pktl_it
->
pkt
.
pts
!=
AV_NOPTS_VALUE
)
pts_buffer
[
0
]
=
pktl
->
pkt
.
pts
;
st
->
start_time
=
pktl_it
->
pkt
.
pts
;
for
(
i
=
0
;
i
<
delay
&&
pts_buffer
[
i
]
>
pts_buffer
[
i
+
1
];
i
++
)
}
FFSWAP
(
int64_t
,
pts_buffer
[
i
],
pts_buffer
[
i
+
1
]);
pktl
->
pkt
.
dts
=
select_from_pts_buffer
(
st
,
pts_buffer
,
pktl
->
pkt
.
dts
);
if
(
has_decode_delay_been_guessed
(
st
))
{
}
update_dts_from_pts
(
s
,
stream_index
,
pktl
);
}
}
if
(
st
->
start_time
==
AV_NOPTS_VALUE
)
if
(
st
->
start_time
==
AV_NOPTS_VALUE
)
...
...
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