Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
2a19f53c
Commit
2a19f53c
authored
Sep 07, 2012
by
Ludovic Fauvet
Committed by
Jean-Baptiste Kempf
Sep 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ogg: fix computation of vorbis stream length (close #1859)
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
397b9e09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
28 deletions
+33
-28
modules/demux/ogg.c
modules/demux/ogg.c
+32
-28
modules/demux/oggseek.c
modules/demux/oggseek.c
+1
-0
No files found.
modules/demux/ogg.c
View file @
2a19f53c
...
...
@@ -135,10 +135,11 @@ static bool Ogg_LogicalStreamResetEsFormat( demux_t *p_demux, logical_stream_t *
/* */
static
void
Ogg_ExtractMeta
(
demux_t
*
p_demux
,
vlc_fourcc_t
i_codec
,
const
uint8_t
*
p_headers
,
int
i_headers
);
static
int64_t
Ogg_GetLastPacket
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
ogg_packet
*
p_oggpacket
,
double
f_rate
);
/* Logical bitstream headers */
static
void
Ogg_ReadTheoraHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadVorbisHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadVorbisHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadSpeexHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadOpusHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadKateHeader
(
logical_stream_t
*
,
ogg_packet
*
);
...
...
@@ -317,7 +318,7 @@ static int Demux( demux_t * p_demux )
oggpacket
.
bytes
>=
7
&&
!
memcmp
(
oggpacket
.
packet
,
"
\x01
vorbis"
,
7
)
)
{
Ogg_ReadVorbisHeader
(
p_stream
,
&
oggpacket
);
Ogg_ReadVorbisHeader
(
p_
demux
,
p_
stream
,
&
oggpacket
);
p_stream
->
i_secondary_header_packets
=
0
;
}
else
if
(
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_CMML
)
...
...
@@ -1096,7 +1097,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
if
(
oggpacket
.
bytes
>=
7
&&
!
memcmp
(
oggpacket
.
packet
,
"
\x01
vorbis"
,
7
)
)
{
Ogg_ReadVorbisHeader
(
p_stream
,
&
oggpacket
);
Ogg_ReadVorbisHeader
(
p_
demux
,
p_
stream
,
&
oggpacket
);
msg_Dbg
(
p_demux
,
"found vorbis header"
);
}
/* Check for Speex header */
...
...
@@ -1826,6 +1827,19 @@ static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8
p_demux
->
info
.
i_update
|=
INPUT_UPDATE_META
;
}
static
int64_t
Ogg_GetLastPacket
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
ogg_packet
*
p_oggpacket
,
double
f_rate
)
{
int64_t
last_packet
=
oggseek_get_last_frame
(
p_demux
,
p_stream
);
/*
* Since there's quite a good chance that ogg_stream_packetout was called,
* the given p_oggpacket may point to invalid data. Fill it with some valid ones
*/
ogg_stream_packetpeek
(
&
p_stream
->
os
,
p_oggpacket
);
return
(
last_packet
>=
0
)
?
last_packet
/
f_rate
:
-
1
;
}
static
void
Ogg_ReadTheoraHeader
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
ogg_packet
*
p_oggpacket
)
{
...
...
@@ -1886,6 +1900,7 @@ static void Ogg_ReadTheoraHeader( demux_t *p_demux, logical_stream_t *p_stream,
i_version
=
i_major
*
1000000
+
i_minor
*
1000
+
i_subminor
;
p_stream
->
i_keyframe_offset
=
0
;
p_stream
->
f_rate
=
((
float
)
i_fps_numerator
)
/
i_fps_denominator
;
if
(
i_version
>=
3002001
)
{
...
...
@@ -1893,24 +1908,14 @@ static void Ogg_ReadTheoraHeader( demux_t *p_demux, logical_stream_t *p_stream,
}
if
(
p_demux
->
p_sys
->
i_length
<
0
)
{
int64_t
last_frame
=
oggseek_get_last_frame
(
p_demux
,
p_stream
);
/*
* Since there's quite a good chance that ogg_stream_packetout was called,
* the given p_oggpacket may point to invalid data. Fill it with some valid ones
*/
ogg_stream_packetpeek
(
&
p_stream
->
os
,
p_oggpacket
);
if
(
last_frame
>=
0
)
{
p_demux
->
p_sys
->
i_length
=
last_frame
/
((
float
)
i_fps_numerator
/
(
float
)
i_fps_denominator
);
}
int64_t
last_packet
=
Ogg_GetLastPacket
(
p_demux
,
p_stream
,
p_oggpacket
,
p_stream
->
f_rate
);
if
(
last_packet
>=
0
)
p_demux
->
p_sys
->
i_length
=
last_packet
;
}
p_stream
->
f_rate
=
((
float
)
i_fps_numerator
)
/
i_fps_denominator
;
}
static
void
Ogg_ReadVorbisHeader
(
logical_stream_t
*
p_stream
,
static
void
Ogg_ReadVorbisHeader
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
ogg_packet
*
p_oggpacket
)
{
oggpack_buffer
opb
;
...
...
@@ -1931,6 +1936,13 @@ static void Ogg_ReadVorbisHeader( logical_stream_t *p_stream,
oggpack_read
(
&
opb
,
32
);
oggpack_adv
(
&
opb
,
32
);
p_stream
->
fmt
.
i_bitrate
=
oggpack_read
(
&
opb
,
32
);
if
(
p_demux
->
p_sys
->
i_length
<
0
)
{
int64_t
last_packet
=
Ogg_GetLastPacket
(
p_demux
,
p_stream
,
p_oggpacket
,
p_stream
->
f_rate
);
if
(
last_packet
>=
0
)
p_demux
->
p_sys
->
i_length
=
last_packet
;
}
}
static
void
Ogg_ReadSpeexHeader
(
logical_stream_t
*
p_stream
,
...
...
@@ -1986,17 +1998,9 @@ static void Ogg_ReadOpusHeader( demux_t *p_demux,
if
(
p_demux
->
p_sys
->
i_length
<
0
)
{
int64_t
last_frame
=
oggseek_get_last_frame
(
p_demux
,
p_stream
);
/*
* Since there's quite a good chance that ogg_stream_packetout was called,
* the given p_oggpacket may point to invalid data. Fill it with some valid ones
*/
ogg_stream_packetpeek
(
&
p_stream
->
os
,
p_oggpacket
);
if
(
last_frame
>=
0
)
{
p_demux
->
p_sys
->
i_length
=
last_frame
/
p_stream
->
f_rate
;
}
int64_t
last_packet
=
Ogg_GetLastPacket
(
p_demux
,
p_stream
,
p_oggpacket
,
p_stream
->
f_rate
);
if
(
last_packet
>=
0
)
p_demux
->
p_sys
->
i_length
=
last_packet
;
}
}
...
...
modules/demux/oggseek.c
View file @
2a19f53c
...
...
@@ -731,6 +731,7 @@ int64_t oggseek_get_last_frame ( demux_t *p_demux, logical_stream_t *p_stream )
int64_t
i_frame
=
-
1
;
if
(
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_THEORA
||
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_VORBIS
||
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_OPUS
)
{
i_frame
=
get_last_frame
(
p_demux
,
p_stream
);
...
...
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