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
bc6a86c0
Commit
bc6a86c0
authored
Sep 06, 2012
by
Ludovic Fauvet
Committed by
Jean-Baptiste Kempf
Sep 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ogg: find the length of an opus stream
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
597e34b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
modules/demux/ogg.c
modules/demux/ogg.c
+19
-3
modules/demux/oggseek.c
modules/demux/oggseek.c
+10
-7
No files found.
modules/demux/ogg.c
View file @
bc6a86c0
...
@@ -140,7 +140,7 @@ static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8
...
@@ -140,7 +140,7 @@ static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8
static
void
Ogg_ReadTheoraHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadTheoraHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadVorbisHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadVorbisHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadSpeexHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadSpeexHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadOpusHeader
(
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
*
);
static
void
Ogg_ReadKateHeader
(
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadFlacHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadFlacHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadAnnodexHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
static
void
Ogg_ReadAnnodexHeader
(
demux_t
*
,
logical_stream_t
*
,
ogg_packet
*
);
...
@@ -1113,7 +1113,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
...
@@ -1113,7 +1113,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
else
if
(
oggpacket
.
bytes
>=
8
&&
else
if
(
oggpacket
.
bytes
>=
8
&&
!
memcmp
(
oggpacket
.
packet
,
"OpusHead"
,
8
)
)
!
memcmp
(
oggpacket
.
packet
,
"OpusHead"
,
8
)
)
{
{
Ogg_ReadOpusHeader
(
p_stream
,
&
oggpacket
);
Ogg_ReadOpusHeader
(
p_
demux
,
p_
stream
,
&
oggpacket
);
msg_Dbg
(
p_demux
,
"found opus header, channels: %i, "
msg_Dbg
(
p_demux
,
"found opus header, channels: %i, "
"pre-skip: %i"
,
"pre-skip: %i"
,
p_stream
->
fmt
.
audio
.
i_channels
,
p_stream
->
fmt
.
audio
.
i_channels
,
...
@@ -1958,7 +1958,8 @@ static void Ogg_ReadSpeexHeader( logical_stream_t *p_stream,
...
@@ -1958,7 +1958,8 @@ static void Ogg_ReadSpeexHeader( logical_stream_t *p_stream,
p_stream
->
fmt
.
i_bitrate
=
oggpack_read
(
&
opb
,
32
);
p_stream
->
fmt
.
i_bitrate
=
oggpack_read
(
&
opb
,
32
);
}
}
static
void
Ogg_ReadOpusHeader
(
logical_stream_t
*
p_stream
,
static
void
Ogg_ReadOpusHeader
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
ogg_packet
*
p_oggpacket
)
ogg_packet
*
p_oggpacket
)
{
{
oggpack_buffer
opb
;
oggpack_buffer
opb
;
...
@@ -1982,6 +1983,21 @@ static void Ogg_ReadOpusHeader( logical_stream_t *p_stream,
...
@@ -1982,6 +1983,21 @@ static void Ogg_ReadOpusHeader( logical_stream_t *p_stream,
oggpack_adv
(
&
opb
,
8
);
/* version_id */
oggpack_adv
(
&
opb
,
8
);
/* version_id */
p_stream
->
fmt
.
audio
.
i_channels
=
oggpack_read
(
&
opb
,
8
);
p_stream
->
fmt
.
audio
.
i_channels
=
oggpack_read
(
&
opb
,
8
);
p_stream
->
i_pre_skip
=
oggpack_read
(
&
opb
,
16
);
p_stream
->
i_pre_skip
=
oggpack_read
(
&
opb
,
16
);
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
;
}
}
}
}
static
void
Ogg_ReadFlacHeader
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
static
void
Ogg_ReadFlacHeader
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
,
...
...
modules/demux/oggseek.c
View file @
bc6a86c0
...
@@ -690,10 +690,11 @@ static demux_index_entry_t *get_bounds_for ( logical_stream_t *p_stream, int64_t
...
@@ -690,10 +690,11 @@ static demux_index_entry_t *get_bounds_for ( logical_stream_t *p_stream, int64_t
}
}
/* get highest frame in theora
stream
*/
/* get highest frame in theora
and opus streams
*/
static
int64_t
find_last_theora
_frame
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
)
static
int64_t
get_last
_frame
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
)
{
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int64_t
i_frame
;
int64_t
i_frame
;
i_frame
=
find_last_frame
(
p_demux
,
p_stream
);
i_frame
=
find_last_frame
(
p_demux
,
p_stream
);
...
@@ -706,9 +707,10 @@ static int64_t find_last_theora_frame ( demux_t *p_demux, logical_stream_t *p_st
...
@@ -706,9 +707,10 @@ static int64_t find_last_theora_frame ( demux_t *p_demux, logical_stream_t *p_st
seek_byte
(
p_demux
,
0
);
seek_byte
(
p_demux
,
0
);
/* Reset stream states */
/* Reset stream states */
p_stream
->
i_serial_no
=
ogg_page_serialno
(
&
p_demux
->
p_sys
->
current_page
);
p_sys
->
i_streams
=
0
;
p_stream
->
i_serial_no
=
ogg_page_serialno
(
&
p_sys
->
current_page
);
ogg_stream_init
(
&
p_stream
->
os
,
p_stream
->
i_serial_no
);
ogg_stream_init
(
&
p_stream
->
os
,
p_stream
->
i_serial_no
);
ogg_stream_pagein
(
&
p_stream
->
os
,
&
p_
demux
->
p_
sys
->
current_page
);
ogg_stream_pagein
(
&
p_stream
->
os
,
&
p_sys
->
current_page
);
return
i_frame
;
return
i_frame
;
}
}
...
@@ -722,15 +724,16 @@ static int64_t find_last_theora_frame ( demux_t *p_demux, logical_stream_t *p_st
...
@@ -722,15 +724,16 @@ static int64_t find_last_theora_frame ( demux_t *p_demux, logical_stream_t *p_st
/* return highest frame number for p_stream (which must be a theora
or dirac video
stream) */
/* return highest frame number for p_stream (which must be a theora
, dirac or opus
stream) */
int64_t
oggseek_get_last_frame
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
)
int64_t
oggseek_get_last_frame
(
demux_t
*
p_demux
,
logical_stream_t
*
p_stream
)
{
{
int64_t
i_frame
=
-
1
;
int64_t
i_frame
=
-
1
;
if
(
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_THEORA
)
if
(
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_THEORA
||
p_stream
->
fmt
.
i_codec
==
VLC_CODEC_OPUS
)
{
{
i_frame
=
find_last_theora
_frame
(
p_demux
,
p_stream
);
i_frame
=
get_last
_frame
(
p_demux
,
p_stream
);
if
(
i_frame
<
0
)
return
-
1
;
if
(
i_frame
<
0
)
return
-
1
;
return
i_frame
;
return
i_frame
;
...
...
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