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
7c8427b0
Commit
7c8427b0
authored
Sep 21, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v0.21.x' into master
parents
7552f70c
b72801ab
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
8 deletions
+39
-8
NEWS
NEWS
+1
-0
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+20
-4
OpusHead.cxx
src/decoder/plugins/OpusHead.cxx
+3
-1
OpusHead.hxx
src/decoder/plugins/OpusHead.hxx
+1
-1
OpusTags.cxx
src/decoder/plugins/OpusTags.cxx
+2
-2
Mix.cxx
src/pcm/Mix.cxx
+1
-0
ByteOrder.hxx
src/util/ByteOrder.hxx
+11
-0
No files found.
NEWS
View file @
7c8427b0
...
...
@@ -54,6 +54,7 @@ ver 0.21.26 (not yet released)
* decoder
- ffmpeg: remove "rtsp://" from the list of supported protocols
- ffmpeg: add "hls+http://" to the list of supported protocols
- opus: support the gain value from the Opus header
- sndfile: fix lost samples at end of file
* fix "single" mode bug after resuming playback
* the default log_level is "default", not "info"
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
7c8427b0
...
...
@@ -76,6 +76,12 @@ class MPDOpusDecoder final : public OggDecoder {
opus_int16
*
output_buffer
=
nullptr
;
/**
* The output gain from the Opus header. Initialized by
* OnOggBeginning().
*/
signed
output_gain
;
/**
* The pre-skip value from the Opus header. Initialized by
* OnOggBeginning().
*/
...
...
@@ -164,7 +170,7 @@ MPDOpusDecoder::OnOggBeginning(const ogg_packet &packet)
throw
std
::
runtime_error
(
"BOS packet must be OpusHead"
);
unsigned
channels
;
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
,
pre_skip
)
||
if
(
!
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
,
output_gain
,
pre_skip
)
||
!
audio_valid_channel_count
(
channels
))
throw
std
::
runtime_error
(
"Malformed BOS packet"
);
...
...
@@ -239,6 +245,15 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
ReplayGainInfo
rgi
;
rgi
.
Clear
();
/**
* Output gain is a Q7.8 fixed point number in dB that should be,
* applied unconditionally, but is often used specifically for
* ReplayGain. Add 5dB to compensate for the different
* reference levels between ReplayGain (89dB) and EBU R128 (-23 LUFS).
*/
rgi
.
track
.
gain
=
float
(
output_gain
)
/
256.0
f
+
5
;
rgi
.
album
.
gain
=
float
(
output_gain
)
/
256.0
f
+
5
;
TagBuilder
tag_builder
;
AddTagHandler
h
(
tag_builder
);
...
...
@@ -384,14 +399,14 @@ mpd_opus_stream_decode(DecoderClient &client,
bool
ReadAndParseOpusHead
(
OggSyncState
&
sync
,
OggStreamState
&
stream
,
unsigned
&
channels
,
unsigned
&
pre_skip
)
unsigned
&
channels
,
signed
&
output_gain
,
unsigned
&
pre_skip
)
{
ogg_packet
packet
;
return
OggReadPacket
(
sync
,
stream
,
packet
)
&&
packet
.
b_o_s
&&
IsOpusHead
(
packet
)
&&
ScanOpusHeader
(
packet
.
packet
,
packet
.
bytes
,
channels
,
pre_skip
)
&&
output_gain
,
pre_skip
)
&&
audio_valid_channel_count
(
channels
);
}
...
...
@@ -436,7 +451,8 @@ mpd_opus_scan_stream(InputStream &is, TagHandler &handler)
OggStreamState
os
(
first_page
);
unsigned
channels
,
pre_skip
;
if
(
!
ReadAndParseOpusHead
(
oy
,
os
,
channels
,
pre_skip
)
||
signed
output_gain
;
if
(
!
ReadAndParseOpusHead
(
oy
,
os
,
channels
,
output_gain
,
pre_skip
)
||
!
ReadAndVisitOpusTags
(
oy
,
os
,
handler
))
return
false
;
...
...
src/decoder/plugins/OpusHead.cxx
View file @
7c8427b0
...
...
@@ -33,12 +33,14 @@ struct OpusHead {
bool
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
,
unsigned
&
pre_skip_r
)
signed
&
output_gain_r
,
unsigned
&
pre_skip_r
)
{
const
auto
*
h
=
(
const
OpusHead
*
)
data
;
if
(
size
<
19
||
(
h
->
version
&
0xf0
)
!=
0
)
return
false
;
output_gain_r
=
FromLE16S
(
h
->
output_gain
);
channels_r
=
h
->
channels
;
pre_skip_r
=
FromLE16
(
h
->
pre_skip
);
return
true
;
...
...
src/decoder/plugins/OpusHead.hxx
View file @
7c8427b0
...
...
@@ -24,6 +24,6 @@
bool
ScanOpusHeader
(
const
void
*
data
,
size_t
size
,
unsigned
&
channels_r
,
unsigned
&
pre_skip_r
);
signed
&
output_gain_r
,
unsigned
&
pre_skip_r
);
#endif
src/decoder/plugins/OpusTags.cxx
View file @
7c8427b0
...
...
@@ -61,7 +61,7 @@ ScanOneOpusTag(StringView name, StringView value,
const
char
*
endptr
;
const
auto
l
=
ParseInt64
(
value
,
&
endptr
,
10
);
if
(
endptr
>
value
.
begin
()
&&
endptr
==
value
.
end
())
rgi
->
track
.
gain
=
float
(
l
)
/
256.0
f
;
rgi
->
track
.
gain
+
=
float
(
l
)
/
256.0
f
;
}
else
if
(
rgi
!=
nullptr
&&
name
.
EqualsIgnoreCase
(
"R128_ALBUM_GAIN"
))
{
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
...
...
@@ -70,7 +70,7 @@ ScanOneOpusTag(StringView name, StringView value,
const
char
*
endptr
;
const
auto
l
=
ParseInt64
(
value
,
&
endptr
,
10
);
if
(
endptr
>
value
.
begin
()
&&
endptr
==
value
.
end
())
rgi
->
album
.
gain
=
float
(
l
)
/
256.0
f
;
rgi
->
album
.
gain
+
=
float
(
l
)
/
256.0
f
;
}
handler
.
OnPair
(
name
,
value
);
...
...
src/pcm/Mix.cxx
View file @
7c8427b0
...
...
@@ -27,6 +27,7 @@
#include "Dither.cxx" // including the .cxx file to get inlined templates
#include <cassert>
#include <cmath>
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
typename
Traits
::
value_type
...
...
src/util/ByteOrder.hxx
View file @
7c8427b0
...
...
@@ -243,4 +243,15 @@ ToLE64(uint64_t value) noexcept
return
IsLittleEndian
()
?
value
:
ByteSwap64
(
value
);
}
/**
* Converts a 16 bit integer from little endian to the host byte order
* and returns it as a signed integer.
*/
constexpr
int16_t
FromLE16S
(
uint16_t
value
)
noexcept
{
/* assuming two's complement representation */
return
static_cast
<
int16_t
>
(
FromLE16
(
value
));
}
#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