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
4364b30c
Commit
4364b30c
authored
Jul 20, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/mad: move RVA2 code to tag_rva2.c
parent
c0da938d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
89 deletions
+153
-89
Makefile.am
Makefile.am
+2
-0
mad_decoder_plugin.c
src/decoder/mad_decoder_plugin.c
+2
-89
tag_rva2.c
src/tag_rva2.c
+110
-0
tag_rva2.h
src/tag_rva2.h
+39
-0
No files found.
Makefile.am
View file @
4364b30c
...
@@ -198,6 +198,7 @@ mpd_headers = \
...
@@ -198,6 +198,7 @@ mpd_headers = \
src/tag_table.h
\
src/tag_table.h
\
src/tag_ape.h
\
src/tag_ape.h
\
src/tag_id3.h
\
src/tag_id3.h
\
src/tag_rva2.h
\
src/tag_print.h
\
src/tag_print.h
\
src/tag_save.h
\
src/tag_save.h
\
src/tokenizer.h
\
src/tokenizer.h
\
...
@@ -405,6 +406,7 @@ TAG_SRC = \
...
@@ -405,6 +406,7 @@ TAG_SRC = \
if
HAVE_ID3TAG
if
HAVE_ID3TAG
TAG_SRC
+=
src/tag_id3.c
\
TAG_SRC
+=
src/tag_id3.c
\
src/tag_rva2.c
\
src/riff.c src/aiff.c
src/riff.c src/aiff.c
endif
endif
...
...
src/decoder/mad_decoder_plugin.c
View file @
4364b30c
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "decoder_api.h"
#include "decoder_api.h"
#include "conf.h"
#include "conf.h"
#include "tag_id3.h"
#include "tag_id3.h"
#include "tag_rva2.h"
#include "audio_check.h"
#include "audio_check.h"
#include <assert.h>
#include <assert.h>
...
@@ -211,94 +212,6 @@ mp3_fill_buffer(struct mp3_data *data)
...
@@ -211,94 +212,6 @@ mp3_fill_buffer(struct mp3_data *data)
}
}
#ifdef HAVE_ID3TAG
#ifdef HAVE_ID3TAG
/* Parse mp3 RVA2 frame. Shamelessly stolen from madplay. */
static
bool
parse_rva2
(
struct
id3_tag
*
tag
,
struct
replay_gain_info
*
replay_gain_info
)
{
struct
id3_frame
const
*
frame
;
id3_latin1_t
const
*
id
;
id3_byte_t
const
*
data
;
id3_length_t
length
;
enum
{
CHANNEL_OTHER
=
0x00
,
CHANNEL_MASTER_VOLUME
=
0x01
,
CHANNEL_FRONT_RIGHT
=
0x02
,
CHANNEL_FRONT_LEFT
=
0x03
,
CHANNEL_BACK_RIGHT
=
0x04
,
CHANNEL_BACK_LEFT
=
0x05
,
CHANNEL_FRONT_CENTRE
=
0x06
,
CHANNEL_BACK_CENTRE
=
0x07
,
CHANNEL_SUBWOOFER
=
0x08
};
/* relative volume adjustment information */
frame
=
id3_tag_findframe
(
tag
,
"RVA2"
,
0
);
if
(
frame
==
NULL
)
return
false
;
id
=
id3_field_getlatin1
(
id3_frame_field
(
frame
,
0
));
data
=
id3_field_getbinarydata
(
id3_frame_field
(
frame
,
1
),
&
length
);
if
(
id
==
NULL
||
data
==
NULL
)
return
false
;
/*
* "The 'identification' string is used to identify the
* situation and/or device where this adjustment should apply.
* The following is then repeated for every channel
*
* Type of channel $xx
* Volume adjustment $xx xx
* Bits representing peak $xx
* Peak volume $xx (xx ...)"
*/
while
(
length
>=
4
)
{
unsigned
int
peak_bytes
;
peak_bytes
=
(
data
[
3
]
+
7
)
/
8
;
if
(
4
+
peak_bytes
>
length
)
break
;
if
(
data
[
0
]
==
CHANNEL_MASTER_VOLUME
)
{
signed
int
voladj_fixed
;
double
voladj_float
;
/*
* "The volume adjustment is encoded as a fixed
* point decibel value, 16 bit signed integer
* representing (adjustment*512), giving +/- 64
* dB with a precision of 0.001953125 dB."
*/
voladj_fixed
=
(
data
[
1
]
<<
8
)
|
(
data
[
2
]
<<
0
);
voladj_fixed
|=
-
(
voladj_fixed
&
0x8000
);
voladj_float
=
(
double
)
voladj_fixed
/
512
;
replay_gain_info
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
voladj_float
;
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
voladj_float
;
g_debug
(
"parseRVA2: Relative Volume "
"%+.1f dB adjustment (%s)
\n
"
,
voladj_float
,
id
);
return
true
;
}
data
+=
4
+
peak_bytes
;
length
-=
4
+
peak_bytes
;
}
return
false
;
}
#endif
#ifdef HAVE_ID3TAG
static
bool
static
bool
parse_id3_replay_gain_info
(
struct
replay_gain_info
*
replay_gain_info
,
parse_id3_replay_gain_info
(
struct
replay_gain_info
*
replay_gain_info
,
struct
id3_tag
*
tag
)
struct
id3_tag
*
tag
)
...
@@ -342,7 +255,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info,
...
@@ -342,7 +255,7 @@ parse_id3_replay_gain_info(struct replay_gain_info *replay_gain_info,
return
found
||
return
found
||
/* fall back on RVA2 if no replaygain tags found */
/* fall back on RVA2 if no replaygain tags found */
parse_rva2
(
tag
,
replay_gain_info
);
tag_rva2_parse
(
tag
,
replay_gain_info
);
}
}
#endif
#endif
...
...
src/tag_rva2.c
0 → 100644
View file @
4364b30c
/*
* Copyright (C) 2003-2010 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "tag_rva2.h"
#include "replay_gain_info.h"
#include <glib.h>
#include <id3tag.h>
bool
tag_rva2_parse
(
struct
id3_tag
*
tag
,
struct
replay_gain_info
*
replay_gain_info
)
{
struct
id3_frame
const
*
frame
;
id3_latin1_t
const
*
id
;
id3_byte_t
const
*
data
;
id3_length_t
length
;
enum
{
CHANNEL_OTHER
=
0x00
,
CHANNEL_MASTER_VOLUME
=
0x01
,
CHANNEL_FRONT_RIGHT
=
0x02
,
CHANNEL_FRONT_LEFT
=
0x03
,
CHANNEL_BACK_RIGHT
=
0x04
,
CHANNEL_BACK_LEFT
=
0x05
,
CHANNEL_FRONT_CENTRE
=
0x06
,
CHANNEL_BACK_CENTRE
=
0x07
,
CHANNEL_SUBWOOFER
=
0x08
};
/* relative volume adjustment information */
frame
=
id3_tag_findframe
(
tag
,
"RVA2"
,
0
);
if
(
frame
==
NULL
)
return
false
;
id
=
id3_field_getlatin1
(
id3_frame_field
(
frame
,
0
));
data
=
id3_field_getbinarydata
(
id3_frame_field
(
frame
,
1
),
&
length
);
if
(
id
==
NULL
||
data
==
NULL
)
return
false
;
/*
* "The 'identification' string is used to identify the
* situation and/or device where this adjustment should apply.
* The following is then repeated for every channel
*
* Type of channel $xx
* Volume adjustment $xx xx
* Bits representing peak $xx
* Peak volume $xx (xx ...)"
*/
while
(
length
>=
4
)
{
unsigned
int
peak_bytes
;
peak_bytes
=
(
data
[
3
]
+
7
)
/
8
;
if
(
4
+
peak_bytes
>
length
)
break
;
if
(
data
[
0
]
==
CHANNEL_MASTER_VOLUME
)
{
signed
int
voladj_fixed
;
double
voladj_float
;
/*
* "The volume adjustment is encoded as a fixed
* point decibel value, 16 bit signed integer
* representing (adjustment*512), giving +/- 64
* dB with a precision of 0.001953125 dB."
*/
voladj_fixed
=
(
data
[
1
]
<<
8
)
|
(
data
[
2
]
<<
0
);
voladj_fixed
|=
-
(
voladj_fixed
&
0x8000
);
voladj_float
=
(
double
)
voladj_fixed
/
512
;
replay_gain_info
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
voladj_float
;
replay_gain_info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
voladj_float
;
g_debug
(
"parseRVA2: Relative Volume "
"%+.1f dB adjustment (%s)
\n
"
,
voladj_float
,
id
);
return
true
;
}
data
+=
4
+
peak_bytes
;
length
-=
4
+
peak_bytes
;
}
return
false
;
}
src/tag_rva2.h
0 → 100644
View file @
4364b30c
/*
* Copyright (C) 2003-2010 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_TAG_RVA2_H
#define MPD_TAG_RVA2_H
#include "check.h"
#include <stdbool.h>
struct
id3_tag
;
struct
replay_gain_info
;
/**
* Parse the RVA2 tag, and fill the #replay_gain_info struct. This is
* used by decoder plugins with ID3 support.
*
* @return true on success
*/
bool
tag_rva2_parse
(
struct
id3_tag
*
tag
,
struct
replay_gain_info
*
replay_gain_info
);
#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