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
5ca137c7
Commit
5ca137c7
authored
Jul 01, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/opus: add API docs
parent
760238fe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+20
-1
No files found.
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
5ca137c7
...
...
@@ -75,7 +75,18 @@ class MPDOpusDecoder final : public OggDecoder {
OpusDecoder
*
opus_decoder
=
nullptr
;
opus_int16
*
output_buffer
=
nullptr
;
unsigned
pre_skip
,
skip
;
/**
* The pre-skip value from the Opus header. Initialized by
* OnOggBeginning().
*/
unsigned
pre_skip
;
/**
* The number of decoded samples which shall be skipped. At
* the beginning of the file, this gets set to #pre_skip (by
* OnOggBeginning()), and may also be set while seeking.
*/
unsigned
skip
;
/**
* If non-zero, then a previous Opus stream has been found
...
...
@@ -240,6 +251,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
opus_strerror
(
nframes
));
if
(
nframes
>
0
)
{
/* apply the "skip" value */
if
(
skip
>=
(
unsigned
)
nframes
)
{
skip
-=
nframes
;
return
;
...
...
@@ -250,6 +262,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
nframes
-=
skip
;
skip
=
0
;
/* submit decoded samples to the DecoderClient */
const
size_t
nbytes
=
nframes
*
frame_size
;
auto
cmd
=
client
.
SubmitData
(
input_stream
,
data
,
nbytes
,
...
...
@@ -274,6 +287,12 @@ MPDOpusDecoder::Seek(uint64_t where_frame)
try
{
SeekGranulePos
(
where_granulepos
);
/* since all frame numbers are offset by the file's
pre-skip value, we need to apply it here as well;
we could just seek to "where_frame+pre_skip" as
well, but I think by decoding those samples and
discard them, we're safer */
skip
=
pre_skip
;
return
true
;
}
catch
(...)
{
...
...
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