Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
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
Steve Lhomme
VLC
Commits
968628e8
Commit
968628e8
authored
Mar 08, 2017
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: ps: improve probing
parent
efb51e5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
11 deletions
+33
-11
modules/demux/mpeg/ps.c
modules/demux/mpeg/ps.c
+33
-11
No files found.
modules/demux/mpeg/ps.c
View file @
968628e8
...
...
@@ -46,6 +46,8 @@
"to calculate position and duration. However sometimes this might not " \
"be usable. Disable this option to calculate from the bitrate instead." )
#define PS_PACKET_PROBE 3
/*****************************************************************************
* Module descriptor
*****************************************************************************/
...
...
@@ -113,28 +115,48 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
demux_sys_t
*
p_sys
;
const
uint8_t
*
p_peek
;
ssize_t
i_peek
=
0
;
ssize_t
i_offset
=
0
;
bool
b_cdxa
=
false
;
if
(
vlc_stream_Peek
(
p_demux
->
s
,
&
p_peek
,
16
)
<
16
)
i_peek
=
vlc_stream_Peek
(
p_demux
->
s
,
&
p_peek
,
16
);
if
(
i_peek
<
16
)
{
msg_Err
(
p_demux
,
"cannot peek"
);
return
VLC_EGENERIC
;
}
if
(
memcmp
(
p_peek
,
"
\x00\x00\x01
"
,
3
)
||
(
p_peek
[
3
]
<
0xb9
)
)
if
(
!
memcmp
(
p_peek
,
"RIFF"
,
4
)
&&
!
memcmp
(
&
p_peek
[
8
],
"CDXA"
,
4
)
)
{
b_cdxa
=
true
;
msg_Info
(
p_demux
,
"Detected CDXA-PS"
);
}
else
if
(
b_force
)
{
msg_Warn
(
p_demux
,
"this does not look like an MPEG PS stream, "
"continuing anyway"
);
}
else
for
(
unsigned
i
=
0
;
i
<
PS_PACKET_PROBE
;
i
++
)
{
if
(
memcmp
(
p_peek
,
"RIFF"
,
4
)
||
memcmp
(
&
p_peek
[
8
],
"CDXA"
,
4
)
)
if
(
i_peek
<
i_offset
+
16
)
{
if
(
!
b_force
)
i_peek
=
vlc_stream_Peek
(
p_demux
->
s
,
&
p_peek
,
i_offset
+
16
);
if
(
i_peek
<
i_offset
+
16
)
return
VLC_EGENERIC
;
msg_Warn
(
p_demux
,
"this does not look like an MPEG PS stream, "
"continuing anyway"
);
}
else
{
b_cdxa
=
true
;
msg_Info
(
p_demux
,
"Detected CDXA-PS"
);
}
const
uint8_t
startcode
[
3
]
=
{
0x00
,
0x00
,
0x01
};
const
uint8_t
*
p_header
=
&
p_peek
[
i_offset
];
if
(
memcmp
(
p_header
,
startcode
,
3
)
||
(
(
p_header
[
3
]
&
0xB0
)
!=
0xB0
&&
!
(
p_header
[
3
]
>=
0xC0
&&
p_header
[
3
]
<=
0xEF
)
&&
p_header
[
3
]
!=
0xFF
)
)
return
VLC_EGENERIC
;
ssize_t
i_pessize
=
ps_pkt_size
(
p_header
,
16
);
if
(
i_pessize
<
5
)
return
VLC_EGENERIC
;
i_offset
+=
i_pessize
;
}
/* Fill p_demux field */
...
...
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