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
de9862a9
Commit
de9862a9
authored
Oct 21, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegts: add and use mpegts_get_dts()
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
04ac0d79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
20 deletions
+48
-20
mpegts.c
libavformat/mpegts.c
+31
-3
lavf_ts
tests/ref/seek/lavf_ts
+17
-17
No files found.
libavformat/mpegts.c
View file @
de9862a9
...
...
@@ -1760,6 +1760,33 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
return
AV_NOPTS_VALUE
;
}
static
int64_t
mpegts_get_dts
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
*
ppos
,
int64_t
pos_limit
)
{
MpegTSContext
*
ts
=
s
->
priv_data
;
int64_t
pos
,
timestamp
;
pos
=
((
*
ppos
+
ts
->
raw_packet_size
-
1
-
ts
->
pos47
)
/
ts
->
raw_packet_size
)
*
ts
->
raw_packet_size
+
ts
->
pos47
;
ff_read_frame_flush
(
s
);
if
(
avio_seek
(
s
->
pb
,
pos
,
SEEK_SET
)
<
0
)
return
AV_NOPTS_VALUE
;
while
(
pos
<
pos_limit
)
{
int
ret
;
AVPacket
pkt
;
av_init_packet
(
&
pkt
);
ret
=
av_read_frame
(
s
,
&
pkt
);
if
(
ret
<
0
)
return
AV_NOPTS_VALUE
;
av_free_packet
(
&
pkt
);
if
(
pkt
.
stream_index
==
stream_index
&&
pkt
.
dts
!=
AV_NOPTS_VALUE
){
*
ppos
=
pkt
.
pos
;
return
pkt
.
dts
;
}
pos
=
pkt
.
pos
;
}
return
AV_NOPTS_VALUE
;
}
#ifdef USE_SYNCPOINT_SEARCH
static
int
read_seek2
(
AVFormatContext
*
s
,
...
...
@@ -1853,7 +1880,8 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in
if
(
av_seek_frame_binary
(
s
,
stream_index
,
target_ts
,
flags
)
<
0
)
return
-
1
;
ff_read_frame_flush
(
s
);
return
0
;
pos
=
avio_tell
(
s
->
pb
);
for
(;;)
{
...
...
@@ -1936,7 +1964,7 @@ AVInputFormat ff_mpegts_demuxer = {
.
read_packet
=
mpegts_read_packet
,
.
read_close
=
mpegts_read_close
,
.
read_seek
=
read_seek
,
.
read_timestamp
=
mpegts_get_
pcr
,
.
read_timestamp
=
mpegts_get_
dts
,
.
flags
=
AVFMT_SHOW_IDS
|
AVFMT_TS_DISCONT
,
#ifdef USE_SYNCPOINT_SEARCH
.
read_seek2
=
read_seek2
,
...
...
@@ -1951,7 +1979,7 @@ AVInputFormat ff_mpegtsraw_demuxer = {
.
read_packet
=
mpegts_raw_read_packet
,
.
read_close
=
mpegts_read_close
,
.
read_seek
=
read_seek
,
.
read_timestamp
=
mpegts_get_
pcr
,
.
read_timestamp
=
mpegts_get_
dts
,
.
flags
=
AVFMT_SHOW_IDS
|
AVFMT_TS_DISCONT
,
#ifdef USE_SYNCPOINT_SEARCH
.
read_seek2
=
read_seek2
,
...
...
tests/ref/seek/lavf_ts
View file @
de9862a9
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:0 dts: 1.4
40000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st: 0 flags:0 dts: 1.4
00000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st:
1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st:
0 flags:0 dts: 1.880000 pts: 1.920000 pos: 216012 size: 17441
ret: 0 st: 0 flags:0 ts: 0.788333
ret: 0 st: 0 flags:0 dts: 1.
520000 pts: 1.560000 pos: 74260 size: 13388
ret: 0 st: 0 flags:0 dts: 1.
400000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st: 0 flags:1 ts:-0.317500
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts: 2.576667
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st: 1 flags:1 ts: 1.470833
ret: 0 st:
0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325240 size: 12679
ret: 0 st:
1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:0 dts: 1.4
40000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st: 0 flags:0 dts: 1.4
00000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:0 ts: 2.153333
ret: 0 st:
1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 20
9
ret: 0 st:
0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325240 size: 1267
9
ret: 0 st: 0 flags:1 ts: 1.047500
ret: 0 st: 0 flags:
0 dts: 1.680000 pts: 1.720000 pos: 130096 size: 14133
ret: 0 st: 0 flags:
1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts:-0.058333
ret: 0 st:
0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st:
1 flags:1 dts: 1.765711 pts: 1.765711 pos: 322232 size: 209
ret: 0 st: 1 flags:1 ts: 2.835833
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 1 flags:1 dts:
2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st: 1 flags:1 dts:
1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:0 ts:-0.481667
ret: 0 st: 0 flags:0 dts: 1.4
40000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st: 0 flags:0 dts: 1.4
00000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st: 0 flags:1 ts: 2.412500
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st: 1 flags:0 ts: 1.306667
ret: 0 st:
0 flags:0 dts: 2.080000 pts: 2.120000 pos: 294032 size: 1383
9
ret: 0 st:
1 flags:1 dts: 1.765711 pts: 1.765711 pos: 322232 size: 20
9
ret: 0 st: 1 flags:1 ts: 0.200844
ret: 0 st:
0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st:
1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:0 dts: 1.4
40000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st: 0 flags:0 dts: 1.4
00000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st:
1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st:
0 flags:0 dts: 1.960000 pts: 2.000000 pos: 250980 size: 13438
ret: 0 st: 0 flags:0 ts: 0.883344
ret: 0 st: 0 flags:0 dts: 1.
600000 pts: 1.640000 pos: 102836 size: 12781
ret: 0 st: 0 flags:0 dts: 1.
400000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st: 0 flags:1 ts:-0.222489
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts: 2.671678
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
ret: 0 st: 1 flags:1 ts: 1.565844
ret: 0 st:
0 flags:0 dts: 2.240000 pts: 2.280000 pos: 350996 size: 11307
ret: 0 st:
1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:0 dts: 1.4
40000 pts: 1.480000 pos: 44932 size: 14502
ret: 0 st: 0 flags:0 dts: 1.4
00000 pts: 1.440000 pos: 27072 size: 16433
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
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