Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a99b4aba
Commit
a99b4aba
authored
Jul 01, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/OpusHead: return pre-skip
parent
472881cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+5
-3
OpusHead.cxx
src/decoder/plugins/OpusHead.cxx
+4
-1
OpusHead.hxx
src/decoder/plugins/OpusHead.hxx
+2
-1
No files found.
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
a99b4aba
...
@@ -136,8 +136,8 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
...
@@ -136,8 +136,8 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
if
(
opus_decoder
!=
nullptr
||
!
IsOpusHead
(
packet
))
if
(
opus_decoder
!=
nullptr
||
!
IsOpusHead
(
packet
))
throw
std
::
runtime_error
(
"BOS packet must be OpusHead"
);
throw
std
::
runtime_error
(
"BOS packet must be OpusHead"
);
unsigned
channels
;
unsigned
channels
,
pre_skip
;
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
)
||
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
,
pre_skip
)
||
!
audio_valid_channel_count
(
channels
))
!
audio_valid_channel_count
(
channels
))
throw
std
::
runtime_error
(
"Malformed BOS packet"
);
throw
std
::
runtime_error
(
"Malformed BOS packet"
);
...
@@ -305,10 +305,12 @@ ReadAndParseOpusHead(OggSyncState &sync, OggStreamState &stream,
...
@@ -305,10 +305,12 @@ ReadAndParseOpusHead(OggSyncState &sync, OggStreamState &stream,
unsigned
&
channels
)
unsigned
&
channels
)
{
{
ogg_packet
packet
;
ogg_packet
packet
;
unsigned
pre_skip
;
return
OggReadPacket
(
sync
,
stream
,
packet
)
&&
packet
.
b_o_s
&&
return
OggReadPacket
(
sync
,
stream
,
packet
)
&&
packet
.
b_o_s
&&
IsOpusHead
(
packet
)
&&
IsOpusHead
(
packet
)
&&
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
)
&&
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
,
pre_skip
)
&&
audio_valid_channel_count
(
channels
);
audio_valid_channel_count
(
channels
);
}
}
...
...
src/decoder/plugins/OpusHead.cxx
View file @
a99b4aba
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
*/
*/
#include "OpusHead.hxx"
#include "OpusHead.hxx"
#include "util/ByteOrder.hxx"
#include <stdint.h>
#include <stdint.h>
...
@@ -31,12 +32,14 @@ struct OpusHead {
...
@@ -31,12 +32,14 @@ struct OpusHead {
};
};
bool
bool
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
)
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
,
unsigned
&
pre_skip_r
)
{
{
const
OpusHead
*
h
=
(
const
OpusHead
*
)
data
;
const
OpusHead
*
h
=
(
const
OpusHead
*
)
data
;
if
(
size
<
19
||
(
h
->
version
&
0xf0
)
!=
0
)
if
(
size
<
19
||
(
h
->
version
&
0xf0
)
!=
0
)
return
false
;
return
false
;
channels_r
=
h
->
channels
;
channels_r
=
h
->
channels
;
pre_skip_r
=
FromLE16
(
h
->
pre_skip
);
return
true
;
return
true
;
}
}
src/decoder/plugins/OpusHead.hxx
View file @
a99b4aba
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <stddef.h>
#include <stddef.h>
bool
bool
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
);
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
,
unsigned
&
pre_skip_r
);
#endif
#endif
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