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
4a04f734
Commit
4a04f734
authored
Nov 11, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/opus: add constexpr output_buffer_frames
parent
134cb6a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+10
-8
No files found.
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
4a04f734
...
...
@@ -40,6 +40,12 @@
static
constexpr
opus_int32
opus_sample_rate
=
48000
;
/**
* Allocate an output buffer for 16 bit PCM samples big enough to hold
* a quarter second, larger than 120ms required by libopus.
*/
static
constexpr
unsigned
opus_output_buffer_frames
=
opus_sample_rate
/
4
;
gcc_pure
static
bool
IsOpusHead
(
const
ogg_packet
&
packet
)
...
...
@@ -70,7 +76,6 @@ class MPDOpusDecoder {
OpusDecoder
*
opus_decoder
;
opus_int16
*
output_buffer
;
unsigned
output_size
;
bool
os_initialized
;
bool
found_opus
;
...
...
@@ -86,7 +91,7 @@ public:
InputStream
&
_input_stream
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
),
opus_decoder
(
nullptr
),
output_buffer
(
nullptr
),
output_size
(
0
),
output_buffer
(
nullptr
),
os_initialized
(
false
),
found_opus
(
false
)
{}
~
MPDOpusDecoder
();
...
...
@@ -264,11 +269,8 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
eos_granulepos
>
0
,
duration
);
frame_size
=
audio_format
.
GetFrameSize
();
/* allocate an output buffer for 16 bit PCM samples big enough
to hold a quarter second, larger than 120ms required by
libopus */
output_size
=
audio_format
.
sample_rate
/
4
;
output_buffer
=
new
opus_int16
[
output_size
*
audio_format
.
channels
];
output_buffer
=
new
opus_int16
[
opus_output_buffer_frames
*
audio_format
.
channels
];
return
decoder_get_command
(
decoder
);
}
...
...
@@ -304,7 +306,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
int
nframes
=
opus_decode
(
opus_decoder
,
(
const
unsigned
char
*
)
packet
.
packet
,
packet
.
bytes
,
output_buffer
,
o
utput_size
,
output_buffer
,
o
pus_output_buffer_frames
,
0
);
if
(
nframes
<
0
)
{
LogError
(
opus_domain
,
opus_strerror
(
nframes
));
...
...
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