Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
db37ca8b
Commit
db37ca8b
authored
Feb 15, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: ts: split PES header parsing
parent
2b51d31e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
40 deletions
+57
-40
modules/demux/ts.c
modules/demux/ts.c
+57
-40
No files found.
modules/demux/ts.c
View file @
db37ca8b
...
...
@@ -2050,30 +2050,12 @@ static block_t *Opus_Parse(demux_t *demux, block_t *block)
/****************************************************************************
* gathering stuff
****************************************************************************/
static
void
ParsePES
(
demux_t
*
p_demux
,
ts_pid_t
*
pid
,
block_t
*
p_pes
)
static
int
ParsePESHeader
(
demux_t
*
p_demux
,
const
uint8_t
*
p_header
,
unsigned
*
pi_skip
,
mtime_t
*
pi_dts
,
mtime_t
*
pi_pts
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
uint8_t
header
[
34
];
unsigned
i_pes_size
=
0
;
unsigned
i_skip
=
0
;
mtime_t
i_dts
=
-
1
;
mtime_t
i_pts
=
-
1
;
mtime_t
i_length
=
0
;
/* FIXME find real max size */
/* const int i_max = */
block_ChainExtract
(
p_pes
,
header
,
34
);
if
(
pid
->
b_scrambled
||
header
[
0
]
!=
0
||
header
[
1
]
!=
0
||
header
[
2
]
!=
1
)
{
if
(
!
pid
->
b_scrambled
)
msg_Warn
(
p_demux
,
"invalid header [0x%02x:%02x:%02x:%02x] (pid: %d)"
,
header
[
0
],
header
[
1
],
header
[
2
],
header
[
3
],
pid
->
i_pid
);
block_ChainRelease
(
p_pes
);
return
;
}
unsigned
i_skip
;
/* TODO check size */
switch
(
header
[
3
]
)
switch
(
p_header
[
3
]
)
{
case
0xBC
:
/* Program stream map */
case
0xBE
:
/* Padding */
...
...
@@ -2086,48 +2068,43 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
i_skip
=
6
;
break
;
default:
if
(
(
header
[
6
]
&
0xC0
)
==
0x80
)
if
(
(
p_
header
[
6
]
&
0xC0
)
==
0x80
)
{
/* mpeg2 PES */
i_skip
=
header
[
8
]
+
9
;
i_skip
=
p_
header
[
8
]
+
9
;
if
(
header
[
7
]
&
0x80
)
/* has pts */
if
(
p_
header
[
7
]
&
0x80
)
/* has pts */
{
i_pts
=
ExtractPESTimestamp
(
&
header
[
9
]
);
i_pts
=
AdjustPTSWrapAround
(
p_demux
,
i_pts
);
*
pi_pts
=
ExtractPESTimestamp
(
&
p_header
[
9
]
);
if
(
header
[
7
]
&
0x40
)
/* has dts */
{
i_dts
=
ExtractPESTimestamp
(
&
header
[
14
]
);
i_dts
=
AdjustPTSWrapAround
(
p_demux
,
i_dts
);
}
if
(
p_header
[
7
]
&
0x40
)
/* has dts */
*
pi_dts
=
ExtractPESTimestamp
(
&
p_header
[
14
]
);
}
}
else
{
i_skip
=
6
;
while
(
i_skip
<
23
&&
header
[
i_skip
]
==
0xff
)
while
(
i_skip
<
23
&&
p_
header
[
i_skip
]
==
0xff
)
{
i_skip
++
;
}
if
(
i_skip
==
23
)
{
msg_Err
(
p_demux
,
"too much MPEG-1 stuffing"
);
block_ChainRelease
(
p_pes
);
return
;
return
VLC_EGENERIC
;
}
if
(
(
header
[
i_skip
]
&
0xC0
)
==
0x40
)
if
(
(
p_
header
[
i_skip
]
&
0xC0
)
==
0x40
)
{
i_skip
+=
2
;
}
if
(
header
[
i_skip
]
&
0x20
)
if
(
p_
header
[
i_skip
]
&
0x20
)
{
i_pts
=
ExtractPESTimestamp
(
&
header
[
i_skip
]
);
*
pi_pts
=
ExtractPESTimestamp
(
&
p_
header
[
i_skip
]
);
if
(
header
[
i_skip
]
&
0x10
)
/* has dts */
if
(
p_
header
[
i_skip
]
&
0x10
)
/* has dts */
{
i_dts
=
ExtractPESTimestamp
(
&
header
[
i_skip
+
5
]
);
*
pi_dts
=
ExtractPESTimestamp
(
&
p_
header
[
i_skip
+
5
]
);
i_skip
+=
10
;
}
else
...
...
@@ -2143,6 +2120,46 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
break
;
}
*
pi_skip
=
i_skip
;
return
VLC_SUCCESS
;
}
static
void
ParsePES
(
demux_t
*
p_demux
,
ts_pid_t
*
pid
,
block_t
*
p_pes
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
uint8_t
header
[
34
];
unsigned
i_pes_size
=
0
;
unsigned
i_skip
=
0
;
mtime_t
i_dts
=
-
1
;
mtime_t
i_pts
=
-
1
;
mtime_t
i_length
=
0
;
/* FIXME find real max size */
/* const int i_max = */
block_ChainExtract
(
p_pes
,
header
,
34
);
if
(
pid
->
b_scrambled
||
header
[
0
]
!=
0
||
header
[
1
]
!=
0
||
header
[
2
]
!=
1
)
{
if
(
!
pid
->
b_scrambled
)
msg_Warn
(
p_demux
,
"invalid header [0x%02x:%02x:%02x:%02x] (pid: %d)"
,
header
[
0
],
header
[
1
],
header
[
2
],
header
[
3
],
pid
->
i_pid
);
block_ChainRelease
(
p_pes
);
return
;
}
/* TODO check size */
if
(
ParsePESHeader
(
p_demux
,
(
uint8_t
*
)
&
header
,
&
i_skip
,
&
i_dts
,
&
i_pts
)
==
VLC_EGENERIC
)
{
block_ChainRelease
(
p_pes
);
return
;
}
else
{
if
(
i_pts
!=
-
1
)
i_pts
=
AdjustPTSWrapAround
(
p_demux
,
i_pts
);
if
(
i_dts
!=
-
1
)
i_dts
=
AdjustPTSWrapAround
(
p_demux
,
i_dts
);
}
if
(
pid
->
es
->
fmt
.
i_codec
==
VLC_FOURCC
(
'a'
,
'5'
,
'2'
,
'b'
)
||
pid
->
es
->
fmt
.
i_codec
==
VLC_FOURCC
(
'd'
,
't'
,
's'
,
'b'
)
)
{
...
...
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