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
4acc86bc
Commit
4acc86bc
authored
Mar 02, 2014
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegts: move last_pcr to MpegTSFilter level
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
f0283290
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
mpegts.c
libavformat/mpegts.c
+9
-13
No files found.
libavformat/mpegts.c
View file @
4acc86bc
...
@@ -60,7 +60,7 @@ enum MpegTSFilterType {
...
@@ -60,7 +60,7 @@ enum MpegTSFilterType {
typedef
struct
MpegTSFilter
MpegTSFilter
;
typedef
struct
MpegTSFilter
MpegTSFilter
;
typedef
int
PESCallback
(
MpegTSFilter
*
f
,
const
uint8_t
*
buf
,
int
len
,
typedef
int
PESCallback
(
MpegTSFilter
*
f
,
const
uint8_t
*
buf
,
int
len
,
int
is_start
,
int64_t
pos
,
int64_t
cur_pcr
);
int
is_start
,
int64_t
pos
);
typedef
struct
MpegTSPESFilter
{
typedef
struct
MpegTSPESFilter
{
PESCallback
*
pes_cb
;
PESCallback
*
pes_cb
;
...
@@ -85,6 +85,7 @@ struct MpegTSFilter {
...
@@ -85,6 +85,7 @@ struct MpegTSFilter {
int
pid
;
int
pid
;
int
es_id
;
int
es_id
;
int
last_cc
;
/* last cc code (-1 if first packet) */
int
last_cc
;
/* last cc code (-1 if first packet) */
int64_t
last_pcr
;
enum
MpegTSFilterType
type
;
enum
MpegTSFilterType
type
;
union
{
union
{
MpegTSPESFilter
pes_filter
;
MpegTSPESFilter
pes_filter
;
...
@@ -216,7 +217,6 @@ typedef struct PESContext {
...
@@ -216,7 +217,6 @@ typedef struct PESContext {
uint8_t
header
[
MAX_PES_HEADER_SIZE
];
uint8_t
header
[
MAX_PES_HEADER_SIZE
];
AVBufferRef
*
buffer
;
AVBufferRef
*
buffer
;
SLConfigDescr
sl
;
SLConfigDescr
sl
;
int64_t
last_pcr
;
}
PESContext
;
}
PESContext
;
extern
AVInputFormat
ff_mpegts_demuxer
;
extern
AVInputFormat
ff_mpegts_demuxer
;
...
@@ -427,6 +427,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts,
...
@@ -427,6 +427,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts,
filter
->
pid
=
pid
;
filter
->
pid
=
pid
;
filter
->
es_id
=
-
1
;
filter
->
es_id
=
-
1
;
filter
->
last_cc
=
-
1
;
filter
->
last_cc
=
-
1
;
filter
->
last_pcr
=
-
1
;
sec
=
&
filter
->
u
.
section_filter
;
sec
=
&
filter
->
u
.
section_filter
;
sec
->
section_cb
=
section_cb
;
sec
->
section_cb
=
section_cb
;
...
@@ -891,7 +892,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
...
@@ -891,7 +892,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
/* return non zero if a packet could be constructed */
/* return non zero if a packet could be constructed */
static
int
mpegts_push_data
(
MpegTSFilter
*
filter
,
static
int
mpegts_push_data
(
MpegTSFilter
*
filter
,
const
uint8_t
*
buf
,
int
buf_size
,
int
is_start
,
const
uint8_t
*
buf
,
int
buf_size
,
int
is_start
,
int64_t
pos
,
int64_t
pcr
)
int64_t
pos
)
{
{
PESContext
*
pes
=
filter
->
u
.
pes_filter
.
opaque
;
PESContext
*
pes
=
filter
->
u
.
pes_filter
.
opaque
;
MpegTSContext
*
ts
=
pes
->
ts
;
MpegTSContext
*
ts
=
pes
->
ts
;
...
@@ -901,9 +902,6 @@ static int mpegts_push_data(MpegTSFilter *filter,
...
@@ -901,9 +902,6 @@ static int mpegts_push_data(MpegTSFilter *filter,
if
(
!
ts
->
pkt
)
if
(
!
ts
->
pkt
)
return
0
;
return
0
;
if
(
pcr
!=
-
1
)
pes
->
last_pcr
=
pcr
;
if
(
is_start
)
{
if
(
is_start
)
{
if
(
pes
->
state
==
MPEGTS_PAYLOAD
&&
pes
->
data_index
>
0
)
{
if
(
pes
->
state
==
MPEGTS_PAYLOAD
&&
pes
->
data_index
>
0
)
{
new_pes_packet
(
pes
,
ts
->
pkt
);
new_pes_packet
(
pes
,
ts
->
pkt
);
...
@@ -1068,12 +1066,12 @@ skip:
...
@@ -1068,12 +1066,12 @@ skip:
MpegTSFilter
*
f
=
pes
->
ts
->
pids
[
p
->
pcr_pid
];
MpegTSFilter
*
f
=
pes
->
ts
->
pids
[
p
->
pcr_pid
];
if
(
f
&&
f
->
type
==
MPEGTS_PES
)
{
if
(
f
&&
f
->
type
==
MPEGTS_PES
)
{
PESContext
*
pcrpes
=
f
->
u
.
pes_filter
.
opaque
;
PESContext
*
pcrpes
=
f
->
u
.
pes_filter
.
opaque
;
if
(
pcrpes
&&
pcrpes
->
last_pcr
!=
-
1
&&
pcrpes
->
st
&&
pcrpes
->
st
->
discard
!=
AVDISCARD_ALL
)
{
if
(
f
->
last_pcr
!=
-
1
&&
pcrpes
&&
pcrpes
->
st
&&
pcrpes
->
st
->
discard
!=
AVDISCARD_ALL
)
{
// teletext packets do not always have correct timestamps,
// teletext packets do not always have correct timestamps,
// the standard says they should be handled after 40.6 ms at most,
// the standard says they should be handled after 40.6 ms at most,
// and the pcr error to this packet should be no more than 100 ms.
// and the pcr error to this packet should be no more than 100 ms.
// TODO: we should interpolate the PCR, not just use the last one
// TODO: we should interpolate the PCR, not just use the last one
int64_t
pcr
=
pcrpes
->
last_pcr
/
300
;
int64_t
pcr
=
f
->
last_pcr
/
300
;
pes
->
st
->
pts_wrap_reference
=
pcrpes
->
st
->
pts_wrap_reference
;
pes
->
st
->
pts_wrap_reference
=
pcrpes
->
st
->
pts_wrap_reference
;
pes
->
st
->
pts_wrap_behavior
=
pcrpes
->
st
->
pts_wrap_behavior
;
pes
->
st
->
pts_wrap_behavior
=
pcrpes
->
st
->
pts_wrap_behavior
;
if
(
pes
->
dts
==
AV_NOPTS_VALUE
||
pes
->
dts
<
pcr
)
{
if
(
pes
->
dts
==
AV_NOPTS_VALUE
||
pes
->
dts
<
pcr
)
{
...
@@ -1146,7 +1144,6 @@ static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
...
@@ -1146,7 +1144,6 @@ static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
pes
->
state
=
MPEGTS_SKIP
;
pes
->
state
=
MPEGTS_SKIP
;
pes
->
pts
=
AV_NOPTS_VALUE
;
pes
->
pts
=
AV_NOPTS_VALUE
;
pes
->
dts
=
AV_NOPTS_VALUE
;
pes
->
dts
=
AV_NOPTS_VALUE
;
pes
->
last_pcr
=
-
1
;
tss
=
mpegts_open_pes_filter
(
ts
,
pid
,
mpegts_push_data
,
pes
);
tss
=
mpegts_open_pes_filter
(
ts
,
pid
,
mpegts_push_data
,
pes
);
if
(
!
tss
)
{
if
(
!
tss
)
{
av_free
(
pes
);
av_free
(
pes
);
...
@@ -2093,14 +2090,13 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
...
@@ -2093,14 +2090,13 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
}
else
{
}
else
{
int
ret
;
int
ret
;
int64_t
pcr
=
-
1
;
int64_t
pcr_h
;
int64_t
pcr_h
;
int
pcr_l
;
int
pcr_l
;
if
(
parse_pcr
(
&
pcr_h
,
&
pcr_l
,
packet
)
==
0
)
if
(
parse_pcr
(
&
pcr_h
,
&
pcr_l
,
packet
)
==
0
)
pcr
=
pcr_h
*
300
+
pcr_l
;
tss
->
last_
pcr
=
pcr_h
*
300
+
pcr_l
;
// Note: The position here points actually behind the current packet.
// Note: The position here points actually behind the current packet.
if
((
ret
=
tss
->
u
.
pes_filter
.
pes_cb
(
tss
,
p
,
p_end
-
p
,
is_start
,
if
((
ret
=
tss
->
u
.
pes_filter
.
pes_cb
(
tss
,
p
,
p_end
-
p
,
is_start
,
pos
-
ts
->
raw_packet_size
,
pcr
))
<
0
)
pos
-
ts
->
raw_packet_size
))
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -2217,9 +2213,9 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
...
@@ -2217,9 +2213,9 @@ static int handle_packets(MpegTSContext *ts, int nb_packets)
av_buffer_unref
(
&
pes
->
buffer
);
av_buffer_unref
(
&
pes
->
buffer
);
pes
->
data_index
=
0
;
pes
->
data_index
=
0
;
pes
->
state
=
MPEGTS_SKIP
;
/* skip until pes header */
pes
->
state
=
MPEGTS_SKIP
;
/* skip until pes header */
pes
->
last_pcr
=
-
1
;
}
}
ts
->
pids
[
i
]
->
last_cc
=
-
1
;
ts
->
pids
[
i
]
->
last_cc
=
-
1
;
ts
->
pids
[
i
]
->
last_pcr
=
-
1
;
}
}
}
}
}
}
...
...
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