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
ac8e5be9
Commit
ac8e5be9
authored
Oct 24, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/opus: support replay gain
Parse the R128_TRACK_GAIN comment string.
parent
c7695253
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
OpusDecoderPlugin.cxx
src/decoder/OpusDecoderPlugin.cxx
+7
-0
OpusTags.cxx
src/decoder/OpusTags.cxx
+14
-1
OpusTags.hxx
src/decoder/OpusTags.hxx
+3
-0
No files found.
src/decoder/OpusDecoderPlugin.cxx
View file @
ac8e5be9
...
...
@@ -282,12 +282,18 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
inline
DecoderCommand
MPDOpusDecoder
::
HandleTags
(
const
ogg_packet
&
packet
)
{
replay_gain_info
rgi
;
replay_gain_info_init
(
&
rgi
);
TagBuilder
tag_builder
;
DecoderCommand
cmd
;
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
&
rgi
,
&
add_tag_handler
,
&
tag_builder
)
&&
!
tag_builder
.
IsEmpty
())
{
decoder_replay_gain
(
decoder
,
&
rgi
);
Tag
tag
;
tag_builder
.
Commit
(
tag
);
cmd
=
decoder_tag
(
decoder
,
input_stream
,
std
::
move
(
tag
));
...
...
@@ -439,6 +445,7 @@ mpd_opus_scan_stream(InputStream &is,
break
;
else
if
(
IsOpusTags
(
packet
))
{
if
(
!
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
nullptr
,
handler
,
handler_ctx
))
result
=
false
;
...
...
src/decoder/OpusTags.cxx
View file @
ac8e5be9
...
...
@@ -23,6 +23,7 @@
#include "XiphTags.hxx"
#include "tag/TagHandler.hxx"
#include "tag/Tag.hxx"
#include "ReplayGainInfo.hxx"
#include <stdint.h>
#include <string.h>
...
...
@@ -41,8 +42,19 @@ ParseOpusTagName(const char *name)
static
void
ScanOneOpusTag
(
const
char
*
name
,
const
char
*
value
,
replay_gain_info
*
rgi
,
const
struct
tag_handler
*
handler
,
void
*
ctx
)
{
if
(
rgi
!=
nullptr
&&
strcmp
(
name
,
"R128_TRACK_GAIN"
)
==
0
)
{
/* R128_TRACK_GAIN is a Q7.8 fixed point number in
dB */
char
*
endptr
;
long
l
=
strtol
(
value
,
&
endptr
,
10
);
if
(
endptr
>
value
&&
*
endptr
==
0
)
rgi
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
double
(
l
)
/
256.
;
}
tag_handler_invoke_pair
(
handler
,
ctx
,
name
,
value
);
if
(
handler
->
tag
!=
nullptr
)
{
...
...
@@ -54,6 +66,7 @@ ScanOneOpusTag(const char *name, const char *value,
bool
ScanOpusTags
(
const
void
*
data
,
size_t
size
,
replay_gain_info
*
rgi
,
const
struct
tag_handler
*
handler
,
void
*
ctx
)
{
OpusReader
r
(
data
,
size
);
...
...
@@ -79,7 +92,7 @@ ScanOpusTags(const void *data, size_t size,
if
(
eq
!=
nullptr
&&
eq
>
p
)
{
*
eq
=
0
;
ScanOneOpusTag
(
p
,
eq
+
1
,
handler
,
ctx
);
ScanOneOpusTag
(
p
,
eq
+
1
,
rgi
,
handler
,
ctx
);
}
delete
[]
p
;
...
...
src/decoder/OpusTags.hxx
View file @
ac8e5be9
...
...
@@ -24,8 +24,11 @@
#include <stddef.h>
struct
replay_gain_info
;
bool
ScanOpusTags
(
const
void
*
data
,
size_t
size
,
replay_gain_info
*
rgi
,
const
struct
tag_handler
*
handler
,
void
*
ctx
);
#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