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
c98cb1d6
Commit
c98cb1d6
authored
Nov 11, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/opus: support chained streams
parent
ba6f2b04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
NEWS
NEWS
+1
-0
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+36
-1
No files found.
NEWS
View file @
c98cb1d6
...
...
@@ -10,6 +10,7 @@ ver 0.19.3 (not yet released)
- audiofile: fix bit rate calculation
- ffmpeg: support opus
- opus: fix bogus duration on streams
- opus: support chained streams
- opus: improved error logging
* fix distorted audio with soxr resampler
* fix build failure on Mac OS X with non-Apple compilers
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
c98cb1d6
...
...
@@ -77,6 +77,14 @@ class MPDOpusDecoder {
OpusDecoder
*
opus_decoder
;
opus_int16
*
output_buffer
;
/**
* If non-zero, then a previous Opus stream has been found
* already with this number of channels. If opus_decoder is
* nullptr, then its end-of-stream packet has been found
* already.
*/
unsigned
previous_channels
;
bool
os_initialized
;
int
opus_serialno
;
...
...
@@ -91,6 +99,7 @@ public:
:
decoder
(
_decoder
),
input_stream
(
_input_stream
),
opus_decoder
(
nullptr
),
output_buffer
(
nullptr
),
previous_channels
(
0
),
os_initialized
(
false
)
{}
~
MPDOpusDecoder
();
...
...
@@ -245,7 +254,14 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
}
assert
(
opus_decoder
==
nullptr
);
assert
(
output_buffer
==
nullptr
);
assert
((
previous_channels
==
0
)
==
(
output_buffer
==
nullptr
));
if
(
previous_channels
!=
0
&&
channels
!=
previous_channels
)
{
FormatWarning
(
opus_domain
,
"Next stream has different channels (%u -> %u)"
,
previous_channels
,
channels
);
return
DecoderCommand
::
STOP
;
}
opus_serialno
=
os
.
serialno
;
...
...
@@ -261,6 +277,13 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
return
DecoderCommand
::
STOP
;
}
if
(
previous_channels
!=
0
)
{
/* decoder was already initialized by the previous
stream; skip the rest of this method */
LogDebug
(
opus_domain
,
"Found another stream"
);
return
decoder_get_command
(
decoder
);
}
eos_granulepos
=
LoadEOSGranulePos
(
input_stream
,
&
decoder
,
opus_serialno
);
const
auto
duration
=
eos_granulepos
>=
0
...
...
@@ -268,6 +291,7 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
opus_sample_rate
)
:
SignedSongTime
::
Negative
();
previous_channels
=
channels
;
const
AudioFormat
audio_format
(
opus_sample_rate
,
SampleFormat
::
S16
,
channels
);
decoder_initialized
(
decoder
,
audio_format
,
...
...
@@ -283,6 +307,17 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
inline
DecoderCommand
MPDOpusDecoder
::
HandleEOS
()
{
if
(
eos_granulepos
<
0
&&
previous_channels
!=
0
)
{
/* allow chaining of (unseekable) streams */
assert
(
opus_decoder
!=
nullptr
);
assert
(
output_buffer
!=
nullptr
);
opus_decoder_destroy
(
opus_decoder
);
opus_decoder
=
nullptr
;
return
decoder_get_command
(
decoder
);
}
return
DecoderCommand
::
STOP
;
}
...
...
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